From ea586478fca1c66de261c1ff832bca26b2a51690 Mon Sep 17 00:00:00 2001 From: bcm820 Date: Fri, 9 Feb 2024 13:18:10 -0500 Subject: [PATCH] e2e: Basic test for cluster controller (#99) * e2e: Basic test for cluster controller * e2e: Add step to clean up cluster * e2e: Add step to verify nodebalancer creation --- .../minimal/01-create-cluster.yaml | 7 +++++++ e2e/linodecluster-controller/minimal/02-assert.yaml | 10 ++++++++++ .../minimal/02-create-linodecluster.tpl.yml | 11 +++++++++++ .../minimal/02-create-linodecluster.yaml | 6 ++++++ .../minimal/03-verify-nodebalancer.yaml | 5 +++++ .../minimal/04-delete-linodecluster.yaml | 6 ++++++ e2e/linodecluster-controller/minimal/04-error.yaml | 4 ++++ .../minimal/05-verify-nodebalancer-destroyed.yaml | 5 +++++ .../minimal/06-cleanup-cluster.yaml | 5 +++++ e2e/linodecluster-controller/minimal/Makefile | 1 + 10 files changed, 60 insertions(+) create mode 100644 e2e/linodecluster-controller/minimal/01-create-cluster.yaml create mode 100644 e2e/linodecluster-controller/minimal/02-assert.yaml create mode 100644 e2e/linodecluster-controller/minimal/02-create-linodecluster.tpl.yml create mode 100644 e2e/linodecluster-controller/minimal/02-create-linodecluster.yaml create mode 100644 e2e/linodecluster-controller/minimal/03-verify-nodebalancer.yaml create mode 100644 e2e/linodecluster-controller/minimal/04-delete-linodecluster.yaml create mode 100644 e2e/linodecluster-controller/minimal/04-error.yaml create mode 100644 e2e/linodecluster-controller/minimal/05-verify-nodebalancer-destroyed.yaml create mode 100644 e2e/linodecluster-controller/minimal/06-cleanup-cluster.yaml create mode 100644 e2e/linodecluster-controller/minimal/Makefile diff --git a/e2e/linodecluster-controller/minimal/01-create-cluster.yaml b/e2e/linodecluster-controller/minimal/01-create-cluster.yaml new file mode 100644 index 000000000..300c2cae0 --- /dev/null +++ b/e2e/linodecluster-controller/minimal/01-create-cluster.yaml @@ -0,0 +1,7 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + name: cluster-sample +spec: + infrastructureRef: + name: linodecluster-sample diff --git a/e2e/linodecluster-controller/minimal/02-assert.yaml b/e2e/linodecluster-controller/minimal/02-assert.yaml new file mode 100644 index 000000000..6293eda30 --- /dev/null +++ b/e2e/linodecluster-controller/minimal/02-assert.yaml @@ -0,0 +1,10 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeCluster +metadata: + name: linodecluster-sample + finalizers: + - infrastructure.cluster.x-k8s.io/v1alpha1 +spec: + region: us-sea +status: + ready: true diff --git a/e2e/linodecluster-controller/minimal/02-create-linodecluster.tpl.yml b/e2e/linodecluster-controller/minimal/02-create-linodecluster.tpl.yml new file mode 100644 index 000000000..81aa7c0ba --- /dev/null +++ b/e2e/linodecluster-controller/minimal/02-create-linodecluster.tpl.yml @@ -0,0 +1,11 @@ +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 new file mode 100644 index 000000000..231b7ef0a --- /dev/null +++ b/e2e/linodecluster-controller/minimal/02-create-linodecluster.yaml @@ -0,0 +1,6 @@ +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 diff --git a/e2e/linodecluster-controller/minimal/03-verify-nodebalancer.yaml b/e2e/linodecluster-controller/minimal/03-verify-nodebalancer.yaml new file mode 100644 index 000000000..bd5d4cea2 --- /dev/null +++ b/e2e/linodecluster-controller/minimal/03-verify-nodebalancer.yaml @@ -0,0 +1,5 @@ +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 new file mode 100644 index 000000000..b8f205339 --- /dev/null +++ b/e2e/linodecluster-controller/minimal/04-delete-linodecluster.yaml @@ -0,0 +1,6 @@ +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/04-error.yaml b/e2e/linodecluster-controller/minimal/04-error.yaml new file mode 100644 index 000000000..d0586b964 --- /dev/null +++ b/e2e/linodecluster-controller/minimal/04-error.yaml @@ -0,0 +1,4 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeCluster +metadata: + 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 new file mode 100644 index 000000000..6eb1db621 --- /dev/null +++ b/e2e/linodecluster-controller/minimal/05-verify-nodebalancer-destroyed.yaml @@ -0,0 +1,5 @@ +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 new file mode 100644 index 000000000..c0eb3fb3f --- /dev/null +++ b/e2e/linodecluster-controller/minimal/06-cleanup-cluster.yaml @@ -0,0 +1,5 @@ +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Cluster +metadata: + name: cluster-sample +spec: diff --git a/e2e/linodecluster-controller/minimal/Makefile b/e2e/linodecluster-controller/minimal/Makefile new file mode 100644 index 000000000..3924bfdc1 --- /dev/null +++ b/e2e/linodecluster-controller/minimal/Makefile @@ -0,0 +1 @@ +include ../../Makefile