aboutsummaryrefslogtreecommitdiffstats
path: root/functest/opnfv_tests/openstack
diff options
context:
space:
mode:
Diffstat (limited to 'functest/opnfv_tests/openstack')
-rw-r--r--functest/opnfv_tests/openstack/healthcheck/healthcheck.sh263
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/openstack/rally/scenario/support/instance_dd_test.sh0
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/openstack/refstack_client/refstack_client.py31
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/openstack/refstack_client/tempest_conf.py2
-rw-r--r--functest/opnfv_tests/openstack/snaps/api_check.py3
-rw-r--r--functest/opnfv_tests/openstack/snaps/health_check.py11
-rw-r--r--functest/opnfv_tests/openstack/snaps/smoke.py19
-rw-r--r--functest/opnfv_tests/openstack/snaps/snaps_test_runner.py4
-rw-r--r--functest/opnfv_tests/openstack/vping/vping_base.py120
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/openstack/vping/vping_ssh.py38
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/openstack/vping/vping_userdata.py17
11 files changed, 80 insertions, 428 deletions
diff --git a/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh b/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh
deleted file mode 100644
index 7fa957c0..00000000
--- a/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh
+++ /dev/null
@@ -1,263 +0,0 @@
-#
-# OpenStack Health Check
-# This script is meant for really basic API operations on OpenStack
-# Services tested: Keystone, Glance, Cinder, Neutron, Nova
-#
-#
-# Author:
-# jose.lausuch@ericsson.com
-#
-#
-# 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
-
-#Redirect all the output (stdout) to a log file and show only possible errors.
-LOG_FILE=/home/opnfv/functest/results/healthcheck.log
-YAML_FILE=${CONFIG_FUNCTEST_YAML}
-echo "">$LOG_FILE
-exec 1<>$LOG_FILE
-
-info () {
- echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healthcheck - INFO - " "$*" | tee -a $LOG_FILE 1>&2
-}
-
-debug () {
- if [[ "${CI_DEBUG,,}" == "true" ]]; then
- echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healthcheck - DEBUG - " "$*" | tee -a $LOG_FILE 1>&2
- fi
-}
-
-error () {
- echo -e "$(date '+%Y-%m-%d %H:%M:%S,%3N') - healthcheck - ERROR - " "$*" | tee -a $LOG_FILE 1>&2
- exit 1
-}
-
-if [ -z $OS_AUTH_URL ]; then
- echo "Source credentials first."
- exit 1
-fi
-
-
-echo "Using following credentials:"
-env | grep OS
-
-## Variables:
-project_1="opnfv-tenant1"
-project_2="opnfv-tenant2"
-user_1="opnfv_user1"
-user_2="opnfv_user2"
-user_3="opnfv_user3"
-user_4="opnfv_user4"
-user_5="opnfv_user5"
-user_6="opnfv_user6"
-kernel_image="opnfv-kernel-img"
-ramdisk_image="opnfv-ramdisk-img"
-image_1="opnfv-image1"
-image_2="opnfv-image2"
-volume_1="opnfv-volume1"
-volume_2="opnfv-volume2"
-net_1="opnfv-network1"
-net_2="opnfv-network2"
-subnet_1="opnfv-subnet1"
-subnet_2="opnfv-subnet2"
-port_1="opnfv-port1"
-port_2="opnfv-port2"
-router_1="opnfv-router1"
-router_2="opnfv-router2"
-flavor="m1.tiny"
-instance_1="opnfv-instance1"
-instance_2="opnfv-instance2"
-instance_3="opnfv-instance3"
-instance_4="opnfv-instance4"
-
-
-
-function wait_for_ip() {
- # $1 is the instance name
- # $2 is the first octet of the subnet ip
- timeout=60
- while [[ ${timeout} > 0 ]]; do
- if [[ $(nova console-log $1|grep "No lease, failing") ]]; then
- error "The instance $1 couldn't get an IP from the DHCP agent." | tee -a $LOG_FILE 1>&2
- exit 1
- elif [[ $(nova console-log $1|grep "^Lease"|grep "obtained") ]]; then
- debug "The instance $1 got an IP successfully from the DHCP agent." | tee -a $LOG_FILE 1>&2
- break
- fi
- let timeout=timeout-1
- sleep 1
- done
-}
-
-
-#################################
-info "Testing Keystone API..." | tee -a $LOG_FILE 1>&2
-#################################
-openstack project create ${project_1}
-debug "project '${project_1}' created."
-openstack project create ${project_2}
-debug "project '${project_2}' created."
-openstack user create ${user_1} --project ${project_1}
-debug "user '${user_1}' created in project ${project_1}."
-openstack user create ${user_2} --project ${project_1}
-debug "user '${user_2}' created in project ${project_1}."
-openstack user create ${user_3} --project ${project_1}
-debug "user '${user_3}' created in project ${project_1}."
-openstack user create ${user_4} --project ${project_2}
-debug "user '${user_4}' created in project ${project_2}."
-openstack user create ${user_5} --project ${project_2}
-debug "user '${user_5}' created in project ${project_2}."
-openstack user create ${user_6} --project ${project_2}
-debug "user '${user_6}' created in project ${project_2}."
-info "...Keystone OK!"
-
-#################################
-info "Testing Glance API..."
-#################################
-disk_img=$(cat ${YAML_FILE} | shyaml get-value healthcheck.disk_image 2> /dev/null || true)
-disk_format=$(cat ${YAML_FILE} | shyaml get-value healthcheck.disk_format 2> /dev/null || true)
-kernel_img=$(cat ${YAML_FILE} | shyaml get-value healthcheck.kernel_image 2> /dev/null || true)
-ramdisk_img=$(cat ${YAML_FILE} | shyaml get-value healthcheck.ramdisk_image 2> /dev/null || true)
-extra_properties=$(cat ${YAML_FILE} | shyaml get-value healthcheck.extra_properties 2> /dev/null || true)
-
-# Test if we need to create a 3party image
-if [ "X$kernel_img" != "X" ]
-then
- img_id=$(openstack image create ${kernel_image} --disk-format aki \
- --container-format bare < ${kernel_img} | awk '$2 == "id" { print $4 }')
- extra_opts="--property kernel_id=${img_id}"
-
- if [ "X$ramdisk_img" != "X" ]
- then
- img_id=$(openstack image create ${ramdisk_image} --disk-format ari \
- --container-format bare < ${ramdisk_img} | awk '$2 == "id" { print $4 }')
- extra_opts="$extra_opts --property ramdisk_id=${img_id}"
- fi
-fi
-
-if [ "X$extra_properties" != "X" ]
-then
- keys=$(cat ${YAML_FILE} | shyaml keys healthcheck.extra_properties)
- for key in ${keys}
- do
- value=$(cat ${YAML_FILE} | shyaml get-value healthcheck.extra_properties.${key})
- extra_opts="$extra_opts --property ${key}=\"${value}\""
- done
-fi
-
-debug "image extra_properties=${extra_properties}"
-
-eval openstack image create ${image_1} --disk-format ${disk_format} --container-format bare \
- ${extra_opts} < ${disk_img}
-debug "image '${image_1}' created."
-eval openstack image create ${image_2} --disk-format ${disk_format} --container-format bare \
- ${extra_opts} < ${disk_img}
-debug "image '${image_2}' created."
-info "... Glance OK!"
-
-#################################
-info "Testing Cinder API..."
-#################################
-cinder create --display_name ${volume_1} 1
-debug "volume '${volume_1}' created."
-cinder create --display_name ${volume_2} 10
-debug "volume '${volume_2}' created."
-info "...Cinder OK!"
-
-#################################
-info "Testing Neutron API..."
-#################################
-
-network_ids=($(neutron net-list|grep -v "+"|grep -v name|awk '{print $2}'))
-for id in ${network_ids[@]}; do
- [[ $(neutron net-show ${id}|grep 'router:external'|grep -i "true") != "" ]] && ext_net_id=${id}
-done
-if [[ "${ext_net_id}" == "" ]]; then
- error "No external network found. Exiting Health Check..."
- exit 1
-else
- info "External network found. ${ext_net_id}"
-fi
-
-info "1. Create Networks..."
-neutron net-create ${net_1}
-debug "net '${net_1}' created."
-neutron net-create ${net_2}
-debug "net '${net_2}' created."
-net1_id=$(neutron net-list | grep ${net_1} | awk '{print $2}')
-net2_id=$(neutron net-list | grep ${net_2} | awk '{print $2}')
-
-info "2. Create subnets..."
-neutron subnet-create --name ${subnet_1} --allocation-pool start=10.6.0.2,end=10.6.0.253 --gateway 10.6.0.254 ${net_1} 10.6.0.0/24
-debug "subnet '${subnet_1}' created."
-neutron subnet-create --name ${subnet_2} --allocation-pool start=10.7.0.2,end=10.7.0.253 --gateway 10.7.0.254 ${net_2} 10.7.0.0/24
-debug "subnet '${subnet_2}' created."
-
-info "3. Create Routers..."
-neutron router-create ${router_1}
-debug "router '${router_1}' created."
-neutron router-create ${router_2}
-debug "router '${router_2}' created."
-
-neutron router-gateway-set ${router_1} ${ext_net_id}
-debug "router '${router_1}' gateway set to ${ext_net_id}."
-neutron router-gateway-set ${router_2} ${ext_net_id}
-debug "router '${router_2}' gateway set to ${ext_net_id}."
-
-neutron router-interface-add ${router_1} ${subnet_1}
-debug "router '${router_1}' interface added ${subnet_1}."
-neutron router-interface-add ${router_2} ${subnet_2}
-debug "router '${router_2}' interface added ${subnet_2}."
-
-info "...Neutron OK!"
-
-#################################
-info "Testing Nova API..."
-#################################
-
-# This delay should be removed after resolving Jira case APEX-149.
-# The purpose is to give some time to populate openflow rules
-# by SDN controller in case of odl_l2 scenario.
-wait_time=$(cat ${YAML_FILE} | shyaml get-value healthcheck.wait_time 2> /dev/null || true)
-sleep ${wait_time}
-
-
-# Check if flavor exists
-if [[ -z $(openstack flavor list -f value -c Name | fgrep -x $flavor) ]]; then
- # if given flavor doesn't exist, we create one
- debug "Flavor $flavor doesn't exist. Creating a new flavor."
- openstack flavor create ${flavor} --id auto --ram 512 --disk 1 --vcpus 1
- openstack flavor set ${flavor} --property hw:mem_page_size=any
-fi
-debug "Using flavor $flavor to boot the instances."
-
-
-nova boot --flavor ${flavor} --image ${image_1} --nic net-id=${net1_id} ${instance_1}
-debug "nova instance '${instance_1}' booted on ${net_1}."
-nova boot --flavor ${flavor} --image ${image_1} --nic net-id=${net1_id} ${instance_2}
-debug "nova instance '${instance_2}' booted on ${net_1}."
-nova boot --flavor ${flavor} --image ${image_2} --nic net-id=${net2_id} ${instance_3}
-debug "nova instance '${instance_3}' booted on ${net_2}."
-nova boot --flavor ${flavor} --image ${image_2} --nic net-id=${net2_id} ${instance_4}
-debug "nova instance '${instance_4}' booted on ${net_2}."
-
-vm1_id=$(nova list | grep ${instance_1} | awk '{print $2}')
-vm2_id=$(nova list | grep ${instance_2} | awk '{print $2}')
-vm3_id=$(nova list | grep ${instance_3} | awk '{print $2}')
-vm4_id=$(nova list | grep ${instance_4} | awk '{print $2}')
-info "...Nova OK!"
-
-info "Checking if instances get an IP from DHCP..."
-wait_for_ip ${instance_1} "10.6"
-wait_for_ip ${instance_2} "10.6"
-wait_for_ip ${instance_3} "10.7"
-wait_for_ip ${instance_4} "10.7"
-info "...DHCP OK!"
-
-info "Health check passed!"
-exit 0
diff --git a/functest/opnfv_tests/openstack/rally/scenario/support/instance_dd_test.sh b/functest/opnfv_tests/openstack/rally/scenario/support/instance_dd_test.sh
index e3bf2340..e3bf2340 100755..100644
--- a/functest/opnfv_tests/openstack/rally/scenario/support/instance_dd_test.sh
+++ b/functest/opnfv_tests/openstack/rally/scenario/support/instance_dd_test.sh
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index 30d1cf08..9edbab5a 100755..100644
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
# matthew.lijun@huawei.com wangwulin@huawei.com
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
@@ -45,31 +45,18 @@ class RefstackClient(testcase.OSGCTestCase):
self.defcorelist = pkg_resources.resource_filename(
'functest', 'opnfv_tests/openstack/refstack_client/defcore.txt')
- def source_venv(self):
-
- cmd = ("cd {0};"
- ". .venv/bin/activate;"
- "cd -;".format(CONST.__getattribute__('dir_refstack_client')))
- ft_utils.execute_command(cmd)
-
def run_defcore(self, conf, testlist):
logger.debug("Generating test case list...")
- cmd = ("cd {0};"
- "./refstack-client test -c {1} -v --test-list {2};"
- "cd -;".format(CONST.__getattribute__('dir_refstack_client'),
- conf,
- testlist))
+ cmd = ("refstack-client test -c {0} -v --test-list {1}"
+ .format(conf, testlist))
ft_utils.execute_command(cmd)
def run_defcore_default(self):
logger.debug("Generating test case list...")
- cmd = ("cd {0};"
- "./refstack-client test -c {1} -v --test-list {2};"
- "cd -;".format(CONST.__getattribute__('dir_refstack_client'),
- self.confpath,
- self.defcorelist))
+ cmd = ("refstack-client test -c {0} -v --test-list {1}"
+ .format(self.confpath, self.defcorelist))
logger.info("Starting Refstack_defcore test case: '%s'." % cmd)
header = ("Refstack environment:\n"
@@ -159,7 +146,6 @@ class RefstackClient(testcase.OSGCTestCase):
try:
tempestconf = TempestConf()
tempestconf.generate_tempestconf()
- self.source_venv()
self.run_defcore_default()
self.parse_refstack_result()
res = testcase.TestCase.EX_OK
@@ -192,7 +178,6 @@ class RefstackClient(testcase.OSGCTestCase):
"%s", e)
return self.EX_RUN_ERROR
try:
- self.source_venv()
self._prep_test()
self.run_defcore(self.confpath, self.testlist)
res = testcase.TestCase.EX_OK
@@ -233,7 +218,7 @@ class RefstackClientParser(object):
return vars(self.parser.parse_args(argv))
-if __name__ == '__main__':
+def main():
logging.basicConfig()
refstackclient = RefstackClient()
parser = RefstackClientParser()
@@ -241,6 +226,6 @@ if __name__ == '__main__':
try:
result = refstackclient.main(**args)
if result != testcase.TestCase.EX_OK:
- sys.exit(result)
+ return result
except Exception:
- sys.exit(testcase.TestCase.EX_RUN_ERROR)
+ return testcase.TestCase.EX_RUN_ERROR
diff --git a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
index 5d429e7c..30590b9e 100755..100644
--- a/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
+++ b/functest/opnfv_tests/openstack/refstack_client/tempest_conf.py
@@ -49,7 +49,7 @@ class TempestConf(object):
logger.error('Error with run: %s', e)
-if __name__ == '__main__':
+def main():
logging.basicConfig()
tempestconf = TempestConf()
tempestconf.main()
diff --git a/functest/opnfv_tests/openstack/snaps/api_check.py b/functest/opnfv_tests/openstack/snaps/api_check.py
index 43518cb4..c3cd9063 100644
--- a/functest/opnfv_tests/openstack/snaps/api_check.py
+++ b/functest/opnfv_tests/openstack/snaps/api_check.py
@@ -37,5 +37,6 @@ class ApiCheck(SnapsTestRunner):
suite=self.suite,
os_creds=self.os_creds,
ext_net_name=self.ext_net_name,
- use_keystone=self.use_keystone)
+ use_keystone=self.use_keystone,
+ image_metadata=self.image_metadata)
return super(self.__class__, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/health_check.py b/functest/opnfv_tests/openstack/snaps/health_check.py
index 4e94460c..1b8d0537 100644
--- a/functest/opnfv_tests/openstack/snaps/health_check.py
+++ b/functest/opnfv_tests/openstack/snaps/health_check.py
@@ -8,9 +8,8 @@
import unittest
-from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
- SnapsTestRunner
-from functest.utils.constants import CONST
+from functest.opnfv_tests.openstack.snaps.snaps_test_runner import (
+ SnapsTestRunner)
from snaps.openstack.tests.os_source_file_test import OSIntegrationTestCase
from snaps.openstack.tests.create_instance_tests import SimpleHealthCheck
@@ -35,15 +34,11 @@ class HealthCheck(SnapsTestRunner):
:param kwargs: the arguments to pass on
:return:
"""
- image_custom_config = None
-
- if hasattr(CONST, 'snaps_images_cirros'):
- image_custom_config = CONST.__getattribute__('snaps_images_cirros')
self.suite.addTest(
OSIntegrationTestCase.parameterize(
SimpleHealthCheck, os_creds=self.os_creds,
ext_net_name=self.ext_net_name,
use_keystone=self.use_keystone,
flavor_metadata=self.flavor_metadata,
- image_metadata=image_custom_config))
+ image_metadata=self.image_metadata))
return super(self.__class__, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/smoke.py b/functest/opnfv_tests/openstack/snaps/smoke.py
index c3c55c7c..7a3eb2f8 100644
--- a/functest/opnfv_tests/openstack/snaps/smoke.py
+++ b/functest/opnfv_tests/openstack/snaps/smoke.py
@@ -6,14 +6,12 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import os
import unittest
from snaps import test_suite_builder
-from functest.opnfv_tests.openstack.snaps.snaps_test_runner import \
- SnapsTestRunner
-from functest.utils.constants import CONST
+from functest.opnfv_tests.openstack.snaps.snaps_test_runner import (
+ SnapsTestRunner)
class SnapsSmoke(SnapsTestRunner):
@@ -35,23 +33,12 @@ class SnapsSmoke(SnapsTestRunner):
:param kwargs: the arguments to pass on
:return:
"""
- image_config = None
- if hasattr(CONST, 'snaps_images_cirros'):
- image_config = CONST.__getattribute__('snaps_images_cirros')
-
- # Tests requiring floating IPs leverage files contained within the
- # SNAPS repository and are found relative to that path
- if self.use_fip:
- snaps_dir = os.path.join(CONST.__getattribute__('dir_repo_snaps'),
- 'snaps')
- os.chdir(snaps_dir)
-
test_suite_builder.add_openstack_integration_tests(
suite=self.suite,
os_creds=self.os_creds,
ext_net_name=self.ext_net_name,
use_keystone=self.use_keystone,
flavor_metadata=self.flavor_metadata,
- image_metadata=image_config,
+ image_metadata=self.image_metadata,
use_floating_ips=self.use_fip)
return super(self.__class__, self).run()
diff --git a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
index e8a42159..0b87440b 100644
--- a/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
+++ b/functest/opnfv_tests/openstack/snaps/snaps_test_runner.py
@@ -46,3 +46,7 @@ class SnapsTestRunner(unit.Suite):
self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
self.logger.info("Using flavor metadata '%s'", self.flavor_metadata)
+
+ self.image_metadata = None
+ if hasattr(CONST, 'snaps_images'):
+ self.image_metadata = CONST.__getattribute__('snaps_images')
diff --git a/functest/opnfv_tests/openstack/vping/vping_base.py b/functest/opnfv_tests/openstack/vping/vping_base.py
index 71460676..7de16ce1 100644
--- a/functest/opnfv_tests/openstack/vping/vping_base.py
+++ b/functest/opnfv_tests/openstack/vping/vping_base.py
@@ -1,6 +1,5 @@
-#!/usr/bin/env python
+# Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
#
-# Copyright (c) 2015 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
@@ -10,7 +9,6 @@
from datetime import datetime
import logging
import os
-import pkg_resources
import time
import uuid
@@ -22,10 +20,10 @@ from snaps.openstack import create_flavor
from snaps.openstack.create_flavor import FlavorSettings, OpenStackFlavor
from snaps.openstack.create_network import NetworkSettings, SubnetSettings
from snaps.openstack.tests import openstack_tests
-from snaps.openstack.utils import deploy_utils, nova_utils
+from snaps.openstack.utils import deploy_utils
-class VPingBase(testcase.OSGCTestCase):
+class VPingBase(testcase.TestCase):
"""
Base class for vPing tests that check connectivity between two VMs shared
@@ -36,16 +34,17 @@ class VPingBase(testcase.OSGCTestCase):
def __init__(self, **kwargs):
super(VPingBase, self).__init__(**kwargs)
- self.logger = logging.getLogger(self.__class__.__name__)
+ # This line is here simply for pep8 as the 'os' package import appears
+ # to be required for mock and the unit tests will fail without it
+ os.environ
- self.functest_repo = pkg_resources.resource_filename(
- 'functest', '..')
- self.guid = ''
- if CONST.__getattribute__('vping_unique_names'):
- self.guid = '-' + str(uuid.uuid4())
+ self.logger = logging.getLogger(self.__class__.__name__)
- self.os_creds = openstack_tests.get_credentials(
- os_env_file=CONST.__getattribute__('openstack_creds'))
+ if 'os_creds' in kwargs:
+ self.os_creds = kwargs['os_creds']
+ else:
+ self.os_creds = openstack_tests.get_credentials(
+ os_env_file=CONST.__getattribute__('openstack_creds'))
self.creators = list()
self.image_creator = None
@@ -53,52 +52,32 @@ class VPingBase(testcase.OSGCTestCase):
self.vm1_creator = None
self.vm2_creator = None
- self.self_cleanup = CONST.__getattribute__('vping_cleanup_objects')
-
- # Image constants
- self.image_name =\
- CONST.__getattribute__('vping_image_name') + self.guid
+ # Shared metadata
+ self.guid = ''
+ if CONST.__getattribute__('vping_unique_names'):
+ self.guid = '-' + str(uuid.uuid4())
- # VM constants
self.vm1_name = CONST.__getattribute__('vping_vm_name_1') + self.guid
self.vm2_name = CONST.__getattribute__('vping_vm_name_2') + self.guid
+
self.vm_boot_timeout = CONST.__getattribute__('vping_vm_boot_timeout')
- self.vm_delete_timeout =\
- CONST.__getattribute__('vping_vm_delete_timeout')
+ self.vm_delete_timeout = CONST.__getattribute__(
+ 'vping_vm_delete_timeout')
self.vm_ssh_connect_timeout = CONST.vping_vm_ssh_connect_timeout
self.ping_timeout = CONST.__getattribute__('vping_ping_timeout')
self.flavor_name = 'vping-flavor' + self.guid
- # NEUTRON Private Network parameters
- self.private_net_name =\
- CONST.__getattribute__('vping_private_net_name') + self.guid
- self.private_subnet_name =\
- CONST.__getattribute__('vping_private_subnet_name') + self.guid
- self.private_subnet_cidr =\
- CONST.__getattribute__('vping_private_subnet_cidr')
-
- scenario = functest_utils.get_scenario()
-
- self.flavor_metadata = None
- if 'ovs' in scenario or 'fdio' in scenario:
- self.flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
-
- self.cirros_image_config = None
-
# Move this configuration option up for all tests to leverage
if hasattr(CONST, 'snaps_images_cirros'):
self.cirros_image_config = CONST.__getattribute__(
'snaps_images_cirros')
+ else:
+ self.cirros_image_config = None
def run(self):
"""
Begins the test execution which should originate from the subclass
"""
-
- if not os.path.exists(self.functest_repo):
- raise Exception(
- "Functest repository not found '%s'" % self.functest_repo)
-
self.logger.info('Begin virtual environment setup')
self.start_time = time.time()
@@ -106,33 +85,43 @@ class VPingBase(testcase.OSGCTestCase):
datetime.fromtimestamp(self.start_time).strftime(
'%Y-%m-%d %H:%M:%S')))
- self.__delete_exist_vms()
-
- image_base_name = self.image_name + '-' + str(self.guid)
+ image_base_name = '{}-{}'.format(
+ CONST.__getattribute__('vping_image_name'),
+ str(self.guid))
os_image_settings = openstack_tests.cirros_image_settings(
image_base_name, image_metadata=self.cirros_image_config)
- self.logger.info("Creating image with name: '%s'" % self.image_name)
+ self.logger.info("Creating image with name: '%s'" % image_base_name)
self.image_creator = deploy_utils.create_image(
self.os_creds, os_image_settings)
self.creators.append(self.image_creator)
+ private_net_name = CONST.__getattribute__(
+ 'vping_private_net_name') + self.guid
+ private_subnet_name = CONST.__getattribute__(
+ 'vping_private_subnet_name') + self.guid
+ private_subnet_cidr = CONST.__getattribute__(
+ 'vping_private_subnet_cidr')
self.logger.info(
- "Creating network with name: '%s'" % self.private_net_name)
+ "Creating network with name: '%s'" % private_net_name)
self.network_creator = deploy_utils.create_network(
self.os_creds,
- NetworkSettings(name=self.private_net_name,
+ NetworkSettings(name=private_net_name,
subnet_settings=[SubnetSettings(
- name=self.private_subnet_name,
- cidr=self.private_subnet_cidr)]))
+ name=private_subnet_name,
+ cidr=private_subnet_cidr)]))
self.creators.append(self.network_creator)
self.logger.info(
"Creating flavor with name: '%s'" % self.flavor_name)
+ scenario = functest_utils.get_scenario()
+ flavor_metadata = create_flavor.MEM_PAGE_SIZE_ANY
+ if 'ovs' in scenario or 'fdio' in scenario:
+ flavor_metadata = create_flavor.MEM_PAGE_SIZE_LARGE
flavor_creator = OpenStackFlavor(
self.os_creds,
FlavorSettings(name=self.flavor_name, ram=512, disk=1, vcpus=1,
- metadata=self.flavor_metadata))
+ metadata=flavor_metadata))
flavor_creator.create()
self.creators.append(flavor_creator)
@@ -164,7 +153,7 @@ class VPingBase(testcase.OSGCTestCase):
Cleanup all OpenStack objects. Should be called on completion
:return:
"""
- if self.self_cleanup:
+ if CONST.__getattribute__('vping_cleanup_objects'):
for creator in reversed(self.creators):
try:
creator.clean()
@@ -180,30 +169,3 @@ class VPingBase(testcase.OSGCTestCase):
:return: T/F
"""
raise NotImplementedError('vping execution is not implemented')
-
- def __delete_exist_vms(self):
- """
- Cleans any existing VMs using the same name.
- """
- nova_client = nova_utils.nova_client(self.os_creds)
- servers = nova_client.servers.list()
- for server in servers:
- if server.name == self.vm1_name or server.name == self.vm2_name:
- self.logger.info("Deleting instance %s..." % server.name)
- server.delete()
-
-
-class VPingMain(object):
-
- def __init__(self, vping_cls):
- self.vping = vping_cls()
-
- def main(self, **kwargs):
- try:
- result = self.vping.run(**kwargs)
- if result != VPingBase.EX_OK:
- return result
- if kwargs['report']:
- return self.vping.publish_report()
- except:
- return VPingBase.EX_RUN_ERROR
diff --git a/functest/opnfv_tests/openstack/vping/vping_ssh.py b/functest/opnfv_tests/openstack/vping/vping_ssh.py
index 1f663307..d4c39ad2 100755..100644
--- a/functest/opnfv_tests/openstack/vping/vping_ssh.py
+++ b/functest/opnfv_tests/openstack/vping/vping_ssh.py
@@ -7,10 +7,9 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import argparse
+import os
import pkg_resources
from scp import SCPClient
-import sys
import time
from snaps.openstack.create_instance import FloatingIpSettings, \
@@ -24,8 +23,8 @@ from snaps.openstack.utils import deploy_utils
from functest.core.testcase import TestCase
from functest.opnfv_tests.openstack.snaps import snaps_utils
+from functest.opnfv_tests.openstack.vping import vping_base
from functest.utils.constants import CONST
-import vping_base
class VPingSSH(vping_base.VPingBase):
@@ -35,6 +34,11 @@ class VPingSSH(vping_base.VPingBase):
"""
def __init__(self, **kwargs):
+
+ # This line is here simply for pep8 as the 'os' package import appears
+ # to be required for mock and the unit tests will fail without it
+ os.environ
+
if "case_name" not in kwargs:
kwargs["case_name"] = "vping_ssh"
super(VPingSSH, self).__init__(**kwargs)
@@ -42,13 +46,11 @@ class VPingSSH(vping_base.VPingBase):
self.kp_name = CONST.__getattribute__('vping_keypair_name') + self.guid
self.kp_priv_file = CONST.__getattribute__('vping_keypair_priv_file')
self.kp_pub_file = CONST.__getattribute__('vping_keypair_pub_file')
- self.router_name =\
- CONST.__getattribute__('vping_router_name') + self.guid
+ self.router_name = CONST.__getattribute__(
+ 'vping_router_name') + self.guid
self.sg_name = CONST.__getattribute__('vping_sg_name') + self.guid
self.sg_desc = CONST.__getattribute__('vping_sg_desc')
- self.ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
-
def run(self):
"""
Sets up the OpenStack keypair, router, security group, and VM instance
@@ -71,11 +73,12 @@ class VPingSSH(vping_base.VPingBase):
% self.router_name)
net_set = self.network_creator.network_settings
sub_set = [net_set.subnet_settings[0].name]
+ ext_net_name = snaps_utils.get_ext_net_name(self.os_creds)
router_creator = deploy_utils.create_router(
self.os_creds,
RouterSettings(
name=self.router_name,
- external_gateway=self.ext_net_name,
+ external_gateway=ext_net_name,
internal_subnets=sub_set))
self.creators.append(router_creator)
@@ -142,13 +145,13 @@ class VPingSSH(vping_base.VPingBase):
"""
if vm_creator.vm_ssh_active(block=True):
ssh = vm_creator.ssh_client()
- if not self.__transfer_ping_script(ssh):
+ if not self._transfer_ping_script(ssh):
return TestCase.EX_RUN_ERROR
- return self.__do_vping_ssh(ssh, test_ip)
+ return self._do_vping_ssh(ssh, test_ip)
else:
return -1
- def __transfer_ping_script(self, ssh):
+ def _transfer_ping_script(self, ssh):
"""
Uses SCP to copy the ping script via the SSH client
:param ssh: the SSH client
@@ -157,7 +160,7 @@ class VPingSSH(vping_base.VPingBase):
self.logger.info("Trying to transfer ping.sh")
scp = SCPClient(ssh.get_transport())
ping_script = pkg_resources.resource_filename(
- 'functest', 'opnfv_tests/openstack/vping/ping.sh')
+ 'functest.opnfv_tests.openstack.vping', 'ping.sh')
try:
scp.put(ping_script, "~/")
except:
@@ -171,7 +174,7 @@ class VPingSSH(vping_base.VPingBase):
return True
- def __do_vping_ssh(self, ssh, test_ip):
+ def _do_vping_ssh(self, ssh, test_ip):
"""
Pings the test_ip via the SSH client
:param ssh: the SSH client used to issue the ping command
@@ -234,12 +237,3 @@ class VPingSSH(vping_base.VPingBase):
name=self.sg_name,
description=self.sg_desc,
rule_settings=sg_rules))
-
-
-if __name__ == '__main__':
- args_parser = argparse.ArgumentParser()
- args_parser.add_argument("-r", "--report",
- help="Create json result file",
- action="store_true")
- args = vars(args_parser.parse_args())
- sys.exit(vping_base.VPingMain(VPingSSH).main(**args))
diff --git a/functest/opnfv_tests/openstack/vping/vping_userdata.py b/functest/opnfv_tests/openstack/vping/vping_userdata.py
index 718f47f0..9aed4c10 100755..100644
--- a/functest/opnfv_tests/openstack/vping/vping_userdata.py
+++ b/functest/opnfv_tests/openstack/vping/vping_userdata.py
@@ -7,17 +7,14 @@
#
# http://www.apache.org/licenses/LICENSE-2.0
-import argparse
-import sys
import time
-from functest.core.testcase import TestCase
-
from snaps.openstack.utils import deploy_utils
from snaps.openstack.create_instance import VmInstanceSettings
from snaps.openstack.create_network import PortSettings
-import vping_base
+from functest.core.testcase import TestCase
+from functest.opnfv_tests.openstack.vping import vping_base
class VPingUserdata(vping_base.VPingBase):
@@ -142,13 +139,3 @@ def _get_userdata(test_ip):
" sleep 1\n"
"done\n" % test_ip)
return None
-
-
-if __name__ == '__main__':
- args_parser = argparse.ArgumentParser()
- args_parser.add_argument("-r", "--report",
- help="Create json result file",
- action="store_true")
- args = vars(args_parser.parse_args())
-
- sys.exit(vping_base.VPingMain(VPingUserdata).main(**args))