Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests for kubernetes 1.27.x #794

Merged
merged 1 commit into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion test/e2e/formatted_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,25 @@ kapp: Error: create job/successful-job (batch/v1) namespace: default:
(reason: Invalid)
`)

_, err := kapp.RunWithOpts([]string{"deploy", "-f", "-", "-a", name},
minorVersion, err := getServerMinorVersion()
require.NoErrorf(t, err, "Error getting k8s server minor version")
// batch.kubernetes.io/controller-uid and batch.kubernetes.io/job-name annotaions are added
if minorVersion >= 27 {
expectedErr = strings.TrimSpace(`
kapp: Error: create job/successful-job (batch/v1) namespace: default:
Creating resource job/successful-job (batch/v1) namespace: default:
API server says:
Job.batch "successful-job" is invalid:

- spec.selector: Invalid value: v1.LabelSelector{MatchLabels:map[string]string{-replaced-, "blah":"balh", -replaced-}, MatchExpressions:[]v1.LabelSelectorRequirement(nil)}: 'selector' not auto-generated

- spec.template.metadata.labels: Invalid value: map[string]string{-replaced-, -replaced-, -replaced-, "foo":"foo", "job-name":"successful-job", -replaced-, -replaced-}: 'selector' does not match template 'labels'

(reason: Invalid)
`)
}

_, err = kapp.RunWithOpts([]string{"deploy", "-f", "-", "-a", name},
RunOpts{StdinReader: strings.NewReader(yaml1), AllowError: true})

out := strings.ReplaceAll(err.Error(), "`", "'")
Expand All @@ -73,6 +91,12 @@ kapp: Error: create job/successful-job (batch/v1) namespace: default:
replaceUIDs := regexp.MustCompile(`"controller-uid":"[^"]+"`)
out = replaceUIDs.ReplaceAllString(out, "-replaced-")

replaceUIDs = regexp.MustCompile(`"batch\.kubernetes\.io\/controller-uid":"[^"]+"`)
out = replaceUIDs.ReplaceAllString(out, "-replaced-")

replaceUIDs = regexp.MustCompile(`"batch\.kubernetes\.io\/job-name":"[^"]+"`)
out = replaceUIDs.ReplaceAllString(out, "-replaced-")

require.Containsf(t, out, expectedErr, "Expected to see expected err in output, but did not")
})
}
2 changes: 1 addition & 1 deletion test/e2e/ignore_failing_api_services_flag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ metadata:
AllowError: true, IntoNs: true, StdinReader: strings.NewReader(yaml3)})
require.Errorf(t, err, "Expected error when deploying with failing api service")

require.Contains(t, err.Error(), "unable to retrieve the complete list of server APIs: samplekapptest.com/v1: the server is currently unable to handle the request",
require.Contains(t, err.Error(), "unable to retrieve the complete list of server APIs: samplekapptest.com/v1",
"Expected api retrieval error")
})

Expand Down