Merge "bluval engine refactoring"
[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 ${RESULT_PATH}    /opt/akraino/validation/results/conformance/
28 ${REPO_PATH}      /opt/akraino/validation/repo/conformance/
29 ${LOG}            ${RESULT_PATH}${/}conformance.log
30
31 *** Test Cases ***
32 Run Sonobuoy Conformance Test
33         # Start the test
34         Run                     kubectl apply -f ${REPO_PATH}${/}sonobuoy.yaml
35         Sleep                   5s
36         ${rc}  ${output}=       Run And Return Rc And Output
37                                 ...  kubectl describe pod/sonobuoy -n heptio-sonobuoy
38         Append To File          ${LOG}  ${output}${\n}
39
40         # Wait until the test finishes execution
41         Run                     until sonobuoy status | grep "Sonobuoy has completed"; do sleep 120; done
42         Append To File          ${LOG}  "Sonobuoy has completed"${\n}
43
44         # Get the result and store the sonobuoy logs
45         ${rc}  ${output}=       Run And Return Rc And Output
46                                 ...  results=$(sonobuoy retrieve ${RESULT_PATH}) && sonobuoy e2e $results
47         Append To File          ${LOG}  ${output}${\n}
48         Should Contain          ${output}       failed tests: 0
49
50 *** Keywords ***
51 Check that k8s cluster is reachable
52         # Check that the config file is mounted in the container
53         File Should Not Be Empty  /root/.kube/config
54
55         # Make sure the pod is reachable with the local k8s client
56         ${rc}  ${output}=       Run And Return Rc And Output
57                                 ...  kubectl get pods --all-namespaces
58         Append To File          ${LOG}  ${output}${\n}
59         Should Contain          ${output}      kube-system
60
61 Cleanup Sonobuoy
62         ${rc}  ${output}=       Run And Return Rc And Output
63                                 ...  kubectl delete -f ${REPO_PATH}${/}sonobuoy.yaml
64         Append To File          ${LOG}  ${output}${\n}
65         Sleep                   3s
66         Should Contain          ${output}      service "sonobuoy-master" deleted