[k8s] Run the tests using bluval 42/942/8
authorCristina Pauna <cristina.pauna@enea.com>
Tue, 4 Jun 2019 10:12:23 +0000 (10:12 +0000)
committerCristina Pauna <cristina.pauna@enea.com>
Fri, 7 Jun 2019 11:56:22 +0000 (14:56 +0300)
- Install pip requirements needed for bluval
- Run the k8s tests using bluval instead of directly using robot,
  thus allowing for more complex decisions regarding which tests to run
- Use relative paths in bluval
- Moved the input variable file in the tests folder (all things related
  to tests shoudl be there)
- Standardized the location and name of the log files

JIRA: VAL-28

Signed-off-by: Cristina Pauna <cristina.pauna@enea.com>
Change-Id: Ifc388d0df8b237d29239b62469f3f117e26e30f0

bluval/bluval.py
docker/k8s/Dockerfile
tests/hardware/bios_version/bios_version_dell.robot
tests/k8s/conformance/conformance.robot
tests/k8s/ha/ha_calico_dns_proxy.robot
tests/k8s/ha/ha_etcd_api_ctl_sch.robot
tests/k8s/ha/ha_services.robot
tests/k8s/ha/ha_worker.robot
tests/variables.yaml [moved from variables.yaml with 100% similarity]

index bd89a48..7855816 100644 (file)
@@ -20,6 +20,7 @@ testcase
 """
 
 import subprocess
 """
 
 import subprocess
+from pathlib import Path
 import click
 import yaml
 
 import click
 import yaml
 
@@ -28,10 +29,18 @@ def run_testcase(testcase):
     """
     show_stopper = testcase.get('show_stopper', False)
     what = testcase.get('what')
     """
     show_stopper = testcase.get('show_stopper', False)
     what = testcase.get('what')
-    variables = "variables.yaml"
-    results = "results/"+testcase.get('layer')+"/"+what
-    test_path = "tests/"+testcase.get('layer')+"/"+what
-    args = ["robot", "-V", variables, "-d", results, test_path]
+    mypath = Path(__file__).absolute()
+    results_path = mypath.parents[2].joinpath("results/"+testcase.get('layer')+"/"+what)
+    test_path = mypath.parents[1].joinpath("tests/"+testcase.get('layer')+"/"+what)
+
+    # add to the variables file the path to where to sotre the logs
+    variables_file = mypath.parents[1].joinpath("tests/variables.yaml")
+    variables_dict = yaml.safe_load(variables_file.open())
+    variables_dict['log_path'] = str(results_path)
+    variables_file.write_text(str(variables_dict))
+
+    # run the test
+    args = ["robot", "-V", str(variables_file), "-d", str(results_path), str(test_path)]
 
     print('Executing testcase {}'.format(testcase['name']))
     print('          show_stopper {}'.format(show_stopper))
 
     print('Executing testcase {}'.format(testcase['name']))
     print('          show_stopper {}'.format(show_stopper))
@@ -77,7 +86,8 @@ def main(blueprint, layer):
     """Takes blueprint name and optional layer. Validates inputs and derives
     yaml location from blueprint name. Invokes validate on blue print.
     """
     """Takes blueprint name and optional layer. Validates inputs and derives
     yaml location from blueprint name. Invokes validate on blue print.
     """
-    yaml_loc = 'bluval/bluval-{}.yaml'.format(blueprint)
+    mypath = Path(__file__).absolute()
+    yaml_loc = mypath.parents[0].joinpath('bluval-{}.yaml'.format(blueprint))
     if layer is not None:
         layer = layer.lower()
     validate_blueprint(yaml_loc, layer)
     if layer is not None:
         layer = layer.lower()
     validate_blueprint(yaml_loc, layer)
index 34bdd7d..48ebee9 100644 (file)
@@ -22,6 +22,7 @@ ARG K8S_TAG=v1.13.0
 
 # Install dependencies
 COPY pip-requirements.txt /wheels/requirements/pip-requirements.txt
 
 # Install dependencies
 COPY pip-requirements.txt /wheels/requirements/pip-requirements.txt
+
 RUN apk --no-cache add --update \
         openssl \
         python3 \
 RUN apk --no-cache add --update \
         openssl \
         python3 \
@@ -49,6 +50,8 @@ RUN if [ $(uname -m) == 'aarch64' ]; then HOST_ARCH=arm64; else HOST_ARCH=amd64;
     make WHAT=test/e2e/e2e.test ARCH=$HOST_ARCH
 RUN go get -u -v github.com/heptio/sonobuoy
 RUN git clone https://gerrit.akraino.org/r/validation /opt/akraino/validation/repo
     make WHAT=test/e2e/e2e.test ARCH=$HOST_ARCH
 RUN go get -u -v github.com/heptio/sonobuoy
 RUN git clone https://gerrit.akraino.org/r/validation /opt/akraino/validation/repo
+RUN cat /opt/akraino/validation/repo/bluval/requirements.txt >> \
+    /wheels/requirements/pip-requirements.txt
 
 WORKDIR /wheels
 RUN pip3 install wheel
 
 WORKDIR /wheels
 RUN pip3 install wheel
