From fd20ee5fdcf696e2680bbbb6f673a2b60437f395 Mon Sep 17 00:00:00 2001 From: Evan Johnson Date: Wed, 28 Feb 2024 18:16:53 -0500 Subject: [PATCH] refactor kuttl tests to remove kuttl-in-kuttl --- e2e/Makefile | 18 +---- e2e/README.MD | 20 +----- .../00-assert.yaml | 0 .../01-create-cluster.yaml | 0 .../02-assert.yaml | 0 .../02-create-linodecluster.yaml | 0 .../03-verify-nodebalancer.yaml | 5 ++ .../04-delete-linodecluster.yaml | 0 .../04-error.yaml | 0 .../05-verify-nodebalancer-destroyed.yaml | 5 ++ .../06-cleanup-cluster.yaml | 0 .../Makefile | 0 .../minimal/03-verify-nodebalancer.yaml | 5 -- .../05-verify-nodebalancer-destroyed.yaml | 5 -- .../byovpc/01-create-cluster.yaml | 69 ------------------- .../byovpc/01-vpc-create-options.json | 10 --- .../byovpc/02-create-linodemachine.yaml | 18 ----- .../byovpc/03-delete-linodemachine.yaml | 6 -- .../byovpc/04-verify-linode-instance.yaml | 5 -- e2e/linodemachine-controller/byovpc/Makefile | 11 --- .../00-assert.yaml | 0 .../01-create-cluster.yaml | 21 ++++++ .../minimal-linodemachine/02-assert.yaml | 23 +++++++ .../02-create-linodemachine.yaml | 32 +++++++++ .../03-verify-linode-instance.yaml | 5 ++ .../04-delete-cluster.yaml | 6 ++ .../04-error.yaml} | 0 .../05-verify-no-linode-instance.yaml | 5 ++ .../06-cleanup-cluster.yaml | 5 ++ .../Makefile | 0 .../minimal/01-create-cluster.yaml | 43 ------------ .../minimal/02-assert.yaml | 10 --- .../minimal/02-create-linodemachine.yaml | 18 ----- .../minimal/03-delete-linodemachine.yaml | 6 -- .../minimal/03-error.yaml | 4 -- .../minimal/04-verify-linode-instance.yaml | 5 -- .../00-assert.yaml | 0 .../vpc-integration}/01-assert.yaml | 1 - .../vpc-integration/01-create-cluster.yaml | 34 +++++++++ .../vpc-integration/02-assert.yaml | 23 +++++++ .../02-create-linodemachine.yaml | 32 +++++++++ .../03-verify-linode-instance.yaml | 7 ++ .../vpc-integration/04-delete-cluster.yaml | 9 +++ .../04-error.yaml} | 12 ++-- .../05-verify-no-linode-instance.yaml | 7 ++ .../vpc-integration/06-cleanup-cluster.yaml | 5 ++ .../vpc-integration}/Makefile | 0 .../00-assert.yaml | 0 .../01-assert.yaml} | 3 +- .../01-create-vpc.yaml | 1 - .../minimal-linodevpc/02-verify-vpc.yaml | 5 ++ .../03-delete-vpc.yaml} | 0 .../minimal-linodevpc/03-error.yaml} | 6 +- .../minimal-linodevpc/04-verify-no-vpc.yaml | 5 ++ .../minimal-linodevpc/Makefile | 1 + .../minimal/03-verify-vpc.yaml | 5 -- 56 files changed, 251 insertions(+), 265 deletions(-) rename e2e/linodecluster-controller/{minimal => minimal-linodecluster}/00-assert.yaml (100%) rename e2e/linodecluster-controller/{minimal => minimal-linodecluster}/01-create-cluster.yaml (100%) rename e2e/linodecluster-controller/{minimal => minimal-linodecluster}/02-assert.yaml (100%) rename e2e/linodecluster-controller/{minimal => minimal-linodecluster}/02-create-linodecluster.yaml (100%) create mode 100644 e2e/linodecluster-controller/minimal-linodecluster/03-verify-nodebalancer.yaml rename e2e/linodecluster-controller/{minimal => minimal-linodecluster}/04-delete-linodecluster.yaml (100%) rename e2e/linodecluster-controller/{minimal => minimal-linodecluster}/04-error.yaml (100%) create mode 100644 e2e/linodecluster-controller/minimal-linodecluster/05-verify-nodebalancer-destroyed.yaml rename e2e/linodecluster-controller/{minimal => minimal-linodecluster}/06-cleanup-cluster.yaml (100%) rename e2e/linodecluster-controller/{minimal => minimal-linodecluster}/Makefile (100%) delete mode 100644 e2e/linodecluster-controller/minimal/03-verify-nodebalancer.yaml delete mode 100644 e2e/linodecluster-controller/minimal/05-verify-nodebalancer-destroyed.yaml delete mode 100644 e2e/linodemachine-controller/byovpc/01-create-cluster.yaml delete mode 100644 e2e/linodemachine-controller/byovpc/01-vpc-create-options.json 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 delete mode 100644 e2e/linodemachine-controller/byovpc/Makefile rename e2e/linodemachine-controller/{byovpc => minimal-linodemachine}/00-assert.yaml (100%) create mode 100644 e2e/linodemachine-controller/minimal-linodemachine/01-create-cluster.yaml create mode 100644 e2e/linodemachine-controller/minimal-linodemachine/02-assert.yaml create mode 100644 e2e/linodemachine-controller/minimal-linodemachine/02-create-linodemachine.yaml create mode 100644 e2e/linodemachine-controller/minimal-linodemachine/03-verify-linode-instance.yaml create mode 100644 e2e/linodemachine-controller/minimal-linodemachine/04-delete-cluster.yaml rename e2e/linodemachine-controller/{byovpc/03-error.yaml => minimal-linodemachine/04-error.yaml} (100%) create mode 100644 e2e/linodemachine-controller/minimal-linodemachine/05-verify-no-linode-instance.yaml create mode 100644 e2e/linodemachine-controller/minimal-linodemachine/06-cleanup-cluster.yaml rename e2e/linodemachine-controller/{minimal => minimal-linodemachine}/Makefile (100%) delete mode 100644 e2e/linodemachine-controller/minimal/01-create-cluster.yaml delete mode 100644 e2e/linodemachine-controller/minimal/02-assert.yaml delete mode 100644 e2e/linodemachine-controller/minimal/02-create-linodemachine.yaml delete mode 100644 e2e/linodemachine-controller/minimal/03-delete-linodemachine.yaml delete mode 100644 e2e/linodemachine-controller/minimal/03-error.yaml delete mode 100644 e2e/linodemachine-controller/minimal/04-verify-linode-instance.yaml rename e2e/linodemachine-controller/{minimal => vpc-integration}/00-assert.yaml (100%) rename e2e/{linodevpc-controller/minimal => linodemachine-controller/vpc-integration}/01-assert.yaml (81%) create mode 100644 e2e/linodemachine-controller/vpc-integration/01-create-cluster.yaml create mode 100644 e2e/linodemachine-controller/vpc-integration/02-assert.yaml create mode 100644 e2e/linodemachine-controller/vpc-integration/02-create-linodemachine.yaml create mode 100644 e2e/linodemachine-controller/vpc-integration/03-verify-linode-instance.yaml create mode 100644 e2e/linodemachine-controller/vpc-integration/04-delete-cluster.yaml rename e2e/linodemachine-controller/{byovpc/02-assert.yaml => vpc-integration/04-error.yaml} (50%) create mode 100644 e2e/linodemachine-controller/vpc-integration/05-verify-no-linode-instance.yaml create mode 100644 e2e/linodemachine-controller/vpc-integration/06-cleanup-cluster.yaml rename e2e/{linodevpc-controller/minimal => linodemachine-controller/vpc-integration}/Makefile (100%) rename e2e/linodevpc-controller/{minimal => minimal-linodevpc}/00-assert.yaml (100%) rename e2e/linodevpc-controller/{minimal/02-error.yaml => minimal-linodevpc/01-assert.yaml} (79%) rename e2e/linodevpc-controller/{minimal => minimal-linodevpc}/01-create-vpc.yaml (79%) create mode 100644 e2e/linodevpc-controller/minimal-linodevpc/02-verify-vpc.yaml rename e2e/linodevpc-controller/{minimal/02-delete-vpc.yaml => minimal-linodevpc/03-delete-vpc.yaml} (100%) rename e2e/{linodemachine-controller/byovpc/01-assert.yaml => linodevpc-controller/minimal-linodevpc/03-error.yaml} (58%) create mode 100644 e2e/linodevpc-controller/minimal-linodevpc/04-verify-no-vpc.yaml create mode 100644 e2e/linodevpc-controller/minimal-linodevpc/Makefile delete mode 100644 e2e/linodevpc-controller/minimal/03-verify-vpc.yaml diff --git a/e2e/Makefile b/e2e/Makefile index 5ca1917a7..994aeff35 100644 --- a/e2e/Makefile +++ b/e2e/Makefile @@ -10,21 +10,9 @@ runThisTest: _runThisTest: @D="$$(mktemp -d)" ;\ 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" - -getKubeUid: - @kubectl get -o jsonpath='{.metadata.uid}' -n "$$NAMESPACE" "$$OBJ" - -getKubeLabel: - @kubectl get -o jsonpath='{.spec.label}' -n "$$NAMESPACE" "$$OBJ" - -patchKubeObj: - @kubectl patch --type=merge -p "$$PATCH" -n "$$NAMESPACE" "$$OBJ" - -patchKubeObjStatus: - @kubectl patch --type=merge --subresource status -p "$$PATCH" -n "$$NAMESPACE" "$$OBJ" + mkdir $$D/suite ;\ + cp -r $(PWD) $$D/suite ;\ + ROOT_DIR=$(ROOT_DIR) KUBECONFIG="$(ROOT_DIR)/kubeconfig" kubectl-kuttl test --timeout 300 --skip-delete "$$D/suite" callLinodeApiGet: @curl -s -H "Authorization: Bearer $$LINODE_TOKEN" -H "X-Filter: $$FILTER" -H "Content-Type: application/json" "https://$(TARGET_API)/$(TARGET_API_VERSION)/$$URI" diff --git a/e2e/README.MD b/e2e/README.MD index 055a2c48e..14ec1fd2e 100644 --- a/e2e/README.MD +++ b/e2e/README.MD @@ -2,9 +2,8 @@ The E2E framework uses Kuttl under the hood. Kuttl is a simple and most importantly static tool that handles applying manifests for running assertions in a namespace it generates for each test. -In order to dynamically generate manifests, Kuttl supports declaring a `TestStep` manifest which includes an option for running scripts. This allows us apply manifests with dynamic values from stdin. -Additionally, helper functions can be invoked in the scripts by creating a Makefile in each test folder that references `../../Makefile` (i.e. `e2e/Makefile`). +Helper functions can be invoked in the scripts by creating a Makefile in each test folder that references `../../Makefile` (i.e. `e2e/Makefile`) in order to do custom validation. ## Example TestStep @@ -13,20 +12,7 @@ apiVersion: kuttl.dev/v1beta1 kind: TestStep commands: - script: |- - cat <