-
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
Conversation
Signed-off-by: Sergen Yalçın <[email protected]>
Signed-off-by: Sergen Yalçın <[email protected]>
Signed-off-by: Sergen Yalçın <[email protected]>
Signed-off-by: Sergen Yalçın <[email protected]>
Signed-off-by: Sergen Yalçın <[email protected]>
9ce4c07
to
21da281
Compare
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.
Thanks @sergenyalcin, lgtm. If we have a bug in the resource updates, let's not hide that as we have discussed.
@@ -17,6 +17,10 @@ on: | |||
default: 'provider' | |||
required: false | |||
type: string | |||
update-test-parameter: |
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.
@@ -12,7 +13,7 @@ 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 comment
The reason will be displayed to describe this comment to others. Learn more.
We may just dump all the claims above with the MRs:
- 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 }} | |
- script: ${KUBECTL} wait {{ $resource.KindGroup }}/{{ $resource.Name }} --for=condition={{ $condition }} --timeout 10s --namespace {{ $resource.Namespace }} |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
- command: ${KUBECTL} get managed -o yaml | |
- script: ${KUBECTL} get managed -o yaml || ${KUBECTL} get claim --all-namespaces -o yaml |
@@ -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 comment
The 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 Dumping all MRs:
, Dumping all claims:
.
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if not $resource.Namespace }} |
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.
In the next iteration, we can consider adding claim update tests.
for key, value := range data { | ||
newPath := currentPath + "." + key | ||
switch v := value.(type) { | ||
case map[string]interface{}: |
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.
We may capture in the description of the update parameter that only maps & nested objects are supported.
internal/tester.go
Outdated
@@ -81,6 +82,15 @@ func (t *tester) prepareConfig() (*config.TestCase, []config.Resource, error) { | |||
Conditions: t.options.DefaultConditions, | |||
} | |||
|
|||
if updateParameter := os.Getenv("UPTEST_UPDATE_PARAMETER"); updateParameter != "" { |
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.
if updateParameter := os.Getenv("UPTEST_UPDATE_PARAMETER"); updateParameter != "" { | |
updateParameter := ... // get value from annotation | |
if updateParameter == "" { | |
updateParameter = os.Getenv("UPTEST_UPDATE_PARAMETER") | |
} | |
if updateParameter != "" { | |
... |
- 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 |
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 have better scale the provider deployment down before updating the status and putting the annotation here.
{{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 comment
The reason will be displayed to describe this comment to others. Learn more.
We may consider moving the kubectl get
outside the loop.
|
||
// 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 comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
//go:embed 01-assert.yaml.tmpl | |
//go:embed 01-assert-update.yaml.tmpl |
{{continue}} | ||
{{- end -}} | ||
{{- if not $resource.Namespace }} | ||
- 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 comment
The reason will be displayed to describe this comment to others. Learn more.
We had better only patch the target manifest in the update tests.
Signed-off-by: Sergen Yalçın <[email protected]>
4ed2f67
to
740e2fc
Compare
Signed-off-by: Sergen Yalçın <[email protected]>
Description of your changes
script
field for supporting multiple commands.I have:
make reviewable test
to ensure this PR is ready for review.How has this code been tested
Tested locally.