From fb1a69609e738a68a9d656d39735c3edbb9b5461 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Fri, 16 Feb 2024 01:27:11 +0100 Subject: [PATCH] chore: migrate from kuttl to chainsaw MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- e2e/.chainsaw.yaml | 12 ++++ e2e/Makefile | 4 +- e2e/README.MD | 2 +- e2e/kuttl-config.yaml | 7 --- .../minimal/02-create-linodecluster.tpl.yml | 11 ---- .../minimal/02-create-linodecluster.yaml | 17 ++++-- .../minimal/03-verify-nodebalancer.yaml | 5 -- .../minimal/04-delete-linodecluster.yaml | 6 -- .../05-verify-nodebalancer-destroyed.yaml | 5 -- .../minimal/06-cleanup-cluster.yaml | 5 -- .../minimal/chainsaw-test.yaml | 41 +++++++++++++ .../byovpc/01-create-cluster.yaml | 11 ---- .../byovpc/02-create-linodemachine.yaml | 6 -- .../byovpc/03-delete-linodemachine.yaml | 6 -- .../byovpc/04-verify-linode-instance.yaml | 5 -- .../byovpc/chainsaw-test.yaml | 60 +++++++++++++++++++ .../minimal/02-create-linodemachine.tpl.yml | 12 ---- .../minimal/02-create-linodemachine.yaml | 18 ++++-- .../minimal/03-delete-linodemachine.yaml | 6 -- .../minimal/04-verify-linode-instance.yaml | 5 -- .../minimal/chainsaw-test.yaml | 36 +++++++++++ .../minimal/02-delete-vpc.yaml | 6 -- .../minimal/03-verify-vpc.yaml | 5 -- .../minimal/chainsaw-test.yaml | 33 ++++++++++ 24 files changed, 208 insertions(+), 116 deletions(-) create mode 100755 e2e/.chainsaw.yaml delete mode 100644 e2e/kuttl-config.yaml delete mode 100644 e2e/linodecluster-controller/minimal/02-create-linodecluster.tpl.yml delete mode 100644 e2e/linodecluster-controller/minimal/03-verify-nodebalancer.yaml delete mode 100644 e2e/linodecluster-controller/minimal/04-delete-linodecluster.yaml delete mode 100644 e2e/linodecluster-controller/minimal/05-verify-nodebalancer-destroyed.yaml delete mode 100644 e2e/linodecluster-controller/minimal/06-cleanup-cluster.yaml create mode 100755 e2e/linodecluster-controller/minimal/chainsaw-test.yaml delete mode 100644 e2e/linodemachine-controller/byovpc/01-create-cluster.yaml delete mode 100644 e2e/linodemachine-controller/byovpc/02-create-linodemachine.yaml delete mode 100644 e2e/linodemachine-controller/byovpc/03-delete-linodemachine.yaml delete mode 100644 e2e/linodemachine-controller/byovpc/04-verify-linode-instance.yaml create mode 100755 e2e/linodemachine-controller/byovpc/chainsaw-test.yaml delete mode 100644 e2e/linodemachine-controller/minimal/02-create-linodemachine.tpl.yml delete mode 100644 e2e/linodemachine-controller/minimal/03-delete-linodemachine.yaml delete mode 100644 e2e/linodemachine-controller/minimal/04-verify-linode-instance.yaml create mode 100755 e2e/linodemachine-controller/minimal/chainsaw-test.yaml delete mode 100644 e2e/linodevpc-controller/minimal/02-delete-vpc.yaml delete mode 100644 e2e/linodevpc-controller/minimal/03-verify-vpc.yaml create mode 100755 e2e/linodevpc-controller/minimal/chainsaw-test.yaml diff --git a/e2e/.chainsaw.yaml b/e2e/.chainsaw.yaml new file mode 100755 index 000000000..e3644593c --- /dev/null +++ b/e2e/.chainsaw.yaml @@ -0,0 +1,12 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/configuration-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Configuration +metadata: + name: configuration +spec: + timeouts: + assert: 5m0s + cleanup: 5m0s + delete: 5m0s + error: 5m0s + exec: 5m0s diff --git a/e2e/Makefile b/e2e/Makefile index 40bc73aa1..a9b44c848 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -12,10 +12,10 @@ _runThisTest: cp $(ROOT_DIR)/e2e/Makefile $$D ;\ mkdir $$D/suit ;\ cp -r $(PWD) $$D/suit ;\ - ROOT_DIR=$(ROOT_DIR) KUBECONFIG="$(ROOT_DIR)/kubeconfig" kubectl-kuttl test --timeout 300 --skip-delete "$$D/suit" + ROOT_DIR=$(ROOT_DIR) KUBECONFIG="$(ROOT_DIR)/kubeconfig" chainsaw test --skip-delete "$$D/suit" runTestSuit: - @T="$$(KUBECONFIG="$$ROOT_DIR/kubeconfig" kubectl-kuttl test --timeout 300 --skip-delete --namespace "$$NAMESPACE" "$$TS" 2>&1)" ;\ + @T="$$(KUBECONFIG="$$ROOT_DIR/kubeconfig" chainsaw test --skip-delete --namespace "$$NAMESPACE" "$$TS" 2>&1)" ;\ echo "$$T" |\ grep -v harness.go |\ grep -v ^=== |\ diff --git a/e2e/README.MD b/e2e/README.MD index e86283df6..fd24228ef 100644 --- a/e2e/README.MD +++ b/e2e/README.MD @@ -1,6 +1,6 @@ # E2E Framework -The E2E framework uses Kuttl under the hood. Kuttl is a simple and most importantly static tool. +The E2E framework uses Chainsaw under the hood. Chainsaw is a simple and most importantly static tool. That means there is no way to dynamically generate manifests. The solution is KIK (Kuttl-In-Kuttl)! diff --git a/e2e/kuttl-config.yaml b/e2e/kuttl-config.yaml deleted file mode 100644 index a9abaa602..000000000 --- a/e2e/kuttl-config.yaml +++ /dev/null @@ -1,7 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestSuite -testDirs: -- e2e/linodecluster-controller -- e2e/linodemachine-controller -- e2e/linodevpc-controller -timeout: 300 diff --git a/e2e/linodecluster-controller/minimal/02-create-linodecluster.tpl.yml b/e2e/linodecluster-controller/minimal/02-create-linodecluster.tpl.yml deleted file mode 100644 index 81aa7c0ba..000000000 --- a/e2e/linodecluster-controller/minimal/02-create-linodecluster.tpl.yml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 -kind: LinodeCluster -metadata: - name: linodecluster-sample - ownerReferences: - - apiVersion: cluster.x-k8s.io/v1beta1 - kind: Cluster - name: cluster-sample - uid: ${CLUSTER_UID} -spec: - region: us-sea diff --git a/e2e/linodecluster-controller/minimal/02-create-linodecluster.yaml b/e2e/linodecluster-controller/minimal/02-create-linodecluster.yaml index 231b7ef0a..957c36513 100644 --- a/e2e/linodecluster-controller/minimal/02-create-linodecluster.yaml +++ b/e2e/linodecluster-controller/minimal/02-create-linodecluster.yaml @@ -1,6 +1,11 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - CLUSTER_UID="$(OBJ=clusters/cluster-sample make getKubeUid)" \ - TS="$(TPL="$PWD/02-create-linodecluster.tpl.yml" make renderTestCase)" make runTestSuit +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeCluster +metadata: + name: linodecluster-sample + ownerReferences: + - apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + name: cluster-sample + uid: (x_k8s_get($client, 'cluster.x-k8s.io/v1beta1', 'Cluster', $namespace, 'cluster-sample').metadata.uid) +spec: + region: us-sea diff --git a/e2e/linodecluster-controller/minimal/03-verify-nodebalancer.yaml b/e2e/linodecluster-controller/minimal/03-verify-nodebalancer.yaml deleted file mode 100644 index bd5d4cea2..000000000 --- a/e2e/linodecluster-controller/minimal/03-verify-nodebalancer.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - URI="nodebalancers" FILTER="{\"tags\":\"$(OBJ=linodeclusters/linodecluster-sample make getKubeUid)\"}" make callLinodeApiGet | grep 'results": 1' diff --git a/e2e/linodecluster-controller/minimal/04-delete-linodecluster.yaml b/e2e/linodecluster-controller/minimal/04-delete-linodecluster.yaml deleted file mode 100644 index b8f205339..000000000 --- a/e2e/linodecluster-controller/minimal/04-delete-linodecluster.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -delete: -- apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 - kind: LinodeCluster - name: linodecluster-sample diff --git a/e2e/linodecluster-controller/minimal/05-verify-nodebalancer-destroyed.yaml b/e2e/linodecluster-controller/minimal/05-verify-nodebalancer-destroyed.yaml deleted file mode 100644 index 6eb1db621..000000000 --- a/e2e/linodecluster-controller/minimal/05-verify-nodebalancer-destroyed.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - URI="nodebalancers" FILTER="{\"tags\":\"$(OBJ=linodeclusters/linodecluster-sample make getKubeUid)\"}" make callLinodeApiGet | grep 'results": 0' diff --git a/e2e/linodecluster-controller/minimal/06-cleanup-cluster.yaml b/e2e/linodecluster-controller/minimal/06-cleanup-cluster.yaml deleted file mode 100644 index c0eb3fb3f..000000000 --- a/e2e/linodecluster-controller/minimal/06-cleanup-cluster.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: cluster.x-k8s.io/v1beta1 -kind: Cluster -metadata: - name: cluster-sample -spec: diff --git a/e2e/linodecluster-controller/minimal/chainsaw-test.yaml b/e2e/linodecluster-controller/minimal/chainsaw-test.yaml new file mode 100755 index 000000000..2e3823605 --- /dev/null +++ b/e2e/linodecluster-controller/minimal/chainsaw-test.yaml @@ -0,0 +1,41 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: minimal +spec: + steps: + - name: step-00 + try: + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - apply: + file: 01-create-cluster.yaml + - name: step-02 + try: + - apply: + file: 02-create-linodecluster.yaml + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - script: + content: 'URI="nodebalancers" FILTER="{\"tags\":\"$(OBJ=linodeclusters/linodecluster-sample + make getKubeUid)\"}" make callLinodeApiGet | grep ''results": 1''' + - name: step-04 + try: + - delete: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeCluster + name: linodecluster-sample + - error: + file: 04-error.yaml + - name: step-05 + try: + - script: + content: 'URI="nodebalancers" FILTER="{\"tags\":\"$(OBJ=linodeclusters/linodecluster-sample + make getKubeUid)\"}" make callLinodeApiGet | grep ''results": 0''' diff --git a/e2e/linodemachine-controller/byovpc/01-create-cluster.yaml b/e2e/linodemachine-controller/byovpc/01-create-cluster.yaml deleted file mode 100644 index dc2cf4ccc..000000000 --- a/e2e/linodemachine-controller/byovpc/01-create-cluster.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - command: make createVPC - - script: |- - VPC_ID=$(make fetchVPCID) \ - TS="$(TPL="$PWD/01-create-vpc.tpl.yml" make renderTestCase)" make runTestSuit - - command: make enableVPC - - script: |- - VPC_UID="$(OBJ=linodevpcs/linodevpc-sample make getKubeUid)" \ - TS="$(TPL="$PWD/01-create-cluster.tpl.yml" make renderTestCase)" make runTestSuit diff --git a/e2e/linodemachine-controller/byovpc/02-create-linodemachine.yaml b/e2e/linodemachine-controller/byovpc/02-create-linodemachine.yaml deleted file mode 100644 index ad15f30bb..000000000 --- a/e2e/linodemachine-controller/byovpc/02-create-linodemachine.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - MACHINE_UID="$(OBJ=machines/machine-sample make getKubeUid)" \ - TS="$(TPL="$PWD/02-create-linodemachine.tpl.yml" make renderTestCase)" make runTestSuit diff --git a/e2e/linodemachine-controller/byovpc/03-delete-linodemachine.yaml b/e2e/linodemachine-controller/byovpc/03-delete-linodemachine.yaml deleted file mode 100644 index 3bf5e64ad..000000000 --- a/e2e/linodemachine-controller/byovpc/03-delete-linodemachine.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -delete: -- apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 - kind: LinodeMachine - name: linodemachine-sample diff --git a/e2e/linodemachine-controller/byovpc/04-verify-linode-instance.yaml b/e2e/linodemachine-controller/byovpc/04-verify-linode-instance.yaml deleted file mode 100644 index 4515f8566..000000000 --- a/e2e/linodemachine-controller/byovpc/04-verify-linode-instance.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - URI="linode/instances" FILTER="{\"tags\":\"$(OBJ=linodemachines/linodemachine-sample make getKubeUid)\"}" make callLinodeApiGet | grep 'results": 0' diff --git a/e2e/linodemachine-controller/byovpc/chainsaw-test.yaml b/e2e/linodemachine-controller/byovpc/chainsaw-test.yaml new file mode 100755 index 000000000..03195bea2 --- /dev/null +++ b/e2e/linodemachine-controller/byovpc/chainsaw-test.yaml @@ -0,0 +1,60 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: byovpc +spec: + steps: + - name: step-00 + try: + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - command: + args: + - createVPC + entrypoint: make + - script: + content: |- + VPC_ID=$(make fetchVPCID) \ + TS="$(TPL="$PWD/01-create-vpc.tpl.yml" make renderTestCase)" make runTestSuit + - command: + args: + - enableVPC + entrypoint: make + - script: + content: |- + VPC_UID="$(OBJ=linodevpcs/linodevpc-sample make getKubeUid)" \ + TS="$(TPL="$PWD/01-create-cluster.tpl.yml" make renderTestCase)" make runTestSuit + - apply: + file: 01-create-cluster.tpl.yml + - apply: + file: 01-create-vpc.tpl.yml + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - script: + content: |- + MACHINE_UID="$(OBJ=machines/machine-sample make getKubeUid)" \ + TS="$(TPL="$PWD/02-create-linodemachine.tpl.yml" make renderTestCase)" make runTestSuit + - apply: + file: 02-create-linodemachine.tpl.yml + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - delete: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachine + name: linodemachine-sample + - error: + file: 03-error.yaml + - name: step-04 + try: + - script: + content: 'URI="linode/instances" FILTER="{\"tags\":\"$(OBJ=linodemachines/linodemachine-sample + make getKubeUid)\"}" make callLinodeApiGet | grep ''results": 0''' diff --git a/e2e/linodemachine-controller/minimal/02-create-linodemachine.tpl.yml b/e2e/linodemachine-controller/minimal/02-create-linodemachine.tpl.yml deleted file mode 100644 index 0a4b23b4e..000000000 --- a/e2e/linodemachine-controller/minimal/02-create-linodemachine.tpl.yml +++ /dev/null @@ -1,12 +0,0 @@ -apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 -kind: LinodeMachine -metadata: - ownerReferences: - - apiVersion: cluster.x-k8s.io/v1beta1 - kind: Machine - name: machine-sample - uid: ${MACHINE_UID} - name: linodemachine-sample -spec: - region: us-sea - type: g5-nanode-1 diff --git a/e2e/linodemachine-controller/minimal/02-create-linodemachine.yaml b/e2e/linodemachine-controller/minimal/02-create-linodemachine.yaml index ad15f30bb..b7ff6920b 100644 --- a/e2e/linodemachine-controller/minimal/02-create-linodemachine.yaml +++ b/e2e/linodemachine-controller/minimal/02-create-linodemachine.yaml @@ -1,6 +1,12 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - MACHINE_UID="$(OBJ=machines/machine-sample make getKubeUid)" \ - TS="$(TPL="$PWD/02-create-linodemachine.tpl.yml" make renderTestCase)" make runTestSuit +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeMachine +metadata: + ownerReferences: + - apiVersion: cluster.x-k8s.io/v1beta1 + kind: Machine + name: machine-sample + uid: (x_k8s_get($client, 'cluster.x-k8s.io/v1beta1', 'Machine', $namespace, 'machine-sample').metadata.uid) + name: linodemachine-sample +spec: + region: us-sea + type: g5-nanode-1 diff --git a/e2e/linodemachine-controller/minimal/03-delete-linodemachine.yaml b/e2e/linodemachine-controller/minimal/03-delete-linodemachine.yaml deleted file mode 100644 index 3bf5e64ad..000000000 --- a/e2e/linodemachine-controller/minimal/03-delete-linodemachine.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -delete: -- apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 - kind: LinodeMachine - name: linodemachine-sample diff --git a/e2e/linodemachine-controller/minimal/04-verify-linode-instance.yaml b/e2e/linodemachine-controller/minimal/04-verify-linode-instance.yaml deleted file mode 100644 index 4515f8566..000000000 --- a/e2e/linodemachine-controller/minimal/04-verify-linode-instance.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - URI="linode/instances" FILTER="{\"tags\":\"$(OBJ=linodemachines/linodemachine-sample make getKubeUid)\"}" make callLinodeApiGet | grep 'results": 0' diff --git a/e2e/linodemachine-controller/minimal/chainsaw-test.yaml b/e2e/linodemachine-controller/minimal/chainsaw-test.yaml new file mode 100755 index 000000000..b8601f848 --- /dev/null +++ b/e2e/linodemachine-controller/minimal/chainsaw-test.yaml @@ -0,0 +1,36 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: minimal +spec: + steps: + - name: step-00 + try: + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - apply: + file: 01-create-cluster.yaml + - name: step-02 + try: + - apply: + file: 02-create-linodemachine.tpl.yml + - assert: + file: 02-assert.yaml + - name: step-03 + try: + - delete: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachine + name: linodemachine-sample + - error: + file: 03-error.yaml + - name: step-04 + try: + - script: + content: 'URI="linode/instances" FILTER="{\"tags\":\"$(OBJ=linodemachines/linodemachine-sample + make getKubeUid)\"}" make callLinodeApiGet | grep ''results": 0''' diff --git a/e2e/linodevpc-controller/minimal/02-delete-vpc.yaml b/e2e/linodevpc-controller/minimal/02-delete-vpc.yaml deleted file mode 100644 index 193c292fd..000000000 --- a/e2e/linodevpc-controller/minimal/02-delete-vpc.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -delete: -- apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 - kind: LinodeVPC - name: linodevpc-sample diff --git a/e2e/linodevpc-controller/minimal/03-verify-vpc.yaml b/e2e/linodevpc-controller/minimal/03-verify-vpc.yaml deleted file mode 100644 index 9d882abd6..000000000 --- a/e2e/linodevpc-controller/minimal/03-verify-vpc.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -commands: - - script: |- - URI="vpcs" FILTER="{\"label\":\"CLi-$(OBJ=linodevpcs/linodevpc-sample make getKubeUid | sed 's/-//g')\"}" make callLinodeApiGet | grep 'results": 0' diff --git a/e2e/linodevpc-controller/minimal/chainsaw-test.yaml b/e2e/linodevpc-controller/minimal/chainsaw-test.yaml new file mode 100755 index 000000000..497954797 --- /dev/null +++ b/e2e/linodevpc-controller/minimal/chainsaw-test.yaml @@ -0,0 +1,33 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json +apiVersion: chainsaw.kyverno.io/v1alpha1 +kind: Test +metadata: + creationTimestamp: null + name: minimal +spec: + steps: + - name: step-00 + try: + - assert: + file: 00-assert.yaml + - name: step-01 + try: + - apply: + file: 01-create-vpc.yaml + - assert: + file: 01-assert.yaml + - name: step-02 + try: + - delete: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + name: linodevpc-sample + - apply: + file: 02-error.yaml + - name: step-03 + try: + - script: + content: 'URI="vpcs" FILTER="{\"label\":\"CLi-$(OBJ=linodevpcs/linodevpc-sample + make getKubeUid | sed ''s/-//g'')\"}" make callLinodeApiGet | grep ''results": + 0'''