Skip to content

Commit a83e2c8

Browse files
jpalagirHenry Wagner
authored andcommitted
Move the cleanup o c leanup section
1 parent 2cb8d57 commit a83e2c8

File tree

11 files changed

+409
-285
lines changed

11 files changed

+409
-285
lines changed

e2e/test/lb-created-with-invalid-ip/chainsaw-test.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ spec:
3838
- describe:
3939
apiVersion: v1
4040
kind: Service
41+
cleanup:
42+
- script:
43+
content: |
44+
set -e
45+
46+
delete_cm=$(kubectl delete configmap invalid-ip-config -n $NAMESPACE)
47+
if [[ "$delete_cm" == "configmap \"invalid-ip-config\" deleted" ]]; then
48+
echo "Configmap deleted successfully"
49+
else
50+
echo "Unable to delete the configmap: $delete_cm. Error: $delete_cm"
51+
fi
52+
check:
53+
($error == null): true
54+
(contains($stdout, 'Unable to delete the configmap')): false
4155
- name: Check that loadbalancer ip is not assigned
4256
try:
4357
- assert:
@@ -78,17 +92,8 @@ spec:
7892
if [[ "$service_ip" == "$invalid_ip" ]]; then
7993
echo "Expected service ip to be null got the invalid ip: $invalid_ip"
8094
fi
81-
82-
delete_cm=$(kubectl delete configmap invalid-ip-config -n $NAMESPACE)
83-
if [[ "$delete_cm" == "configmap \"invalid-ip-config\" deleted" ]]; then
84-
echo "Configmap deleted successfully"
85-
else
86-
echo "Unable to delete the configmap: $delete_cm. Error: $delete_cm"
87-
fi
88-
8995
check:
9096
($error == null): true
9197
(contains($stdout, 'Warning event not found')): false
9298
(contains($stdout, 'No invalid ip found in configmap')): false
93-
(contains($stdout, 'Unable to delete the configmap')): false
9499
(contains($stdout, 'Expected service ip to be null got the invalid ip')): false

e2e/test/lb-created-with-reserved-ip-and-nb-id-annotations/chainsaw-test.yaml

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,39 @@ spec:
8585
- describe:
8686
apiVersion: v1
8787
kind: Service
88+
cleanup:
89+
- script:
90+
content: |
91+
set -e
92+
93+
reserved_ip=$(kubectl get configmap nb-config -o=jsonpath='{.data.Reserved_IP}' -n $NAMESPACE)
94+
if [ -z "$reserved_ip" ]; then
95+
echo "Error: No reserved ip found in configmap"
96+
fi
97+
98+
delete_rip=$(curl -s --request DELETE \
99+
-H "Authorization: Bearer $LINODE_TOKEN" \
100+
-H "Content-Type: application/json" \
101+
"${LINODE_URL}/v4beta/networking/reserved/ips/$reserved_ip" )
102+
103+
if [[ "$delete_rip" == "{}" ]]; then
104+
echo "Reserved IP $reserved_ip deleted successfully"
105+
else
106+
echo "Unable to delete reserved ip: $reserved_ip. Error: $delete_rip"
107+
fi
108+
109+
delete_cm=$(kubectl delete configmap nb-config -n $NAMESPACE)
110+
if [[ "$delete_cm" == "configmap \"nb-config\" deleted" ]]; then
111+
echo "Configmap deleted successfully"
112+
else
113+
echo "Unable to delete the configmap: $delete_cm. Error: $delete_cm"
114+
fi
115+
116+
check:
117+
($error == null): true
118+
(contains($stdout, 'No reserved ip found in configmap')): false
119+
(contains($stdout, 'Unable to delete the configmap')): false
120+
(contains($stdout, 'Unable to delete reserved ip')): false
88121
- name: Check that loadbalancer ip is assigned
89122
try:
90123
- assert:
@@ -127,30 +160,10 @@ spec:
127160
else
128161
echo "IPs do not match"
129162
fi
130-
131-
delete_rip=$(curl -s --request DELETE \
132-
-H "Authorization: Bearer $LINODE_TOKEN" \
133-
-H "Content-Type: application/json" \
134-
"${LINODE_URL}/v4beta/networking/reserved/ips/$reserved_ip" )
135-
136-
if [[ "$delete_rip" == "{}" ]]; then
137-
echo "Reserved IP $reserved_ip deleted successfully"
138-
else
139-
echo "Unable to delete reserved ip: $reserved_ip. Error: $delete_rip"
140-
fi
141-
142-
delete_cm=$(kubectl delete configmap nb-config -n $NAMESPACE)
143-
if [[ "$delete_cm" == "configmap \"nb-config\" deleted" ]]; then
144-
echo "Configmap deleted successfully"
145-
else
146-
echo "Unable to delete the configmap: $delete_cm. Error: $delete_cm"
147-
fi
148-
149163
check:
150164
($error == null): true
151165
(contains($stdout, 'No reserved ip found in configmap')): false
152166
(contains($stdout, 'No service ip found for service svc-test')): false
153167
(contains($stdout, 'IPs do not match')): false
154168
(contains($stdout, 'NB IDs do not match')): false
155-
(contains($stdout, 'Unable to delete the configmap')): false
156-
(contains($stdout, 'Unable to delete reserved ip')): false
169+

