From: Cristina Pauna Date: Tue, 4 Jun 2019 10:12:23 +0000 (+0000) Subject: [k8s] Run the tests using bluval X-Git-Tag: 2.0.0~77^2 X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F942%2F8;p=validation.git [k8s] Run the tests using bluval - 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 Change-Id: Ifc388d0df8b237d29239b62469f3f117e26e30f0 --- diff --git a/bluval/bluval.py b/bluval/bluval.py index bd89a48..7855816 100644 --- a/bluval/bluval.py +++ b/bluval/bluval.py @@ -20,6 +20,7 @@ testcase """ import subprocess +from pathlib import Path import click import yaml @@ -28,10 +29,18 @@ def run_testcase(testcase): """ 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)) @@ -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. """ - 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) diff --git a/docker/k8s/Dockerfile b/docker/k8s/Dockerfile index 34bdd7d..48ebee9 100644 --- a/docker/k8s/Dockerfile +++ b/docker/k8s/Dockerfile @@ -22,6 +22,7 @@ ARG K8S_TAG=v1.13.0 # Install dependencies COPY pip-requirements.txt /wheels/requirements/pip-requirements.txt + 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 +RUN cat /opt/akraino/validation/repo/bluval/requirements.txt >> \ + /wheels/requirements/pip-requirements.txt 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 -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 diff --git a/tests/hardware/bios_version/bios_version_dell.robot b/tests/hardware/bios_version/bios_version_dell.robot index cf64398..166182c 100644 --- a/tests/hardware/bios_version/bios_version_dell.robot +++ b/tests/hardware/bios_version/bios_version_dell.robot @@ -28,7 +28,7 @@ Suite Teardown Close All Connections #${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 diff --git a/tests/k8s/conformance/conformance.robot b/tests/k8s/conformance/conformance.robot index a18b56a..5fa1127 100644 --- a/tests/k8s/conformance/conformance.robot +++ b/tests/k8s/conformance/conformance.robot @@ -24,14 +24,12 @@ Test Setup Check that k8s cluster is reachable 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 - 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 @@ -43,7 +41,7 @@ Run Sonobuoy Conformance Test # 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 @@ -60,7 +58,7 @@ Check that k8s cluster is reachable 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 diff --git a/tests/k8s/ha/ha_calico_dns_proxy.robot b/tests/k8s/ha/ha_calico_dns_proxy.robot index 7f2f2ab..b7fa0c4 100644 --- a/tests/k8s/ha/ha_calico_dns_proxy.robot +++ b/tests/k8s/ha/ha_calico_dns_proxy.robot @@ -27,7 +27,7 @@ Suite Teardown Close All Connections *** Variables *** ${HOST} localhost ${USERNAME} localadmin -${LOG} /opt/akraino/validation/ha/print_calico_coredns_haproxy.txt +${LOG} ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log diff --git a/tests/k8s/ha/ha_etcd_api_ctl_sch.robot b/tests/k8s/ha/ha_etcd_api_ctl_sch.robot index 31b6f0b..b32b430 100644 --- a/tests/k8s/ha/ha_etcd_api_ctl_sch.robot +++ b/tests/k8s/ha/ha_etcd_api_ctl_sch.robot @@ -28,7 +28,7 @@ Suite Teardown Close All Connections ${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 diff --git a/tests/k8s/ha/ha_services.robot b/tests/k8s/ha/ha_services.robot index 3e1e7be..3e5b46d 100644 --- a/tests/k8s/ha/ha_services.robot +++ b/tests/k8s/ha/ha_services.robot @@ -27,7 +27,7 @@ Suite Teardown Close All Connections *** Variables *** ${HOST} localhost ${USERNAME} localadmin -${LOG} /opt/akraino/validation/ha/print_docker_kubelet.txt +${LOG} ${LOG_PATH}${/}${SUITE_NAME.replace(' ','_')}.log ## Container Runtime diff --git a/tests/k8s/ha/ha_worker.robot b/tests/k8s/ha/ha_worker.robot index 3019edf..989c700 100644 --- a/tests/k8s/ha/ha_worker.robot +++ b/tests/k8s/ha/ha_worker.robot @@ -26,7 +26,7 @@ Suite Teardown Close All Connections ${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 diff --git a/variables.yaml b/tests/variables.yaml similarity index 100% rename from variables.yaml rename to tests/variables.yaml