Add Helm chart repository Robot tests 28/1528/3
authorJuha Kosonen <juha.kosonen@nokia.com>
Wed, 4 Sep 2019 08:25:46 +0000 (11:25 +0300)
committerJuha Kosonen <juha.kosonen@nokia.com>
Wed, 11 Sep 2019 10:52:26 +0000 (13:52 +0300)
Verifies charts can be added and removed from a chart repository.

Tests verified on REC cluster only.

JIRA: VAL-43

Change-Id: Iad1a5771210d8d2a7386f64db57a382a8bb96054
Signed-off-by: Juha Kosonen <juha.kosonen@nokia.com>
docker/helm/Dockerfile
tests/helm/helm_repository.resource [new file with mode: 0644]
tests/helm/helm_repository.robot [new file with mode: 0644]

index 841d261..896403b 100644 (file)
@@ -33,11 +33,13 @@ WORKDIR /wheels
 RUN pip3 install wheel
 RUN pip3 wheel -r /wheels/requirements/pip-requirements.txt
 RUN git clone https://gerrit.akraino.org/r/validation /opt/akraino/validation
+RUN git clone https://github.com/helm/helm.git /opt/helm
 
 # Copy binaries in the final container and install requirements
 FROM python:3.6-alpine3.9
 COPY --from=build /wheels /wheels
 COPY --from=build /opt/akraino/validation /opt/akraino/validation
+COPY --from=build /opt/helm/docs/examples/alpine /opt/akraino/bluval-test-alpine
 
 RUN pip3 install -r /wheels/requirements/pip-requirements.txt \
                  -f /wheels && \
diff --git a/tests/helm/helm_repository.resource b/tests/helm/helm_repository.resource
new file mode 100644 (file)
index 0000000..e6ca3a2
--- /dev/null
@@ -0,0 +1,98 @@
+##############################################################################
+# Copyright (c) 2019 AT&T Intellectual Property.                             #
+# Copyright (c) 2019 Nokia.                                                  #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License");            #
+# you maynot use this file except in compliance with the License.            #
+#                                                                            #
+# You may obtain a copy of the License at                                    #
+#       http://www.apache.org/licenses/LICENSE-2.0                           #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+##############################################################################
+
+
+*** Settings ***
+Library             OperatingSystem
+Library             Process
+Library             SSHLibrary
+Library             String
+
+
+*** Variables ***
+${REPORTDIR}        ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}
+${DESTDIR}          /tmp/helm-repo
+${REPONAME}         default
+${REPOURL}          Actual value set dynamically at suite setup
+${CHARTARC}         Actual value set dynamically at suite setup
+${CHARTNAME}        bluval-test-alpine
+
+
+*** Keywords ***
+Open Connection And Log In
+    Open Connection         ${HOST}
+    Login With Public Key   ${USERNAME}  ${SSH_KEYFILE}
+
+Build Chart Archive
+    Run Process             sed  -i  s/name: alpine/name: ${CHARTNAME}/  /opt/akraino/${CHARTNAME}/Chart.yaml
+    Execute Command         rm -r ${DESTDIR}
+    Put Directory           /opt/akraino/${CHARTNAME}  ${DESTDIR}/${CHARTNAME}  recursive=True
+    ${stdout}=              Execute Command  helm package ${DESTDIR}/${CHARTNAME} -d ${DESTDIR}
+    Should Contain          ${stdout}  Successfully packaged chart and saved it to:
+    ${CHARTARC}=            Fetch From Right  ${stdout}  /
+    Set Suite Variable      ${CHARTARC}
+
+Get Default Repository
+    ${REPOURL}=             Execute Command  helm repo list | grep '^${REPONAME} ' | cut -f2
+    Set Suite Variable      ${REPOURL}
+    Should Not Be Empty     ${REPOURL}
+
+Fail If Previous Test Failed
+    Run Keyword If          '${PREV_TEST_STATUS}'=='FAIL'  Fail  Skipping because '${PREV_TEST_NAME}' failed.
+
+Upload Chart To Repository
+    ${STATUS}=              Execute Command  curl -X PUT --data-binary "@${DESTDIR}/${CHARTARC}" ${REPOURL}/${CHARTARC}
+    Set Test Variable       ${STATUS}
+
+Chart Upload Should Have Succeeded
+    Should Be Empty         ${STATUS}
+
+Chart Upload Should Have Failed
+    Should Not Be Empty     ${STATUS}
+
+Update Repository Info
+    ${stdout}=              Execute Command  helm repo update
+    Should Contain          ${stdout}  Successfully got an update from the "${REPONAME}" chart repository
+
+Inspect Chart
+    ${STATUS}=              Execute Command  helm inspect chart ${REPONAME}/${CHARTNAME}
+    ...                       return_stdout=False
+    ...                       return_rc=True
+    Set Test Variable       ${STATUS}
+
+Find Chart In Repository
+    ${STATUS}=              Execute Command  helm search -r '\\v${REPONAME}/${CHARTNAME}\\v'
+    Set Test Variable       ${STATUS}
+
+Chart Should Be Available
+    Should Contain          ${STATUS}  ${REPONAME}/${CHARTNAME}
+
+Chart Should Not Be Available
+    Should Contain          ${STATUS}  No results found
+
+Chart Should Be Accessible
+    Should Be Equal As Integers  ${STATUS}  0
+
+Delete Chart
+    ${STATUS}=              Execute Command  curl -X DELETE ${REPOURL}/${CHARTARC}
+    Set Test Variable       ${STATUS}
+
+Chart Delete Should Have Succeeded
+    Should Be Empty         ${STATUS}
+
+Chart Delete Should Have Failed
+    Should Not Be Empty     ${STATUS}
diff --git a/tests/helm/helm_repository.robot b/tests/helm/helm_repository.robot
new file mode 100644 (file)
index 0000000..ba7fbd6
--- /dev/null
@@ -0,0 +1,54 @@
+##############################################################################
+# Copyright (c) 2019 AT&T Intellectual Property.                             #
+# Copyright (c) 2019 Nokia.                                                  #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License");            #
+# you maynot use this file except in compliance with the License.            #
+#                                                                            #
+# You may obtain a copy of the License at                                    #
+#       http://www.apache.org/licenses/LICENSE-2.0                           #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+##############################################################################
+
+
+*** Settings ***
+Documentation       Tests to validate Helm chart repositories.
+Resource            helm_repository.resource
+Suite Setup         Run Keywords
+...                 Open Connection And Log In
+...                 Build Chart Archive
+...                 Get Default Repository
+Suite Teardown      Close All Connections
+
+
+*** Test Cases ***
+Chart Storing
+    Upload Chart to Repository
+    Chart Upload Should Have Succeeded
+    Update Repository Info
+    Find Chart In Repository
+    Chart Should Be Available
+    Inspect Chart
+    Chart Should Be Accessible
+
+Upload Already Uploaded Chart
+    [Setup]  Fail If Previous Test Failed
+    Upload Chart to Repository
+    Chart Upload Should Have Failed
+
+Chart Removal
+    Delete Chart
+    Chart Delete Should Have Succeeded
+    Update Repository Info
+    Find Chart In Repository
+    Chart Should Not Be Available
+
+Delete Already Deleted Chart
+    [Setup]  Fail If Previous Test Failed
+    Delete Chart
+    Chart Delete Should Have Failed