diff options
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/ci/periodic.sh | 77 | ||||
-rw-r--r-- | tests/ci/run_compute_qpi.sh (renamed from tests/ci/run_ci.sh) | 20 | ||||
-rw-r--r-- | tests/unit/ansible_library/modules/apex_generate_inventory_test.py | 10 | ||||
-rw-r--r-- | tests/unit/ansible_library/modules/fuel_test.py | 12 | ||||
-rw-r--r-- | tests/unit/cli/cmd_qpi_test.py | 24 |
5 files changed, 103 insertions, 40 deletions
diff --git a/tests/ci/periodic.sh b/tests/ci/periodic.sh new file mode 100755 index 00000000..4235cdee --- /dev/null +++ b/tests/ci/periodic.sh @@ -0,0 +1,77 @@ +#! /bin/bash +############################################################################## +# Copyright (c) 2017 ZTE and others. +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +set -e + + +case $INSTALLER_TYPE in + apex) + INSTALLER_IP=`sudo virsh domifaddr undercloud | grep ipv4 | awk '{print $4}' | cut -d/ -f1` + ;; +esac + +cat << EOF > $WORKSPACE/env_file +INSTALLER_TYPE=$INSTALLER_TYPE +INSTALLER_IP=$INSTALLER_IP +POD_NAME=$NODE_NAME +SCENARIO=$DEPLOY_SCENARIO +TESTAPI_URL=$TESTAPI_URL +EOF + +echo "--------------------------------------------------------" +cat $WORKSPACE/env_file +echo "--------------------------------------------------------" + +# Remove previous running containers if exist +if [[ ! -z $(docker ps -a | grep "opnfv/qtip:$DOCKER_TAG") ]]; then + echo "Removing existing opnfv/qtip containers..." + # workaround: sometimes it throws an error when stopping qtip container. + # To make sure ci job unblocked, remove qtip container by force without stopping it. + docker rm -f $(docker ps -a | grep "opnfv/qtip:$DOCKER_TAG" | awk '{print $1}') +fi + +# Remove existing images if exist +if [[ $(docker images opnfv/qtip:${DOCKER_TAG} | wc -l) -gt 1 ]]; then + echo "Removing docker image opnfv/qtip:$DOCKER_TAG..." + docker rmi -f opnfv/qtip:$DOCKER_TAG +fi + +echo "Qtip: Pulling docker image: opnfv/qtip:${DOCKER_TAG}" +docker pull opnfv/qtip:$DOCKER_TAG >/dev/null + +envs="--env-file $WORKSPACE/env_file" +docker_volume="-v /var/run/docker.sock:/var/run/docker.sock" + +cmd="docker run -id ${envs} ${docker_volume} opnfv/qtip:${DOCKER_TAG} /bin/bash" +echo "Qtip: Running docker command: ${cmd}" +${cmd} + +container_id=$(docker ps | grep "opnfv/qtip:${DOCKER_TAG}" | awk '{print $1}' | head -1) +if [ $(docker ps | grep 'opnfv/qtip' | wc -l) == 0 ]; then + echo "The container opnfv/qtip with ID=${container_id} has not been properly started. Exiting..." + exit 1 +fi + +echo "The container ID is: ${container_id}" +QTIP_REPO=/home/opnfv/repos/qtip + +if [[ "$INSTALLER_TYPE" == "apex" ]];then + if [ -f /root/.ssh/id_rsa ]; then + sudo chmod 600 /root/.ssh/id_rsa + sudo docker cp /root/.ssh/id_rsa ${container_id}:/root/.ssh/ + fi +fi + +case $TEST_SUITE in + compute) + docker exec -t ${container_id} bash -c "bash ${QTIP_REPO}/tests/ci/run_compute_qpi.sh" + ;; +esac + +echo "Qtip done!" +exit 0
\ No newline at end of file diff --git a/tests/ci/run_ci.sh b/tests/ci/run_compute_qpi.sh index 02dfca09..09762b15 100644 --- a/tests/ci/run_ci.sh +++ b/tests/ci/run_compute_qpi.sh @@ -50,21 +50,21 @@ pod_name=${pod_name:-$POD_NAME} scenario=${scenario:-$SCENARIO} testapi_url=${testapi_url:-$TESTAPI_URL} +# we currently support ericsson, intel, lf and zte labs +if [[ ! "$installer_type" =~ (fuel|apex) ]]; then + echo "Unsupported/unidentified installer $installer_type. Cannot continue!" + exit 1 +fi + sshoptions="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" verify_connectivity ${installer_ip} -ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa -q - -# ssh-copy-id publickey to installer case "$installer_type" in fuel) + ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa -q sshpass -p r00tme ssh-copy-id $sshoptions ${installer_ip} ;; - *) - echo "Unkown installer $installer_type specified" - exit 1 - ;; esac cd /home/opnfv @@ -89,11 +89,7 @@ case "$installer_type" in publickey=$(sed -r 's/\//\\\//g' /root/.ssh/id_rsa.pub) ssh $sshoptions root@${installer_ip} "sed -i '/$publickey/d' /root/.ssh/authorized_keys" ;; - *) - echo "Not support $installer_type." - exit 1 - ;; esac -echo "Qtip done!" +echo "Compute QPI done!" exit 0
\ No newline at end of file diff --git a/tests/unit/ansible_library/modules/apex_generate_inventory_test.py b/tests/unit/ansible_library/modules/apex_generate_inventory_test.py index 7df9d35c..668a0155 100644 --- a/tests/unit/ansible_library/modules/apex_generate_inventory_test.py +++ b/tests/unit/ansible_library/modules/apex_generate_inventory_test.py @@ -23,8 +23,8 @@ def test_generate_inventory(data_root): u'compute': [u'192.0.2.5', u'192.0.2.6'], u'control': [u'192.0.2.7', u'192.0.2.8', u'192.0.2.9']} assert dict(inventory['hosts_meta']) == { - u'192.0.2.5': {'ansible_ssh_host': u'192.0.2.5'}, - u'192.0.2.6': {'ansible_ssh_host': u'192.0.2.6'}, - u'192.0.2.7': {'ansible_ssh_host': u'192.0.2.7'}, - u'192.0.2.8': {'ansible_ssh_host': u'192.0.2.8'}, - u'192.0.2.9': {'ansible_ssh_host': u'192.0.2.9'}} + u'192.0.2.5': {'ansible_ssh_host': u'192.0.2.5', 'ansible_user': 'heat-admin'}, + u'192.0.2.6': {'ansible_ssh_host': u'192.0.2.6', 'ansible_user': 'heat-admin'}, + u'192.0.2.7': {'ansible_ssh_host': u'192.0.2.7', 'ansible_user': 'heat-admin'}, + u'192.0.2.8': {'ansible_ssh_host': u'192.0.2.8', 'ansible_user': 'heat-admin'}, + u'192.0.2.9': {'ansible_ssh_host': u'192.0.2.9', 'ansible_user': 'heat-admin'}} diff --git a/tests/unit/ansible_library/modules/fuel_test.py b/tests/unit/ansible_library/modules/fuel_test.py index e004fc17..9ec1806f 100644 --- a/tests/unit/ansible_library/modules/fuel_test.py +++ b/tests/unit/ansible_library/modules/fuel_test.py @@ -34,21 +34,21 @@ def test_generate_inventory(data_root): u'node-27'], u'mongo': [u'node-24']} assert dict(inventory['hosts_meta']) == { - u'node-23': {'ansible_ssh_host': u'10.20.11.10', 'cluster': 4, 'ip': u'10.20.11.10', + u'node-23': {'ansible_ssh_host': u'10.20.11.10', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.10', 'mac': u'74:4a:a4:01:71:61', 'name': u'Untitled (71:61)', 'online': True, 'os_platform': u'ubuntu', 'status': u'ready'}, - u'node-24': {'ansible_ssh_host': u'10.20.11.11', 'cluster': 4, 'ip': u'10.20.11.11', + u'node-24': {'ansible_ssh_host': u'10.20.11.11', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.11', 'mac': u'74:4a:a4:01:73:50', 'name': u'Untitled (73:50)', 'online': True, 'os_platform': u'ubuntu', 'status': u'ready'}, - u'node-25': {'ansible_ssh_host': u'10.20.11.12', 'cluster': 4, 'ip': u'10.20.11.12', + u'node-25': {'ansible_ssh_host': u'10.20.11.12', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.12', 'mac': u'74:4a:a4:00:d8:76', 'name': u'Untitled (d8:76)', 'online': True, 'os_platform': u'ubuntu', 'status': u'ready'}, - u'node-26': {'ansible_ssh_host': u'10.20.11.15', 'cluster': 4, 'ip': u'10.20.11.15', + u'node-26': {'ansible_ssh_host': u'10.20.11.15', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.15', 'mac': u'74:4a:a4:01:61:ae', 'name': u'Untitled (61:ae)', 'online': True, 'os_platform': u'ubuntu', 'status': u'ready'}, - u'node-27': {'ansible_ssh_host': u'10.20.11.13', 'cluster': 4, 'ip': u'10.20.11.13', + u'node-27': {'ansible_ssh_host': u'10.20.11.13', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.13', 'mac': u'74:4a:a4:01:82:c0', 'name': u'Untitled (82:c0)', 'online': True, 'os_platform': u'ubuntu', 'status': u'ready'}, - u'node-28': {'ansible_ssh_host': u'10.20.11.14', 'cluster': 4, 'ip': u'10.20.11.14', + u'node-28': {'ansible_ssh_host': u'10.20.11.14', 'ansible_user': 'root', 'cluster': 4, 'ip': u'10.20.11.14', 'mac': u'74:4a:a4:01:74:63', 'name': u'Untitled (74:63)', 'online': True, 'os_platform': u'ubuntu', 'status': u'ready'}} diff --git a/tests/unit/cli/cmd_qpi_test.py b/tests/unit/cli/cmd_qpi_test.py index e7823c9b..ba5f814e 100644 --- a/tests/unit/cli/cmd_qpi_test.py +++ b/tests/unit/cli/cmd_qpi_test.py @@ -20,24 +20,14 @@ def runner(): def test_list(runner): result = runner.invoke(cli, ['qpi', 'list']) - assert 'QPIs' and 'compute' in result.output - - -def test_run(runner): - result = runner.invoke(cli, ['qpi', 'run', 'fake-qpi']) - assert result.output == '' - - result = runner.invoke(cli, ['qpi', 'run']) - assert 'Missing argument "name".' in result.output + assert 'QPI' in result.output + assert 'compute' in result.output + assert 'Description' in result.output + assert 'QTIP Performance Index of compute' in result.output def test_show(runner): result = runner.invoke(cli, ['qpi', 'show', 'compute']) - assert 'Name: compute' in result.output - assert 'Description: sample performance index of computing' in result.output - - result = runner.invoke(cli, ['qpi', 'show']) - assert 'Missing argument "name".' in result.output - - result = runner.invoke(cli, ['qpi', 'show', 'xyz']) - assert "ERROR: qpi spec: xyz not found" in result.output + assert 'QPI' in result.output + assert 'Description' in result.output + assert 'Formula' in result.output |