-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathchainsaw-test.yaml
More file actions
executable file
·164 lines (164 loc) · 5.24 KB
/
chainsaw-test.yaml
File metadata and controls
executable file
·164 lines (164 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# 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: linodecluster-vpcref-integration
# Label to trigger the test on every PR
labels:
all:
quick:
linodemachine:
linodevpc:
spec:
bindings:
# A short identifier for the E2E test run
- name: run
value: (join('-', ['e2e', 'lc-vpc', random('[0-9a-z]{7}')]))
- name: cluster
# Format the cluster name
value: (trim((truncate(($run), `29`)), '-'))
- name: vpc
# Format the VPC name into a valid Kubernetes object name
value: (trim((truncate(($run), `63`)), '-'))
template: true
steps:
- 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/v1alpha2
kind: LinodeCluster
- describe:
apiVersion: infrastructure.cluster.x-k8s.io/v1alpha2
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/v1alpha2
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/v1alpha2
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