@@ -67,6 +70,4 @@ RUN pip3 install -r /wheels/requirements/pip-requirements.txt \
      rm -rf /root/.cache/pip/*
 
 # Set the default command for running the tests
      rm -rf /root/.cache/pip/*
 
 # Set the default command for running the tests
-CMD /usr/local/bin/robot --loglevel DEBUG \
-    --outputdir /opt/akraino/validation/results/conformance \
-    /opt/akraino/validation/repo/conformance/conformance.robot
+CMD python3 /opt/akraino/validation/repo/bluval/bluval.py base -l k8s
index cf64398..166182c 100644 (file)
@@ -28,7 +28,7 @@ Suite Teardown    Close All Connections
 #${USERNAME}       localadmin
 #${SYSINFO}        PowerEdge R740xd
 #${BIOS_REVISION}   1.3
 #${USERNAME}       localadmin
 #${SYSINFO}        PowerEdge R740xd
 #${BIOS_REVISION}   1.3
-${LOG}            /opt/akraino/validation/bios_version/print_bios.txt
+${LOG}             ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log
 
 *** Test Cases ***
 Get HW Details
 
 *** Test Cases ***
 Get HW Details
index a18b56a..5fa1127 100644 (file)
@@ -24,14 +24,12 @@ Test Setup        Check that k8s cluster is reachable
 Test Teardown     Cleanup Sonobuoy
 
 *** Variables ***
 Test Teardown     Cleanup Sonobuoy
 
 *** Variables ***
-${RESULT_PATH}    /opt/akraino/validation/results/conformance/
-${REPO_PATH}      /opt/akraino/validation/repo/conformance/
-${LOG}            ${RESULT_PATH}${/}conformance.log
+${LOG}            ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log
 
 *** Test Cases ***
 Run Sonobuoy Conformance Test
         # Start the test
 
 *** Test Cases ***
 Run Sonobuoy Conformance Test
         # Start the test
-        Run                     kubectl apply -f ${REPO_PATH}${/}sonobuoy.yaml
+        Run                     kubectl apply -f ${CURDIR}${/}sonobuoy.yaml
         Sleep                   5s
         ${rc}  ${output}=       Run And Return Rc And Output
                                 ...  kubectl describe pod/sonobuoy -n heptio-sonobuoy
         Sleep                   5s
         ${rc}  ${output}=       Run And Return Rc And Output
                                 ...  kubectl describe pod/sonobuoy -n heptio-sonobuoy
@@ -43,7 +41,7 @@ Run Sonobuoy Conformance Test
 
         # Get the result and store the sonobuoy logs
         ${rc}  ${output}=       Run And Return Rc And Output
 
         # Get the result and store the sonobuoy logs
         ${rc}  ${output}=       Run And Return Rc And Output
-                                ...  results=$(sonobuoy retrieve ${RESULT_PATH}) && sonobuoy e2e $results
+                                ...  results=$(sonobuoy retrieve ${LOG_PATH}) && sonobuoy e2e $results
         Append To File          ${LOG}  ${output}${\n}
         Should Contain          ${output}       failed tests: 0
 
         Append To File          ${LOG}  ${output}${\n}
         Should Contain          ${output}       failed tests: 0
 
@@ -60,7 +58,7 @@ Check that k8s cluster is reachable
 
 Cleanup Sonobuoy
         ${rc}  ${output}=       Run And Return Rc And Output
 
 Cleanup Sonobuoy
         ${rc}  ${output}=       Run And Return Rc And Output
-                                ...  kubectl delete -f ${REPO_PATH}${/}sonobuoy.yaml
+                                ...  kubectl delete -f ${CURDIR}${/}sonobuoy.yaml
         Append To File          ${LOG}  ${output}${\n}
         Sleep                   3s
         Should Contain          ${output}      service "sonobuoy-master" deleted
         Append To File          ${LOG}  ${output}${\n}
         Sleep                   3s
         Should Contain          ${output}      service "sonobuoy-master" deleted
index 7f2f2ab..b7fa0c4 100644 (file)
@@ -27,7 +27,7 @@ Suite Teardown    Close All Connections
 *** Variables ***
 ${HOST}           localhost
 ${USERNAME}       localadmin
 *** Variables ***
 ${HOST}           localhost
 ${USERNAME}       localadmin
-${LOG}            /opt/akraino/validation/ha/print_calico_coredns_haproxy.txt
+${LOG}            ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log
 
 
 
 
 
 
index 31b6f0b..b32b430 100644 (file)
@@ -28,7 +28,7 @@ Suite Teardown    Close All Connections
 ${HOST}           localhost
 ${USERNAME}       localadmin
 ${NODENAME}       aknode109
 ${HOST}           localhost
 ${USERNAME}       localadmin
 ${NODENAME}       aknode109
-${LOG}            /opt/akraino/validation/ha/print_etcd_api_ctl-manager_sch.txt
+${LOG}            ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log
 
 
 ## kubernetes-etcd
 
 
 ## kubernetes-etcd
index 3e1e7be..3e5b46d 100644 (file)
@@ -27,7 +27,7 @@ Suite Teardown    Close All Connections
 *** Variables ***
 ${HOST}           localhost
 ${USERNAME}       localadmin
 *** Variables ***
 ${HOST}           localhost
 ${USERNAME}       localadmin
-${LOG}            /opt/akraino/validation/ha/print_docker_kubelet.txt
+${LOG}            ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log
 
 
 ## Container Runtime
 
 
 ## Container Runtime
index 3019edf..989c700 100644 (file)
@@ -26,7 +26,7 @@ Suite Teardown    Close All Connections
 ${HOST}           localhost
 ${USERNAME}       ipmi_admin_username
 ${PASSWORD}       ipmi_admin_password
 ${HOST}           localhost
 ${USERNAME}       ipmi_admin_username
 ${PASSWORD}       ipmi_admin_password
-${LOG}            /opt/akraino/validation/ha/print_ha.txt
+${LOG}            ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log
 
 *** Test Cases ***
 Power Status of Host
 
 *** Test Cases ***
 Power Status of Host
similarity index 100%
rename from variables.yaml
rename to tests/variables.yaml