e2e/test/lb-created-with-reserved-ip-attached-to-nb/chainsaw-test.yaml

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,38 @@ spec:
8585
- describe:
8686
apiVersion: v1
8787
kind: Service
88+
cleanup:
89+
- script:
90+
content: |
91+
set -e
92+
93+
reserved_ip=$(kubectl get configmap nb-config -o=jsonpath='{.data.Reserved_IP}' -n $NAMESPACE)
94+
if [ -z "$reserved_ip" ]; then
95+
echo "Error: No reserved ip found in configmap"
96+
fi
97+
98+
delete_rip=$(curl -s --request DELETE \
99+
-H "Authorization: Bearer $LINODE_TOKEN" \
100+
-H "Content-Type: application/json" \
101+
"${LINODE_URL}/v4beta/networking/reserved/ips/$reserved_ip" )
102+
103+
if [[ "$delete_rip" == "{}" ]]; then
104+
echo "Reserved IP $reserved_ip deleted successfully"
105+
else
106+
echo "Unable to delete reserved ip: $reserved_ip. Error: $delete_rip"
107+
fi
108+
109+
delete_cm=$(kubectl delete configmap nb-config -n $NAMESPACE)
110+
if [[ "$delete_cm" == "configmap \"nb-config\" deleted" ]]; then
111+
echo "Configmap deleted successfully"
112+
else
113+
echo "Unable to delete the configmap: $delete_cm. Error: $delete_cm"
114+
fi
115+
check:
116+
($error == null): true
117+
(contains($stdout, 'No reserved ip found in configmap')): false
118+
(contains($stdout, 'Unable to delete the configmap')): false
119+
(contains($stdout, 'Unable to delete reserved ip')): false
88120
- name: Check that loadbalancer ip is assigned
89121
try:
90122
- assert:
@@ -123,29 +155,9 @@ spec:
123155
else
124156
echo "IPs do not match"
125157
fi
126-
127-
delete_rip=$(curl -s --request DELETE \
128-
-H "Authorization: Bearer $LINODE_TOKEN" \
129-
-H "Content-Type: application/json" \
130-
"${LINODE_URL}/v4beta/networking/reserved/ips/$reserved_ip" )
131-
132-
if [[ "$delete_rip" == "{}" ]]; then
133-
echo "Reserved IP $reserved_ip deleted successfully"
134-
else
135-
echo "Unable to delete reserved ip: $reserved_ip. Error: $delete_rip"
136-
fi
137-
138-
delete_cm=$(kubectl delete configmap nb-config -n $NAMESPACE)
139-
if [[ "$delete_cm" == "configmap \"nb-config\" deleted" ]]; then
140-
echo "Configmap deleted successfully"
141-
else
142-
echo "Unable to delete the configmap: $delete_cm. Error: $delete_cm"
143-
fi
144-
145158
check:
146159
($error == null): true
147160
(contains($stdout, 'No reserved ip found in configmap')): false
148161
(contains($stdout, 'Service ip found for service svc-test. Expected to be empty')): false
149162
(contains($stdout, 'IPs do not match')): true
150-
(contains($stdout, 'Unable to delete the configmap')): false
151-
(contains($stdout, 'Unable to delete reserved ip')): false
163+

