Skip to content

Commit

Permalink
adeodhar: add try catch block
Browse files Browse the repository at this point in the history
  • Loading branch information
amold1 committed May 1, 2024
1 parent acc8b58 commit 009cf87
Show file tree
Hide file tree
Showing 8 changed files with 812 additions and 733 deletions.
224 changes: 117 additions & 107 deletions e2e/capl-cluster-flavors/default-CAPL-cluster/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,112 +12,122 @@ metadata:
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`)), '-'))
- 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:
- events:
namespace: ($namespace)
- get:
apiVersion: cluster.x-k8s.io/v1beta1
kind: MachineDeployment
- 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
- 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
Loading

0 comments on commit 009cf87

Please sign in to comment.