[RECV-94] Separate docker/robot invoking
[validation.git] / tests / k8s / conformance / conformance.robot
1 ##############################################################################
2 # Copyright (c) 2019 AT&T Intellectual Property.                             #
3 # Copyright (c) 2019 Nokia.                                                  #
4 # Copyright (c) 2019 Enea AB
5 #                                                                            #
6 # Licensed under the Apache License, Version 2.0 (the "License");            #
7 # you maynot use this file except in compliance with the License.            #
8 #                                                                            #
9 # You may obtain a copy of the License at                                    #
10 #       http://www.apache.org/licenses/LICENSE-2.0                           #
11 #                                                                            #
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 ##############################################################################
18
19 *** Settings ***
20 Documentation     Run k8s conformance test using sonobuoy
21 Library           OperatingSystem
22 Library           BuiltIn
23 Test Setup        Check that k8s cluster is reachable
24 Test Teardown     Cleanup Sonobuoy
25
26 *** Variables ***
27 ${LOG}            ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log
28
29 *** Test Cases ***
30 Run Sonobuoy Conformance Test
31         # Start the test
32         Run                     kubectl apply -f ${CURDIR}${/}sonobuoy.yaml
33         Sleep                   5s
34         ${rc}  ${output}=       Run And Return Rc And Output
35                                 ...  kubectl describe pod/sonobuoy -n heptio-sonobuoy
36         Append To File          ${LOG}  ${output}${\n}
37
38         # Wait until the test finishes execution
39         Run                     while sonobuoy status | grep "Sonobuoy is still running"; do sleep 120; done
40         Append To File          ${LOG}  "Sonobuoy has completed"${\n}
41
42         # Get the result and store the sonobuoy logs
43         ${rc}  ${output}=       Run And Return Rc And Output
44                                 ...  results=$(sonobuoy retrieve ${LOG_PATH}) && sonobuoy e2e $results
45         Append To File          ${LOG}  ${output}${\n}
46         Should Contain          ${output}       failed tests: 0
47
48 *** Keywords ***
49 Check that k8s cluster is reachable
50         # Check that the config file is mounted in the container
51         File Should Not Be Empty  /root/.kube/config
52
53         # Make sure the pod is reachable with the local k8s client
54         ${rc}  ${output}=       Run And Return Rc And Output
55                                 ...  kubectl get pods --all-namespaces
56         Append To File          ${LOG}  ${output}${\n}
57         Should Contain          ${output}      kube-system
58
59 Cleanup Sonobuoy
60         ${rc}  ${output}=       Run And Return Rc And Output
61                                 ...  kubectl delete -f ${CURDIR}${/}sonobuoy.yaml
62         Append To File          ${LOG}  ${output}${\n}
63         Sleep                   3s
64         Should Contain          ${output}      service "sonobuoy-master" deleted