summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.coveragerc1
-rw-r--r--docker/Dockerfile5
-rw-r--r--docker/Dockerfile.aarch645
-rw-r--r--docker/thirdparty-requirements.txt5
-rw-r--r--[-rwxr-xr-x]functest/ci/check_os.sh0
-rw-r--r--functest/ci/config_aarch64_patch.yaml8
-rw-r--r--functest/ci/config_functest.yaml20
-rwxr-xr-xfunctest/ci/download_images.sh7
-rwxr-xr-xfunctest/ci/prepare_env.py15
-rwxr-xr-xfunctest/ci/run_tests.py7
-rw-r--r--functest/ci/testcases.yaml2
-rw-r--r--functest/cli/commands/cli_os.py4
-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
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/sdn/odl/odl.py27
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/sdn/onos/sfc/sfc.py6
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/vnf/aaa/aaa.py0
-rw-r--r--[-rwxr-xr-x]functest/opnfv_tests/vnf/ims/orchestra_ims.py0
-rw-r--r--functest/tests/unit/ci/test_prepare_env.py6
-rw-r--r--functest/tests/unit/cli/commands/test_cli_os.py4
-rw-r--r--functest/tests/unit/odl/test_odl.py48
-rw-r--r--functest/tests/unit/openstack/refstack_client/test_refstack_client.py22
-rw-r--r--functest/tests/unit/openstack/vping/test_vping.py157
-rw-r--r--functest/tests/unit/utils/test_openstack_utils.py53
-rw-r--r--[-rwxr-xr-x]functest/utils/openstack_clean.py7
-rw-r--r--[-rwxr-xr-x]functest/utils/openstack_snapshot.py7
-rw-r--r--functest/utils/openstack_utils.py37
-rw-r--r--setup.cfg10
37 files changed, 334 insertions, 637 deletions
diff --git a/.coveragerc b/.coveragerc
index fe258c6c6..613ea33df 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -1,3 +1,4 @@
[report]
exclude_lines =
if __name__ == .__main__.:
+ def main
diff --git a/docker/Dockerfile b/docker/Dockerfile
index a3ebc1a1c..d38713e06 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -90,7 +90,6 @@ RUN ln -s /usr/local/lib/python2.7/dist-packages/functest ${FUNCTEST_REPO_DIR}/f
# OPNFV repositories
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/copper ${REPOS_DIR}/copper
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/domino ${REPOS_DIR}/domino
-RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/parser ${REPOS_DIR}/parser
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/doctor ${REPOS_DIR}/doctor
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/promise ${REPOS_DIR}/promise
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/netready ${REPOS_DIR}/netready
@@ -118,8 +117,7 @@ RUN find -L ${FUNCTEST_REPO_DIR} -name "*.py" \
-not -path "*functest_venv*" \
|xargs grep \#\! |cut -d\: -f 1 |xargs chmod -c 755
-RUN /bin/bash ${REPOS_DIR}/parser/tests/parser_install.sh ${REPOS_DIR}
-RUN wget -q https://raw.githubusercontent.com/openstack/rally/${RALLY_TAG}/install_rally.sh \
+RUN wget -q https://git.openstack.org/cgit/openstack/rally/plain/install_rally.sh?h=${RALLY_TAG} -O install_rally.sh \
&& bash install_rally.sh --branch ${RALLY_TAG} --yes && rm install_rally.sh
RUN add_images.sh
@@ -133,6 +131,7 @@ RUN /bin/bash -c ". /usr/local/lib/python2.7/dist-packages/sfc/tests/functest/se
# refstack-client integration
RUN wget -q https://raw.githubusercontent.com/openstack/refstack-client/master/setup_env \
&& bash setup_env -t ${REFSTACK_TAG} && rm setup_env
+RUN ln -s ${HOME}/.tempest /usr/local/lib/python2.7/dist-packages/.tempest
RUN /bin/bash -c ". /etc/profile.d/rvm.sh \
&& cd ${REPOS_VNFS_DIR}/vims-test \
diff --git a/docker/Dockerfile.aarch64 b/docker/Dockerfile.aarch64
index 1a7dc0279..77c94b02f 100644
--- a/docker/Dockerfile.aarch64
+++ b/docker/Dockerfile.aarch64
@@ -85,7 +85,6 @@ RUN pip install ${PIP_OPTS} \
# OPNFV repositories
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/copper ${REPOS_DIR}/copper
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/domino ${REPOS_DIR}/domino
-RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/parser ${REPOS_DIR}/parser
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/doctor ${REPOS_DIR}/doctor
RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/promise ${REPOS_DIR}/promise
@@ -110,8 +109,7 @@ RUN find -L ${FUNCTEST_REPO_DIR} -name "*.py" \
-not -path "*functest_venv*" \
|xargs grep \#\! |cut -d\: -f 1 |xargs chmod -c 755
-RUN /bin/bash ${REPOS_DIR}/parser/tests/parser_install.sh ${REPOS_DIR}
-RUN wget -q https://raw.githubusercontent.com/openstack/rally/${RALLY_TAG}/install_rally.sh \
+RUN wget -q https://git.openstack.org/cgit/openstack/rally/plain/install_rally.sh?h=${RALLY_TAG} -O install_rally.sh \
&& bash install_rally.sh --branch ${RALLY_TAG} --yes && rm install_rally.sh
RUN add_images.sh
@@ -125,6 +123,7 @@ RUN /bin/bash -c ". /usr/local/lib/python2.7/dist-packages/sfc/tests/functest/se
# refstack-client integration
RUN wget -q https://raw.githubusercontent.com/openstack/refstack-client/master/setup_env \
&& bash setup_env -t ${REFSTACK_TAG} && rm setup_env
+RUN ln -s ${HOME}/.tempest /usr/local/lib/python2.7/dist-packages/.tempest
RUN /bin/bash -c ". /etc/profile.d/rvm.sh \
&& cd ${REPOS_VNFS_DIR}/vims-test \
diff --git a/docker/thirdparty-requirements.txt b/docker/thirdparty-requirements.txt
index f51a5e29d..d1c3a917f 100644
--- a/docker/thirdparty-requirements.txt
+++ b/docker/thirdparty-requirements.txt
@@ -3,7 +3,8 @@ git+https://gerrit.opnfv.org/gerrit/sdnvpn#egg=sdnvpn
git+https://gerrit.opnfv.org/gerrit/opera#egg=opera
git+https://gerrit.opnfv.org/gerrit/securityscanning#egg=securityscanning
git+https://gerrit.opnfv.org/gerrit/sfc#egg=sfc
-networking-bgpvpn
+tosca-parser>=0.7.0 # Apache-2.0
+heat-translator>=0.4.0 # Apache-2.0
rally
tempest>=15.0.0 # Apache-2.0
-git+https://github.com/openstack/refstack-client#egg=refstack-client
+git+https://github.com/openstack/refstack-client#egg=refstack-client \ No newline at end of file
diff --git a/functest/ci/check_os.sh b/functest/ci/check_os.sh
index 7b66f3da6..7b66f3da6 100755..100644
--- a/functest/ci/check_os.sh
+++ b/functest/ci/check_os.sh
diff --git a/functest/ci/config_aarch64_patch.yaml b/functest/ci/config_aarch64_patch.yaml
index 80cf4ccc2..45af8d743 100644
--- a/functest/ci/config_aarch64_patch.yaml
+++ b/functest/ci/config_aarch64_patch.yaml
@@ -5,14 +5,6 @@ os:
image_file_name: cirros-d161201-aarch64-disk.img
image_password: gocubsgo
- snaps_health_check:
- disk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-disk.img
- kernel_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-kernel
- ramdisk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-initramfs
- extra_properties:
- os_command_line: root=/dev/vdb1 rw rootwait console=tty0 console=ttyS0 console=ttyAMA0
- hw_video_model: vga
-
vping:
image_name: TestVM
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index 1199be5ad..b93730cdf 100644
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -11,9 +11,7 @@ general:
repo_barometer: /home/opnfv/repos/barometer
repo_doctor: /home/opnfv/repos/doctor
repo_copper: /home/opnfv/repos/copper
- repo_parser: /home/opnfv/repos/parser
repo_domino: /home/opnfv/repos/domino
- repo_snaps: /home/opnfv/repos/snaps
repo_fds: /home/opnfv/repos/fds
repo_securityscan: /home/opnfv/repos/securityscanning
repo_vrouter: /home/opnfv/repos/vnfs/vrouter
@@ -24,7 +22,6 @@ general:
ims_data: /home/opnfv/functest/data/ims/
functest_images: /home/opnfv/functest/images
rally_inst: /home/opnfv/.rally
- refstack_client: /home/opnfv/repos/refstack-client
openstack:
creds: /home/opnfv/functest/conf/openstack.creds
@@ -58,19 +55,14 @@ snaps:
use_keystone: True
use_floating_ips: True
images:
+ glance_tests:
+ disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img
cirros:
disk_file: /home/opnfv/functest/images/cirros-0.3.5-x86_64-disk.img
- # ARM
-# disk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-disk.img
-# kernel_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-kernel
-# ramdisk_url: http://download.cirros-cloud.net/daily/20161201/cirros-d161201-aarch64-initramfs
-# extra_properties:
-# os_command_line: root=/dev/vdb1 rw rootwait console=tty0 console=ttyS0 console=ttyAMA0
-# hw_video_model: vga
-# ubuntu:
-# disk_url: http://uec-images.ubuntu.com/releases/trusty/14.04/ubuntu-14.04-server-cloudimg-amd64-disk1.img
-# centos:
-# disk_url: http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2
+ ubuntu:
+ disk_file: /home/opnfv/functest/images/ubuntu-14.04-server-cloudimg-amd64-disk1.img
+ centos:
+ disk_file: /home/opnfv/functest/images/CentOS-7-x86_64-GenericCloud.qcow2
vping:
ping_timeout: 200
diff --git a/functest/ci/download_images.sh b/functest/ci/download_images.sh
index f3fdef2e3..23e09c10b 100755
--- a/functest/ci/download_images.sh
+++ b/functest/ci/download_images.sh
@@ -28,4 +28,11 @@ wget -nc http://artifacts.opnfv.org/sdnvpn/ubuntu-16.04-server-cloudimg-amd64-di
wget -nc ${CIRROS_REPO_URL}/daily/20${CIRROS_AARCH64_TAG}/cirros-d${CIRROS_AARCH64_TAG}-aarch64-disk.img -P ${IMAGES_FOLDER_DIR}
wget -nc ${CIRROS_REPO_URL}/daily/20${CIRROS_AARCH64_TAG}/cirros-d${CIRROS_AARCH64_TAG}-aarch64-initramfs -P ${IMAGES_FOLDER_DIR}
wget -nc ${CIRROS_REPO_URL}/daily/20${CIRROS_AARCH64_TAG}/cirros-d${CIRROS_AARCH64_TAG}-aarch64-kernel -P ${IMAGES_FOLDER_DIR}
+
+# Add Ubuntu 14 qcow2 image
+wget -nc http://uec-images.ubuntu.com/releases/trusty/14.04/ubuntu-14.04-server-cloudimg-amd64-disk1.img -P ${IMAGES_FOLDER_DIR}
+
+# Add Centos 7 qcow2 image
+wget -nc http://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2 -P ${IMAGES_FOLDER_DIR}
+
set +ex \ No newline at end of file
diff --git a/functest/ci/prepare_env.py b/functest/ci/prepare_env.py
index 64fcc9256..ae9d9537e 100755
--- a/functest/ci/prepare_env.py
+++ b/functest/ci/prepare_env.py
@@ -251,8 +251,7 @@ def update_db_url():
def verify_deployment():
print_separator()
logger.info("Verifying OpenStack services...")
- cmd = ("%s" % pkg_resources.resource_filename(
- 'functest', 'ci/check_os.sh'))
+ cmd = "check_os.sh"
logger.debug("Executing command: %s" % cmd)
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
@@ -261,7 +260,7 @@ def verify_deployment():
line = p.stdout.readline().rstrip()
if "ERROR" in line:
logger.error(line)
- raise Exception("Problem while running 'check_os.sh'.")
+ raise Exception("Problem while running '{}'.".format(cmd))
logger.info(line)
@@ -358,7 +357,7 @@ def print_deployment_info():
handler.get_deployment_info())
-def main(**kwargs):
+def prepare_env(**kwargs):
try:
if not (kwargs['action'] in actions):
logger.error('Argument not valid.')
@@ -384,9 +383,13 @@ def main(**kwargs):
return 0
-if __name__ == '__main__':
+def main():
logging.config.fileConfig(pkg_resources.resource_filename(
'functest', 'ci/logging.ini'))
parser = PrepareEnvParser()
args = parser.parse_args(sys.argv[1:])
- sys.exit(main(**args))
+ return prepare_env(**args)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/functest/ci/run_tests.py b/functest/ci/run_tests.py
index 722df14fe..5155adc46 100755
--- a/functest/ci/run_tests.py
+++ b/functest/ci/run_tests.py
@@ -269,10 +269,13 @@ class Runner(object):
return self.overall_result
-if __name__ == '__main__':
+def main():
logging.config.fileConfig(pkg_resources.resource_filename(
'functest', 'ci/logging.ini'))
parser = RunTestsParser()
args = parser.parse_args(sys.argv[1:])
runner = Runner()
- sys.exit(runner.main(**args).value)
+ return runner.main(**args).value
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml
index 11af98231..be916498f 100644
--- a/functest/ci/testcases.yaml
+++ b/functest/ci/testcases.yaml
@@ -314,7 +314,7 @@ tiers:
module: 'functest.core.feature'
class: 'BashFeature'
args:
- cmd: '. /home/opnfv/functest/conf/stackrc && cd /usr/local/lib/python2.7/dist-packages && python security_scan.py --config config.ini && cd -'
+ cmd: '. /home/opnfv/functest/conf/stackrc && security_scan --config /usr/local/etc/securityscanning/config.ini'
-
case_name: copper
diff --git a/functest/cli/commands/cli_os.py b/functest/cli/commands/cli_os.py
index 875529f25..44181d4f0 100644
--- a/functest/cli/commands/cli_os.py
+++ b/functest/cli/commands/cli_os.py
@@ -9,7 +9,6 @@
import os
-import pkg_resources
import click
@@ -50,8 +49,7 @@ class CliOpenStack(object):
def check(self):
self.ping_endpoint()
- ft_utils.execute_command("sh %s" % pkg_resources.resource_filename(
- 'functest', 'ci/check_os.sh'), verbose=False)
+ ft_utils.execute_command("check_os.sh", verbose=False)
def snapshot_create(self):
self.ping_endpoint()
diff --git a/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh b/functest/opnfv_tests/openstack/healthcheck/healthcheck.sh
deleted file mode 100644
index 7fa957c01..000000000
--- 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 e3bf23405..e3bf23405 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 30d1cf089..9edbab5a1 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 5d429e7c2..30590b9eb 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 43518cb4e..c3cd90635 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 4e94460c2..1b8d05375 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 c3c55c7c3..7a3eb2f8f 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 e8a421595..0b87440b8 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 714606769..7de16ce15 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 1f663307c..d4c39ad27 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 718f47f0d..9aed4c10a 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))
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index fb5dcbc6e..67bf66e34 100755..100644
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -117,7 +117,7 @@ class ODLTests(testcase.TestCase):
self.details['description'] = result.suite.name
self.details['tests'] = visitor.get_data()
- def main(self, suites=None, **kwargs):
+ def run_suites(self, suites=None, **kwargs):
"""Run the test suites
It has been designed to be called in any context.
@@ -246,7 +246,7 @@ class ODLTests(testcase.TestCase):
self.__logger.exception("Cannot run ODL testcases.")
return self.EX_RUN_ERROR
- return self.main(suites, **kwargs)
+ return self.run_suites(suites, **kwargs)
class ODLParser(object): # pylint: disable=too-few-public-methods
@@ -301,16 +301,19 @@ class ODLParser(object): # pylint: disable=too-few-public-methods
return vars(self.parser.parse_args(argv))
-if __name__ == '__main__':
+def main():
+ """Entry point"""
logging.basicConfig()
- ODL = ODLTests()
- PARSER = ODLParser()
- ARGS = PARSER.parse_args(sys.argv[1:])
+ odl = ODLTests()
+ parser = ODLParser()
+ args = parser.parse_args(sys.argv[1:])
try:
- RESULT = ODL.main(ODLTests.default_suites, **ARGS)
- if RESULT != testcase.TestCase.EX_OK:
- sys.exit(RESULT)
- if ARGS['pushtodb']:
- sys.exit(ODL.push_to_db())
+ result = odl.run_suites(ODLTests.default_suites, **args)
+ if result != testcase.TestCase.EX_OK:
+ return result
+ if args['pushtodb']:
+ return odl.push_to_db()
+ else:
+ return result
except Exception: # pylint: disable=broad-except
- sys.exit(testcase.TestCase.EX_RUN_ERROR)
+ return testcase.TestCase.EX_RUN_ERROR
diff --git a/functest/opnfv_tests/sdn/onos/sfc/sfc.py b/functest/opnfv_tests/sdn/onos/sfc/sfc.py
index a2dd7e9a0..2bb9082ca 100755..100644
--- a/functest/opnfv_tests/sdn/onos/sfc/sfc.py
+++ b/functest/opnfv_tests/sdn/onos/sfc/sfc.py
@@ -165,14 +165,10 @@ def PushDB(status, info):
def main():
"""Script to Test the SFC scenarios in ONOS."""
+ logging.basicConfig()
PreConfig()
CreateNodes()
ConfigSfc()
VerifySfcTraffic()
CleanUp()
PushDB("PASS", "")
-
-
-if __name__ == '__main__':
- logging.basicConfig()
- main()
diff --git a/functest/opnfv_tests/vnf/aaa/aaa.py b/functest/opnfv_tests/vnf/aaa/aaa.py
index 71e3c972a..71e3c972a 100755..100644
--- a/functest/opnfv_tests/vnf/aaa/aaa.py
+++ b/functest/opnfv_tests/vnf/aaa/aaa.py
diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
index 7b1ea9ad8..7b1ea9ad8 100755..100644
--- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
diff --git a/functest/tests/unit/ci/test_prepare_env.py b/functest/tests/unit/ci/test_prepare_env.py
index 69abd6433..7d4b5fb25 100644
--- a/functest/tests/unit/ci/test_prepare_env.py
+++ b/functest/tests/unit/ci/test_prepare_env.py
@@ -441,7 +441,7 @@ class PrepareEnvTesting(unittest.TestCase):
mock_check_env):
with mock.patch("__builtin__.open", mock.mock_open()) as m:
args = {'action': 'start'}
- self.assertEqual(prepare_env.main(**args), 0)
+ self.assertEqual(prepare_env.prepare_env(**args), 0)
mock_logger_info.assert_any_call("######### Preparing Functest "
"environment #########\n")
self.assertTrue(mock_env_var.called)
@@ -459,13 +459,13 @@ class PrepareEnvTesting(unittest.TestCase):
@mock.patch('functest.ci.prepare_env.check_environment')
def test_main_check(self, mock_check_env):
args = {'action': 'check'}
- self.assertEqual(prepare_env.main(**args), 0)
+ self.assertEqual(prepare_env.prepare_env(**args), 0)
self.assertTrue(mock_check_env.called)
@mock.patch('functest.ci.prepare_env.logger.error')
def test_main_no_arg(self, mock_logger_error):
args = {'action': 'not_valid'}
- self.assertEqual(prepare_env.main(**args), -1)
+ self.assertEqual(prepare_env.prepare_env(**args), -1)
mock_logger_error.assert_called_once_with('Argument not valid.')
diff --git a/functest/tests/unit/cli/commands/test_cli_os.py b/functest/tests/unit/cli/commands/test_cli_os.py
index 50ebe4b5d..a3d930de7 100644
--- a/functest/tests/unit/cli/commands/test_cli_os.py
+++ b/functest/tests/unit/cli/commands/test_cli_os.py
@@ -8,7 +8,6 @@
#
import logging
-import pkg_resources
import unittest
import os
@@ -65,8 +64,7 @@ class CliOpenStackTesting(unittest.TestCase):
with mock.patch.object(self.cli_os, 'ping_endpoint'):
self.cli_os.check()
mock_ftutils_execute.assert_called_once_with(
- "sh %s" % pkg_resources.resource_filename(
- 'functest', 'ci/check_os.sh'), verbose=False)
+ "check_os.sh", verbose=False)
@mock.patch('functest.cli.commands.cli_os.os.path.isfile',
return_value=False)
diff --git a/functest/tests/unit/odl/test_odl.py b/functest/tests/unit/odl/test_odl.py
index 60adf211d..070a8d2ec 100644
--- a/functest/tests/unit/odl/test_odl.py
+++ b/functest/tests/unit/odl/test_odl.py
@@ -202,10 +202,10 @@ class ODLRobotTesting(ODLTesting):
class ODLMainTesting(ODLTesting):
- """The class testing ODLTests.main()."""
+ """The class testing ODLTests.run_suites()."""
# pylint: disable=missing-docstring
- def _get_main_kwargs(self, key=None):
+ def _get_run_suites_kwargs(self, key=None):
kwargs = {'odlusername': self._odl_username,
'odlpassword': self._odl_password,
'neutronip': self._neutron_ip,
@@ -220,9 +220,9 @@ class ODLMainTesting(ODLTesting):
del kwargs[key]
return kwargs
- def _test_main(self, status, *args):
- kwargs = self._get_main_kwargs()
- self.assertEqual(self.test.main(**kwargs), status)
+ def _test_run_suites(self, status, *args):
+ kwargs = self._get_run_suites_kwargs()
+ self.assertEqual(self.test.run_suites(**kwargs), status)
if len(args) > 0:
args[0].assert_called_once_with(
odl.ODLTests.res_dir)
@@ -249,8 +249,8 @@ class ODLMainTesting(ODLTesting):
os.path.join(odl.ODLTests.res_dir, 'stdout.txt'))
def _test_no_keyword(self, key):
- kwargs = self._get_main_kwargs(key)
- self.assertEqual(self.test.main(**kwargs),
+ kwargs = self._get_run_suites_kwargs(key)
+ self.assertEqual(self.test.run_suites(**kwargs),
testcase.TestCase.EX_RUN_ERROR)
def test_no_odlusername(self):
@@ -286,7 +286,7 @@ class ODLMainTesting(ODLTesting):
def test_set_vars_ko(self):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=False) as mock_object:
- self._test_main(testcase.TestCase.EX_RUN_ERROR)
+ self._test_run_suites(testcase.TestCase.EX_RUN_ERROR)
mock_object.assert_called_once_with(
self._odl_username, self._odl_password)
@@ -295,15 +295,15 @@ class ODLMainTesting(ODLTesting):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True), \
self.assertRaises(Exception):
- self._test_main(testcase.TestCase.EX_RUN_ERROR,
- mock_method)
+ self._test_run_suites(testcase.TestCase.EX_RUN_ERROR,
+ mock_method)
@mock.patch('os.makedirs', side_effect=OSError)
def test_makedirs_oserror(self, mock_method):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True):
- self._test_main(testcase.TestCase.EX_RUN_ERROR,
- mock_method)
+ self._test_run_suites(testcase.TestCase.EX_RUN_ERROR,
+ mock_method)
@mock.patch('robot.run', side_effect=RobotError)
@mock.patch('os.makedirs')
@@ -311,7 +311,7 @@ class ODLMainTesting(ODLTesting):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True), \
self.assertRaises(RobotError):
- self._test_main(testcase.TestCase.EX_RUN_ERROR, *args)
+ self._test_run_suites(testcase.TestCase.EX_RUN_ERROR, *args)
@mock.patch('robot.run')
@mock.patch('os.makedirs')
@@ -320,7 +320,7 @@ class ODLMainTesting(ODLTesting):
return_value=True), \
mock.patch.object(self.test, 'parse_results',
side_effect=RobotError):
- self._test_main(testcase.TestCase.EX_RUN_ERROR, *args)
+ self._test_run_suites(testcase.TestCase.EX_RUN_ERROR, *args)
@mock.patch('robot.run')
@mock.patch('os.makedirs')
@@ -328,7 +328,7 @@ class ODLMainTesting(ODLTesting):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True), \
mock.patch.object(self.test, 'parse_results'):
- self._test_main(testcase.TestCase.EX_OK, *args)
+ self._test_run_suites(testcase.TestCase.EX_OK, *args)
@mock.patch('robot.run')
@mock.patch('os.makedirs', side_effect=OSError(errno.EEXIST, ''))
@@ -336,7 +336,7 @@ class ODLMainTesting(ODLTesting):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True), \
mock.patch.object(self.test, 'parse_results'):
- self._test_main(testcase.TestCase.EX_OK, *args)
+ self._test_run_suites(testcase.TestCase.EX_OK, *args)
@mock.patch('robot.run', return_value=1)
@mock.patch('os.makedirs')
@@ -344,7 +344,7 @@ class ODLMainTesting(ODLTesting):
with mock.patch.object(self.test, 'set_robotframework_vars',
return_value=True), \
mock.patch.object(self.test, 'parse_results'):
- self._test_main(testcase.TestCase.EX_OK, *args)
+ self._test_run_suites(testcase.TestCase.EX_OK, *args)
class ODLRunTesting(ODLTesting):
@@ -371,11 +371,11 @@ class ODLRunTesting(ODLTesting):
return_value="http://{}:9696".format(
ODLTesting._neutron_ip)):
if exception:
- self.test.main = mock.Mock(side_effect=exception)
+ self.test.run_suites = mock.Mock(side_effect=exception)
else:
- self.test.main = mock.Mock(return_value=status)
+ self.test.run_suites = mock.Mock(return_value=status)
self.assertEqual(self.test.run(), status)
- self.test.main.assert_called_once_with(
+ self.test.run_suites.assert_called_once_with(
odl.ODLTests.default_suites,
neutronip=self._neutron_ip,
odlip=odlip, odlpassword=self._odl_password,
@@ -394,9 +394,9 @@ class ODLRunTesting(ODLTesting):
with mock.patch('functest.utils.openstack_utils.get_endpoint',
return_value="http://{}:9696".format(
ODLTesting._neutron_ip)):
- self.test.main = mock.Mock(return_value=status)
+ self.test.run_suites = mock.Mock(return_value=status)
self.assertEqual(self.test.run(suites=suites), status)
- self.test.main.assert_called_once_with(
+ self.test.run_suites.assert_called_once_with(
suites,
neutronip=self._neutron_ip,
odlip=odlip, odlpassword=self._odl_password,
@@ -424,13 +424,13 @@ class ODLRunTesting(ODLTesting):
def test_no_os_tenant_name(self):
self._test_no_env_var("OS_TENANT_NAME")
- def test_main_false(self):
+ def test_run_suites_false(self):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
self._test_run(testcase.TestCase.EX_RUN_ERROR,
odlip=self._sdn_controller_ip,
odlwebport=self._odl_webport)
- def test_main_exc(self):
+ def test_run_suites_exc(self):
with self.assertRaises(Exception):
os.environ["SDN_CONTROLLER_IP"] = self._sdn_controller_ip
self._test_run(status=testcase.TestCase.EX_RUN_ERROR,
diff --git a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
index 3a121245c..f92d28065 100644
--- a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
+++ b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
@@ -1,5 +1,6 @@
#!/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
# which accompanies this distribution, and is available at
@@ -12,7 +13,6 @@ import unittest
from functest.core import testcase
from functest.opnfv_tests.openstack.refstack_client import refstack_client
-from functest.utils.constants import CONST
class OSRefstackClientTesting(unittest.TestCase):
@@ -28,27 +28,13 @@ class OSRefstackClientTesting(unittest.TestCase):
'testlist': self._testlist}
self.refstackclient = refstack_client.RefstackClient()
- def test_source_venv(self):
- with mock.patch('functest.opnfv_tests.openstack.refstack_client.'
- 'refstack_client.ft_utils.execute_command') as m:
- cmd = ("cd {0};"
- ". .venv/bin/activate;"
- "cd -;"
- .format(CONST.__getattribute__('dir_refstack_client')))
- self.refstackclient.source_venv()
- m.assert_any_call(cmd)
-
def test_run_defcore(self):
config = 'tempest.conf'
testlist = 'testlist'
with mock.patch('functest.opnfv_tests.openstack.refstack_client.'
'refstack_client.ft_utils.execute_command') as m:
- cmd = ("cd {0};"
- "./refstack-client test -c {1} -v --test-list {2};"
- "cd -;"
- .format(CONST.__getattribute__('dir_refstack_client'),
- config,
- testlist))
+ cmd = ("refstack-client test -c {0} -v --test-list {1}"
+ .format(config, testlist))
self.refstackclient.run_defcore(config, testlist)
m.assert_any_call(cmd)
diff --git a/functest/tests/unit/openstack/vping/test_vping.py b/functest/tests/unit/openstack/vping/test_vping.py
new file mode 100644
index 000000000..b229c3519
--- /dev/null
+++ b/functest/tests/unit/openstack/vping/test_vping.py
@@ -0,0 +1,157 @@
+# Copyright (c) 2017 Cable Television Laboratories, Inc. 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
+
+import unittest
+
+import mock
+
+from snaps.openstack.create_image import OpenStackImage
+from snaps.openstack.create_instance import OpenStackVmInstance, \
+ VmInstanceSettings
+from snaps.openstack.create_keypairs import OpenStackKeypair, KeypairSettings
+from snaps.openstack.create_network import OpenStackNetwork, NetworkSettings, \
+ SubnetSettings, PortSettings
+from snaps.openstack.create_router import OpenStackRouter, RouterSettings
+from snaps.openstack.create_security_group import OpenStackSecurityGroup, \
+ SecurityGroupSettings
+from snaps.openstack.os_credentials import OSCreds
+
+from functest.core.testcase import TestCase
+from functest.opnfv_tests.openstack.vping import vping_userdata, vping_ssh
+
+
+class VPingUserdataTesting(unittest.TestCase):
+ """
+ Ensures the VPingUserdata class can run in Functest. This test does not
+ actually connect with an OpenStack pod.
+ """
+
+ def setUp(self):
+ self.os_creds = OSCreds(
+ username='user', password='pass',
+ auth_url='http://foo.com:5000/v3', project_name='bar')
+
+ self.vping_userdata = vping_userdata.VPingUserdata(
+ os_creds=self.os_creds)
+
+ @mock.patch('snaps.openstack.utils.deploy_utils.create_vm_instance')
+ @mock.patch('functest.opnfv_tests.openstack.vping.vping_base.os.'
+ 'path.exists', return_value=True)
+ @mock.patch('snaps.openstack.create_flavor.OpenStackFlavor.create',
+ return_value=None)
+ @mock.patch('snaps.openstack.create_instance.OpenStackVmInstance.'
+ 'get_port_ip', return_value='10.0.0.1')
+ @mock.patch('snaps.openstack.create_instance.OpenStackVmInstance.'
+ 'vm_active', return_value=True)
+ def test_vping_userdata(self, deploy_vm, path_exists, create_flavor,
+ get_port_ip, vm_active):
+ os_vm_inst = mock.MagicMock(name='get_console_output')
+ os_vm_inst.get_console_output.return_value = 'vPing OK'
+ with mock.patch('snaps.openstack.utils.deploy_utils.create_image',
+ return_value=OpenStackImage(self.os_creds, None)), \
+ mock.patch('snaps.openstack.utils.deploy_utils.create_network',
+ return_value=OpenStackNetwork(
+ self.os_creds, NetworkSettings(name='foo'))), \
+ mock.patch('snaps.openstack.utils.deploy_utils.'
+ 'create_vm_instance',
+ return_value=OpenStackVmInstance(
+ self.os_creds,
+ VmInstanceSettings(
+ name='foo', flavor='bar',
+ port_settings=[PortSettings(
+ name='foo', network_name='bar')]),
+ None)), \
+ mock.patch('snaps.openstack.create_instance.'
+ 'OpenStackVmInstance.get_os_vm_server_obj',
+ return_value=os_vm_inst):
+ self.assertEquals(TestCase.EX_OK, self.vping_userdata.run())
+
+
+class VPingSSHTesting(unittest.TestCase):
+ """
+ Ensures the VPingUserdata class can run in Functest. This test does not
+ actually connect with an OpenStack pod.
+ """
+
+ def setUp(self):
+ self.os_creds = OSCreds(
+ username='user', password='pass',
+ auth_url='http://foo.com:5000/v3', project_name='bar')
+
+ self.vping_ssh = vping_ssh.VPingSSH(
+ os_creds=self.os_creds)
+
+ @mock.patch('snaps.openstack.utils.deploy_utils.create_vm_instance')
+ @mock.patch('functest.opnfv_tests.openstack.vping.vping_base.os.'
+ 'path.exists', return_value=True)
+ @mock.patch('snaps.openstack.create_flavor.OpenStackFlavor.create',
+ return_value=None)
+ @mock.patch('snaps.openstack.create_instance.OpenStackVmInstance.'
+ 'get_port_ip', return_value='10.0.0.1')
+ @mock.patch('snaps.openstack.create_instance.OpenStackVmInstance.'
+ 'vm_active', return_value=True)
+ @mock.patch('snaps.openstack.create_instance.OpenStackVmInstance.'
+ 'vm_ssh_active', return_value=True)
+ @mock.patch('snaps.openstack.create_instance.OpenStackVmInstance.'
+ 'ssh_client', return_value=True)
+ @mock.patch('scp.SCPClient')
+ @mock.patch('functest.opnfv_tests.openstack.vping.vping_ssh.'
+ 'VPingSSH._transfer_ping_script', return_value=True)
+ @mock.patch('functest.opnfv_tests.openstack.vping.vping_ssh.'
+ 'VPingSSH._do_vping_ssh', return_value=TestCase.EX_OK)
+ @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
+ 'get_ext_net_name', return_value='foo')
+ def test_vping_ssh(self, create_vm, path_exists,
+ flavor_create, get_port_ip, vm_active, ssh_active,
+ ssh_client, scp_client, trans_script, do_vping_ssh,
+ ext_net_name):
+ os_vm_inst = mock.MagicMock(name='get_console_output')
+ os_vm_inst.get_console_output.return_value = 'vPing OK'
+ ssh_client = mock.MagicMock(name='get_transport')
+ ssh_client.get_transport.return_value = None
+ scp_client = mock.MagicMock(name='put')
+ scp_client.put.return_value = None
+
+ with mock.patch('snaps.openstack.utils.deploy_utils.create_image',
+ return_value=OpenStackImage(self.os_creds, None)), \
+ mock.patch('snaps.openstack.utils.deploy_utils.create_network',
+ return_value=OpenStackNetwork(
+ self.os_creds,
+ NetworkSettings(
+ name='foo',
+ subnet_settings=[
+ SubnetSettings(
+ name='bar',
+ cidr='10.0.0.1/24')]))), \
+ mock.patch('snaps.openstack.utils.deploy_utils.'
+ 'create_vm_instance',
+ return_value=OpenStackVmInstance(
+ self.os_creds,
+ VmInstanceSettings(
+ name='foo', flavor='bar',
+ port_settings=[PortSettings(
+ name='foo', network_name='bar')]),
+ None)), \
+ mock.patch('snaps.openstack.utils.deploy_utils.create_keypair',
+ return_value=OpenStackKeypair(
+ self.os_creds, KeypairSettings(name='foo'))), \
+ mock.patch('snaps.openstack.utils.deploy_utils.create_router',
+ return_value=OpenStackRouter(
+ self.os_creds, RouterSettings(name='foo'))), \
+ mock.patch('snaps.openstack.utils.deploy_utils.'
+ 'create_security_group',
+ return_value=OpenStackSecurityGroup(
+ self.os_creds,
+ SecurityGroupSettings(name='foo'))), \
+ mock.patch('snaps.openstack.create_instance.'
+ 'OpenStackVmInstance.'
+ 'get_vm_inst', return_value=os_vm_inst), \
+ mock.patch('snaps.openstack.create_instance.'
+ 'OpenStackVmInstance.'
+ 'ssh_client', return_value=ssh_client):
+ self.assertEquals(TestCase.EX_OK, self.vping_ssh.run())
diff --git a/functest/tests/unit/utils/test_openstack_utils.py b/functest/tests/unit/utils/test_openstack_utils.py
index 74b49aaaf..828fb3d45 100644
--- a/functest/tests/unit/utils/test_openstack_utils.py
+++ b/functest/tests/unit/utils/test_openstack_utils.py
@@ -255,12 +255,6 @@ class OSUtilsTesting(unittest.TestCase):
'delete_port.return_value': mock.Mock(),
'remove_interface_router.return_value': mock.Mock(),
'remove_gateway_router.return_value': mock.Mock(),
- 'create_bgpvpn.return_value': self.mock_return,
- 'create_network_association.return_value': self.mock_return,
- 'create_router_association.return_value': self.mock_return,
- 'update_bgpvpn.return_value': self.mock_return,
- 'delete_bgpvpn.return_value': self.mock_return,
- 'show_bgpvpn.return_value': self.mock_return,
'list_security_groups.return_value': {'security_groups':
[self.sec_group]},
'list_security_group_rules.'
@@ -1212,53 +1206,6 @@ class OSUtilsTesting(unittest.TestCase):
'router_id'))
self.assertTrue(mock_logger_error.called)
- def test_create_bgpvpn(self):
- self.assertEqual(openstack_utils.
- create_bgpvpn(self.neutron_client),
- self.mock_return)
-
- def test_create_network_association(self):
- self.assertEqual(openstack_utils.
- create_network_association(self.neutron_client,
- 'bgpvpn_id',
- 'network_id'),
- self.mock_return)
-
- def test_create_router_association(self):
- self.assertEqual(openstack_utils.
- create_router_association(self.neutron_client,
- 'bgpvpn_id',
- 'router_id'),
- self.mock_return)
-
- def test_update_bgpvpn(self):
- self.assertEqual(openstack_utils.
- update_bgpvpn(self.neutron_client,
- 'bgpvpn_id'),
- self.mock_return)
-
- def test_delete_bgpvpn(self):
- self.assertEqual(openstack_utils.
- delete_bgpvpn(self.neutron_client,
- 'bgpvpn_id'),
- self.mock_return)
-
- def test_get_bgpvpn(self):
- self.assertEqual(openstack_utils.
- get_bgpvpn(self.neutron_client,
- 'bgpvpn_id'),
- self.mock_return)
-
- def test_get_bgpvpn_routers(self):
- with mock.patch('functest.utils.openstack_utils.'
- 'get_bgpvpn',
- return_value={'bgpvpn':
- {'routers': [self.router]}}):
- self.assertEqual(openstack_utils.
- get_bgpvpn_routers(self.neutron_client,
- 'bgpvpn_id'),
- [self.router])
-
def test_get_security_groups_default(self):
self.assertEqual(openstack_utils.
get_security_groups(self.neutron_client),
diff --git a/functest/utils/openstack_clean.py b/functest/utils/openstack_clean.py
index e88245d61..d7df8f848 100755..100644
--- a/functest/utils/openstack_clean.py
+++ b/functest/utils/openstack_clean.py
@@ -23,7 +23,6 @@
#
import logging
-import sys
import time
import yaml
@@ -382,6 +381,7 @@ def remove_tenants(keystone_client, default_tenants):
def main():
+ logging.basicConfig()
logger.info("Cleaning OpenStack resources...")
nova_client = os_utils.get_nova_client()
@@ -430,8 +430,3 @@ def main():
remove_tenants(keystone_client, default_tenants)
separator()
return 0
-
-
-if __name__ == '__main__':
- logging.basicConfig()
- sys.exit(main())
diff --git a/functest/utils/openstack_snapshot.py b/functest/utils/openstack_snapshot.py
index f4ef751c6..3dc6f80c7 100755..100644
--- a/functest/utils/openstack_snapshot.py
+++ b/functest/utils/openstack_snapshot.py
@@ -22,7 +22,6 @@
import logging
import yaml
-import sys
import functest.utils.openstack_utils as os_utils
from functest.utils.constants import CONST
@@ -131,6 +130,7 @@ def get_tenants(keystone_client):
def main():
+ logging.basicConfig()
logger.info("Generating OpenStack snapshot...")
nova_client = os_utils.get_nova_client()
@@ -163,8 +163,3 @@ def main():
logger.debug("NOTE: These objects will NOT be deleted after " +
"running the test.")
return 0
-
-
-if __name__ == '__main__':
- logging.basicConfig()
- sys.exit(main())
diff --git a/functest/utils/openstack_utils.py b/functest/utils/openstack_utils.py
index e7cdfc862..0ab630583 100644
--- a/functest/utils/openstack_utils.py
+++ b/functest/utils/openstack_utils.py
@@ -962,43 +962,6 @@ def create_shared_network_full(net_name, subnt_name, router_name, subnet_cidr):
return network_dic
-def create_bgpvpn(neutron_client, **kwargs):
- # route_distinguishers
- # route_targets
- json_body = {"bgpvpn": kwargs}
- return neutron_client.create_bgpvpn(json_body)
-
-
-def create_network_association(neutron_client, bgpvpn_id, neutron_network_id):
- json_body = {"network_association": {"network_id": neutron_network_id}}
- return neutron_client.create_network_association(bgpvpn_id, json_body)
-
-
-def create_router_association(neutron_client, bgpvpn_id, router_id):
- json_body = {"router_association": {"router_id": router_id}}
- return neutron_client.create_router_association(bgpvpn_id, json_body)
-
-
-def update_bgpvpn(neutron_client, bgpvpn_id, **kwargs):
- json_body = {"bgpvpn": kwargs}
- return neutron_client.update_bgpvpn(bgpvpn_id, json_body)
-
-
-def delete_bgpvpn(neutron_client, bgpvpn_id):
- return neutron_client.delete_bgpvpn(bgpvpn_id)
-
-
-def get_bgpvpn(neutron_client, bgpvpn_id):
- return neutron_client.show_bgpvpn(bgpvpn_id)
-
-
-def get_bgpvpn_routers(neutron_client, bgpvpn_id):
- return get_bgpvpn(neutron_client, bgpvpn_id)['bgpvpn']['routers']
-
-
-def get_bgpvpn_networks(neutron_client, bgpvpn_id):
- return get_bgpvpn(neutron_client, bgpvpn_id)['bgpvpn']['networks']
-
# *********************************************
# SEC GROUPS
# *********************************************
diff --git a/setup.cfg b/setup.cfg
index ba137687d..7296ec8de 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -9,7 +9,17 @@ scripts =
docker/docker_remote_api/enable_remote_api.sh
docker/add_images.sh
docker/config_install_env.sh
+ functest/ci/download_images.sh
+ functest/ci/check_os.sh
[entry_points]
console_scripts =
functest = functest.cli.cli_base:cli
+ functest_odl = functest.opnfv_tests.sdn.odl.odl:main
+ functest_onos_sfc = functest.opnfv_tests.sdn.onos.sfc.sfc:main
+ functest_refstack_client = functest.opnfv_tests.openstack.refstack_client.refstack_client:main
+ functest_tempest_conf = functest.opnfv_tests.openstack.refstack_client.tempest_conf:main
+ openstack_snapshot = functest.utils.openstack_snapshot:main
+ openstack_clean = functest.utils.openstack_clean:main
+ prepare_env = functest.ci.prepare_env:main
+ run_tests = functest.ci.run_tests:main