From 0357041167b7f85942ef95cc6a3fa7a55112f899 Mon Sep 17 00:00:00 2001 From: Khaja Omer <56000175+komer3@users.noreply.github.com> Date: Wed, 1 May 2024 09:52:44 -0500 Subject: [PATCH] Adding an E2E test that runs a full CAPL cluster test (default, k3s, & rke2) on merging to main (#266) * adeodhar: add try catch block --------- Co-authored-by: Khaja Omer Co-authored-by: Amol Deodhar --- .github/workflows/build_test_ci.yml | 25 +- Makefile | 4 +- docs/src/developers/testing.md | 43 ++- .../assert-capi-resources.yaml | 39 +++ .../assert-child-cluster-resources.yaml | 61 ++++ .../default-CAPL-cluster/chainsaw-test.yaml | 132 ++++++++ .../check-child-cluster-and-vpc-deleted.yaml | 10 + .../assert-capi-resources.yaml | 31 ++ .../assert-child-cluster-resources.yaml | 45 +++ .../k3s-capl-cluster/chainsaw-test.yaml | 129 ++++++++ .../check-child-cluster-and-vpc-deleted.yaml | 10 + .../assert-capi-resources.yaml | 31 ++ .../assert-child-cluster-resources.yaml | 45 +++ .../rke2-capl-cluster/chainsaw-test.yaml | 129 ++++++++ .../check-child-cluster-and-vpc-deleted.yaml | 10 + e2e/gha-clusterctl-config.yaml | 16 + .../06-cleanup-cluster.yaml | 5 - ...assert.yaml => assert-capi-resources.yaml} | 0 ...-assert.yaml => assert-linodecluster.yaml} | 0 .../minimal-linodecluster/chainsaw-test.yaml | 168 +++++----- ....yaml => check-linodecluster-deleted.yaml} | 0 ...reate-cluster.yaml => create-cluster.yaml} | 0 ...cluster.yaml => create-linodecluster.yaml} | 0 .../06-cleanup-cluster.yaml | 5 - .../assert-capi-resources.yaml | 31 ++ ...-assert.yaml => assert-linodemachine.yaml} | 0 .../minimal-linodemachine/chainsaw-test.yaml | 167 +++++----- ...yaml => check-linodemachine-deletion.yaml} | 0 ...reate-cluster.yaml => create-cluster.yaml} | 0 ...machine.yaml => create-linodemachine.yaml} | 0 .../vpc-integration/06-cleanup-cluster.yaml | 5 - .../assert-capi-resources.yaml | 31 ++ ...-assert.yaml => assert-linodemachine.yaml} | 0 .../{01-assert.yaml => assert-vpc.yaml} | 0 .../vpc-integration/chainsaw-test.yaml | 286 ++++++++++-------- ...-error.yaml => check-vpc-lm-deletion.yaml} | 0 ...e-cluster.yaml => create-cluster-vpc.yaml} | 0 ...machine.yaml => create-linodemachine.yaml} | 0 .../00-assert.yaml | 15 - .../assert-capi-resources.yaml} | 0 ...{05-assert.yaml => assert-key-secret.yaml} | 0 .../{03-assert.yaml => assert-keygen.yaml} | 0 ...assert.yaml => assert-obj-and-secret.yaml} | 0 .../chainsaw-test.yaml | 167 +++++----- ...s.yaml => check-obj-and-key-deletion.yaml} | 0 ... => create-linodeobjectstoragebucket.yaml} | 0 .../{03-patch-bucket.yaml => patch-obj.yaml} | 0 .../minimal-linodevpc/00-assert.yaml | 15 - .../assert-capi-resources.yaml} | 0 .../{01-assert.yaml => assert-vpc.yaml} | 0 .../minimal-linodevpc/chainsaw-test.yaml | 124 ++++---- ...reate-vpc.yaml => check-vpc-deletion.yaml} | 0 .../{03-error.yaml => create-vpc.yaml} | 0 53 files changed, 1302 insertions(+), 477 deletions(-) create mode 100644 e2e/capl-cluster-flavors/default-CAPL-cluster/assert-capi-resources.yaml create mode 100644 e2e/capl-cluster-flavors/default-CAPL-cluster/assert-child-cluster-resources.yaml create mode 100755 e2e/capl-cluster-flavors/default-CAPL-cluster/chainsaw-test.yaml create mode 100644 e2e/capl-cluster-flavors/default-CAPL-cluster/check-child-cluster-and-vpc-deleted.yaml create mode 100644 e2e/capl-cluster-flavors/k3s-capl-cluster/assert-capi-resources.yaml create mode 100644 e2e/capl-cluster-flavors/k3s-capl-cluster/assert-child-cluster-resources.yaml create mode 100755 e2e/capl-cluster-flavors/k3s-capl-cluster/chainsaw-test.yaml create mode 100644 e2e/capl-cluster-flavors/k3s-capl-cluster/check-child-cluster-and-vpc-deleted.yaml create mode 100644 e2e/capl-cluster-flavors/rke2-capl-cluster/assert-capi-resources.yaml create mode 100644 e2e/capl-cluster-flavors/rke2-capl-cluster/assert-child-cluster-resources.yaml create mode 100755 e2e/capl-cluster-flavors/rke2-capl-cluster/chainsaw-test.yaml create mode 100644 e2e/capl-cluster-flavors/rke2-capl-cluster/check-child-cluster-and-vpc-deleted.yaml create mode 100644 e2e/gha-clusterctl-config.yaml delete mode 100644 e2e/linodecluster-controller/minimal-linodecluster/06-cleanup-cluster.yaml rename e2e/linodecluster-controller/minimal-linodecluster/{00-assert.yaml => assert-capi-resources.yaml} (100%) rename e2e/linodecluster-controller/minimal-linodecluster/{02-assert.yaml => assert-linodecluster.yaml} (100%) rename e2e/linodecluster-controller/minimal-linodecluster/{04-error.yaml => check-linodecluster-deleted.yaml} (100%) rename e2e/linodecluster-controller/minimal-linodecluster/{01-create-cluster.yaml => create-cluster.yaml} (100%) rename e2e/linodecluster-controller/minimal-linodecluster/{02-create-linodecluster.yaml => create-linodecluster.yaml} (100%) delete mode 100644 e2e/linodemachine-controller/minimal-linodemachine/06-cleanup-cluster.yaml create mode 100644 e2e/linodemachine-controller/minimal-linodemachine/assert-capi-resources.yaml rename e2e/linodemachine-controller/minimal-linodemachine/{02-assert.yaml => assert-linodemachine.yaml} (100%) rename e2e/linodemachine-controller/minimal-linodemachine/{04-error.yaml => check-linodemachine-deletion.yaml} (100%) rename e2e/linodemachine-controller/minimal-linodemachine/{01-create-cluster.yaml => create-cluster.yaml} (100%) rename e2e/linodemachine-controller/minimal-linodemachine/{02-create-linodemachine.yaml => create-linodemachine.yaml} (100%) delete mode 100644 e2e/linodemachine-controller/vpc-integration/06-cleanup-cluster.yaml create mode 100644 e2e/linodemachine-controller/vpc-integration/assert-capi-resources.yaml rename e2e/linodemachine-controller/vpc-integration/{02-assert.yaml => assert-linodemachine.yaml} (100%) rename e2e/linodemachine-controller/vpc-integration/{01-assert.yaml => assert-vpc.yaml} (100%) rename e2e/linodemachine-controller/vpc-integration/{04-error.yaml => check-vpc-lm-deletion.yaml} (100%) rename e2e/linodemachine-controller/vpc-integration/{01-create-cluster.yaml => create-cluster-vpc.yaml} (100%) rename e2e/linodemachine-controller/vpc-integration/{02-create-linodemachine.yaml => create-linodemachine.yaml} (100%) delete mode 100644 e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/00-assert.yaml rename e2e/{linodemachine-controller/minimal-linodemachine/00-assert.yaml => linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/assert-capi-resources.yaml} (100%) rename e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/{05-assert.yaml => assert-key-secret.yaml} (100%) rename e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/{03-assert.yaml => assert-keygen.yaml} (100%) rename e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/{01-assert.yaml => assert-obj-and-secret.yaml} (100%) rename e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/{07-errors.yaml => check-obj-and-key-deletion.yaml} (100%) rename e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/{01-create-linodeobjectstoragebucket.yaml => create-linodeobjectstoragebucket.yaml} (100%) rename e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/{03-patch-bucket.yaml => patch-obj.yaml} (100%) delete mode 100644 e2e/linodevpc-controller/minimal-linodevpc/00-assert.yaml rename e2e/{linodemachine-controller/vpc-integration/00-assert.yaml => linodevpc-controller/minimal-linodevpc/assert-capi-resources.yaml} (100%) rename e2e/linodevpc-controller/minimal-linodevpc/{01-assert.yaml => assert-vpc.yaml} (100%) rename e2e/linodevpc-controller/minimal-linodevpc/{01-create-vpc.yaml => check-vpc-deletion.yaml} (100%) rename e2e/linodevpc-controller/minimal-linodevpc/{03-error.yaml => create-vpc.yaml} (100%) diff --git a/.github/workflows/build_test_ci.yml b/.github/workflows/build_test_ci.yml index 10bb55908..51aadb088 100644 --- a/.github/workflows/build_test_ci.yml +++ b/.github/workflows/build_test_ci.yml @@ -74,6 +74,9 @@ jobs: needs: [go-build-test, docker-build] runs-on: ubuntu-latest if: github.event.pull_request.draft == false + env: + GITHUB_TOKEN: ${{ secrets.github_token }} + LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }} steps: - name: Harden Runner uses: step-security/harden-runner@v2 @@ -85,6 +88,7 @@ jobs: api.github.com:443 github.com:443 gcr.io:443 + ghcr.io:443 proxy.golang.org:443 sum.golang.org:443 *.githubusercontent.com:443 @@ -103,6 +107,8 @@ jobs: cloud.tilt.dev:443 kubernetes-sigs.github.io:443 charts.jetstack.io:443 + helm.cilium.io:443 + linode.github.io:443 - uses: actions/checkout@v4 @@ -117,11 +123,24 @@ jobs: with: key: docker-${{ runner.os }}-${{ hashFiles('go.sum') }} - - name: E2E test + - name: Complete E2E Test + if: github.ref == 'refs/heads/main' run: make e2etest env: - GITHUB_TOKEN: ${{ secrets.github_token }} - LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }} + E2E_FLAGS: '--assert-timeout 15m0s' + INSTALL_K3S_PROVIDER: true + INSTALL_RKE2_PROVIDER: true + LINODE_REGION: us-sea + LINODE_CONTROL_PLANE_MACHINE_TYPE: g6-standard-2 + LINODE_MACHINE_TYPE: g6-standard-2 + CLUSTERCTL_CONFIG: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/e2e/gha-clusterctl-config.yaml + + + - name: Quick E2E Test + if: github.ref != 'refs/heads/main' + run: make e2etest + env: + E2E_FLAGS: '--selector quick' - name: Copy logs if: ${{ always() }} diff --git a/Makefile b/Makefile index eb4a8edd6..a1985c22c 100644 --- a/Makefile +++ b/Makefile @@ -146,8 +146,8 @@ test: generate fmt vet envtest ## Run tests. rm cover.out.tmp .PHONY: e2etest -e2etest: generate local-deploy chainsaw - GIT_REF=$(GIT_REF) $(CHAINSAW) test ./e2e +e2etest: generate local-release local-deploy chainsaw + GIT_REF=$(GIT_REF) $(CHAINSAW) test ./e2e $(E2E_FLAGS) local-deploy: kind ctlptl tilt kustomize clusterctl @echo -n "LINODE_TOKEN=$(LINODE_TOKEN)" > config/default/.env.linode diff --git a/docs/src/developers/testing.md b/docs/src/developers/testing.md index 9835e20c7..526c021fe 100644 --- a/docs/src/developers/testing.md +++ b/docs/src/developers/testing.md @@ -177,14 +177,51 @@ var _ = Describe("linode creation", func() { For e2e tests CAPL uses the [Chainsaw project](https://kyverno.github.io/chainsaw) which leverages `kind` and `tilt` to spin up a cluster with the CAPL controllers installed and then uses `chainsaw-test.yaml` files to drive e2e testing. -All test live in the e2e folder with a directory structure of `e2e/${CONTROLLER_NAME}/${TEST_NAME}` +All test live in the e2e folder with a directory structure of `e2e/${COMPONENT}/${TEST_NAME}` ### Running tests -In order to run e2e tests run the following command +In order to run e2e tests run the following commands: ```bash +# Required env vars to run e2e tests +export INSTALL_K3S_PROVIDER=true +export INSTALL_RKE2_PROVIDER=true +export LINODE_REGION=us-sea +export LINODE_CONTROL_PLANE_MACHINE_TYPE=g6-standard-2 +export LINODE_MACHINE_TYPE=g6-standard-2 + +# IMPORTANT: Set linode, k3s, and rke2 providers in this config file. +# Find an example at e2e/gha-clusterctl-config.yaml +export CLUSTERCTL_CONFIG=~/.cluster-api/clusterctl.yaml + make e2etest ``` +*Note: By default `make e2etest` runs all the e2e tests defined under `/e2e` dir* + +In order to run specific test, you need to pass flags to chainsaw by setting env var `E2E_FLAGS` + +Example: Only running e2e tests for flavors *(default, k3s, rke2)* +```bash +make e2etest E2E_FLAGS='--selector flavors --assert-timeout 10m0s' +``` +*Note: We need to bump up the assert timeout to 10 mins to allow the cluster to complete building and become available* + +There are other selectors you can use to invoke specfic tests. Please look at the table below for all the selectors available: + +| Tests | Selector | +| ------------- | ------------- | +| All Controllers | `quick` | +| All Flavors (default, k3s, rke2) | `flavors` | +| K3S Cluster | `k3s` | +| RKE2 Cluster | `rke2` | +| Default (kubeadm) Cluster | `default-cluster` | +| Linode Cluster Controller | `linodecluster` | +| Linode Machine Controller | `linodemachine` | +| Linode Obj Controller | `linodeobj` | +| Linode VPC Controller | `linodevpc` | + +*Note: For any flavor e2e tests, please set the required env variables* + ### Adding tests -1. Create a new directory under the controller you are testing with the naming scheme of `e2e/${CONTROLLER_NAME}/${TEST_NAME}` +1. Create a new directory under the controller you are testing with the naming scheme of `e2e/${COMPONENT}/${TEST_NAME}` 2. Create a minimal `chainsaw-test.yaml` file in the new test dir ```yaml # yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json diff --git a/e2e/capl-cluster-flavors/default-CAPL-cluster/assert-capi-resources.yaml b/e2e/capl-cluster-flavors/default-CAPL-cluster/assert-capi-resources.yaml new file mode 100644 index 000000000..0c8d0fc15 --- /dev/null +++ b/e2e/capl-cluster-flavors/default-CAPL-cluster/assert-capi-resources.yaml @@ -0,0 +1,39 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-controller-manager + namespace: capi-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capl-controller-manager + namespace: capl-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-kubeadm-bootstrap-controller-manager + namespace: kubeadm-bootstrap-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-kubeadm-control-plane-controller-manager + namespace: kubeadm-control-plane-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: caaph-controller-manager + namespace: caaph-system +status: + availableReplicas: 1 diff --git a/e2e/capl-cluster-flavors/default-CAPL-cluster/assert-child-cluster-resources.yaml b/e2e/capl-cluster-flavors/default-CAPL-cluster/assert-child-cluster-resources.yaml new file mode 100644 index 000000000..a1575a44f --- /dev/null +++ b/e2e/capl-cluster-flavors/default-CAPL-cluster/assert-child-cluster-resources.yaml @@ -0,0 +1,61 @@ +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeMachine +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +spec: + region: (env('LINODE_REGION')) + type: g6-standard-2 +status: + ready: true + instanceState: running +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Machine +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +spec: + clusterName: ($cluster) +status: + bootstrapReady: true + infrastructureReady: true +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +spec: + clusterName: ($cluster) + replicas: 1 +status: + readyReplicas: 1 + unavailableReplicas: 0 + availableReplicas: 1 +--- +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +kind: KubeadmControlPlane +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +status: + readyReplicas: 1 + unavailableReplicas: 0 + ready: true +--- +apiVersion: addons.cluster.x-k8s.io/v1alpha1 +kind: HelmReleaseProxy +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +status: + conditions: + - type: Ready + status: "True" + - type: ClusterAvailable + status: "True" + - type: HelmReleaseReady + status: "True" + status: deployed diff --git a/e2e/capl-cluster-flavors/default-CAPL-cluster/chainsaw-test.yaml b/e2e/capl-cluster-flavors/default-CAPL-cluster/chainsaw-test.yaml new file mode 100755 index 000000000..1b1f62acb --- /dev/null +++ b/e2e/capl-cluster-flavors/default-CAPL-cluster/chainsaw-test.yaml @@ -0,0 +1,132 @@ +# 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: default-capl-cluster + # Labels to allow the test to be triggered based on selector flag + labels: + default-cluster: + flavors: +spec: + bindings: + # A short identifier for the E2E test run + - name: run + value: (join('-', ['e2e', 'default-cluster', env('GIT_REF')])) + - name: cluster + # Format the cluster name + value: (trim((truncate(($run), `32`)), '-')) + template: true + steps: + - name: Check if CAPI provider resources exist + try: + - assert: + file: assert-capi-resources.yaml + - name: Generate cluster using clusterctl + try: + - script: + env: + - name: CLUSTER + value: ($cluster) + - name: NAMESPACE + value: ($namespace) + - name: CLUSTERCTL_CONFIG + value: (env('CLUSTERCTL_CONFIG')) + content: | + set -e + clusterctl generate cluster $CLUSTER -n $NAMESPACE \ + --kubernetes-version v1.29.1 \ + --infrastructure local-linode:v0.0.0 \ + --control-plane-machine-count 1 --worker-machine-count 1 \ + --config $CLUSTERCTL_CONFIG > default-cluster.yaml + check: + ($error == null): true + - name: Apply generated cluster yaml + try: + - apply: + file: default-cluster.yaml + - assert: + file: assert-child-cluster-resources.yaml + catch: + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachine + - describe: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Machine + - describe: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: MachineDeployment + - describe: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KubeadmControlPlane + - describe: + apiVersion: addons.cluster.x-k8s.io/v1alpha1 + kind: HelmReleaseProxy + - name: Check if the linodes are created + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: linode/instances + - name: FILTER + value: (to_string({"tags":($cluster)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 2 + - name: Delete child cluster + try: + - delete: + ref: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + name: ($cluster) + - delete: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + name: ($cluster) + - error: + file: check-child-cluster-and-vpc-deleted.yaml + - name: Check if the linodes are deleted + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: linode/instances + - name: FILTER + value: (to_string({"tags":($cluster)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 0 + - name: Delete generated child cluster manifest yaml + try: + - script: + content: | + rm -f default-cluster.yaml + check: + ($error == null): true diff --git a/e2e/capl-cluster-flavors/default-CAPL-cluster/check-child-cluster-and-vpc-deleted.yaml b/e2e/capl-cluster-flavors/default-CAPL-cluster/check-child-cluster-and-vpc-deleted.yaml new file mode 100644 index 000000000..c533bac64 --- /dev/null +++ b/e2e/capl-cluster-flavors/default-CAPL-cluster/check-child-cluster-and-vpc-deleted.yaml @@ -0,0 +1,10 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeMachine +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeVPC +metadata: + name: ($cluster) diff --git a/e2e/capl-cluster-flavors/k3s-capl-cluster/assert-capi-resources.yaml b/e2e/capl-cluster-flavors/k3s-capl-cluster/assert-capi-resources.yaml new file mode 100644 index 000000000..f49986846 --- /dev/null +++ b/e2e/capl-cluster-flavors/k3s-capl-cluster/assert-capi-resources.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-controller-manager + namespace: capi-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capl-controller-manager + namespace: capl-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-k3s-bootstrap-controller-manager + namespace: capi-k3s-bootstrap-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-k3s-control-plane-controller-manager + namespace: capi-k3s-control-plane-system +status: + availableReplicas: 1 diff --git a/e2e/capl-cluster-flavors/k3s-capl-cluster/assert-child-cluster-resources.yaml b/e2e/capl-cluster-flavors/k3s-capl-cluster/assert-child-cluster-resources.yaml new file mode 100644 index 000000000..345fa407d --- /dev/null +++ b/e2e/capl-cluster-flavors/k3s-capl-cluster/assert-child-cluster-resources.yaml @@ -0,0 +1,45 @@ +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeMachine +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +spec: + region: (env('LINODE_REGION')) + type: g6-standard-2 +status: + ready: true + instanceState: running +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Machine +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +spec: + clusterName: ($cluster) +status: + bootstrapReady: true + infrastructureReady: true +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +spec: + clusterName: ($cluster) + replicas: 1 +status: + readyReplicas: 1 + unavailableReplicas: 0 + availableReplicas: 1 +--- +apiVersion: controlplane.cluster.x-k8s.io/v1beta1 +kind: KThreesControlPlane +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +status: + ready: true + readyReplicas: 1 diff --git a/e2e/capl-cluster-flavors/k3s-capl-cluster/chainsaw-test.yaml b/e2e/capl-cluster-flavors/k3s-capl-cluster/chainsaw-test.yaml new file mode 100755 index 000000000..3d36dc716 --- /dev/null +++ b/e2e/capl-cluster-flavors/k3s-capl-cluster/chainsaw-test.yaml @@ -0,0 +1,129 @@ +# 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: k3s-capl-cluster + # Labels to allow the test to be triggered based on selector flag + labels: + k3s: + flavors: +spec: + bindings: + # A short identifier for the E2E test run + - name: run + value: (join('-', ['e2e', 'k3s-cluster', env('GIT_REF')])) + - name: cluster + # Format the cluster name + value: (trim((truncate(($run), `32`)), '-')) + template: true + steps: + - name: Check if CAPI provider resources exist + try: + - assert: + file: assert-capi-resources.yaml + - name: Generate cluster using clusterctl + try: + - script: + env: + - name: CLUSTER + value: ($cluster) + - name: NAMESPACE + value: ($namespace) + - name: CLUSTERCTL_CONFIG + value: (env('CLUSTERCTL_CONFIG')) + content: | + set -e + clusterctl generate cluster $CLUSTER -n $NAMESPACE \ + --flavor k3s --kubernetes-version v1.29.1+k3s2 \ + --infrastructure local-linode:v0.0.0 \ + --control-plane-machine-count 1 --worker-machine-count 1 \ + --config $CLUSTERCTL_CONFIG > k3s-cluster.yaml + check: + ($error == null): true + - name: Apply generated cluster yaml + try: + - apply: + file: k3s-cluster.yaml + - assert: + file: assert-child-cluster-resources.yaml + catch: + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachine + - describe: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Machine + - describe: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: MachineDeployment + - describe: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KThreesControlPlane + - name: Check if the linodes are created + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: linode/instances + - name: FILTER + value: (to_string({"tags":($cluster)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 2 + - name: Delete child cluster + try: + - delete: + ref: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + name: ($cluster) + - delete: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + name: ($cluster) + - error: + file: check-child-cluster-and-vpc-deleted.yaml + - name: Check if the linodes are deleted + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: linode/instances + - name: FILTER + value: (to_string({"tags":($cluster)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 0 + - name: Delete generated child cluster manifest yaml + try: + - script: + content: | + rm -f k3s-cluster.yaml + check: + ($error == null): true diff --git a/e2e/capl-cluster-flavors/k3s-capl-cluster/check-child-cluster-and-vpc-deleted.yaml b/e2e/capl-cluster-flavors/k3s-capl-cluster/check-child-cluster-and-vpc-deleted.yaml new file mode 100644 index 000000000..c533bac64 --- /dev/null +++ b/e2e/capl-cluster-flavors/k3s-capl-cluster/check-child-cluster-and-vpc-deleted.yaml @@ -0,0 +1,10 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeMachine +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeVPC +metadata: + name: ($cluster) diff --git a/e2e/capl-cluster-flavors/rke2-capl-cluster/assert-capi-resources.yaml b/e2e/capl-cluster-flavors/rke2-capl-cluster/assert-capi-resources.yaml new file mode 100644 index 000000000..a11178dc1 --- /dev/null +++ b/e2e/capl-cluster-flavors/rke2-capl-cluster/assert-capi-resources.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-controller-manager + namespace: capi-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capl-controller-manager + namespace: capl-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: rke2-bootstrap-controller-manager + namespace: rke2-bootstrap-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: rke2-control-plane-controller-manager + namespace: rke2-control-plane-system +status: + availableReplicas: 1 diff --git a/e2e/capl-cluster-flavors/rke2-capl-cluster/assert-child-cluster-resources.yaml b/e2e/capl-cluster-flavors/rke2-capl-cluster/assert-child-cluster-resources.yaml new file mode 100644 index 000000000..daeefa32d --- /dev/null +++ b/e2e/capl-cluster-flavors/rke2-capl-cluster/assert-child-cluster-resources.yaml @@ -0,0 +1,45 @@ +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeMachine +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +spec: + region: (env('LINODE_REGION')) + type: g6-standard-2 +status: + ready: true + instanceState: running +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: Machine +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +spec: + clusterName: ($cluster) +status: + bootstrapReady: true + infrastructureReady: true +--- +apiVersion: cluster.x-k8s.io/v1beta1 +kind: MachineDeployment +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +spec: + clusterName: ($cluster) + replicas: 1 +status: + readyReplicas: 1 + unavailableReplicas: 0 + availableReplicas: 1 +--- +apiVersion: controlplane.cluster.x-k8s.io/v1alpha1 +kind: RKE2ControlPlane +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +status: + ready: true + readyReplicas: 1 diff --git a/e2e/capl-cluster-flavors/rke2-capl-cluster/chainsaw-test.yaml b/e2e/capl-cluster-flavors/rke2-capl-cluster/chainsaw-test.yaml new file mode 100755 index 000000000..a2bdb5a64 --- /dev/null +++ b/e2e/capl-cluster-flavors/rke2-capl-cluster/chainsaw-test.yaml @@ -0,0 +1,129 @@ +# 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: rke2-capl-cluster + # Labels to allow the test to be triggered based on selector flag + labels: + rke2: + flavors: +spec: + bindings: + # A short identifier for the E2E test run + - name: run + value: (join('-', ['e2e', 'rke2-cluster', env('GIT_REF')])) + - name: cluster + # Format the cluster name + value: (trim((truncate(($run), `32`)), '-')) + template: true + steps: + - name: Check if CAPI provider resources exist + try: + - assert: + file: assert-capi-resources.yaml + - name: Generate cluster using clusterctl + try: + - script: + env: + - name: CLUSTER + value: ($cluster) + - name: NAMESPACE + value: ($namespace) + - name: CLUSTERCTL_CONFIG + value: (env('CLUSTERCTL_CONFIG')) + content: | + set -e + clusterctl generate cluster $CLUSTER -n $NAMESPACE \ + --flavor rke2 --kubernetes-version v1.29.1+rke2r1 \ + --infrastructure local-linode:v0.0.0 \ + --control-plane-machine-count 1 --worker-machine-count 1 \ + --config $CLUSTERCTL_CONFIG> rke2-cluster.yaml + check: + ($error == null): true + - name: Apply generated cluster yaml + try: + - apply: + file: rke2-cluster.yaml + - assert: + file: assert-child-cluster-resources.yaml + catch: + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachine + - describe: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Machine + - describe: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: MachineDeployment + - describe: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: RKE2ControlPlane + - name: Check if the linodes are created + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: linode/instances + - name: FILTER + value: (to_string({"tags":($cluster)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 2 + - name: Delete child cluster + try: + - delete: + ref: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + name: ($cluster) + - delete: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + name: ($cluster) + - error: + file: check-child-cluster-and-vpc-deleted.yaml + - name: Check if the linodes are deleted + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: linode/instances + - name: FILTER + value: (to_string({"tags":($cluster)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 0 + - name: Delete generated child cluster manifest yaml + try: + - script: + content: | + rm -f rke2-cluster.yaml + check: + ($error == null): true diff --git a/e2e/capl-cluster-flavors/rke2-capl-cluster/check-child-cluster-and-vpc-deleted.yaml b/e2e/capl-cluster-flavors/rke2-capl-cluster/check-child-cluster-and-vpc-deleted.yaml new file mode 100644 index 000000000..c533bac64 --- /dev/null +++ b/e2e/capl-cluster-flavors/rke2-capl-cluster/check-child-cluster-and-vpc-deleted.yaml @@ -0,0 +1,10 @@ +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeMachine +metadata: + labels: + cluster.x-k8s.io/cluster-name: ($cluster) +--- +apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 +kind: LinodeVPC +metadata: + name: ($cluster) diff --git a/e2e/gha-clusterctl-config.yaml b/e2e/gha-clusterctl-config.yaml new file mode 100644 index 000000000..460e1b6fb --- /dev/null +++ b/e2e/gha-clusterctl-config.yaml @@ -0,0 +1,16 @@ +providers: + - name: local-linode + url: /home/runner/work/cluster-api-provider-linode/cluster-api-provider-linode/infrastructure-local-linode/v0.0.0/infrastructure-components.yaml + type: InfrastructureProvider + - name: "k3s" + url: https://github.com/k3s-io/cluster-api-k3s/releases/latest/bootstrap-components.yaml + type: "BootstrapProvider" + - name: "k3s" + url: https://github.com/k3s-io/cluster-api-k3s/releases/latest/control-plane-components.yaml + type: "ControlPlaneProvider" + - name: "rke2" + url: "https://github.com/rancher-sandbox/cluster-api-provider-rke2/releases/latest/bootstrap-components.yaml" + type: "BootstrapProvider" + - name: "rke2" + url: "https://github.com/rancher-sandbox/cluster-api-provider-rke2/releases/latest/control-plane-components.yaml" + type: "ControlPlaneProvider" diff --git a/e2e/linodecluster-controller/minimal-linodecluster/06-cleanup-cluster.yaml b/e2e/linodecluster-controller/minimal-linodecluster/06-cleanup-cluster.yaml deleted file mode 100644 index 285f1dc25..000000000 --- a/e2e/linodecluster-controller/minimal-linodecluster/06-cleanup-cluster.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: cluster.x-k8s.io/v1beta1 -kind: Cluster -metadata: - name: ($cluster) -spec: diff --git a/e2e/linodecluster-controller/minimal-linodecluster/00-assert.yaml b/e2e/linodecluster-controller/minimal-linodecluster/assert-capi-resources.yaml similarity index 100% rename from e2e/linodecluster-controller/minimal-linodecluster/00-assert.yaml rename to e2e/linodecluster-controller/minimal-linodecluster/assert-capi-resources.yaml diff --git a/e2e/linodecluster-controller/minimal-linodecluster/02-assert.yaml b/e2e/linodecluster-controller/minimal-linodecluster/assert-linodecluster.yaml similarity index 100% rename from e2e/linodecluster-controller/minimal-linodecluster/02-assert.yaml rename to e2e/linodecluster-controller/minimal-linodecluster/assert-linodecluster.yaml diff --git a/e2e/linodecluster-controller/minimal-linodecluster/chainsaw-test.yaml b/e2e/linodecluster-controller/minimal-linodecluster/chainsaw-test.yaml index 5514ba06a..a00c8e996 100755 --- a/e2e/linodecluster-controller/minimal-linodecluster/chainsaw-test.yaml +++ b/e2e/linodecluster-controller/minimal-linodecluster/chainsaw-test.yaml @@ -4,88 +4,96 @@ kind: Test metadata: creationTimestamp: null name: minimal-linodecluster + # Label to trigger the test on every PR + labels: + quick: + linodecluster: spec: bindings: # A short identifier for the E2E test run - - name: run - value: (join('-', ['e2e', 'min-cluster', env('GIT_REF')])) - - name: cluster - # Format the cluster name - value: (trim((truncate(($run), `32`)), '-')) - - name: nodebalancer - value: ($cluster) + - name: run + value: (join('-', ['e2e', 'min-cluster', env('GIT_REF')])) + - name: cluster + # Format the cluster name + value: (trim((truncate(($run), `32`)), '-')) + - name: nodebalancer + value: ($cluster) template: true 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: - env: - - name: TARGET_API - value: api.linode.com - - name: TARGET_API_VERSION - value: v4beta - - name: URI - value: nodebalancers - - name: FILTER - value: (to_string({"label":($nodebalancer)})) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "X-Filter: $FILTER" \ - -H "Content-Type: application/json" \ - "https://$TARGET_API/$TARGET_API_VERSION/$URI" - check: - ($error): ~ - (json_parse($stdout)): - results: 1 - - name: step-04 - try: - - delete: - ref: - apiVersion: cluster.x-k8s.io/v1beta1 - kind: Cluster - name: ($cluster) - - error: - file: 04-error.yaml - - name: step-05 - try: - - script: - env: - - name: TARGET_API - value: api.linode.com - - name: TARGET_API_VERSION - value: v4beta - - name: URI - value: nodebalancers - - name: FILTER - value: (to_string({"label":($nodebalancer)})) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "X-Filter: $FILTER" \ - -H "Content-Type: application/json" \ - "https://$TARGET_API/$TARGET_API_VERSION/$URI" - check: - ($error): ~ - (json_parse($stdout)): - results: 0 - - name: step-06 - try: - - apply: - file: 06-cleanup-cluster.yaml + - name: Check if CAPI provider resources exist + try: + - assert: + file: assert-capi-resources.yaml + - name: Create Cluster resource + try: + - apply: + file: create-cluster.yaml + catch: + - describe: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + - name: Create LinodeCluster resource + try: + - apply: + file: create-linodecluster.yaml + - assert: + file: assert-linodecluster.yaml + catch: + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeCluster + - name: Check if the nodebalancer exists + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: nodebalancers + - name: FILTER + value: (to_string({"label":($nodebalancer)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 1 + - name: Delete Cluster resource + try: + - delete: + ref: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + name: ($cluster) + - error: + file: check-linodecluster-deleted.yaml + - name: Check if the nodebalancer is deleted + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: nodebalancers + - name: FILTER + value: (to_string({"label":($nodebalancer)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 0 diff --git a/e2e/linodecluster-controller/minimal-linodecluster/04-error.yaml b/e2e/linodecluster-controller/minimal-linodecluster/check-linodecluster-deleted.yaml similarity index 100% rename from e2e/linodecluster-controller/minimal-linodecluster/04-error.yaml rename to e2e/linodecluster-controller/minimal-linodecluster/check-linodecluster-deleted.yaml diff --git a/e2e/linodecluster-controller/minimal-linodecluster/01-create-cluster.yaml b/e2e/linodecluster-controller/minimal-linodecluster/create-cluster.yaml similarity index 100% rename from e2e/linodecluster-controller/minimal-linodecluster/01-create-cluster.yaml rename to e2e/linodecluster-controller/minimal-linodecluster/create-cluster.yaml diff --git a/e2e/linodecluster-controller/minimal-linodecluster/02-create-linodecluster.yaml b/e2e/linodecluster-controller/minimal-linodecluster/create-linodecluster.yaml similarity index 100% rename from e2e/linodecluster-controller/minimal-linodecluster/02-create-linodecluster.yaml rename to e2e/linodecluster-controller/minimal-linodecluster/create-linodecluster.yaml diff --git a/e2e/linodemachine-controller/minimal-linodemachine/06-cleanup-cluster.yaml b/e2e/linodemachine-controller/minimal-linodemachine/06-cleanup-cluster.yaml deleted file mode 100644 index 285f1dc25..000000000 --- a/e2e/linodemachine-controller/minimal-linodemachine/06-cleanup-cluster.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: cluster.x-k8s.io/v1beta1 -kind: Cluster -metadata: - name: ($cluster) -spec: diff --git a/e2e/linodemachine-controller/minimal-linodemachine/assert-capi-resources.yaml b/e2e/linodemachine-controller/minimal-linodemachine/assert-capi-resources.yaml new file mode 100644 index 000000000..2e5c6a3a7 --- /dev/null +++ b/e2e/linodemachine-controller/minimal-linodemachine/assert-capi-resources.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-controller-manager + namespace: capi-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capl-controller-manager + namespace: capl-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-kubeadm-bootstrap-controller-manager + namespace: kubeadm-bootstrap-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-kubeadm-control-plane-controller-manager + namespace: kubeadm-control-plane-system +status: + availableReplicas: 1 diff --git a/e2e/linodemachine-controller/minimal-linodemachine/02-assert.yaml b/e2e/linodemachine-controller/minimal-linodemachine/assert-linodemachine.yaml similarity index 100% rename from e2e/linodemachine-controller/minimal-linodemachine/02-assert.yaml rename to e2e/linodemachine-controller/minimal-linodemachine/assert-linodemachine.yaml diff --git a/e2e/linodemachine-controller/minimal-linodemachine/chainsaw-test.yaml b/e2e/linodemachine-controller/minimal-linodemachine/chainsaw-test.yaml index 796f76d81..74a63c18b 100755 --- a/e2e/linodemachine-controller/minimal-linodemachine/chainsaw-test.yaml +++ b/e2e/linodemachine-controller/minimal-linodemachine/chainsaw-test.yaml @@ -4,86 +4,97 @@ kind: Test metadata: creationTimestamp: null name: minimal-linodemachine + # Label to trigger the test on every PR + labels: + quick: + linodemachine: spec: bindings: # A short identifier for the E2E test run - - name: run - value: (join('-', ['e2e', 'min-lm', env('GIT_REF')])) - - name: cluster - # Format the cluster name - value: (trim((truncate(($run), `32`)), '-')) + - name: run + value: (join('-', ['e2e', 'min-lm', env('GIT_REF')])) + - name: cluster + # Format the cluster name + value: (trim((truncate(($run), `32`)), '-')) template: true 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.yaml - - assert: - file: 02-assert.yaml - - name: step-03 - try: - - script: - env: - - name: TARGET_API - value: api.linode.com - - name: TARGET_API_VERSION - value: v4beta - - name: URI - value: linode/instances - - name: FILTER - value: (to_string({"tags":($cluster)})) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "X-Filter: $FILTER" \ - -H "Content-Type: application/json" \ - "https://$TARGET_API/$TARGET_API_VERSION/$URI" - check: - ($error): ~ - (json_parse($stdout)): - results: 1 - - name: step-04 - try: - - delete: - ref: - apiVersion: cluster.x-k8s.io/v1beta1 - kind: Cluster - name: ($cluster) - - error: - file: 04-error.yaml - - name: step-05 - try: - - script: - env: - - name: TARGET_API - value: api.linode.com - - name: TARGET_API_VERSION - value: v4beta - - name: URI - value: linode/instances - - name: FILTER - value: (to_string({"tags":($cluster)})) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "X-Filter: $FILTER" \ - -H "Content-Type: application/json" \ - "https://$TARGET_API/$TARGET_API_VERSION/$URI" - check: - ($error): ~ - (json_parse($stdout)): - results: 0 - - name: step-06 - try: - - apply: - file: 06-cleanup-cluster.yaml + - name: Check if CAPI provider resources exist + try: + - assert: + file: assert-capi-resources.yaml + - name: Create Cluster resource + try: + - apply: + file: create-cluster.yaml + catch: + - describe: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + - name: Create LinodeMachine resource + try: + - apply: + file: create-linodemachine.yaml + - assert: + file: assert-linodemachine.yaml + catch: + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachineTemplate + - describe: + apiVersion: controlplane.cluster.x-k8s.io/v1beta1 + kind: KubeadmControlPlane + - name: Check if the Linodes were created + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: linode/instances + - name: FILTER + value: (to_string({"tags":($cluster)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 1 + - name: Delete Cluster resource + try: + - delete: + ref: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + name: ($cluster) + - error: + file: check-linodemachine-deletion.yaml + - name: Check if the Linodes were deleted + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: linode/instances + - name: FILTER + value: (to_string({"tags":($cluster)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 0 diff --git a/e2e/linodemachine-controller/minimal-linodemachine/04-error.yaml b/e2e/linodemachine-controller/minimal-linodemachine/check-linodemachine-deletion.yaml similarity index 100% rename from e2e/linodemachine-controller/minimal-linodemachine/04-error.yaml rename to e2e/linodemachine-controller/minimal-linodemachine/check-linodemachine-deletion.yaml diff --git a/e2e/linodemachine-controller/minimal-linodemachine/01-create-cluster.yaml b/e2e/linodemachine-controller/minimal-linodemachine/create-cluster.yaml similarity index 100% rename from e2e/linodemachine-controller/minimal-linodemachine/01-create-cluster.yaml rename to e2e/linodemachine-controller/minimal-linodemachine/create-cluster.yaml diff --git a/e2e/linodemachine-controller/minimal-linodemachine/02-create-linodemachine.yaml b/e2e/linodemachine-controller/minimal-linodemachine/create-linodemachine.yaml similarity index 100% rename from e2e/linodemachine-controller/minimal-linodemachine/02-create-linodemachine.yaml rename to e2e/linodemachine-controller/minimal-linodemachine/create-linodemachine.yaml diff --git a/e2e/linodemachine-controller/vpc-integration/06-cleanup-cluster.yaml b/e2e/linodemachine-controller/vpc-integration/06-cleanup-cluster.yaml deleted file mode 100644 index 285f1dc25..000000000 --- a/e2e/linodemachine-controller/vpc-integration/06-cleanup-cluster.yaml +++ /dev/null @@ -1,5 +0,0 @@ -apiVersion: cluster.x-k8s.io/v1beta1 -kind: Cluster -metadata: - name: ($cluster) -spec: diff --git a/e2e/linodemachine-controller/vpc-integration/assert-capi-resources.yaml b/e2e/linodemachine-controller/vpc-integration/assert-capi-resources.yaml new file mode 100644 index 000000000..2e5c6a3a7 --- /dev/null +++ b/e2e/linodemachine-controller/vpc-integration/assert-capi-resources.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-controller-manager + namespace: capi-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capl-controller-manager + namespace: capl-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-kubeadm-bootstrap-controller-manager + namespace: kubeadm-bootstrap-system +status: + availableReplicas: 1 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: capi-kubeadm-control-plane-controller-manager + namespace: kubeadm-control-plane-system +status: + availableReplicas: 1 diff --git a/e2e/linodemachine-controller/vpc-integration/02-assert.yaml b/e2e/linodemachine-controller/vpc-integration/assert-linodemachine.yaml similarity index 100% rename from e2e/linodemachine-controller/vpc-integration/02-assert.yaml rename to e2e/linodemachine-controller/vpc-integration/assert-linodemachine.yaml diff --git a/e2e/linodemachine-controller/vpc-integration/01-assert.yaml b/e2e/linodemachine-controller/vpc-integration/assert-vpc.yaml similarity index 100% rename from e2e/linodemachine-controller/vpc-integration/01-assert.yaml rename to e2e/linodemachine-controller/vpc-integration/assert-vpc.yaml diff --git a/e2e/linodemachine-controller/vpc-integration/chainsaw-test.yaml b/e2e/linodemachine-controller/vpc-integration/chainsaw-test.yaml index 8ddccd91b..dd61e84f8 100755 --- a/e2e/linodemachine-controller/vpc-integration/chainsaw-test.yaml +++ b/e2e/linodemachine-controller/vpc-integration/chainsaw-test.yaml @@ -4,142 +4,160 @@ kind: Test metadata: creationTimestamp: null name: vpc-integration + # Label to trigger the test on every PR + labels: + quick: + linodemachine: + linodevpc: spec: bindings: # A short identifier for the E2E test run - - name: run - value: (join('-', ['e2e', 'lm-vpc', env('GIT_REF')])) - - name: cluster - # Format the cluster name - value: (trim((truncate(($run), `32`)), '-')) - - name: vpc - # Format the VPC name into a valid Kubernetes object name - value: (trim((truncate(($run), `63`)), '-')) + - name: run + value: (join('-', ['e2e', 'lm-vpc', env('GIT_REF')])) + - name: cluster + # Format the cluster name + value: (trim((truncate(($run), `32`)), '-')) + - name: vpc + # Format the VPC name into a valid Kubernetes object name + value: (trim((truncate(($run), `63`)), '-')) template: true steps: - - name: step-00 - try: - - assert: - file: 00-assert.yaml - - name: step-01 - try: - - apply: - file: 01-create-cluster.yaml - - assert: - file: 01-assert.yaml - - name: step-02 - try: - - apply: - file: 02-create-linodemachine.yaml - - assert: - file: 02-assert.yaml - - name: step-03 - try: - - script: - env: - - name: TARGET_API - value: api.linode.com - - name: TARGET_API_VERSION - value: v4beta - - name: URI - value: linode/instances - - name: FILTER - value: (to_string({"tags":($cluster)})) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "X-Filter: $FILTER" \ - -H "Content-Type: application/json" \ - "https://$TARGET_API/$TARGET_API_VERSION/$URI" - check: - ($error): ~ - (json_parse($stdout)): - results: 1 - - script: - env: - - name: TARGET_API - value: api.linode.com - - name: TARGET_API_VERSION - value: v4beta - - name: URI - value: vpcs - - name: FILTER - value: (to_string({"label":($vpc)})) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "X-Filter: $FILTER" \ - -H "Content-Type: application/json" \ - "https://$TARGET_API/$TARGET_API_VERSION/$URI" - check: - ($error): ~ - (json_parse($stdout)): - data: - - subnets: - - linodes: - - interfaces: - - active: true - - name: step-04 - try: - - delete: - ref: - apiVersion: cluster.x-k8s.io/v1beta1 - kind: Cluster - name: ($cluster) - - delete: - ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 - kind: LinodeVPC - name: ($vpc) - - error: - file: 04-error.yaml - - name: step-05 - try: - - script: - env: - - name: TARGET_API - value: api.linode.com - - name: TARGET_API_VERSION - value: v4beta - - name: URI - value: linode/instances - - name: FILTER - value: (to_string({"tags":($cluster)})) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "X-Filter: $FILTER" \ - -H "Content-Type: application/json" \ - "https://$TARGET_API/$TARGET_API_VERSION/$URI" - check: - ($error): ~ - (json_parse($stdout)): - results: 0 - - script: - env: - - name: TARGET_API - value: api.linode.com - - name: TARGET_API_VERSION - value: v4beta - - name: URI - value: vpcs - - name: FILTER - value: (to_string({"label":($vpc)})) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "X-Filter: $FILTER" \ - -H "Content-Type: application/json" \ - "https://$TARGET_API/$TARGET_API_VERSION/$URI" - check: - ($error): ~ - (json_parse($stdout)): - results: 0 - - name: step-06 - try: - - apply: - file: 06-cleanup-cluster.yaml + - name: Check if CAPI provider resources exist + try: + - assert: + file: assert-capi-resources.yaml + - name: Create Cluster and LinodeVPC resources + try: + - apply: + file: create-cluster-vpc.yaml + - assert: + file: assert-vpc.yaml + catch: + - describe: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeCluster + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + - name: Create LinodeMachine resource + try: + - apply: + file: create-linodemachine.yaml + - assert: + file: assert-linodemachine.yaml + catch: + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeMachine + - describe: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Machine + - name: Check if the Linodes & VPC were created + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: linode/instances + - name: FILTER + value: (to_string({"tags":($cluster)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 1 + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: vpcs + - name: FILTER + value: (to_string({"label":($vpc)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + data: + - subnets: + - linodes: + - interfaces: + - active: true + - name: Delete the Cluster & LinodeVPC resource + try: + - delete: + ref: + apiVersion: cluster.x-k8s.io/v1beta1 + kind: Cluster + name: ($cluster) + - delete: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + name: ($vpc) + - error: + file: check-vpc-lm-deletion.yaml + - name: Check if the Linodes & VPC were deleted + try: + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: linode/instances + - name: FILTER + value: (to_string({"tags":($cluster)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 0 + - script: + env: + - name: TARGET_API + value: api.linode.com + - name: TARGET_API_VERSION + value: v4beta + - name: URI + value: vpcs + - name: FILTER + value: (to_string({"label":($vpc)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://$TARGET_API/$TARGET_API_VERSION/$URI" + check: + ($error): ~ + (json_parse($stdout)): + results: 0 diff --git a/e2e/linodemachine-controller/vpc-integration/04-error.yaml b/e2e/linodemachine-controller/vpc-integration/check-vpc-lm-deletion.yaml similarity index 100% rename from e2e/linodemachine-controller/vpc-integration/04-error.yaml rename to e2e/linodemachine-controller/vpc-integration/check-vpc-lm-deletion.yaml diff --git a/e2e/linodemachine-controller/vpc-integration/01-create-cluster.yaml b/e2e/linodemachine-controller/vpc-integration/create-cluster-vpc.yaml similarity index 100% rename from e2e/linodemachine-controller/vpc-integration/01-create-cluster.yaml rename to e2e/linodemachine-controller/vpc-integration/create-cluster-vpc.yaml diff --git a/e2e/linodemachine-controller/vpc-integration/02-create-linodemachine.yaml b/e2e/linodemachine-controller/vpc-integration/create-linodemachine.yaml similarity index 100% rename from e2e/linodemachine-controller/vpc-integration/02-create-linodemachine.yaml rename to e2e/linodemachine-controller/vpc-integration/create-linodemachine.yaml diff --git a/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/00-assert.yaml b/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/00-assert.yaml deleted file mode 100644 index 8a5b8dbab..000000000 --- a/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/00-assert.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: capi-controller-manager - namespace: capi-system -status: - availableReplicas: 1 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: capl-controller-manager - namespace: capl-system -status: - availableReplicas: 1 diff --git a/e2e/linodemachine-controller/minimal-linodemachine/00-assert.yaml b/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/assert-capi-resources.yaml similarity index 100% rename from e2e/linodemachine-controller/minimal-linodemachine/00-assert.yaml rename to e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/assert-capi-resources.yaml diff --git a/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/05-assert.yaml b/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/assert-key-secret.yaml similarity index 100% rename from e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/05-assert.yaml rename to e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/assert-key-secret.yaml diff --git a/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/03-assert.yaml b/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/assert-keygen.yaml similarity index 100% rename from e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/03-assert.yaml rename to e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/assert-keygen.yaml diff --git a/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/01-assert.yaml b/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/assert-obj-and-secret.yaml similarity index 100% rename from e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/01-assert.yaml rename to e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/assert-obj-and-secret.yaml diff --git a/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/chainsaw-test.yaml b/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/chainsaw-test.yaml index a0520d6f2..e5508d089 100755 --- a/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/chainsaw-test.yaml +++ b/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/chainsaw-test.yaml @@ -3,82 +3,101 @@ apiVersion: chainsaw.kyverno.io/v1alpha1 kind: Test metadata: name: minimal-linodeobjectstoragebucket + # Label to trigger the test on every PR + labels: + quick: + linodeobj: spec: bindings: # A short identifier for the E2E test run - - name: run - value: (join('-', ['e2e', 'min-obj', env('GIT_REF')])) - - name: bucket - # Format the bucket name into a valid Kubernetes object name - # TODO: This is over-truncated to account for the Kubernetes access key Secret - value: (trim((truncate(($run), `52`)), '-')) - - name: access_keys_secret - value: (join('-', [($bucket), 'bucket-details'])) + - name: run + value: (join('-', ['e2e', 'min-obj', env('GIT_REF')])) + - name: bucket + # Format the bucket name into a valid Kubernetes object name + # TODO: This is over-truncated to account for the Kubernetes access key Secret + value: (trim((truncate(($run), `52`)), '-')) + - name: access_keys_secret + value: (join('-', [($bucket), 'bucket-details'])) template: true steps: - - name: step-00 - try: - - assert: - file: 00-assert.yaml - - name: step-01 - try: - - apply: - file: 01-create-linodeobjectstoragebucket.yaml - - assert: - file: 01-assert.yaml - - name: step-02 - try: - - script: - env: - - name: BUCKET - value: ($bucket) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "Content-Type: application/json" \ - "https://api.linode.com/v4/object-storage/buckets/us-sea-1/$BUCKET" - check: - ($error): ~ - (json_parse($stdout)): - label: ($bucket) - - name: step-03 - try: - - apply: - file: 03-patch-bucket.yaml - - assert: - file: 03-assert.yaml - - name: step-04 - try: - - delete: - ref: - apiVersion: v1 - kind: Secret - name: (join('-', [($namespace), 'backups-bucket-details'])) - - name: step-05 - try: - - assert: - file: 05-assert.yaml - - name: step-06 - try: - - delete: - ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 - kind: LinodeObjectStorageBucket - name: ($bucket) - - script: - env: - - name: BUCKET - value: ($bucket) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -X DELETE \ - "https://api.linode.com/v4/object-storage/buckets/us-sea-1/$BUCKET" - check: - ($error): ~ - - name: step-07 - try: - - error: - file: 07-errors.yaml + - name: Check if CAPI provider resources exist + try: + - assert: + file: assert-capi-resources.yaml + - name: Create LinodeObjectStorageBucket + try: + - apply: + file: create-linodeobjectstoragebucket.yaml + - assert: + file: assert-obj-and-secret.yaml + catch: + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeObjectStorageBucket + - describe: + apiVersion: v1 + kind: Secret + - name: Check if the bucket was created + try: + - script: + env: + - name: BUCKET + value: ($bucket) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "Content-Type: application/json" \ + "https://api.linode.com/v4/object-storage/buckets/us-sea-1/$BUCKET" + check: + ($error): ~ + (json_parse($stdout)): + label: ($bucket) + - name: Test Key Generation + try: + - apply: + file: patch-obj.yaml + - assert: + file: assert-keygen.yaml + catch: + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeObjectStorageBucket + - name: Delete LinodeObjectStorageBucket details Secret + try: + - delete: + ref: + apiVersion: v1 + kind: Secret + name: (join('-', [($namespace), 'backups-bucket-details'])) + - name: Assert LinodeObjectStorageBucket key secret exists + try: + - assert: + file: assert-key-secret.yaml + catch: + - describe: + apiVersion: v1 + kind: Secret + - name: Delete LinodeObjectStorageBucket + try: + - delete: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeObjectStorageBucket + name: ($bucket) + - script: + env: + - name: BUCKET + value: ($bucket) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -X DELETE \ + "https://api.linode.com/v4/object-storage/buckets/us-sea-1/$BUCKET" + check: + ($error): ~ + - name: Check if the LinodeObjectStorageBucket was deleted + try: + - error: + file: check-obj-and-key-deletion.yaml diff --git a/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/07-errors.yaml b/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/check-obj-and-key-deletion.yaml similarity index 100% rename from e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/07-errors.yaml rename to e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/check-obj-and-key-deletion.yaml diff --git a/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/01-create-linodeobjectstoragebucket.yaml b/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/create-linodeobjectstoragebucket.yaml similarity index 100% rename from e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/01-create-linodeobjectstoragebucket.yaml rename to e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/create-linodeobjectstoragebucket.yaml diff --git a/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/03-patch-bucket.yaml b/e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/patch-obj.yaml similarity index 100% rename from e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/03-patch-bucket.yaml rename to e2e/linodeobjectstoragebucket-controller/minimal-linodeobjectstoragebucket/patch-obj.yaml diff --git a/e2e/linodevpc-controller/minimal-linodevpc/00-assert.yaml b/e2e/linodevpc-controller/minimal-linodevpc/00-assert.yaml deleted file mode 100644 index 8a5b8dbab..000000000 --- a/e2e/linodevpc-controller/minimal-linodevpc/00-assert.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: capi-controller-manager - namespace: capi-system -status: - availableReplicas: 1 ---- -apiVersion: apps/v1 -kind: Deployment -metadata: - name: capl-controller-manager - namespace: capl-system -status: - availableReplicas: 1 diff --git a/e2e/linodemachine-controller/vpc-integration/00-assert.yaml b/e2e/linodevpc-controller/minimal-linodevpc/assert-capi-resources.yaml similarity index 100% rename from e2e/linodemachine-controller/vpc-integration/00-assert.yaml rename to e2e/linodevpc-controller/minimal-linodevpc/assert-capi-resources.yaml diff --git a/e2e/linodevpc-controller/minimal-linodevpc/01-assert.yaml b/e2e/linodevpc-controller/minimal-linodevpc/assert-vpc.yaml similarity index 100% rename from e2e/linodevpc-controller/minimal-linodevpc/01-assert.yaml rename to e2e/linodevpc-controller/minimal-linodevpc/assert-vpc.yaml diff --git a/e2e/linodevpc-controller/minimal-linodevpc/chainsaw-test.yaml b/e2e/linodevpc-controller/minimal-linodevpc/chainsaw-test.yaml index 9de33ae04..7fd41d240 100644 --- a/e2e/linodevpc-controller/minimal-linodevpc/chainsaw-test.yaml +++ b/e2e/linodevpc-controller/minimal-linodevpc/chainsaw-test.yaml @@ -3,66 +3,74 @@ apiVersion: chainsaw.kyverno.io/v1alpha1 kind: Test metadata: name: minimal-linodevpc + # Label to trigger the test on every PR + labels: + quick: + linodevpc: spec: bindings: # A short identifier for the E2E test run - - name: run - value: (join('-', ['e2e', 'min-vpc', env('GIT_REF')])) - - name: vpc - # Format the VPC name into a valid Kubernetes object name - value: (trim((truncate(($run), `63`)), '-')) + - name: run + value: (join('-', ['e2e', 'min-vpc', env('GIT_REF')])) + - name: vpc + # Format the VPC name into a valid Kubernetes object name + value: (trim((truncate(($run), `63`)), '-')) template: true 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: - - script: - env: - - name: FILTER - value: (to_string({"label":($vpc)})) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "X-Filter: $FILTER" \ - -H "Content-Type: application/json" \ - "https://api.linode.com/v4/vpcs" - check: - ($error): ~ - (json_parse($stdout)): - results: 1 - - name: step-03 - try: - - delete: - ref: - apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 - kind: LinodeVPC - name: ($vpc) - - error: - file: 03-error.yaml - - name: step-04 - try: - - script: - env: - - name: FILTER - value: (to_string({"label":($vpc)})) - content: | - set -e - curl -s \ - -H "Authorization: Bearer $LINODE_TOKEN" \ - -H "X-Filter: $FILTER" \ - -H "Content-Type: application/json" \ - "https://api.linode.com/v4/nodebalancers" - check: - ($error): ~ - (json_parse($stdout)): - results: 0 + - name: Check if CAPI provider resources exist + try: + - assert: + file: assert-capi-resources.yaml + - name: Create LinodeVPC + try: + - apply: + file: create-vpc.yaml + - assert: + file: assert-vpc.yaml + catch: + - describe: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + - name: Check if the VPC was created + try: + - script: + env: + - name: FILTER + value: (to_string({"label":($vpc)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://api.linode.com/v4/vpcs" + check: + ($error): ~ + (json_parse($stdout)): + results: 1 + - name: Delete VPC + try: + - delete: + ref: + apiVersion: infrastructure.cluster.x-k8s.io/v1alpha1 + kind: LinodeVPC + name: ($vpc) + - error: + file: check-vpc-deletion.yaml + - name: Check if the VPC was deleted + try: + - script: + env: + - name: FILTER + value: (to_string({"label":($vpc)})) + content: | + set -e + curl -s \ + -H "Authorization: Bearer $LINODE_TOKEN" \ + -H "X-Filter: $FILTER" \ + -H "Content-Type: application/json" \ + "https://api.linode.com/v4/nodebalancers" + check: + ($error): ~ + (json_parse($stdout)): + results: 0 diff --git a/e2e/linodevpc-controller/minimal-linodevpc/01-create-vpc.yaml b/e2e/linodevpc-controller/minimal-linodevpc/check-vpc-deletion.yaml similarity index 100% rename from e2e/linodevpc-controller/minimal-linodevpc/01-create-vpc.yaml rename to e2e/linodevpc-controller/minimal-linodevpc/check-vpc-deletion.yaml diff --git a/e2e/linodevpc-controller/minimal-linodevpc/03-error.yaml b/e2e/linodevpc-controller/minimal-linodevpc/create-vpc.yaml similarity index 100% rename from e2e/linodevpc-controller/minimal-linodevpc/03-error.yaml rename to e2e/linodevpc-controller/minimal-linodevpc/create-vpc.yaml