-
Notifications
You must be signed in to change notification settings - Fork 23
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
Add yaml outputs of resources to streaming logs and add import&update steps to uptest #136
Changes from 3 commits
6368327
b00f8c8
3b210de
cee19d8
21da281
740e2fc
61dd809
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,6 +3,7 @@ kind: TestAssert | |||||
timeout: {{ .TestCase.Timeout }} | ||||||
commands: | ||||||
- command: ${KUBECTL} annotate managed --all upjet.upbound.io/test=true --overwrite | ||||||
- command: ${KUBECTL} get managed -o yaml | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: We had better include a header in the debug log messages like |
||||||
{{- range $resource := .Resources }} | ||||||
{{- if eq $resource.KindGroup "secret." -}} | ||||||
{{continue}} | ||||||
|
@@ -12,9 +13,9 @@ commands: | |||||
{{- end }} | ||||||
{{- range $condition := $resource.Conditions }} | ||||||
{{- if $resource.Namespace }} | ||||||
- command: ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=condition={{ $condition }} --timeout 10s --namespace {{ $resource.Namespace }} | ||||||
- script: ${KUBECTL} get --namespace {{ $resource.Namespace }} {{ $resource.KindGroup }}/{{ $resource.Name }} -o yaml && ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=condition={{ $condition }} --timeout 10s --namespace {{ $resource.Namespace }} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may just dump all the claims above with the MRs:
Suggested change
|
||||||
{{- else }} | ||||||
- command: ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=condition={{ $condition }} --timeout 10s | ||||||
- script: ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=condition={{ $condition }} --timeout 10s | ||||||
{{- end }} | ||||||
{{- end }} | ||||||
{{- if $resource.PostAssertScriptPath }} | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's put a YAML comment at the top of this file telling that this assert step belongs to the resource update test. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2,17 +2,12 @@ apiVersion: kuttl.dev/v1beta1 | |||||
kind: TestAssert | ||||||
timeout: {{ .TestCase.Timeout }} | ||||||
commands: | ||||||
- command: ${KUBECTL} get managed -o yaml | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
{{- range $resource := .Resources }} | ||||||
{{- if eq $resource.KindGroup "secret." -}} | ||||||
{{continue}} | ||||||
{{- end -}} | ||||||
{{- if $resource.Namespace }} | ||||||
- command: ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=delete --timeout 10s --namespace {{ $resource.Namespace }} | ||||||
{{- else }} | ||||||
- command: ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=delete --timeout 10s | ||||||
{{- if not $resource.Namespace }} | ||||||
- script: ${KUBECTL} get {{ $resource.KindGroup }}/{{ $resource.Name }} -o=jsonpath='{.status.atProvider.{{ $resource.UpdateAssertField }}}' | grep -q "^{{ $resource.UpdateAssertValue }}$" | ||||||
{{- end }} | ||||||
{{- end }} | ||||||
- command: ${KUBECTL} wait managed --all --for=delete --timeout 10s | ||||||
{{- if .TestCase.TeardownScriptPath }} | ||||||
- command: {{ .TestCase.TeardownScriptPath }} | ||||||
{{- end }} |
sergenyalcin marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if not $resource.Namespace }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the next iteration, we can consider adding claim update tests. |
||
- script: '${KUBECTL} patch {{ $resource.KindGroup }}/{{ $resource.Name }} --type=json -p "[{"op": "add", "path": "/spec/forProvider/{{ $resource.UpdateField }}", "value": {{ $resource.UpdateValue }}}]"' | ||
sergenyalcin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
timeout: {{ .TestCase.Timeout }} | ||
commands: | ||
- command: ${KUBECTL} get managed -o yaml | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- range $condition := $resource.Conditions }} | ||
{{- if not $resource.Namespace }} | ||
- script: ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=condition={{ $condition }} --timeout 10s | ||
{{- end }} | ||
{{- end }} | ||
{{- if not $resource.Namespace }} | ||
- script: annotation_value_1=$(${KUBECTL} get {{ $resource.KindGroup }}/{{ $resource.Name }} -o=jsonpath='{.metadata.annotations.crossplane\.io/external-name}') && annotation_value_2=$(${KUBECTL} get {{ $resource.KindGroup }}/{{ $resource.Name }} -o=jsonpath='{.metadata.annotations.uptest-external-name}') && [ "$annotation_value_1" == "$annotation_value_2" ] | ||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if not $resource.Namespace }} | ||
- script: ${KUBECTL} --subresource=status patch {{ $resource.KindGroup }}/{{ $resource.Name }} --type=merge -p '{"status":{"conditions":[]}}' | ||
- script: ${KUBECTL} annotate {{ $resource.KindGroup }}/{{ $resource.Name }} uptest-external-name=$(${KUBECTL} get {{ $resource.KindGroup }}/{{ $resource.Name }} -o=jsonpath='{.metadata.annotations.crossplane\.io/external-name}') --overwrite | ||
{{- end }} | ||
{{- end }} | ||
- script: ${KUBECTL} -n upbound-system get pods --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n upbound-system delete pod |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
timeout: {{ .TestCase.Timeout }} | ||
commands: | ||
- command: ${KUBECTL} get managed -o yaml | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if $resource.Namespace }} | ||
- script: ${KUBECTL} get --namespace {{ $resource.Namespace }} {{ $resource.KindGroup }}/{{ $resource.Name }} -o yaml --ignore-not-found && ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=delete --timeout 10s --namespace {{ $resource.Namespace }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We may consider moving the |
||
{{- else }} | ||
- script: ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=delete --timeout 10s | ||
{{- end }} | ||
{{- end }} | ||
- command: ${KUBECTL} wait managed --all --for=delete --timeout 10s | ||
{{- if .TestCase.TeardownScriptPath }} | ||
- command: {{ .TestCase.TeardownScriptPath }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,12 +26,32 @@ var inputFileTemplate string | |||||
//go:embed 00-assert.yaml.tmpl | ||||||
var assertFileTemplate string | ||||||
|
||||||
// updateFileTemplate is the template for the update file. | ||||||
// | ||||||
//go:embed 01-update.yaml.tmpl | ||||||
var updateFileTemplate string | ||||||
|
||||||
// assertUpdatedFileTemplate is the template for update assert file. | ||||||
// | ||||||
//go:embed 01-assert.yaml.tmpl | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit:
Suggested change
|
||||||
var assertUpdatedFileTemplate string | ||||||
|
||||||
// deleteFileTemplate is the template for the import file. | ||||||
// | ||||||
//go:embed 02-import.yaml.tmpl | ||||||
var importFileTemplate string | ||||||
|
||||||
// assertDeletedFileTemplate is the template for import assert file. | ||||||
// | ||||||
//go:embed 02-assert.yaml.tmpl | ||||||
var assertImportedFileTemplate string | ||||||
|
||||||
// deleteFileTemplate is the template for the delete file. | ||||||
// | ||||||
//go:embed 01-delete.yaml.tmpl | ||||||
//go:embed 03-delete.yaml.tmpl | ||||||
var deleteFileTemplate string | ||||||
|
||||||
// assertDeletedFileTemplate is the template for delete assert file. | ||||||
// | ||||||
//go:embed 01-assert.yaml.tmpl | ||||||
//go:embed 03-assert.yaml.tmpl | ||||||
var assertDeletedFileTemplate string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.