-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from sergenyalcin/chainsaw-migration
Migrate the underlying test framework from `kuttl` to `chainsaw`
- Loading branch information
Showing
20 changed files
with
1,125 additions
and
543 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,66 @@ | ||
# This file belongs to the resource apply step. | ||
{{ if .TestCase.SetupScriptPath -}} | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
- command: {{ .TestCase.SetupScriptPath }} | ||
{{ end }} | ||
{{- range $resource := .Resources -}} | ||
--- | ||
{{ $resource.YAML }} | ||
{{- end }} | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: apply | ||
spec: | ||
timeouts: | ||
apply: {{ .TestCase.Timeout }} | ||
assert: {{ .TestCase.Timeout }} | ||
exec: {{ .TestCase.Timeout }} | ||
steps: | ||
- name: Run Setup Script | ||
description: Setup the test environment by running the setup script. | ||
try: | ||
- command: | ||
entrypoint: {{ .TestCase.SetupScriptPath }} | ||
- name: Apply Resources | ||
description: Apply resources to the cluster. | ||
try: | ||
- apply: | ||
file: {{ .TestCase.TestDirectory }} | ||
- script: | ||
content: | | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if not $resource.Namespace }} | ||
${KUBECTL} annotate {{ $resource.KindGroup }}/{{ $resource.Name }} upjet.upbound.io/test=true --overwrite | ||
{{- end }} | ||
{{- end }} | ||
- name: Assert Status Conditions | ||
description: | | ||
Assert applied resources. First, run the pre-assert script if exists. | ||
Then, check the status conditions. Finally run the post-assert script if it | ||
exists. | ||
try: | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if $resource.PreAssertScriptPath }} | ||
- command: | ||
entrypoint: {{ $resource.PreAssertScriptPath }} | ||
{{- end }} | ||
- assert: | ||
resource: | ||
apiVersion: {{ $resource.APIVersion }} | ||
kind: {{ $resource.Kind }} | ||
metadata: | ||
name: {{ $resource.Name }} | ||
{{- if $resource.Namespace }} | ||
namespace: {{ $resource.Namespace }} | ||
{{- end }} | ||
status: | ||
{{- range $condition := $resource.Conditions }} | ||
((conditions[?type == '{{ $condition }}'])[0]): | ||
status: "True" | ||
{{- end }} | ||
{{- if $resource.PostAssertScriptPath }} | ||
- command: | ||
entrypoint: {{ $resource.PostAssertScriptPath }} | ||
{{- end }} | ||
{{- end }} | ||
{{ end }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,56 @@ | ||
# This file belongs to the resource update step. | ||
apiVersion: kuttl.dev/v1beta1 | ||
kind: TestStep | ||
commands: | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if eq $resource.KindGroup "namespace." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if not $resource.Namespace }} | ||
{{- if $resource.Root }} | ||
- command: ${KUBECTL} patch {{ $resource.KindGroup }}/{{ $resource.Name }} --type=merge -p '{"spec":{"forProvider":{{ $resource.UpdateParameter }}}}' | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: update | ||
spec: | ||
timeouts: | ||
apply: {{ .TestCase.Timeout }} | ||
assert: {{ .TestCase.Timeout }} | ||
exec: {{ .TestCase.Timeout }} | ||
steps: | ||
- name: Update Root Resource | ||
description: | | ||
Update the root resource by using the specified update-parameter in annotation. | ||
Before updating the resources, the status conditions are cleaned. | ||
try: | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if not $resource.Namespace }} | ||
{{- if $resource.Root }} | ||
- script: | ||
content: | | ||
${KUBECTL} --subresource=status patch {{ $resource.KindGroup }}/{{ $resource.Name }} --type=merge -p '{"status":{"conditions":[]}}' | ||
${KUBECTL} patch {{ $resource.KindGroup }}/{{ $resource.Name }} --type=merge -p '{"spec":{"forProvider":{{ $resource.UpdateParameter }}}}' | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
- name: Assert Updated Resource | ||
description: | | ||
Assert update operation. Firstly check the status conditions. Then assert | ||
the updated field in status.atProvider. | ||
{{- range $resource := .Resources }} | ||
{{- if eq $resource.KindGroup "secret." -}} | ||
{{continue}} | ||
{{- end -}} | ||
{{- if not $resource.Namespace }} | ||
{{- if $resource.Root }} | ||
try: | ||
- assert: | ||
resource: | ||
apiVersion: {{ $resource.APIVersion }} | ||
kind: {{ $resource.Kind }} | ||
metadata: | ||
name: {{ $resource.Name }} | ||
status: | ||
{{- range $condition := $resource.Conditions }} | ||
((conditions[?type == '{{ $condition }}'])[0]): | ||
status: "True" | ||
{{- end }} | ||
- script: | ||
content: ${KUBECTL} get {{ $resource.KindGroup }}/{{ $resource.Name }} -o=jsonpath='{.status.atProvider{{ $resource.UpdateAssertKey }}}' | grep -q "^{{ $resource.UpdateAssertValue }}$" | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.