Add Helm chart repository Robot tests
[validation.git] / tests / helm / helm_repository.resource
1 ##############################################################################
2 # Copyright (c) 2019 AT&T Intellectual Property.                             #
3 # Copyright (c) 2019 Nokia.                                                  #
4 #                                                                            #
5 # Licensed under the Apache License, Version 2.0 (the "License");            #
6 # you maynot use this file except in compliance with the License.            #
7 #                                                                            #
8 # You may obtain a copy of the License at                                    #
9 #       http://www.apache.org/licenses/LICENSE-2.0                           #
10 #                                                                            #
11 # Unless required by applicable law or agreed to in writing, software        #
12 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
13 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
14 # See the License for the specific language governing permissions and        #
15 # limitations under the License.                                             #
16 ##############################################################################
17
18
19 *** Settings ***
20 Library             OperatingSystem
21 Library             Process
22 Library             SSHLibrary
23 Library             String
24
25
26 *** Variables ***
27 ${REPORTDIR}        ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}
28 ${DESTDIR}          /tmp/helm-repo
29 ${REPONAME}         default
30 ${REPOURL}          Actual value set dynamically at suite setup
31 ${CHARTARC}         Actual value set dynamically at suite setup
32 ${CHARTNAME}        bluval-test-alpine
33
34
35 *** Keywords ***
36 Open Connection And Log In
37     Open Connection         ${HOST}
38     Login With Public Key   ${USERNAME}  ${SSH_KEYFILE}
39
40 Build Chart Archive
41     Run Process             sed  -i  s/name: alpine/name: ${CHARTNAME}/  /opt/akraino/${CHARTNAME}/Chart.yaml
42     Execute Command         rm -r ${DESTDIR}
43     Put Directory           /opt/akraino/${CHARTNAME}  ${DESTDIR}/${CHARTNAME}  recursive=True
44     ${stdout}=              Execute Command  helm package ${DESTDIR}/${CHARTNAME} -d ${DESTDIR}
45     Should Contain          ${stdout}  Successfully packaged chart and saved it to:
46     ${CHARTARC}=            Fetch From Right  ${stdout}  /
47     Set Suite Variable      ${CHARTARC}
48
49 Get Default Repository
50     ${REPOURL}=             Execute Command  helm repo list | grep '^${REPONAME} ' | cut -f2
51     Set Suite Variable      ${REPOURL}
52     Should Not Be Empty     ${REPOURL}
53
54 Fail If Previous Test Failed
55     Run Keyword If          '${PREV_TEST_STATUS}'=='FAIL'  Fail  Skipping because '${PREV_TEST_NAME}' failed.
56
57 Upload Chart To Repository
58     ${STATUS}=              Execute Command  curl -X PUT --data-binary "@${DESTDIR}/${CHARTARC}" ${REPOURL}/${CHARTARC}
59     Set Test Variable       ${STATUS}
60
61 Chart Upload Should Have Succeeded
62     Should Be Empty         ${STATUS}
63
64 Chart Upload Should Have Failed
65     Should Not Be Empty     ${STATUS}
66
67 Update Repository Info
68     ${stdout}=              Execute Command  helm repo update
69     Should Contain          ${stdout}  Successfully got an update from the "${REPONAME}" chart repository
70
71 Inspect Chart
72     ${STATUS}=              Execute Command  helm inspect chart ${REPONAME}/${CHARTNAME}
73     ...                       return_stdout=False
74     ...                       return_rc=True
75     Set Test Variable       ${STATUS}
76
77 Find Chart In Repository
78     ${STATUS}=              Execute Command  helm search -r '\\v${REPONAME}/${CHARTNAME}\\v'
79     Set Test Variable       ${STATUS}
80
81 Chart Should Be Available
82     Should Contain          ${STATUS}  ${REPONAME}/${CHARTNAME}
83
84 Chart Should Not Be Available
85     Should Contain          ${STATUS}  No results found
86
87 Chart Should Be Accessible
88     Should Be Equal As Integers  ${STATUS}  0
89
90 Delete Chart
91     ${STATUS}=              Execute Command  curl -X DELETE ${REPOURL}/${CHARTARC}
92     Set Test Variable       ${STATUS}
93
94 Chart Delete Should Have Succeeded
95     Should Be Empty         ${STATUS}
96
97 Chart Delete Should Have Failed
98     Should Not Be Empty     ${STATUS}