-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Co-authored-by: Amol Deodhar <[email protected]>
- Loading branch information
1 parent
1af26a0
commit 0357041
Showing
53 changed files
with
1,302 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
e2e/capl-cluster-flavors/default-CAPL-cluster/assert-capi-resources.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
61 changes: 61 additions & 0 deletions
61
e2e/capl-cluster-flavors/default-CAPL-cluster/assert-child-cluster-resources.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
132 changes: 132 additions & 0 deletions
132
e2e/capl-cluster-flavors/default-CAPL-cluster/chainsaw-test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
10 changes: 10 additions & 0 deletions
10
e2e/capl-cluster-flavors/default-CAPL-cluster/check-child-cluster-and-vpc-deleted.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
31 changes: 31 additions & 0 deletions
31
e2e/capl-cluster-flavors/k3s-capl-cluster/assert-capi-resources.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Oops, something went wrong.