diff options
-rwxr-xr-x | docker/common.sh | 3 | ||||
-rw-r--r-- | docker/requirements.pip | 3 | ||||
-rwxr-xr-x | testcases/Controllers/ODL/CI/start_tests.sh | 11 | ||||
-rw-r--r-- | testcases/config_functest.yaml | 4 | ||||
-rw-r--r-- | testcases/vPing/CI/libraries/vPing.py | 3 | ||||
-rw-r--r-- | testcases/vPing/CI/libraries/vPing2.py | 86 |
6 files changed, 73 insertions, 37 deletions
diff --git a/docker/common.sh b/docker/common.sh index c1c78398..7d973ab2 100755 --- a/docker/common.sh +++ b/docker/common.sh @@ -51,6 +51,9 @@ RALLY_REPO_DIR=$(cat $config_file | grep -w dir_repo_rally | awk 'END {print $NF RELENG_REPO_DIR=$(cat $config_file | grep -w dir_repo_releng | awk 'END {print $NF}') VIMS_REPO_DIR=$(cat $config_file | grep -w dir_repo_vims_test | awk 'END {print $NF}') BGPVPN_REPO_DIR=$(cat $config_file | grep -w dir_repo_bgpvpn | awk 'END {print $NF}') +ONOS_REPO_DIR=$(cat $config_file | grep -w dir_repo_onos | awk 'END {print $NF}') +PROMISE_REPO_DIR=$(cat $config_file | grep -w dir_repo_promise | awk 'END {print $NF}') +OVNO_REPO_DIR=$(cat $config_file | grep -w dir_repo_ovno | awk 'END {print $NF}') FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}') FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}') diff --git a/docker/requirements.pip b/docker/requirements.pip index 2389d60a..e2b67d3b 100644 --- a/docker/requirements.pip +++ b/docker/requirements.pip @@ -24,4 +24,5 @@ robotframework-sshlibrary==2.1.1 configObj==5.0.6 Flask==0.10.1 xmltodict==0.9.2 - +scp==0.10.2 +paramiko==1.16.0
\ No newline at end of file diff --git a/testcases/Controllers/ODL/CI/start_tests.sh b/testcases/Controllers/ODL/CI/start_tests.sh index a2fd0129..4d600224 100755 --- a/testcases/Controllers/ODL/CI/start_tests.sh +++ b/testcases/Controllers/ODL/CI/start_tests.sh @@ -53,14 +53,15 @@ PASS=${PASS:-'octopus'} NEUTRON_IP=${NEUTRON_IP:-192.168.0.68} set +x - +init_file=${REPO_DIR}/test/csit/suites/openstack/neutron/__init__.robot # Change openstack password for admin tenant in neutron suite -sed -i "s/\"password\": \".*\"/\"password\": \"${PASS}\"/" ${REPO_DIR}/test/csit/suites/openstack/neutron/__init__.robot +sed -i "s/\"password\": \".*\"/\"password\": \"${PASS}\"/" $init_file # Add Start Suite and Teardown Suite -sed -i "/^Documentation.*/a Suite Teardown Stop Suite" ${REPO_DIR}/test/csit/suites/openstack/neutron/__init__.robot -sed -i "/^Documentation.*/a Suite Setup Start Suite" ${REPO_DIR}/test/csit/suites/openstack/neutron/__init__.robot - +if [[ ! `grep 'Suite Teardown' ${init_file}` ]]; then + sed -i "/^Documentation.*/a Suite Teardown Stop Suite" $init_file + sed -i "/^Documentation.*/a Suite Setup Start Suite" $init_file +fi # add custom tests to suite, if there are more custom tests needed this will be reworked echo -e "${green}Copy custom tests to suite.${nc}" diff --git a/testcases/config_functest.yaml b/testcases/config_functest.yaml index 729d972f..ab59de2e 100644 --- a/testcases/config_functest.yaml +++ b/testcases/config_functest.yaml @@ -65,7 +65,7 @@ general: neutron_router_name: functest-router vping: - ping_timeout: 200 + ping_timeout: 300 vm_flavor: m1.small #adapt to your environment vm_name_1: opnfv-vping-1 vm_name_2: opnfv-vping-2 @@ -234,8 +234,10 @@ test-dependencies: installer: '(apex)|(fuel)' functest: vims: + scenario: '(ocl)|(odl)|(nosdn)' vping: vping_userdata: + scenario: '(ocl)|(odl)|(nosdn)' tempest: rally: odl: diff --git a/testcases/vPing/CI/libraries/vPing.py b/testcases/vPing/CI/libraries/vPing.py index dc2d2abe..0b09b6d4 100644 --- a/testcases/vPing/CI/libraries/vPing.py +++ b/testcases/vPing/CI/libraries/vPing.py @@ -412,7 +412,6 @@ def main(): name=NAME_VM_2, flavor=flavor, image=image, - # nics = [{"net-id": network_id, "v4-fixed-ip": IP_2}], nics=[{"port-id": port_id2}], userdata=u ) @@ -459,7 +458,7 @@ def main(): " Waiting a bit...") metadata_tries += 1 else: - logger.debug("No ping detected yet...") + logger.debug("Pinging %s. Waiting for response..." % IP_2) sec += 1 test_status = "NOK" diff --git a/testcases/vPing/CI/libraries/vPing2.py b/testcases/vPing/CI/libraries/vPing2.py index b103febf..35822358 100644 --- a/testcases/vPing/CI/libraries/vPing2.py +++ b/testcases/vPing/CI/libraries/vPing2.py @@ -13,16 +13,17 @@ # 0.2: measure test duration and publish results under json format # # - -import os -import time import argparse +import datetime +import logging +import os +import paramiko import pprint +import subprocess import sys -import logging +import time import yaml -import datetime -import subprocess +from scp import SCPClient from novaclient import client as novaclient from neutronclient.v2_0 import client as neutronclient from keystoneclient.v2_0 import client as keystoneclient @@ -414,7 +415,6 @@ def main(): name=NAME_VM_2, flavor=flavor, image=image, - # nics = [{"net-id": network_id, "v4-fixed-ip": IP_2}], nics=[{"port-id": port_id2}] ) @@ -431,51 +431,81 @@ def main(): floatip = functest_utils.create_floating_ip(neutron_client) if floatip == None: logger.error("Cannot create floating IP.") + cleanup(nova_client, neutron_client, image_id, network_dic, + port_id1, port_id2) return (EXIT_CODE) logger.info("Floating IP created: '%s'" % floatip) logger.info("Associating floating ip: '%s' to VM2 " % floatip) if not functest_utils.add_floating_ip(nova_client, vm2.id, floatip): logger.error("Cannot associate floating IP to VM.") + cleanup(nova_client, neutron_client, image_id, network_dic, + port_id1, port_id2) return (EXIT_CODE) - timeout = 30 + logger.info("Trying to stablish SSH connection to %s..." % floatip) + username='cirros' + password='cubswin:)' + ssh = paramiko.SSHClient() + ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) + + timeout = 50 while timeout > 0: - response = os.system("ping -c 1 " + floatip) - if response == 0: - logger.debug("Floating IP '%s' is reachable!" % floatip) - time.sleep(5) # the VM still needs to do some bootup actions + try: + ssh.connect(floatip, username=username, password=password) + logger.debug("Floating IP '%s' is ssh-able!" % floatip) break - timeout -= 1 - time.sleep(2) + except Exception, e: + #print e + logger.debug("Waiting for %s..." % floatip) + time.sleep(6) + timeout -= 1 - if timeout == 0: + if timeout == 0: # 300 sec timeout (5 min) logger.error("Cannot ping the floating IP '%s'." % floatip) + cleanup(nova_client, neutron_client, image_id, network_dic, + port_id1, port_id2) return (EXIT_CODE) - logger.info("SCP ping script to VM2...") - SSH_OPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "+\ - "-o LogLevel=quiet" + scp = SCPClient(ssh.get_transport()) + ping_script = REPO_PATH + "testcases/vPing/CI/libraries/ping.sh" - cmd1 = "sshpass -p 'cubswin:)' scp " + SSH_OPTS + " " + \ - ping_script + " cirros@"+floatip+":~/ping.sh" - cmd2 = "sshpass -p 'cubswin:)' ssh " + SSH_OPTS + \ - " cirros@"+floatip+" 'chmod 755 ~/ping.sh '" - cmd3 = "sshpass -p 'cubswin:)' ssh " + SSH_OPTS + \ - " cirros@"+floatip+" '~/ping.sh "+IP_1+"'" + try: + scp.put(ping_script,"~/") + except Exception, e: + logger.error("Cannot SCP the file '%s' to VM '%s'" % (ping_script,floatip)) + + + #SSH_OPTS="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "+\ + # "-o LogLevel=quiet" + + #cmd1 = "sshpass -p 'cubswin:)' scp " + SSH_OPTS + " " + \ + # ping_script + " cirros@"+floatip+":~/ping.sh" + #cmd2 = "sshpass -p 'cubswin:)' ssh " + SSH_OPTS + \ + # " cirros@"+floatip+" 'chmod 755 ~/ping.sh '" + #cmd3 = "sshpass -p 'cubswin:)' ssh " + SSH_OPTS + \ + # " cirros@"+floatip+" '~/ping.sh "+IP_1+"'" + + cmd = 'chmod 755 ~/ping.sh' + (stdin, stdout, stderr) = ssh.exec_command(cmd) + for line in stdout.readlines(): + print line logger.info("Waiting for ping...") sec = 0 duration = 0 + cmd = '~/ping.sh ' + IP_1 while True: time.sleep(1) # we do the SCP every time in the loop because while testing, I observed # that for some strange reason, the cirros VM was deleting the file if # do the scp only once - subprocess.Popen(cmd1, shell=True, stdout=subprocess.PIPE).stdout.read() - subprocess.Popen(cmd2, shell=True, stdout=subprocess.PIPE).stdout.read() - output=subprocess.Popen(cmd3, shell=True, stdout=subprocess.PIPE).stdout.read() + (stdin, stdout, stderr) = ssh.exec_command(cmd) + output = stdout.readlines() + #for line in output: + # print line + # print "--"+console_log # report if the test is failed if "vPing OK" in output: @@ -491,7 +521,7 @@ def main(): logger.info("Timeout reached.") break else: - logger.debug("No vPing detected...") + logger.debug("Pinging %s. Waiting for response..." % IP_2) sec += 1 cleanup(nova_client, neutron_client, image_id, network_dic, |