e2e/test/lb-created-with-reserved-ip-change-ip-concurrently/chainsaw-test.yaml

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,54 @@ spec:
6767
- describe:
6868
apiVersion: v1
6969
kind: Service
70+
cleanup:
71+
- script:
72+
content: |
73+
set -e
74+
75+
reserved_ip=$(kubectl get configmap reserved-ip-config -o=jsonpath='{.data.ReservedIP}' -n $NAMESPACE)
76+
if [ -z "$reserved_ip" ]; then
77+
echo "Error: No reserved ip found in configmap"
78+
fi
79+
80+
reserved_ip2=$(kubectl get configmap reserved-ip-config -o=jsonpath='{.data.ReservedIP2}' -n $NAMESPACE)
81+
if [ -z "$reserved_ip2" ]; then
82+
echo "Error: No reserved ip found in configmap"
83+
fi
84+
85+
delete_rip=$(curl -s --request DELETE \
86+
-H "Authorization: Bearer $LINODE_TOKEN" \
87+
-H "Content-Type: application/json" \
88+
"${LINODE_URL}/v4beta/networking/reserved/ips/$reserved_ip" )
89+
90+
if [[ "$delete_rip" == "{}" ]]; then
91+
echo "Reserved IP $reserved_ip deleted successfully"
92+
else
93+
echo "Unable to delete reserved ip: $reserved_ip. Error: $delete_rip"
94+
fi
95+
96+
delete_rip2=$(curl -s --request DELETE \
97+
-H "Authorization: Bearer $LINODE_TOKEN" \
98+
-H "Content-Type: application/json" \
99+
"${LINODE_URL}/v4beta/networking/reserved/ips/$reserved_ip2" )
100+
101+
if [[ "$delete_rip2" == "{}" ]]; then
102+
echo "Reserved IP $reserved_ip2 deleted successfully"
103+
else
104+
echo "Unable to delete reserved ip: $reserved_ip. Error: $delete_rip2"
105+
fi
106+
107+
delete_cm=$(kubectl delete configmap reserved-ip-config -n $NAMESPACE)
108+
if [[ "$delete_cm" == "configmap \"reserved-ip-config\" deleted" ]]; then
109+
echo "Configmap deleted successfully"
110+
else
111+
echo "Unable to delete the configmap: $delete_cm. Error: $delete_cm"
112+
fi
113+
check:
114+
($error == null): true
115+
(contains($stdout, 'No reserved ip found in configmap')): false
116+
(contains($stdout, 'Unable to delete the configmap')): false
117+
(contains($stdout, 'Unable to delete reserved ip')): false
70118
- name: Check that loadbalancer ip is assigned
71119
try:
72120
- assert:
@@ -157,39 +205,8 @@ spec:
157205
else
158206
echo "IPs do not match"
159207
fi
160-
161-
delete_rip=$(curl -s --request DELETE \
162-
-H "Authorization: Bearer $LINODE_TOKEN" \
163-
-H "Content-Type: application/json" \
164-
"${LINODE_URL}/v4beta/networking/reserved/ips/$reserved_ip" )
165-
166-
if [[ "$delete_rip" == "{}" ]]; then
167-
echo "Reserved IP $reserved_ip deleted successfully"
168-
else
169-
echo "Unable to delete reserved ip: $reserved_ip. Error: $delete_rip"
170-
fi
171-
172-
delete_rip2=$(curl -s --request DELETE \
173-
-H "Authorization: Bearer $LINODE_TOKEN" \
174-
-H "Content-Type: application/json" \
175-
"${LINODE_URL}/v4beta/networking/reserved/ips/$reserved_ip2" )
176-
177-
if [[ "$delete_rip2" == "{}" ]]; then
178-
echo "Reserved IP $reserved_ip2 deleted successfully"
179-
else
180-
echo "Unable to delete reserved ip: $reserved_ip. Error: $delete_rip2"
181-
fi
182-
183-
delete_cm=$(kubectl delete configmap reserved-ip-config -n $NAMESPACE)
184-
if [[ "$delete_cm" == "configmap \"reserved-ip-config\" deleted" ]]; then
185-
echo "Configmap deleted successfully"
186-
else
187-
echo "Unable to delete the configmap: $delete_cm. Error: $delete_cm"
188-
fi
189208
check:
190209
($error == null): true
191210
(contains($stdout, 'No reserved ip found in configmap')): false
192211
(contains($stdout, 'No service ip found for service svc-test')): false
193212
(contains($stdout, 'IPs do not match')): false
194-
(contains($stdout, 'Unable to delete the configmap')): false
195-
(contains($stdout, 'Unable to delete reserved ip')): false

