1 ##############################################################################
2 # Copyright (c) 2019 AT&T Intellectual Property. #
3 # Copyright (c) 2019 Nokia. #
4 # Copyright (c) 2019 Enea AB
6 # Licensed under the Apache License, Version 2.0 (the "License"); #
7 # you maynot use this file except in compliance with the License. #
9 # You may obtain a copy of the License at #
10 # http://www.apache.org/licenses/LICENSE-2.0 #
12 # Unless required by applicable law or agreed to in writing, software #
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT #
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
15 # See the License for the specific language governing permissions and #
16 # limitations under the License. #
17 ##############################################################################
20 Documentation Run k8s conformance test using sonobuoy
21 Library OperatingSystem
27 Test Setup Run Keywords
28 ... Check that k8s cluster is reachable
30 ... Create Manifest File
31 Test Teardown Run Keywords
33 ... Close All Connections
36 ${LOG} ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log
38 &{SONOBUOY} path=gcr.io/heptio-images
39 ... name=sonobuoy:v0.15.1
41 ... name=validation:kube-conformance-v1.15
42 &{SYSTEMD_LOGS} path=akraino
43 ... name=validation:sonobuoy-plugin-systemd-logs-latest
44 &{SONOBUOY_IMGS} sonobuoy=&{SONOBUOY}
46 ... systemd_logs=&{SYSTEMD_LOGS}
49 Run Sonobuoy Conformance Test
51 Run kubectl apply -f ${CURDIR}${/}sonobuoy.yaml
53 ${rc} ${output}= Run And Return Rc And Output
54 ... kubectl describe pod/sonobuoy -n heptio-sonobuoy
55 Append To File ${LOG} ${output}${\n}
57 # Wait until the test finishes execution
58 Run while sonobuoy status | grep "Sonobuoy is still running"; do sleep 180; done
59 Append To File ${LOG} "Sonobuoy has completed"${\n}
61 # Get the result and store the sonobuoy logs
62 ${rc} ${output}= Run And Return Rc And Output
63 ... results=$(sonobuoy retrieve ${LOG_PATH}) && sonobuoy e2e $results
64 Append To File ${LOG} ${output}${\n}
65 Should Contain ${output} failed tests: 0
68 Check that k8s cluster is reachable
69 # Check that the config file is mounted in the container
70 File Should Not Be Empty /root/.kube/config
72 # Make sure the pod is reachable with the local k8s client
73 ${rc} ${output}= Run And Return Rc And Output
74 ... kubectl get pods --all-namespaces
75 Append To File ${LOG} ${output}${\n}
76 Should Contain ${output} kube-system
79 ${rc} ${output}= Run And Return Rc And Output
80 ... kubectl delete -f ${CURDIR}${/}sonobuoy.yaml
81 Append To File ${LOG} ${output}${\n}
83 Should Contain ${output} service "sonobuoy-master" deleted
85 Open Connection And Log In
86 Open Connection ${HOST}
87 Login With Public Key ${USERNAME} ${SSH_KEYFILE}
89 Upload To Internal Registry
90 [Arguments] ${path} ${name}
91 ${rc}= Execute Command
92 ... docker pull ${path}/${name}
93 ... return_stdout=False return_rc=True
94 Should Be Equal As Integers ${rc} 0
95 ${rc}= Execute Command
96 ... docker tag ${path}/${name} ${INT_REG}/bluval/${name}
97 ... return_stdout=False return_rc=True
98 Should Be Equal As Integers ${rc} 0
99 ${rc}= Execute Command
100 ... docker push ${INT_REG}/bluval/${name}
101 ... return_stdout=False return_rc=True
102 Should Be Equal As Integers ${rc} 0
104 Onboard Sonobuoy Images
105 FOR ${img} IN @{SONOBUOY_IMGS}
106 ${path}= Get From Dictionary ${SONOBUOY_IMGS['${img}']} path
107 ${name}= Get From Dictionary ${SONOBUOY_IMGS['${img}']} name
108 Upload To Internal Registry ${path} ${name}
109 Set To Dictionary ${SONOBUOY_IMGS['${img}']} path=${INT_REG}/bluval
112 Onboard Kubernetes e2e Test Images
113 ${result}= Run Process sonobuoy images
114 Should Be Equal As Integers ${result.rc} 0
115 @{images}= Split String ${result.stdout}
116 FOR ${img} IN @{images}
117 ${path} ${name} Split String From Right ${img} / 1
118 Upload To Internal Registry ${path} ${name}
122 ${INT_REG}= Get Variable Value ${INTERNAL_REGISTRY} ${EMPTY}
123 Set Test Variable ${INT_REG}
124 Return From Keyword If $INT_REG == '${EMPTY}'
125 Open Connection And Log In
126 Onboard Sonobuoy Images
127 Onboard Kubernetes e2e Test Images
130 @{flags}= Set Variable
131 ... --e2e-focus \\[Conformance\\\]
132 ... --e2e-skip Aggregator|Alpha|\\[(Disruptive|Feature:[^\\]]+|Flaky)\\]
133 ... --kube-conformance-image ${SONOBUOY_IMGS.e2e.path}/${SONOBUOY_IMGS.e2e.name}
134 ... --sonobuoy-image ${SONOBUOY_IMGS.sonobuoy.path}/${SONOBUOY_IMGS.sonobuoy.name}
135 ... --image-pull-policy Always
137 Run Keyword If $INT_REG != '${EMPTY}' Run Keywords
138 ... Append To List ${flags}
139 ... --e2e-repo-config ${CURDIR}${/}custom_repos.yaml
141 ... Run Process sed -i s|{{ registry }}|${INT_REG}/bluval|g
142 ... ${CURDIR}${/}custom_repos.yaml
143 ${result}= Run Process sonobuoy gen @{flags}
144 Should Be Equal As Integers ${result.rc} 0
145 ${manifest}= Replace String ${result.stdout}
146 ... image: gcr.io/heptio-images/sonobuoy-plugin-systemd-logs:latest
147 ... image: ${SONOBUOY_IMGS.systemd_logs.path}/${SONOBUOY_IMGS.systemd_logs.name}
148 Create File ${CURDIR}${/}sonobuoy.yaml ${manifest}