-
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 all 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
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 |
---|---|---|
@@ -1,18 +1,19 @@ | ||
# This assert file belongs to the resource update step. | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
timeout: {{ .TestCase.Timeout }} | ||
commands: | ||
- script: echo "Dump MR manifests for the update assertion step:"; ${KUBECTL} get managed -o yaml | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.UpdateParameter "" -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- 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 }} | ||
{{- if $resource.Root }} | ||
- script: ${KUBECTL} get {{ $resource.KindGroup }}/{{ $resource.Name }} -o=jsonpath='{.status.atProvider{{ $resource.UpdateAssertKey }}}' | 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,17 @@ | ||
# This file belongs to the resource update step. | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.UpdateParameter "" -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- 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. |
||
{{- if $resource.Root }} | ||
- command: ${KUBECTL} patch {{ $resource.KindGroup }}/{{ $resource.Name }} --type=merge -p '{"spec":{"forProvider":{{ $resource.UpdateParameter }}}}' | ||
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 constrain the update parameter to be a direct child of 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 had better only patch the target manifest in the update tests. |
||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This assert file belongs to the resource import step. | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
timeout: {{ .TestCase.Timeout }} | ||
commands: | ||
- script: echo "Dump MR manifests for the import assertion step:"; ${KUBECTL} get managed -o yaml | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- range $condition := $resource.Conditions }} | ||
{{- if not $resource.Namespace }} | ||
- command: ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=condition={{ $condition }} --timeout 10s | ||
{{- end }} | ||
{{- end }} | ||
{{- if not $resource.Namespace }} | ||
- script: new_id=$(${KUBECTL} get {{ $resource.KindGroup }}/{{ $resource.Name }} -o=jsonpath='{.status.atProvider.id}') && old_id=$(${KUBECTL} get {{ $resource.KindGroup }}/{{ $resource.Name }} -o=jsonpath='{.metadata.annotations.uptest-old-id}') && [ "$new_id" == "$old_id" ] | ||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# This file belongs to the resource import step. | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- command: ${KUBECTL} scale deployment crossplane -n upbound-system --replicas=0 | ||
- script: ${KUBECTL} -n upbound-system get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n upbound-system scale deploy --replicas=0 | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if not $resource.Namespace }} | ||
- command: ${KUBECTL} --subresource=status patch {{ $resource.KindGroup }}/{{ $resource.Name }} --type=merge -p '{"status":{"conditions":[]}}' | ||
- script: ${KUBECTL} annotate {{ $resource.KindGroup }}/{{ $resource.Name }} uptest-old-id=$(${KUBECTL} get {{ $resource.KindGroup }}/{{ $resource.Name }} -o=jsonpath='{.status.atProvider.id}') --overwrite | ||
Comment on lines
+12
to
+13
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 have better scale the provider deployment down before updating the status and putting the annotation here. |
||
{{- end }} | ||
{{- end }} | ||
- command: ${KUBECTL} scale deployment crossplane -n upbound-system --replicas=1 | ||
- script: ${KUBECTL} -n upbound-system get deploy --no-headers -o custom-columns=":metadata.name" | grep "provider-" | xargs ${KUBECTL} -n upbound-system scale deploy --replicas=1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This assert file belongs to the resource delete step. | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestAssert | ||
timeout: {{ .TestCase.Timeout }} | ||
commands: | ||
- script: echo "Dump MR manifests for the delete assertion step:"; ${KUBECTL} get managed -o yaml | ||
- script: echo "Dump Claim manifests for the delete assertion step:" || ${KUBECTL} get claim --all-namespaces -o yaml | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if $resource.Namespace }} | ||
- script: ${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 | ||
{{- 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# This file belongs to the resource delete step. | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
|
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.
nit: We may consider adding a description to the new parameter.
Let's also document that the update parameter should be a serialized JSON object and if the JSON object has nested children, then there must be only one leaf.