e2e/test/lb-created-with-reserved-ip-change-ip-unreserved/chainsaw-test.yaml

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,38 @@ spec:
5454
- describe:
5555
apiVersion: v1
5656
kind: Service
57+
cleanup:
58+
- script:
59+
content: |
60+
set -e
61+
62+
reserved_ip=$(kubectl get configmap reserved-ip-config -o=jsonpath='{.data.ReservedIP}' -n $NAMESPACE)
63+
if [ -z "$reserved_ip" ]; then
64+
echo "Error: No reserved ip found in configmap"
65+
fi
66+
67+
delete_rip=$(curl -s --request DELETE \
68+
-H "Authorization: Bearer $LINODE_TOKEN" \
69+
-H "Content-Type: application/json" \
70+
"${LINODE_URL}/v4beta/networking/reserved/ips/$reserved_ip" )
71+
72+
if [[ "$delete_rip" == "{}" ]]; then
73+
echo "Reserved IP $reserved_ip deleted successfully"
74+
else
75+
echo "Unable to delete reserved ip: $reserved_ip. Error: $delete_rip"
76+
fi
77+
78+
delete_cm=$(kubectl delete configmap reserved-ip-config -n $NAMESPACE)
79+
if [[ "$delete_cm" == "configmap \"reserved-ip-config\" deleted" ]]; then
80+
echo "Configmap deleted successfully"
81+
else
82+
echo "Unable to delete the configmap: $delete_cm. Error: $delete_cm"
83+
fi
84+
check:
85+
($error == null): true
86+
(contains($stdout, 'No reserved ip found in configmap')): false
87+
(contains($stdout, 'Unable to delete the configmap')): false
88+
(contains($stdout, 'Unable to delete reserved ip')): false
5789
- name: Check that loadbalancer ip is assigned
5890
try:
5991
- assert:
@@ -135,28 +167,9 @@ spec:
135167
else
136168
echo "IPs do not match"
137169
fi
138-
139-
delete_rip=$(curl -s --request DELETE \
140-
-H "Authorization: Bearer $LINODE_TOKEN" \
141-
-H "Content-Type: application/json" \
142-
"${LINODE_URL}/v4beta/networking/reserved/ips/$reserved_ip" )
143-
144-
if [[ "$delete_rip" == "{}" ]]; then
145-
echo "Reserved IP $reserved_ip deleted successfully"
146-
else
147-
echo "Unable to delete reserved ip: $reserved_ip. Error: $delete_rip"
148-
fi
149-
150-
delete_cm=$(kubectl delete configmap reserved-ip-config -n $NAMESPACE)
151-
if [[ "$delete_cm" == "configmap \"reserved-ip-config\" deleted" ]]; then
152-
echo "Configmap deleted successfully"
153-
else
154-
echo "Unable to delete the configmap: $delete_cm. Error: $delete_cm"
155-
fi
156170
check:
157171
($error == null): true
158172
(contains($stdout, 'No reserved ip found in configmap')): false
159173
(contains($stdout, 'No service ip found for service svc-test')): false
160174
(contains($stdout, 'IPs do not match')): false
161-
(contains($stdout, 'Unable to delete the configmap')): false
162-
(contains($stdout, 'Unable to delete reserved ip')): false
175+

0 commit comments

Comments
 (0)