summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--build.sh8
-rw-r--r--docker/Dockerfile8
-rw-r--r--docker/components/Dockerfile4
-rw-r--r--docker/components/hooks/post_checkout6
-rw-r--r--docker/components/testcases.yaml56
-rw-r--r--docker/features/Dockerfile19
-rw-r--r--docker/features/hooks/post_checkout6
-rw-r--r--docker/features/testcases.yaml110
-rw-r--r--docker/features/thirdparty-requirements.txt4
-rw-r--r--docker/healthcheck/hooks/build7
-rw-r--r--docker/healthcheck/hooks/post_checkout6
-rw-r--r--docker/smoke/Dockerfile6
-rw-r--r--docker/smoke/hooks/build7
-rw-r--r--docker/smoke/hooks/post_checkout6
-rw-r--r--docker/smoke/testcases.yaml61
-rw-r--r--docker/smoke/thirdparty-requirements.txt7
-rw-r--r--functest/ci/config_aarch64_patch.yaml14
-rw-r--r--functest/ci/config_functest.yaml5
-rw-r--r--functest/ci/testcases.yaml24
-rw-r--r--functest/opnfv_tests/openstack/refstack_client/refstack_client.py12
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py17
-rw-r--r--functest/opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml13
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py16
-rw-r--r--functest/opnfv_tests/openstack/vping/ping.sh19
-rw-r--r--functest/opnfv_tests/sdn/odl/odl.py3
-rw-r--r--functest/opnfv_tests/sdn/onos/teston/adapters/connection.py2
-rw-r--r--functest/opnfv_tests/sdn/onos/teston/adapters/environment.py22
-rw-r--r--functest/opnfv_tests/vnf/ims/orchestra_ims.py873
-rw-r--r--functest/opnfv_tests/vnf/ims/orchestra_ims.yaml38
-rw-r--r--functest/tests/unit/core/test_feature.py4
-rw-r--r--functest/tests/unit/openstack/refstack_client/test_refstack_client.py32
-rw-r--r--functest/tests/unit/openstack/tempest/test_conf_utils.py5
-rw-r--r--functest/tests/unit/vnf/ims/test_cloudify_ims.py9
-rw-r--r--functest/tests/unit/vnf/ims/test_orchestra_ims.py224
-rw-r--r--functest/tests/unit/vnf/rnc/__init__.py0
35 files changed, 1224 insertions, 429 deletions
diff --git a/build.sh b/build.sh
index dbc79e0d3..77ea98beb 100644
--- a/build.sh
+++ b/build.sh
@@ -3,11 +3,17 @@
set -e
repo=${repo:-opnfv}
+dirs="\
+docker/core \
+docker/healthcheck \
+docker/smoke \
+docker/features \
+docker/components"
(cd docker && docker build -t "${repo}/functest" .)
docker push "${repo}/functest"
-for dir in docker/core docker/healthcheck docker/smoke; do
+for dir in ${dirs}; do
(cd ${dir} && docker build -t "${repo}/functest-${dir##**/}" .)
docker push "${repo}/functest-${dir##**/}"
done
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 924da6847..89cf86a69 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -84,15 +84,15 @@ RUN wget -q -O- https://git.openstack.org/cgit/openstack/requirements/plain/uppe
rm thirdparty-requirements.txt upper-constraints.txt
# 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/copper /src/copper
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/domino /src/domino
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
-RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/fds ${REPOS_DIR}/fds
+RUN git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/fds /src/fds
# other repositories
-RUN git clone --depth 1 -b $ODL_TAG https://git.opendaylight.org/gerrit/p/integration/test.git ${REPOS_DIR}/odl_test
+RUN git clone --depth 1 -b $ODL_TAG https://git.opendaylight.org/gerrit/p/integration/test.git /src/odl_test
RUN git clone --depth 1 -b $VIMS_TAG https://github.com/boucherv-orange/clearwater-live-test ${REPOS_VNFS_DIR}/vims-test
RUN git clone --depth 1 -b $VROUTER_TAG https://github.com/oolorg/opnfv-functest-vrouter.git ${REPOS_VNFS_DIR}/vrouter
RUN git clone --depth 1 https://github.com/wuwenbin2/OnosSystemTest.git ${REPOS_DIR}/onos
diff --git a/docker/components/Dockerfile b/docker/components/Dockerfile
new file mode 100644
index 000000000..8923e4cd7
--- /dev/null
+++ b/docker/components/Dockerfile
@@ -0,0 +1,4 @@
+FROM opnfv/functest-core
+
+COPY testcases.yaml /usr/lib/python2.7/site-packages/functest/ci/testcases.yaml
+CMD ["bash","-c","prepare_env start && run_tests -t all"]
diff --git a/docker/components/hooks/post_checkout b/docker/components/hooks/post_checkout
new file mode 100644
index 000000000..20a6d4b95
--- /dev/null
+++ b/docker/components/hooks/post_checkout
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+from="${DOCKER_REPO%/*}/functest-core"
+sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
+
+exit $?
diff --git a/docker/components/testcases.yaml b/docker/components/testcases.yaml
new file mode 100644
index 000000000..1604161ac
--- /dev/null
+++ b/docker/components/testcases.yaml
@@ -0,0 +1,56 @@
+tiers:
+ -
+ name: components
+ order: 3
+ ci_loop: 'weekly'
+ description : >-
+ Extensive testing of OpenStack API.
+ testcases:
+ -
+ case_name: tempest_full_parallel
+ project_name: functest
+ criteria: 80
+ blocking: false
+ description: >-
+ The list of test cases is generated by
+ Tempest automatically and depends on the parameters of
+ the OpenStack deplopyment.
+ dependencies:
+ installer: '^((?!netvirt).)*$'
+ scenario: ''
+ run:
+ module: 'functest.opnfv_tests.openstack.tempest.tempest'
+ class: 'TempestFullParallel'
+
+ -
+ case_name: tempest_custom
+ project_name: functest
+ criteria: 100
+ blocking: false
+ description: >-
+ The test case allows running a customized list of tempest
+ test cases defined in a file under
+ <dir_functest_repo>/functest/opnfv_tests/openstack/
+ /tempest/custom_tests/test_list.txt
+ The file is empty and can be customized with the desired tests.
+ dependencies:
+ installer: 'unknown'
+ scenario: 'unknown'
+ run:
+ module: 'functest.opnfv_tests.openstack.tempest.tempest'
+ class: 'TempestCustom'
+
+ -
+ case_name: rally_full
+ project_name: functest
+ criteria: 90
+ blocking: false
+ description: >-
+ This test case runs the full suite of scenarios of the OpenStack
+ Rally suite using several threads and iterations.
+ dependencies:
+ installer: '^((?!netvirt).)*$'
+ scenario: ''
+ run:
+ module: 'functest.opnfv_tests.openstack.rally.rally'
+ class: 'RallyFull' \ No newline at end of file
diff --git a/docker/features/Dockerfile b/docker/features/Dockerfile
new file mode 100644
index 000000000..73f4d2cef
--- /dev/null
+++ b/docker/features/Dockerfile
@@ -0,0 +1,19 @@
+FROM opnfv/functest-core
+
+ARG BRANCH=master
+ARG OPENSTACK_TAG=stable/ocata
+
+COPY thirdparty-requirements.txt thirdparty-requirements.txt
+RUN apk --no-cache add --virtual .build-deps --update \
+ python-dev build-base linux-headers libffi-dev \
+ openssl-dev libjpeg-turbo-dev git && \
+ pip install --no-cache-dir --src /src \
+ -chttps://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=$OPENSTACK_TAG \
+ -chttps://git.opnfv.org/functest/plain/upper-constraints.txt?h=$BRANCH \
+ -rthirdparty-requirements.txt && \
+ git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/domino /src/domino && \
+ git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/copper /src/copper && \
+ rm -r thirdparty-requirements.txt /src/domino/.git /src/copper/.git && \
+ apk del .build-deps
+COPY testcases.yaml /usr/lib/python2.7/site-packages/functest/ci/testcases.yaml
+CMD ["bash","-c","prepare_env start && run_tests -t all"]
diff --git a/docker/features/hooks/post_checkout b/docker/features/hooks/post_checkout
new file mode 100644
index 000000000..20a6d4b95
--- /dev/null
+++ b/docker/features/hooks/post_checkout
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+from="${DOCKER_REPO%/*}/functest-core"
+sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
+
+exit $?
diff --git a/docker/features/testcases.yaml b/docker/features/testcases.yaml
new file mode 100644
index 000000000..48b1468df
--- /dev/null
+++ b/docker/features/testcases.yaml
@@ -0,0 +1,110 @@
+tiers:
+ -
+ name: features
+ order: 2
+ ci_loop: '(daily)|(weekly)'
+ description : >-
+ Test suites from feature projects
+ integrated in functest
+ testcases:
+ -
+ case_name: bgpvpn
+ project_name: sdnvpn
+ criteria: 100
+ blocking: false
+ description: >-
+ Test suite from SDNVPN project.
+ dependencies:
+ installer: '(fuel)|(apex)|(netvirt)'
+ scenario: 'bgpvpn'
+ run:
+ module: 'functest.core.feature'
+ class: 'BashFeature'
+ args:
+ cmd: 'run_sdnvpn_tests.py'
+
+ -
+ case_name: security_scan
+ enabled: false
+ project_name: securityscanning
+ criteria: 100
+ blocking: false
+ description: >-
+ Simple Security Scan
+ dependencies:
+ installer: 'apex'
+ scenario: '^((?!fdio).)*$'
+ run:
+ module: 'functest.core.feature'
+ class: 'BashFeature'
+ args:
+ cmd: '. /home/opnfv/functest/conf/stackrc && security_scan --config /usr/local/etc/securityscanning/config.ini'
+
+ -
+ case_name: copper
+ enabled: false
+ project_name: copper
+ criteria: 100
+ blocking: false
+ description: >-
+ Test suite for policy management based on OpenStack Congress
+ dependencies:
+ installer: 'apex'
+ scenario: '^((?!fdio).)*$'
+ run:
+ module: 'functest.core.feature'
+ class: 'BashFeature'
+ args:
+ cmd: 'cd /src/copper/tests && bash run.sh && cd -'
+
+ -
+ case_name: functest-odl-sfc
+ enabled: false
+ project_name: sfc
+ criteria: 100
+ blocking: false
+ description: >-
+ Test suite for odl-sfc to test two chains and two SFs
+ dependencies:
+ installer: '(apex)|(fuel)'
+ scenario: 'odl_l2-sfc'
+ run:
+ module: 'functest.core.feature'
+ class: 'BashFeature'
+ args:
+ cmd: 'run_sfc_tests.py'
+
+ -
+ case_name: domino-multinode
+ enabled: false
+ project_name: domino
+ criteria: 100
+ blocking: false
+ description: >-
+ Test suite from Domino project.
+ dependencies:
+ installer: ''
+ scenario: ''
+ run:
+ module: 'functest.core.feature'
+ class: 'BashFeature'
+ args:
+ cmd: 'cd /src/domino && ./tests/run_multinode.sh'
+
+ -
+ case_name: barometercollectd
+ enabled: false
+ project_name: barometer
+ criteria: 100
+ blocking: false
+ description: >-
+ Test suite for the Barometer project. Separate tests verify the
+ proper configuration and functionality of the following
+ collectd plugins Ceilometer, Hugepages, Memory RAS (mcelog),
+ and OVS Events
+ dependencies:
+ installer: 'fuel'
+ scenario: 'kvm_ovs_dpdk_bar'
+ run:
+ module: 'baro_tests.barometer'
+ class: 'BarometerCollectd'
diff --git a/docker/features/thirdparty-requirements.txt b/docker/features/thirdparty-requirements.txt
new file mode 100644
index 000000000..ee2e5e9ca
--- /dev/null
+++ b/docker/features/thirdparty-requirements.txt
@@ -0,0 +1,4 @@
+baro_tests
+sdnvpn
+securityscanning
+sfc
diff --git a/docker/healthcheck/hooks/build b/docker/healthcheck/hooks/build
deleted file mode 100644
index e5d15b526..000000000
--- a/docker/healthcheck/hooks/build
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-from="${DOCKER_REPO%/*}/functest-core"
-sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile &&
- docker build -t "${IMAGE_NAME}" .
-
-exit $?
diff --git a/docker/healthcheck/hooks/post_checkout b/docker/healthcheck/hooks/post_checkout
new file mode 100644
index 000000000..20a6d4b95
--- /dev/null
+++ b/docker/healthcheck/hooks/post_checkout
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+from="${DOCKER_REPO%/*}/functest-core"
+sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
+
+exit $?
diff --git a/docker/smoke/Dockerfile b/docker/smoke/Dockerfile
index 22ff2eb3a..223ed64d0 100644
--- a/docker/smoke/Dockerfile
+++ b/docker/smoke/Dockerfile
@@ -2,6 +2,7 @@ FROM opnfv/functest-core
ARG BRANCH=master
ARG OPENSTACK_TAG=stable/ocata
+ARG ODL_TAG=release/beryllium-sr4
COPY thirdparty-requirements.txt thirdparty-requirements.txt
RUN apk --no-cache add --virtual .build-deps --update \
@@ -11,9 +12,12 @@ RUN apk --no-cache add --virtual .build-deps --update \
-chttps://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt?h=$OPENSTACK_TAG \
-chttps://git.opnfv.org/functest/plain/upper-constraints.txt?h=$BRANCH \
-rthirdparty-requirements.txt && \
+ git clone --depth 1 -b $ODL_TAG https://git.opendaylight.org/gerrit/p/integration/test.git /src/odl_test && \
+ git clone --depth 1 -b $BRANCH https://gerrit.opnfv.org/gerrit/fds /src/fds && \
ln -s /src/tempest /src/refstack-client/.tempest && \
virtualenv --system-site-packages /src/tempest/.venv && \
- rm -r thirdparty-requirements.txt /src/refstack-client/.git && \
+ rm -r thirdparty-requirements.txt /src/refstack-client/.git /src/odl_test/.git \
+ /src/fds/.git && \
apk del .build-deps
COPY testcases.yaml /usr/lib/python2.7/site-packages/functest/ci/testcases.yaml
CMD ["bash","-c","prepare_env start && run_tests -t all"]
diff --git a/docker/smoke/hooks/build b/docker/smoke/hooks/build
deleted file mode 100644
index e5d15b526..000000000
--- a/docker/smoke/hooks/build
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-from="${DOCKER_REPO%/*}/functest-core"
-sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile &&
- docker build -t "${IMAGE_NAME}" .
-
-exit $?
diff --git a/docker/smoke/hooks/post_checkout b/docker/smoke/hooks/post_checkout
new file mode 100644
index 000000000..20a6d4b95
--- /dev/null
+++ b/docker/smoke/hooks/post_checkout
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+from="${DOCKER_REPO%/*}/functest-core"
+sed -i "s|^FROM.*$|FROM ${from}|" Dockerfile
+
+exit $?
diff --git a/docker/smoke/testcases.yaml b/docker/smoke/testcases.yaml
index 69ea038a4..772196a00 100644
--- a/docker/smoke/testcases.yaml
+++ b/docker/smoke/testcases.yaml
@@ -85,6 +85,67 @@ tiers:
class: 'RefstackClient'
-
+ case_name: odl
+ project_name: functest
+ criteria: 100
+ blocking: true
+ description: >-
+ Test Suite for the OpenDaylight SDN Controller. It
+ integrates some test suites from upstream using
+ Robot as the test framework.
+ dependencies:
+ installer: ''
+ scenario: 'odl'
+ run:
+ module: 'functest.opnfv_tests.sdn.odl.odl'
+ class: 'ODLTests'
+ args:
+ suites:
+ - /src/odl_test/csit/suites/integration/basic
+ - /src/odl_test/csit/suites/openstack/neutron
+
+ -
+ case_name: odl_netvirt
+ project_name: functest
+ criteria: 100
+ blocking: false
+ description: >-
+ Test Suite for the OpenDaylight SDN Controller when
+ the NetVirt features are installed. It integrates
+ some test suites from upstream using Robot as the
+ test framework.
+ dependencies:
+ installer: 'apex'
+ scenario: 'os-odl_l3-nofeature'
+ run:
+ module: 'functest.opnfv_tests.sdn.odl.odl'
+ class: 'ODLTests'
+ args:
+ suites:
+ - /src/odl_test/csit/suites/integration/basic
+ - /src/odl_test/csit/suites/openstack/neutron
+ - /src/odl_test/csit/suites/openstack/connectivity
+
+ -
+ case_name: fds
+ project_name: functest
+ criteria: 100
+ blocking: false
+ description: >-
+ Test Suite for the OpenDaylight SDN Controller when GBP features are
+ installed. It integrates some test suites from upstream using
+ Robot as the test framework.
+ dependencies:
+ installer: 'apex'
+ scenario: 'odl.*-fdio'
+ run:
+ module: 'functest.opnfv_tests.sdn.odl.odl'
+ class: 'ODLTests'
+ args:
+ suites:
+ - /src/fds/testing/robot
+
+ -
case_name: snaps_smoke
project_name: functest
criteria: 100
diff --git a/docker/smoke/thirdparty-requirements.txt b/docker/smoke/thirdparty-requirements.txt
index be1980f2c..b298601b7 100644
--- a/docker/smoke/thirdparty-requirements.txt
+++ b/docker/smoke/thirdparty-requirements.txt
@@ -1,8 +1 @@
-baro_tests
-sdnvpn
-opera
-securityscanning
-sfc
-tosca-parser>=0.7.0 # Apache-2.0
-heat-translator>=0.4.0 # Apache-2.0
refstack-client
diff --git a/functest/ci/config_aarch64_patch.yaml b/functest/ci/config_aarch64_patch.yaml
index 27b270626..de82dbc70 100644
--- a/functest/ci/config_aarch64_patch.yaml
+++ b/functest/ci/config_aarch64_patch.yaml
@@ -8,18 +8,16 @@ os:
images:
glance_tests:
disk_file: /home/opnfv/functest/images/cirros-d161201-aarch64-disk.img
- kernel_file: /home/opnfv/functest/images/cirros-d161201-aarch64-kernel
- ramdisk_file: /home/opnfv/functest/images/cirros-d161201-aarch64-initramfs
extra_properties:
- os_command_line: root=/dev/vdb1 rw rootwait console=tty0 console=ttyS0 console=ttyAMA0
- hw_video_model: vga
+ hw_firmware_type: 'uefi'
+ short_id: 'ubuntu16.04'
+ hw_video_model: 'vga'
cirros:
disk_file: /home/opnfv/functest/images/cirros-d161201-aarch64-disk.img
- kernel_file: /home/opnfv/functest/images/cirros-d161201-aarch64-kernel
- ramdisk_file: /home/opnfv/functest/images/cirros-d161201-aarch64-initramfs
extra_properties:
- os_command_line: root=/dev/vdb1 rw rootwait console=tty0 console=ttyS0 console=ttyAMA0
- hw_video_model: vga
+ hw_firmware_type: 'uefi'
+ short_id: 'ubuntu16.04'
+ hw_video_model: 'vga'
vping:
image_name: TestVM
diff --git a/functest/ci/config_functest.yaml b/functest/ci/config_functest.yaml
index e26b31398..31ce4b90e 100644
--- a/functest/ci/config_functest.yaml
+++ b/functest/ci/config_functest.yaml
@@ -10,9 +10,8 @@ general:
repo_netready: /home/opnfv/repos/netready
repo_barometer: /home/opnfv/repos/barometer
repo_doctor: /home/opnfv/repos/doctor
- repo_copper: /home/opnfv/repos/copper
- repo_domino: /home/opnfv/repos/domino
- repo_fds: /home/opnfv/repos/fds
+ repo_odl_test: /src/odl_test
+ repo_fds: /src/fds
repo_securityscan: /home/opnfv/repos/securityscanning
repo_vrouter: /home/opnfv/repos/vnfs/vrouter
functest: /home/opnfv/functest
diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml
index 6a589c9b1..99c0cc202 100644
--- a/functest/ci/testcases.yaml
+++ b/functest/ci/testcases.yaml
@@ -162,8 +162,8 @@ tiers:
class: 'ODLTests'
args:
suites:
- - /home/opnfv/repos/odl_test/csit/suites/integration/basic
- - /home/opnfv/repos/odl_test/csit/suites/openstack/neutron
+ - /src/odl_test/csit/suites/integration/basic
+ - /src/odl_test/csit/suites/openstack/neutron
-
case_name: odl_netvirt
@@ -183,9 +183,9 @@ tiers:
class: 'ODLTests'
args:
suites:
- - /home/opnfv/repos/odl_test/csit/suites/integration/basic
- - /home/opnfv/repos/odl_test/csit/suites/openstack/neutron
- - /home/opnfv/repos/odl_test/csit/suites/openstack/connectivity
+ - /src/odl_test/csit/suites/integration/basic
+ - /src/odl_test/csit/suites/openstack/neutron
+ - /src/odl_test/csit/suites/openstack/connectivity
-
case_name: fds
@@ -204,7 +204,7 @@ tiers:
class: 'ODLTests'
args:
suites:
- - /home/opnfv/repos/fds/testing/robot
+ - /src/fds/testing/robot
-
case_name: onos
@@ -297,7 +297,7 @@ tiers:
module: 'functest.core.feature'
class: 'BashFeature'
args:
- cmd: 'cd /usr/local/lib/python2.7/dist-packages/sdnvpn/test/functest && python ./run_tests.py'
+ cmd: 'run_sdnvpn_tests.py'
-
case_name: security_scan
@@ -331,7 +331,7 @@ tiers:
module: 'functest.core.feature'
class: 'BashFeature'
args:
- cmd: 'cd /home/opnfv/repos/copper/tests && bash run.sh && cd -'
+ cmd: 'cd /src/copper/tests && bash run.sh && cd -'
-
case_name: multisite
@@ -363,7 +363,7 @@ tiers:
module: 'functest.core.feature'
class: 'BashFeature'
args:
- cmd: 'cd /usr/local/lib/python2.7/dist-packages/sfc/tests/functest && python ./run_tests.py'
+ cmd: 'run_sfc_tests.py'
-
case_name: onos_sfc
@@ -411,7 +411,7 @@ tiers:
module: 'functest.core.feature'
class: 'BashFeature'
args:
- cmd: 'cd /home/opnfv/repos/domino && ./tests/run_multinode.sh'
+ cmd: 'cd /src/domino && ./tests/run_multinode.sh'
-
case_name: gluon_vping
@@ -543,7 +543,7 @@ tiers:
-
case_name: orchestra_ims
- enabled: false
+ enabled: true
project_name: functest
criteria: 100
blocking: false
@@ -551,7 +551,7 @@ tiers:
VNF deployment with OpenBaton (Orchestra)
dependencies:
installer: ''
- scenario: ''
+ scenario: 'os-nosdn-nofeature-ha'
run:
module: 'functest.opnfv_tests.vnf.ims.orchestra_ims'
class: 'ImsVnf'
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index 76bee19d1..921d69b4d 100644
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -106,15 +106,15 @@ class RefstackClient(testcase.OSGCTestCase):
for match in re.findall(r"(- Failed: )(\d+)", output):
num_failures = match[1]
LOGGER.info("".join(match))
- success_testcases = ""
+ success_testcases = []
for match in re.findall(r"\{0\}(.*?)[. ]*ok", output):
- success_testcases += match + ", "
- failed_testcases = ""
+ success_testcases.append(match)
+ failed_testcases = []
for match in re.findall(r"\{0\}(.*?)[. ]*FAILED", output):
- failed_testcases += match + ", "
- skipped_testcases = ""
+ failed_testcases.append(match)
+ skipped_testcases = []
for match in re.findall(r"\{0\}(.*?)[. ]*SKIPPED:", output):
- skipped_testcases += match + ", "
+ skipped_testcases.append(match)
num_executed = int(num_tests) - int(num_skipped)
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index d494db5eb..2313ec04b 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -15,6 +15,8 @@ import re
import shutil
import subprocess
+import yaml
+
from functest.utils.constants import CONST
import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
@@ -38,6 +40,8 @@ TEMPEST_RAW_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_raw_list.txt')
TEMPEST_LIST = os.path.join(TEMPEST_RESULTS_DIR, 'test_list.txt')
REFSTACK_RESULTS_DIR = os.path.join(CONST.__getattribute__('dir_results'),
'refstack')
+TEMPEST_CONF_YAML = pkg_resources.resource_filename(
+ 'functest', 'opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml')
CI_INSTALLER_TYPE = CONST.__getattribute__('INSTALLER_TYPE')
CI_INSTALLER_IP = CONST.__getattribute__('INSTALLER_IP')
@@ -328,6 +332,19 @@ def configure_tempest_update_params(tempest_conf_file,
config.set(service, 'endpoint_type',
CONST.__getattribute__('OS_ENDPOINT_TYPE'))
+ logger.debug('Add/Update required params defined in tempest_conf.yaml '
+ 'into tempest.conf file')
+ with open(TEMPEST_CONF_YAML) as f:
+ conf_yaml = yaml.safe_load(f)
+ if not conf_yaml:
+ sections = config.sections()
+ for section in conf_yaml:
+ if section not in sections:
+ config.add_section(section)
+ sub_conf = conf_yaml.get(section)
+ for key, value in sub_conf.items():
+ config.set(section, key, value)
+
with open(tempest_conf_file, 'wb') as config_file:
config.write(config_file)
diff --git a/functest/opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml b/functest/opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml
new file mode 100644
index 000000000..b47a9736a
--- /dev/null
+++ b/functest/opnfv_tests/openstack/tempest/custom_tests/tempest_conf.yaml
@@ -0,0 +1,13 @@
+# This is an empty configuration file to be filled up with the desired options
+# to generate a custom tempest.conf
+# Examples:
+# network-feature-enabled:
+# port_security: True
+
+# volume-feature-enabled:
+# api_v1: False
+
+# validation:
+# image_ssh_user: root
+# ssh_timeout: 300
+
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index e565f5f9d..4993c74a9 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -195,17 +195,21 @@ class TempestCommon(testcase.OSGCTestCase):
"tempest.log"), 'r') as logfile:
output = logfile.read()
- error_logs = ""
+ success_testcases = []
+ for match in re.findall('(.*?)[. ]*success ', output):
+ success_testcases.append(match)
+ failed_testcases = []
for match in re.findall('(.*?)[. ]*fail ', output):
- error_logs += match
- skipped_testcase = ""
+ failed_testcases.append(match)
+ skipped_testcases = []
for match in re.findall('(.*?)[. ]*skip:', output):
- skipped_testcase += match
+ skipped_testcases.append(match)
self.details = {"tests": int(num_tests),
"failures": int(num_failures),
- "errors": error_logs,
- "skipped": skipped_testcase}
+ "success": success_testcases,
+ "errors": failed_testcases,
+ "skipped": skipped_testcases}
except Exception:
self.result = 0
diff --git a/functest/opnfv_tests/openstack/vping/ping.sh b/functest/opnfv_tests/openstack/vping/ping.sh
index 693b86825..15f5e84e1 100644
--- a/functest/opnfv_tests/openstack/vping/ping.sh
+++ b/functest/opnfv_tests/openstack/vping/ping.sh
@@ -1,13 +1,10 @@
#!/bin/sh
-while true; do
- ping -c 1 $1 2>&1 >/dev/null
- RES=$?
- if [ "Z$RES" = "Z0" ] ; then
- echo 'vPing OK'
- break
- else
- echo 'vPing KO'
- fi
- sleep 1
-done \ No newline at end of file
+
+ping -c 1 $1 2>&1 >/dev/null
+RES=$?
+if [ "Z$RES" = "Z0" ] ; then
+ echo 'vPing OK'
+else
+ echo 'vPing KO'
+fi
diff --git a/functest/opnfv_tests/sdn/odl/odl.py b/functest/opnfv_tests/sdn/odl/odl.py
index 5724012ca..841da834b 100644
--- a/functest/opnfv_tests/sdn/odl/odl.py
+++ b/functest/opnfv_tests/sdn/odl/odl.py
@@ -66,8 +66,7 @@ class ODLResultVisitor(robot.api.ResultVisitor):
class ODLTests(testcase.TestCase):
"""ODL test runner."""
- odl_test_repo = os.path.join(
- constants.CONST.__getattribute__('dir_repos'), 'odl_test')
+ odl_test_repo = constants.CONST.__getattribute__('dir_repo_odl_test')
neutron_suite_dir = os.path.join(odl_test_repo,
"csit/suites/openstack/neutron")
basic_suite_dir = os.path.join(odl_test_repo,
diff --git a/functest/opnfv_tests/sdn/onos/teston/adapters/connection.py b/functest/opnfv_tests/sdn/onos/teston/adapters/connection.py
index dfaa5cc14..a6d192ee5 100644
--- a/functest/opnfv_tests/sdn/onos/teston/adapters/connection.py
+++ b/functest/opnfv_tests/sdn/onos/teston/adapters/connection.py
@@ -64,7 +64,7 @@ class Connection(Foundation):
"""
os.getenv only returns current user value
GetEnvValue returns a environment value of
- current handle
+ current handle
eg: GetEnvValue(handle,'HOME')
"""
envhandle = handle
diff --git a/functest/opnfv_tests/sdn/onos/teston/adapters/environment.py b/functest/opnfv_tests/sdn/onos/teston/adapters/environment.py
index cb75b5c3c..875a2dc9b 100644
--- a/functest/opnfv_tests/sdn/onos/teston/adapters/environment.py
+++ b/functest/opnfv_tests/sdn/onos/teston/adapters/environment.py
@@ -1,11 +1,11 @@
"""
Description:
- This file is used to setup the running environment
- Include Download code,setup environment variable
- Set onos running config
- Set user name/password
- Onos-push-keys and so on
- lanqinglong@huawei.com
+This file is used to setup the running environment
+Include Download code,setup environment variable
+Set onos running config
+Set user name/password
+Onos-push-keys and so on
+lanqinglong@huawei.com
#
# All rights reserved. This program and the accompanying materials
@@ -17,7 +17,7 @@ Description:
import logging
import pexpect
-import pxssh
+from pexpect import pxssh
import re
import os
import sys
@@ -196,10 +196,10 @@ class Environment(Connection):
def ChangeTestCasePara(self, testcase, user, password):
"""
- When running test script, there's something need
- to change in every test folder's *.param & *.topo files
- user: onos&compute node user
- password: onos&compute node password
+ When running test script, there\'s something need
+ to change in every test folder\'s \*.param & \*.topo files
+ user: onos\&compute node user
+ password: onos\&compute node password
"""
self.logger.info("Now Changing " + testcase + " name&password")
if self.masterusername == 'root':
diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.py b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
index 7b1ea9ad8..0a0a766a3 100644
--- a/functest/opnfv_tests/vnf/ims/orchestra_ims.py
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.py
@@ -7,21 +7,42 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
+"""Orchestra OpenIMS testcase implementation."""
+
import json
import logging
import os
-import pkg_resources
import socket
-import sys
import time
+import pkg_resources
import yaml
+
+from snaps.openstack.create_image import OpenStackImage, ImageSettings
+from snaps.openstack.create_flavor import OpenStackFlavor, FlavorSettings
+from snaps.openstack.create_security_group import (
+ OpenStackSecurityGroup,
+ SecurityGroupSettings,
+ SecurityGroupRuleSettings,
+ Direction,
+ Protocol)
+from snaps.openstack.create_network import (
+ OpenStackNetwork,
+ NetworkSettings,
+ SubnetSettings,
+ PortSettings)
+from snaps.openstack.create_router import OpenStackRouter, RouterSettings
+from snaps.openstack.os_credentials import OSCreds
+from snaps.openstack.create_instance import (
+ VmInstanceSettings, OpenStackVmInstance)
+from functest.opnfv_tests.openstack.snaps import snaps_utils
+
import functest.core.vnf as vnf
import functest.utils.openstack_utils as os_utils
from functest.utils.constants import CONST
-from org.openbaton.cli.agents.agents import MainAgent
from org.openbaton.cli.errors.errors import NfvoException
+from org.openbaton.cli.agents.agents import MainAgent
__author__ = "Pauls, Michael <michael.pauls@fokus.fraunhofer.de>"
@@ -32,404 +53,570 @@ __author__ = "Pauls, Michael <michael.pauls@fokus.fraunhofer.de>"
# -----------------------------------------------------------
-def get_config(parameter, my_file):
+def get_config(parameter, file_path):
"""
+ Get config parameter.
+
Returns the value of a given parameter in file.yaml
parameter must be given in string format with dots
Example: general.openstack.image_name
"""
- with open(file) as f:
- file_yaml = yaml.safe_load(f)
- f.close()
+ with open(file_path) as config_file:
+ file_yaml = yaml.safe_load(config_file)
+ config_file.close()
value = file_yaml
for element in parameter.split("."):
value = value.get(element)
if value is None:
raise ValueError("The parameter %s is not defined in"
- " %s" % (parameter, my_file))
+ " reporting.yaml", parameter)
return value
def servertest(host, port):
+ """Method to test that a server is reachable at IP:port"""
args = socket.getaddrinfo(host, port, socket.AF_INET, socket.SOCK_STREAM)
for family, socktype, proto, canonname, sockaddr in args:
- s = socket.socket(family, socktype, proto)
+ sock = socket.socket(family, socktype, proto)
try:
- s.connect(sockaddr)
+ sock.connect(sockaddr)
except socket.error:
return False
else:
- s.close()
+ sock.close()
return True
+def get_userdata(orchestrator=dict):
+ """Build userdata for Open Baton machine"""
+ userdata = "#!/bin/bash\n"
+ userdata += "echo \"Executing userdata...\"\n"
+ userdata += "set -x\n"
+ userdata += "set -e\n"
+ userdata += "echo \"Set nameserver to '8.8.8.8'...\"\n"
+ userdata += "echo \"nameserver 8.8.8.8\" >> /etc/resolv.conf\n"
+ userdata += "echo \"Install curl...\"\n"
+ userdata += "apt-get install curl\n"
+ userdata += "echo \"Inject public key...\"\n"
+ userdata += ("echo \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuPXrV3"
+ "geeHc6QUdyUr/1Z+yQiqLcOskiEGBiXr4z76MK4abiFmDZ18OMQlc"
+ "fl0p3kS0WynVgyaOHwZkgy/DIoIplONVr2CKBKHtPK+Qcme2PVnCtv"
+ "EqItl/FcD+1h5XSQGoa+A1TSGgCod/DPo+pes0piLVXP8Ph6QS1k7S"
+ "ic7JDeRQ4oT1bXYpJ2eWBDMfxIWKZqcZRiGPgMIbJ1iEkxbpeaAd9O"
+ "4MiM9nGCPESmed+p54uYFjwEDlAJZShcAZziiZYAvMZhvAhe6USljc"
+ "7YAdalAnyD/jwCHuwIrUw/lxo7UdNCmaUxeobEYyyFA1YVXzpNFZya"
+ "XPGAAYIJwEq/ openbaton@opnfv\" >> /home/ubuntu/.ssh/aut"
+ "horized_keys\n")
+ userdata += "echo \"Download bootstrap...\"\n"
+ userdata += ("curl -s %s "
+ "> ./bootstrap\n" % orchestrator['bootstrap']['url'])
+ userdata += ("curl -s %s" "> ./config_file\n" %
+ orchestrator['bootstrap']['config']['url'])
+ userdata += ("echo \"Disable usage of mysql...\"\n")
+ userdata += "sed -i s/mysql=.*/mysql=no/g /config_file\n"
+ userdata += ("echo \"Setting 'rabbitmq_broker_ip' to '%s'\"\n"
+ % orchestrator['details']['fip'].ip)
+ userdata += ("sed -i s/rabbitmq_broker_ip=localhost/rabbitmq_broker_ip"
+ "=%s/g /config_file\n" % orchestrator['details']['fip'].ip)
+ userdata += "echo \"Set autostart of components to 'false'\"\n"
+ userdata += "export OPENBATON_COMPONENT_AUTOSTART=false\n"
+ userdata += "echo \"Execute bootstrap...\"\n"
+ bootstrap = "sh ./bootstrap release -configFile=./config_file"
+ userdata += bootstrap + "\n"
+ userdata += "echo \"Setting 'nfvo.plugin.timeout' to '300000'\"\n"
+ userdata += ("echo \"nfvo.plugin.timeout=600000\" >> "
+ "/etc/openbaton/openbaton-nfvo.properties\n")
+ userdata += (
+ "wget %s -O /etc/openbaton/openbaton-vnfm-generic-user-data.sh\n" %
+ orchestrator['gvnfm']['userdata']['url'])
+ userdata += "sed -i '113i"'\ \ \ \ '"sleep 60' " \
+ "/etc/openbaton/openbaton-vnfm-generic-user-data.sh\n"
+ userdata += "echo \"Starting NFVO\"\n"
+ userdata += "service openbaton-nfvo restart\n"
+ userdata += "echo \"Starting Generic VNFM\"\n"
+ userdata += "service openbaton-vnfm-generic restart\n"
+ userdata += "echo \"...end of userdata...\"\n"
+ return userdata
+
+
class ImsVnf(vnf.VnfOnBoarding):
"""OpenIMS VNF deployed with openBaton orchestrator"""
- def __init__(self, project='functest', case_name='orchestra_ims',
- repo='', cmd=''):
- super(ImsVnf, self).__init__(project, case_name, repo, cmd)
- self.logger = logging.getLogger(__name__)
- self.logger.info("Orchestra IMS VNF onboarding test starting")
- self.ob_password = "openbaton"
- self.ob_username = "admin"
- self.ob_https = False
- self.ob_port = "8080"
- self.ob_ip = "localhost"
- self.ob_instance_id = ""
+ # logger = logging.getLogger(__name__)
+
+ def __init__(self, **kwargs):
+ if "case_name" not in kwargs:
+ kwargs["case_name"] = "orchestra_ims"
+ super(ImsVnf, self).__init__(**kwargs)
+ self.logger = logging.getLogger("functest.ci.run_tests.orchestra")
+ self.logger.info("kwargs %s", (kwargs))
+
self.case_dir = pkg_resources.resource_filename(
'functest', 'opnfv_tests/vnf/ims/')
self.data_dir = CONST.__getattribute__('dir_ims_data')
self.test_dir = CONST.__getattribute__('dir_repo_vims_test')
- self.ob_projectid = ""
- self.keystone_client = os_utils.get_keystone_client()
- self.ob_nsr_id = ""
- self.nsr = None
- self.main_agent = None
- # vIMS Data directory creation
- if not os.path.exists(self.data_dir):
- os.makedirs(self.data_dir)
- # Retrieve the configuration
+ self.created_resources = []
+ self.logger.info("Orchestra IMS VNF onboarding test starting")
+
try:
self.config = CONST.__getattribute__(
'vnf_{}_config'.format(self.case_name))
except BaseException:
raise Exception("Orchestra VNF config file not found")
config_file = self.case_dir + self.config
- self.imagename = get_config("openbaton.imagename", config_file)
- self.bootstrap_link = get_config("openbaton.bootstrap_link",
- config_file)
- self.bootstrap_config_link = get_config(
- "openbaton.bootstrap_config_link", config_file)
- self.market_link = get_config("openbaton.marketplace_link",
- config_file)
+
+ self.baton = dict(
+ requirements=get_config("orchestrator.requirements", config_file),
+ credentials=get_config("orchestrator.credentials", config_file),
+ bootstrap=get_config("orchestrator.bootstrap", config_file),
+ gvnfm=get_config("orchestrator.gvnfm", config_file),
+ )
+ self.logger.debug("Orchestrator configuration %s", self.baton)
+
+ self.details['orchestrator'] = dict(
+ name=get_config("orchestrator.name", config_file),
+ version=get_config("orchestrator.version", config_file),
+ status='ERROR',
+ result=''
+ )
+ self.baton['details'] = {}
+ self.baton['details']['image'] = self.baton['requirements']['os_image']
+ self.baton['details']['name'] = self.details['orchestrator']['name']
+
+ self.vnf = dict(
+ descriptor=get_config("vnf.descriptor", config_file),
+ requirements=get_config("vnf.requirements", config_file)
+ )
+ self.details['vnf'] = dict(
+ name=get_config("vnf.name", config_file),
+ )
+ self.logger.debug("VNF configuration: %s", self.vnf)
+
+ self.details['test_vnf'] = dict(
+ name="openims-test",
+ )
+
+ # vIMS Data directory creation
+ if not os.path.exists(self.data_dir):
+ os.makedirs(self.data_dir)
+
self.images = get_config("tenant_images", config_file)
self.ims_conf = get_config("vIMS", config_file)
- self.userdata_file = get_config("openbaton.userdata.file",
- config_file)
+ self.snaps_creds = None
- def deploy_orchestrator(self):
- self.logger.info("Additional pre-configuration steps")
- nova_client = os_utils.get_nova_client()
- neutron_client = os_utils.get_neutron_client()
- glance_client = os_utils.get_glance_client()
+ def prepare(self):
+ """Prepare testscase (Additional pre-configuration steps)."""
+ super(ImsVnf, self).prepare()
- # Import images if needed
- # needs some images
- self.logger.info("Upload some OS images if it doesn't exist")
- temp_dir = os.path.join(self.data_dir, "tmp/")
+ self.logger.info("Additional pre-configuration steps")
+ self.logger.info("creds %s", (self.creds))
+
+ self.snaps_creds = OSCreds(
+ username=self.creds['username'],
+ password=self.creds['password'],
+ auth_url=self.creds['auth_url'],
+ project_name=self.creds['tenant'],
+ identity_api_version=int(os_utils.get_keystone_client_version()))
+
+ self.prepare_images()
+ self.prepare_flavor()
+ self.prepare_security_groups()
+ self.prepare_network()
+ self.prepare_floating_ip()
+
+ def prepare_images(self):
+ """Upload images if they doen't exist yet"""
+ self.logger.info("Upload images if they doen't exist yet")
for image_name, image_url in self.images.iteritems():
self.logger.info("image: %s, url: %s", image_name, image_url)
- try:
- image_id = os_utils.get_image_id(glance_client,
- image_name)
- self.logger.info("image_id: %s", image_id)
- except BaseException:
- self.logger.error("Unexpected error: %s", sys.exc_info()[0])
-
- if image_id == '':
- self.logger.info("""%s image doesn't exist on glance
- repository. Try downloading this image
- and upload on glance !""" % image_name)
- image_id = os_utils.download_and_add_image_on_glance(
- glance_client,
- image_name,
- image_url,
- temp_dir)
- if image_id == '':
- self.logger.error("Failed to find or upload required OS "
- "image for this deployment")
- return False
+ if image_url and image_name:
+ image = OpenStackImage(
+ self.snaps_creds,
+ ImageSettings(name=image_name,
+ image_user='cloud',
+ img_format='qcow2',
+ url=image_url))
+ image.create()
+ # self.created_resources.append(image);
+
+ def prepare_security_groups(self):
+ """Create Open Baton security group if it doesn't exist yet"""
+ self.logger.info(
+ "Creating security group for Open Baton if not yet existing...")
+ sg_rules = list()
+ sg_rules.append(
+ SecurityGroupRuleSettings(
+ sec_grp_name="orchestra-sec-group-allowall",
+ direction=Direction.ingress,
+ protocol=Protocol.tcp,
+ port_range_min=1,
+ port_range_max=65535))
+ sg_rules.append(
+ SecurityGroupRuleSettings(
+ sec_grp_name="orchestra-sec-group-allowall",
+ direction=Direction.egress,
+ protocol=Protocol.tcp,
+ port_range_min=1,
+ port_range_max=65535))
+ sg_rules.append(
+ SecurityGroupRuleSettings(
+ sec_grp_name="orchestra-sec-group-allowall",
+ direction=Direction.ingress,
+ protocol=Protocol.udp,
+ port_range_min=1,
+ port_range_max=65535))
+ sg_rules.append(
+ SecurityGroupRuleSettings(
+ sec_grp_name="orchestra-sec-group-allowall",
+ direction=Direction.egress,
+ protocol=Protocol.udp,
+ port_range_min=1,
+ port_range_max=65535))
+ # sg_rules.append(
+ # SecurityGroupRuleSettings(
+ # sec_grp_name="orchestra-sec-group-allowall",
+ # direction=Direction.ingress,
+ # protocol=Protocol.icmp,
+ # port_range_min=-1,
+ # port_range_max=-1))
+ # sg_rules.append(
+ # SecurityGroupRuleSettings(
+ # sec_grp_name="orchestra-sec-group-allowall",
+ # direction=Direction.egress,
+ # protocol=Protocol.icmp,
+ # port_range_min=-1,
+ # port_range_max=-1))
+
+ security_group = OpenStackSecurityGroup(
+ self.snaps_creds,
+ SecurityGroupSettings(
+ name="orchestra-sec-group-allowall",
+ rule_settings=sg_rules))
+
+ security_group_info = security_group.create()
+ self.created_resources.append(security_group)
+ self.baton['details']['sec_group'] = security_group_info.name
+ self.logger.info(
+ "Security group orchestra-sec-group-allowall prepared")
- network_dic = os_utils.create_network_full(neutron_client,
- "openbaton_mgmt",
- "openbaton_mgmt_subnet",
- "openbaton_router",
- "192.168.100.0/24")
+ def prepare_flavor(self):
+ """Create Open Baton flavor if it doesn't exist yet"""
+ self.logger.info(
+ "Create Flavor for Open Baton NFVO if not yet existing")
+
+ flavor_settings = FlavorSettings(
+ name=self.baton['requirements']['flavor']['name'],
+ ram=self.baton['requirements']['flavor']['ram_min'],
+ disk=self.baton['requirements']['flavor']['disk'],
+ vcpus=self.baton['requirements']['flavor']['vcpus'])
+ flavor = OpenStackFlavor(self.snaps_creds, flavor_settings)
+ flavor_info = flavor.create()
+ self.created_resources.append(flavor)
+ self.baton['details']['flavor'] = {}
+ self.baton['details']['flavor']['name'] = flavor_settings.name
+ self.baton['details']['flavor']['id'] = flavor_info.id
+
+ def prepare_network(self):
+ """Create network/subnet/router if they doen't exist yet"""
+ self.logger.info(
+ "Creating network/subnet/router if they doen't exist yet...")
+ subnet_settings = SubnetSettings(
+ name='%s_subnet' %
+ self.baton['details']['name'],
+ cidr="192.168.100.0/24")
+ network_settings = NetworkSettings(
+ name='%s_net' %
+ self.baton['details']['name'],
+ subnet_settings=[subnet_settings])
+ orchestra_network = OpenStackNetwork(
+ self.snaps_creds, network_settings)
+ orchestra_network_info = orchestra_network.create()
+ self.baton['details']['network'] = {}
+ self.baton['details']['network']['id'] = orchestra_network_info.id
+ self.baton['details']['network']['name'] = orchestra_network_info.name
+ self.baton['details']['external_net_name'] = \
+ snaps_utils.get_ext_net_name(self.snaps_creds)
+ self.created_resources.append(orchestra_network)
+ orchestra_router = OpenStackRouter(
+ self.snaps_creds,
+ RouterSettings(
+ name='%s_router' %
+ self.baton['details']['name'],
+ external_gateway=self.baton['details']['external_net_name'],
+ internal_subnets=[
+ subnet_settings.name]))
+ orchestra_router.create()
+ self.created_resources.append(orchestra_router)
+ self.logger.info("Created network and router for Open Baton NFVO...")
+
+ def prepare_floating_ip(self):
+ """Select/Create Floating IP if it doesn't exist yet"""
+ self.logger.info("Retrieving floating IP for Open Baton NFVO")
+ neutron_client = snaps_utils.neutron_utils.neutron_client(
+ self.snaps_creds)
+ # Finding Tenant ID to check to which tenant the Floating IP belongs
+ tenant_id = os_utils.get_tenant_id(
+ os_utils.get_keystone_client(self.creds),
+ self.tenant_name)
+ # Use os_utils to retrieve complete information of Floating IPs
+ floating_ips = os_utils.get_floating_ips(neutron_client)
+ my_floating_ips = []
+ # Filter Floating IPs with tenant id
+ for floating_ip in floating_ips:
+ # self.logger.info("Floating IP: %s", floating_ip)
+ if floating_ip.get('tenant_id') == tenant_id:
+ my_floating_ips.append(floating_ip.get('floating_ip_address'))
+ # Select if Floating IP exist else create new one
+ if len(my_floating_ips) >= 1:
+ # Get Floating IP object from snaps for clean up
+ snaps_floating_ips = snaps_utils.neutron_utils.get_floating_ips(
+ neutron_client)
+ for my_floating_ip in my_floating_ips:
+ for snaps_floating_ip in snaps_floating_ips:
+ if snaps_floating_ip.ip == my_floating_ip:
+ self.baton['details']['fip'] = snaps_floating_ip
+ self.logger.info(
+ "Selected floating IP for Open Baton NFVO %s",
+ (self.baton['details']['fip'].ip))
+ break
+ if self.baton['details']['fip'] is not None:
+ break
+ else:
+ self.logger.info("Creating floating IP for Open Baton NFVO")
+ self.baton['details']['fip'] = \
+ snaps_utils.neutron_utils.create_floating_ip(
+ neutron_client, self.baton['details']['external_net_name'])
+ self.logger.info(
+ "Created floating IP for Open Baton NFVO %s",
+ (self.baton['details']['fip'].ip))
- # orchestrator VM flavor
+ def get_vim_descriptor(self):
+ """"Create VIM descriptor to be used for onboarding"""
self.logger.info(
- "Check if orchestra Flavor is available, if not create one")
- flavor_exist, flavor_id = os_utils.get_or_create_flavor(
- "orchestra",
- "4096",
- '20',
- '2',
- public=True)
- self.logger.debug("Flavor id: %s" % flavor_id)
-
- if not network_dic:
- self.logger.error("There has been a problem when creating the "
- "neutron network")
-
- network_id = network_dic["net_id"]
-
- self.logger.info("Creating floating IP for VM in advance...")
- floatip_dic = os_utils.create_floating_ip(neutron_client)
- floatip = floatip_dic['fip_addr']
-
- if floatip is None:
- self.logger.error("Cannot create floating IP.")
- return False
+ "Building VIM descriptor with PoP creds: %s",
+ self.creds)
+ # Depending on API version either tenant ID or project name must be
+ # used
+ if os_utils.is_keystone_v3():
+ self.logger.info(
+ "Using v3 API of OpenStack... -> Using OS_PROJECT_ID")
+ project_id = os_utils.get_tenant_id(
+ os_utils.get_keystone_client(),
+ self.creds.get("project_name"))
+ else:
+ self.logger.info(
+ "Using v2 API of OpenStack... -> Using OS_TENANT_NAME")
+ project_id = self.creds.get("tenant_name")
+ self.logger.debug("VIM project/tenant id: %s", project_id)
+ vim_json = {
+ "name": "vim-instance",
+ "authUrl": self.creds.get("auth_url"),
+ "tenant": project_id,
+ "username": self.creds.get("username"),
+ "password": self.creds.get("password"),
+ "securityGroups": [
+ self.baton['details']['sec_group']
+ ],
+ "type": "openstack",
+ "location": {
+ "name": "opnfv",
+ "latitude": "52.525876",
+ "longitude": "13.314400"
+ }
+ }
+ self.logger.info("Built VIM descriptor: %s", vim_json)
+ return vim_json
- userdata = "#!/bin/bash\n"
- userdata += "echo \"Executing userdata...\"\n"
- userdata += "set -x\n"
- userdata += "set -e\n"
- userdata += "echo \"Set nameserver to '8.8.8.8'...\"\n"
- userdata += "echo \"nameserver 8.8.8.8\" >> /etc/resolv.conf\n"
- userdata += "echo \"Install curl...\"\n"
- userdata += "apt-get install curl\n"
- userdata += "echo \"Inject public key...\"\n"
- userdata += ("echo \"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCuPXrV3"
- "geeHc6QUdyUr/1Z+yQiqLcOskiEGBiXr4z76MK4abiFmDZ18OMQlc"
- "fl0p3kS0WynVgyaOHwZkgy/DIoIplONVr2CKBKHtPK+Qcme2PVnCtv"
- "EqItl/FcD+1h5XSQGoa+A1TSGgCod/DPo+pes0piLVXP8Ph6QS1k7S"
- "ic7JDeRQ4oT1bXYpJ2eWBDMfxIWKZqcZRiGPgMIbJ1iEkxbpeaAd9O"
- "4MiM9nGCPESmed+p54uYFjwEDlAJZShcAZziiZYAvMZhvAhe6USljc"
- "7YAdalAnyD/jwCHuwIrUw/lxo7UdNCmaUxeobEYyyFA1YVXzpNFZya"
- "XPGAAYIJwEq/ openbaton@opnfv\" >> /home/ubuntu/.ssh/aut"
- "horized_keys\n")
- userdata += "echo \"Download bootstrap...\"\n"
- userdata += ("curl -s %s "
- "> ./bootstrap\n" % self.bootstrap_link)
- userdata += ("curl -s %s"
- "> ./config_file\n" % self.bootstrap_config_link)
- userdata += ("echo \"Disable usage of mysql...\"\n")
- userdata += "sed -i s/mysql=.*/mysql=no/g /config_file\n"
- userdata += ("echo \"Setting 'rabbitmq_broker_ip' to '%s'\"\n"
- % floatip)
- userdata += ("sed -i s/rabbitmq_broker_ip=localhost/rabbitmq_broker_ip"
- "=%s/g /config_file\n" % floatip)
- userdata += "echo \"Set autostart of components to 'false'\"\n"
- userdata += "export OPENBATON_COMPONENT_AUTOSTART=false\n"
- userdata += "echo \"Execute bootstrap...\"\n"
- bootstrap = "sh ./bootstrap release -configFile=./config_file"
- userdata += bootstrap + "\n"
- userdata += "echo \"Setting 'nfvo.plugin.timeout' to '300000'\"\n"
- userdata += ("echo \"nfvo.plugin.timeout=600000\" >> "
- "/etc/openbaton/openbaton-nfvo.properties\n")
- userdata += (
- "wget %s -O /etc/openbaton/openbaton-vnfm-generic-user-data.sh\n" %
- self.userdata_file)
- userdata += "sed -i '113i\ \ \ \ sleep 60' " \
- "/etc/openbaton/openbaton-vnfm-generic-user-data.sh\n"
- userdata += "echo \"Starting NFVO\"\n"
- userdata += "service openbaton-nfvo restart\n"
- userdata += "echo \"Starting Generic VNFM\"\n"
- userdata += "service openbaton-vnfm-generic restart\n"
- userdata += "echo \"...end of userdata...\"\n"
-
- sg_id = os_utils.create_security_group_full(neutron_client,
- "orchestra-sec-group",
- "allowall")
-
- os_utils.create_secgroup_rule(neutron_client, sg_id, "ingress",
- "icmp", 0, 255)
- os_utils.create_secgroup_rule(neutron_client, sg_id, "egress",
- "icmp", 0, 255)
- os_utils.create_secgroup_rule(neutron_client, sg_id, "ingress",
- "tcp", 1, 65535)
- os_utils.create_secgroup_rule(neutron_client, sg_id, "ingress",
- "udp", 1, 65535)
- os_utils.create_secgroup_rule(neutron_client, sg_id, "egress",
- "tcp", 1, 65535)
- os_utils.create_secgroup_rule(neutron_client, sg_id, "egress",
- "udp", 1, 65535)
-
- self.logger.info("Security group set")
-
- self.logger.info("Create instance....")
- self.logger.info("flavor: m1.medium\n"
+ def deploy_orchestrator(self):
+ self.logger.info("Deploying orchestrator Open Baton ...")
+ self.logger.info("Details: %s", self.baton['details'])
+ start_time = time.time()
+
+ self.logger.info("Creating orchestra instance...")
+ userdata = get_userdata(self.baton)
+ self.logger.info("flavor: %s\n"
"image: %s\n"
- "network_id: %s\n"
- "userdata: %s\n",
- self.imagename,
- network_id,
- userdata)
-
- instance = os_utils.create_instance_and_wait_for_active(
- "orchestra",
- os_utils.get_image_id(glance_client, self.imagename),
- network_id,
- "orchestra-openbaton",
- config_drive=False,
+ "network_id: %s\n",
+ self.baton['details']['flavor']['name'],
+ self.baton['details']['image'],
+ self.baton['details']['network']['id'])
+ self.logger.debug("userdata: %s\n", userdata)
+ # setting up image
+ image_settings = ImageSettings(
+ name=self.baton['details']['image'],
+ image_user='ubuntu',
+ exists=True)
+ # setting up port
+ port_settings = PortSettings(
+ name='%s_port' % self.baton['details']['name'],
+ network_name=self.baton['details']['network']['name'])
+ # build configuration of vm
+ orchestra_settings = VmInstanceSettings(
+ name=self.baton['details']['name'],
+ flavor=self.baton['details']['flavor']['name'],
+ port_settings=[port_settings],
+ security_group_names=[self.baton['details']['sec_group']],
userdata=userdata)
+ orchestra_vm = OpenStackVmInstance(self.snaps_creds,
+ orchestra_settings,
+ image_settings)
- self.ob_instance_id = instance.id
-
- self.logger.info("Adding sec group to orchestra instance")
- os_utils.add_secgroup_to_instance(nova_client,
- self.ob_instance_id, sg_id)
+ orchestra_vm.create()
+ self.created_resources.append(orchestra_vm)
+ self.baton['details']['id'] = orchestra_vm.get_vm_info()['id']
+ self.logger.info(
+ "Created orchestra instance: %s",
+ self.baton['details']['id'])
self.logger.info("Associating floating ip: '%s' to VM '%s' ",
- floatip,
- "orchestra-openbaton")
- if not os_utils.add_floating_ip(nova_client, instance.id, floatip):
+ self.baton['details']['fip'].ip,
+ self.baton['details']['name'])
+ nova_client = os_utils.get_nova_client()
+ if not os_utils.add_floating_ip(
+ nova_client,
+ self.baton['details']['id'],
+ self.baton['details']['fip'].ip):
+ duration = time.time() - start_time
+ self.details["orchestrator"].update(
+ status='FAIL', duration=duration)
self.logger.error("Cannot associate floating IP to VM.")
return False
self.logger.info("Waiting for Open Baton NFVO to be up and running...")
- x = 0
- while x < 200:
- if servertest(floatip, "8080"):
+ timeout = 0
+ while timeout < 200:
+ if servertest(
+ self.baton['details']['fip'].ip,
+ "8080"):
break
else:
- self.logger.debug(
- "Open Baton NFVO is not started yet (%ss)" %
- (x * 5))
+ self.logger.info("Open Baton NFVO is not started yet (%ss)",
+ (timeout * 5))
time.sleep(5)
- x += 1
+ timeout += 1
- if x == 200:
+ if timeout >= 200:
+ duration = time.time() - start_time
+ self.details["orchestrator"].update(
+ status='FAIL', duration=duration)
self.logger.error("Open Baton is not started correctly")
+ return False
- self.ob_ip = floatip
- self.ob_password = "openbaton"
- self.ob_username = "admin"
- self.ob_https = False
- self.ob_port = "8080"
- self.logger.info("Waiting for all components up and running...")
+ self.logger.info("Waiting for all components to be up and running...")
time.sleep(60)
- self.details["orchestrator"] = {
- 'status': "PASS", 'result': "Deploy Open Baton NFVO: OK"}
+ duration = time.time() - start_time
+ self.details["orchestrator"].update(status='PASS', duration=duration)
self.logger.info("Deploy Open Baton NFVO: OK")
return True
def deploy_vnf(self):
- self.logger.info("Starting vIMS Deployment...")
+ start_time = time.time()
+ self.logger.info("Deploying OpenIMS...")
- self.main_agent = MainAgent(nfvo_ip=self.ob_ip,
- nfvo_port=self.ob_port,
- https=self.ob_https,
- version=1,
- username=self.ob_username,
- password=self.ob_password)
+ main_agent = MainAgent(
+ nfvo_ip=self.baton['details']['fip'].ip,
+ nfvo_port=8080,
+ https=False,
+ version=1,
+ username=self.baton['credentials']['username'],
+ password=self.baton['credentials']['password'])
self.logger.info(
- "Check if openims Flavor is available, if not create one")
- flavor_exist, flavor_id = os_utils.get_or_create_flavor(
- "m1.small",
- "2048",
- '20',
- '1',
- public=True)
- self.logger.debug("Flavor id: %s", flavor_id)
+ "Check if openims Flavor is available, if not, create one")
+ flavor_settings = FlavorSettings(
+ name=self.vnf['requirements']['flavor']['name'],
+ ram=self.vnf['requirements']['flavor']['ram_min'],
+ disk=self.vnf['requirements']['flavor']['disk'],
+ vcpus=self.vnf['requirements']['flavor']['vcpus'])
+ flavor = OpenStackFlavor(self.snaps_creds, flavor_settings)
+ flavor_info = flavor.create()
+ self.logger.debug("Flavor id: %s", flavor_info.id)
self.logger.info("Getting project 'default'...")
- project_agent = self.main_agent.get_agent("project", self.ob_projectid)
- for p in json.loads(project_agent.find()):
- if p.get("name") == "default":
- self.ob_projectid = p.get("id")
- self.logger.info("Found project 'default': %s", p)
+ project_agent = main_agent.get_agent("project", "")
+ for project in json.loads(project_agent.find()):
+ if project.get("name") == "default":
+ self.baton['details']['project_id'] = project.get("id")
+ self.logger.info("Found project 'default': %s", project)
break
- self.logger.debug("project id: %s", self.ob_projectid)
- if self.ob_projectid == "":
- self.logger.error("Default project id was not found!")
+ vim_json = self.get_vim_descriptor()
+ self.logger.info("Registering VIM: %s", vim_json)
- creds = os_utils.get_credentials()
- self.logger.info("PoP creds: %s", creds)
+ main_agent.get_agent(
+ "vim", project_id=self.baton['details']['project_id']).create(
+ entity=json.dumps(vim_json))
- if os_utils.is_keystone_v3():
- self.logger.info(
- "Using v3 API of OpenStack... -> Using OS_PROJECT_ID")
- project_id = os_utils.get_tenant_id(
- os_utils.get_keystone_client(),
- creds.get("project_name"))
- else:
- self.logger.info(
- "Using v2 API of OpenStack... -> Using OS_TENANT_NAME")
- project_id = creds.get("tenant_name")
+ market_agent = main_agent.get_agent(
+ "market", project_id=self.baton['details']['project_id'])
- self.logger.debug("project id: %s", project_id)
-
- vim_json = {
- "name": "vim-instance",
- "authUrl": creds.get("auth_url"),
- "tenant": project_id,
- "username": creds.get("username"),
- "password": creds.get("password"),
- "securityGroups": [
- "default",
- "orchestra-sec-group"
- ],
- "type": "openstack",
- "location": {
- "name": "opnfv",
- "latitude": "52.525876",
- "longitude": "13.314400"
- }
- }
-
- self.logger.debug("Registering VIM: %s", vim_json)
-
- self.main_agent.get_agent(
- "vim",
- project_id=self.ob_projectid).create(entity=json.dumps(vim_json))
-
- market_agent = self.main_agent.get_agent("market",
- project_id=self.ob_projectid)
-
- nsd = {}
try:
- self.logger.info("sending: %s", self.market_link)
- nsd = market_agent.create(entity=self.market_link)
+ self.logger.info("sending: %s", self.vnf['descriptor']['url'])
+ nsd = market_agent.create(entity=self.vnf['descriptor']['url'])
+ if nsd.get('id') is None:
+ self.logger.error("NSD not onboarded correctly")
+ duration = time.time() - start_time
+ self.details["vnf"].update(status='FAIL', duration=duration)
+ return False
+ self.baton['details']['nsd_id'] = nsd.get('id')
self.logger.info("Onboarded NSD: " + nsd.get("name"))
- except NfvoException as e:
- self.logger.error(e.message)
- nsr_agent = self.main_agent.get_agent("nsr",
- project_id=self.ob_projectid)
- nsd_id = nsd.get('id')
- if nsd_id is None:
- self.logger.error("NSD not onboarded correctly")
+ nsr_agent = main_agent.get_agent(
+ "nsr", project_id=self.baton['details']['project_id'])
- try:
- self.nsr = nsr_agent.create(nsd_id)
- except NfvoException as e:
- self.logger.error(e.message)
+ self.baton['details']['nsr'] = nsr_agent.create(
+ self.baton['details']['nsd_id'])
+ except NfvoException as exc:
+ self.logger.error(exc.message)
+ duration = time.time() - start_time
+ self.details["vnf"].update(status='FAIL', duration=duration)
+ return False
- if self.nsr.get('code') is not None:
+ if self.baton['details']['nsr'].get('code') is not None:
self.logger.error(
"vIMS cannot be deployed: %s -> %s",
- self.nsr.get('code'),
- self.nsr.get('message'))
+ self.baton['details']['nsr'].get('code'),
+ self.baton['details']['nsr'].get('message'))
self.logger.error("vIMS cannot be deployed")
+ duration = time.time() - start_time
+ self.details["vnf"].update(status='FAIL', duration=duration)
+ return False
- i = 0
+ timeout = 0
self.logger.info("Waiting for NSR to go to ACTIVE...")
- while self.nsr.get("status") != 'ACTIVE' and self.nsr.get(
- "status") != 'ERROR':
- i += 1
- if i == 150:
- self.logger.error("INACTIVE NSR after %s sec..", 5 * i)
-
+ while self.baton['details']['nsr'].get("status") != 'ACTIVE' \
+ and self.baton['details']['nsr'].get("status") != 'ERROR':
+ timeout += 1
+ self.logger.info("NSR is not yet ACTIVE... (%ss)", 5 * timeout)
+ if timeout == 150:
+ self.logger.error("INACTIVE NSR after %s sec..", 5 * timeout)
+ duration = time.time() - start_time
+ self.details["vnf"].update(status='FAIL', duration=duration)
+ return False
time.sleep(5)
- self.nsr = json.loads(nsr_agent.find(self.nsr.get('id')))
-
- if self.nsr.get("status") == 'ACTIVE':
- self.details["vnf"] = {'status': "PASS", 'result': self.nsr}
- self.logger.info("Deploy VNF: OK")
+ self.baton['details']['nsr'] = json.loads(
+ nsr_agent.find(self.baton['details']['nsr'].get('id')))
+
+ duration = time.time() - start_time
+ if self.baton['details']['nsr'].get("status") == 'ACTIVE':
+ self.details["vnf"].update(status='PASS', duration=duration)
+ self.logger.info("Sleep for 60s to ensure that all "
+ "services are up and running...")
+ time.sleep(60)
+ result = True
else:
- self.details["vnf"] = {'status': "FAIL", 'result': self.nsr}
- self.logger.error(self.nsr)
- self.logger.error("Deploy VNF: ERROR")
- return False
-
- self.ob_nsr_id = self.nsr.get("id")
- self.logger.info(
- "Sleep for 60s to ensure that all services are up and running...")
- time.sleep(60)
- return True
+ self.details["vnf"].update(status='FAIL', duration=duration)
+ self.logger.error("NSR: %s", self.baton['details'].get('nsr'))
+ result = False
+ return result
def test_vnf(self):
- # Adaptations probably needed
- # code used for cloudify_ims
- # ruby client on jumphost calling the vIMS on the SUT
+ self.logger.info("Testing VNF OpenIMS...")
+ start_time = time.time()
self.logger.info(
- "Testing if %s works properly...", self.nsr.get('name'))
- for vnfr in self.nsr.get('vnfr'):
+ "Testing if %s works properly...",
+ self.baton['details']['nsr'].get('name'))
+ for vnfr in self.baton['details']['nsr'].get('vnfr'):
self.logger.info(
"Checking ports %s of VNF %s",
self.ims_conf.get(vnfr.get('name')).get('ports'),
@@ -439,49 +626,75 @@ class ImsVnf(vnf.VnfOnBoarding):
self.logger.debug(
"Checking ports of VNFC instance %s",
vnfci.get('hostname'))
- for floatingIp in vnfci.get('floatingIps'):
+ for floating_ip in vnfci.get('floatingIps'):
self.logger.debug(
"Testing %s:%s",
vnfci.get('hostname'),
- floatingIp.get('ip'))
+ floating_ip.get('ip'))
for port in self.ims_conf.get(
vnfr.get('name')).get('ports'):
- if servertest(floatingIp.get('ip'), port):
+ if servertest(floating_ip.get('ip'), port):
self.logger.info(
"VNFC instance %s is reachable at %s:%s",
vnfci.get('hostname'),
- floatingIp.get('ip'),
+ floating_ip.get('ip'),
port)
else:
self.logger.error(
"VNFC instance %s is not reachable "
"at %s:%s",
vnfci.get('hostname'),
- floatingIp.get('ip'),
+ floating_ip.get('ip'),
port)
- self.details["test_vnf"] = {
- 'status': "FAIL", 'result': (
+ duration = time.time() - start_time
+ self.details["test_vnf"].update(
+ status='FAIL', duration=duration, esult=(
"Port %s of server %s -> %s is "
"not reachable",
port,
vnfci.get('hostname'),
- floatingIp.get('ip'))}
+ floating_ip.get('ip')))
self.logger.error("Test VNF: ERROR")
return False
-
- self.details["test_vnf"] = {
- 'status': "PASS",
- 'result': "All tests have been executed successfully"}
+ duration = time.time() - start_time
+ self.details["test_vnf"].update(status='PASS', duration=duration)
self.logger.info("Test VNF: OK")
return True
def clean(self):
- self.main_agent.get_agent(
- "nsr",
- project_id=self.ob_projectid).delete(self.ob_nsr_id)
- time.sleep(5)
- os_utils.delete_instance(nova_client=os_utils.get_nova_client(),
- instance_id=self.ob_instance_id)
- # question is the clean removing also the VM?
- # I think so since is goinf to remove the tenant...
+ self.logger.info("Cleaning...")
+ try:
+ main_agent = MainAgent(
+ nfvo_ip=self.baton['details']['fip'].ip,
+ nfvo_port=8080,
+ https=False,
+ version=1,
+ username=self.baton['credentials']['username'],
+ password=self.baton['credentials']['password'])
+ self.logger.info("Terminating OpenIMS VNF...")
+ if (self.baton['details'].get('nsr')):
+ main_agent.get_agent(
+ "nsr",
+ project_id=self.baton['details']['project_id'])\
+ .delete(self.baton['details']['nsr'].get('id'))
+ self.logger.info("Waiting 60sec for terminating OpenIMS VNF..")
+ time.sleep(60)
+ # os_utils.delete_instance(nova_client=os_utils.get_nova_client(),
+ # instance_id=self.baton_instance_id)
+ except (NfvoException, KeyError) as exc:
+ self.logger.error('Unexpected error cleaning - %s', exc)
+
+ try:
+ neutron_client = os_utils.get_neutron_client(self.creds)
+ snaps_utils.neutron_utils.delete_floating_ip(
+ neutron_client, self.baton['details']['fip'])
+ except Exception as exc:
+ self.logger.error('Unexpected error cleaning - %s', exc)
+
+ for resource in reversed(self.created_resources):
+ try:
+ self.logger.info("Cleaning %s", str(resource))
+ resource.clean()
+ except Exception as exc:
+ self.logger.error('Unexpected error cleaning - %s', exc)
super(ImsVnf, self).clean()
diff --git a/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml b/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml
index 5b25d3c96..9deb11c7b 100644
--- a/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml
+++ b/functest/opnfv_tests/vnf/ims/orchestra_ims.yaml
@@ -1,13 +1,37 @@
tenant_images:
ubuntu_14.04: http://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.img
openims: http://marketplace.openbaton.org:8082/api/v1/images/52e2ccc0-1dce-4663-894d-28aab49323aa/img
-openbaton:
- bootstrap_link: http://get.openbaton.org/bootstraps/bootstrap_3.2.0_opnfv/bootstrap
- bootstrap_config_link: http://get.openbaton.org/bootstraps/bootstrap_3.2.0_opnfv/bootstrap-config-file
- userdata:
- file: https://raw.githubusercontent.com/openbaton/generic-vnfm/3.2.0/src/main/resources/user-data.sh
- marketplace_link: http://marketplace.openbaton.org:8082/api/v1/nsds/fokus/OpenImsCore/3.2.0/json
- imagename: ubuntu_14.04
+orchestrator:
+ name: openbaton
+ version: '3.2.0'
+ requirements:
+ flavor:
+ name: orchestra
+ ram_min: 4096
+ disk: 5
+ vcpus: 2
+ os_image: 'ubuntu_14.04'
+ bootstrap:
+ url: http://get.openbaton.org/bootstraps/bootstrap_3.2.0_opnfv/bootstrap
+ config:
+ url: http://get.openbaton.org/bootstraps/bootstrap_3.2.0_opnfv/bootstrap-config-file
+ gvnfm:
+ userdata:
+ url: https://raw.githubusercontent.com/openbaton/generic-vnfm/3.2.0/src/main/resources/user-data.sh
+ credentials:
+ username: admin
+ password: openbaton
+vnf:
+ name: openims
+ descriptor:
+ url: http://marketplace.openbaton.org:8082/api/v1/nsds/fokus/OpenImsCore/3.2.0/json
+ requirements:
+ flavor:
+ name: m1.small
+ ram_min: 2048
+ disk: 5
+ vcpus: 2
+
vIMS:
scscf:
ports: [3870, 6060]
diff --git a/functest/tests/unit/core/test_feature.py b/functest/tests/unit/core/test_feature.py
index 988981eff..553a5dfa4 100644
--- a/functest/tests/unit/core/test_feature.py
+++ b/functest/tests/unit/core/test_feature.py
@@ -22,8 +22,8 @@ class FeatureTestingBase(unittest.TestCase):
_case_name = "foo"
_project_name = "bar"
- _repo = "dir_repo_copper"
- _cmd = "cd /home/opnfv/repos/foo/tests && bash run.sh && cd -"
+ _repo = "dir_repo_bar"
+ _cmd = "cd /home/opnfv/repos/bar/tests && bash run.sh && cd -"
_output_file = '/home/opnfv/functest/results/foo.log'
feature = None
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 51dbb6408..e4e3364d6 100644
--- a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
+++ b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
@@ -55,6 +55,38 @@ class OSRefstackClientTesting(unittest.TestCase):
refstackclient.run_defcore(config, testlist)
m.assert_any_call(cmd)
+ @mock.patch('functest.opnfv_tests.openstack.refstack_client.'
+ 'refstack_client.LOGGER.info')
+ @mock.patch('__builtin__.open', side_effect=Exception)
+ def test_parse_refstack_result_missing_log_file(self, mock_open,
+ mock_logger_info):
+ self.case_name = 'refstack_defcore'
+ self.result = 0
+ self.refstackclient.parse_refstack_result()
+ mock_logger_info.assert_called_once_with(
+ "Testcase %s success_rate is %s%%",
+ self.case_name, self.result)
+
+ def test_parse_refstack_result_default(self):
+ log_file = ('''
+ {0} tempest.api.compute [18.464988s] ... ok
+ {0} tempest.api.volume [0.230334s] ... FAILED
+ {0} tempest.api.network [1.265828s] ... SKIPPED:
+ Ran: 3 tests in 1259.0000 sec.
+ - Passed: 1
+ - Skipped: 1
+ - Failed: 1
+ ''')
+ self.details = {"tests": 3,
+ "failures": 1,
+ "success": [' tempest.api.compute [18.464988s]'],
+ "errors": [' tempest.api.volume [0.230334s]'],
+ "skipped": [' tempest.api.network [1.265828s]']}
+ with mock.patch('__builtin__.open',
+ mock.mock_open(read_data=log_file)):
+ self.refstackclient.parse_refstack_result()
+ self.assertEqual(self.refstackclient.details, self.details)
+
def _get_main_kwargs(self, key=None):
kwargs = {'config': self._config,
'testlist': self._testlist}
diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py
index 379049653..79ef99150 100644
--- a/functest/tests/unit/openstack/tempest/test_conf_utils.py
+++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py
@@ -261,8 +261,11 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
'write') as mwrite, \
mock.patch('__builtin__.open', mock.mock_open()), \
mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.backup_tempest_config'):
+ 'conf_utils.backup_tempest_config'), \
+ mock.patch('functest.utils.functest_utils.yaml.safe_load') \
+ as mock_yaml:
CONST.__setattr__('OS_ENDPOINT_TYPE', None)
+ mock_yaml.return_value = mock.Mock()
conf_utils.\
configure_tempest_update_params('test_conf_file',
IMAGE_ID=image_id,
diff --git a/functest/tests/unit/vnf/ims/test_cloudify_ims.py b/functest/tests/unit/vnf/ims/test_cloudify_ims.py
index 537c5146b..f0483c69f 100644
--- a/functest/tests/unit/vnf/ims/test_cloudify_ims.py
+++ b/functest/tests/unit/vnf/ims/test_cloudify_ims.py
@@ -13,6 +13,8 @@ import mock
from functest.core import vnf
from functest.opnfv_tests.vnf.ims import cloudify_ims
+from snaps.openstack.os_credentials import OSCreds
+
class CloudifyImsTesting(unittest.TestCase):
@@ -79,8 +81,11 @@ class CloudifyImsTesting(unittest.TestCase):
@mock.patch('snaps.openstack.create_image.OpenStackImage.create')
def test_prepare_bad_auth_url(self, *args):
with self.assertRaises(Exception):
- self.ims_vnf.prepare()
- args[0].assert_not_called()
+ self.ims_vnf.image_creator(
+ OSCreds(username='user', password='pass', auth_url='url',
+ project_name='project', identity_api_version=3),
+ mock.Mock())
+ args[0].assert_not_called()
def test_prepare_missing_param(self):
with self.assertRaises(vnf.VnfPreparationException):
diff --git a/functest/tests/unit/vnf/ims/test_orchestra_ims.py b/functest/tests/unit/vnf/ims/test_orchestra_ims.py
new file mode 100644
index 000000000..5a1efc7fd
--- /dev/null
+++ b/functest/tests/unit/vnf/ims/test_orchestra_ims.py
@@ -0,0 +1,224 @@
+#!/usr/bin/env python
+
+# 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
+
+"""Test module for orchestra_ims"""
+
+import logging
+import unittest
+
+import mock
+
+from functest.core import vnf
+from functest.opnfv_tests.vnf.ims import orchestra_ims
+
+
+class OrchestraImsTesting(unittest.TestCase):
+ """Test class for orchestra_ims"""
+ def setUp(self):
+
+ self.tenant = 'orchestra_ims'
+ self.creds = {'username': 'mocked_username',
+ 'password': 'mocked_password'}
+ self.tenant_images = {
+ 'image1': 'mocked_image_url_1',
+ 'image2': 'mocked_image_url_2'
+ }
+ self.orchestrator = {
+ 'name': 'openbaton',
+ 'version': '3.2.0',
+ 'object': 'foo',
+ 'requirements': {
+ 'flavor': {
+ 'name': 'mocked_flavor',
+ 'ram_min': 4096,
+ 'disk': 5,
+ 'vcpus': 2
+ },
+ 'os_image': 'mocked_image'
+ },
+ 'bootstrap': {
+ 'url': 'mocked_bootstrap_url',
+ 'config': {
+ 'url': 'mocked_config_url'}
+ },
+ 'gvnfm': {
+ 'userdata': {
+ 'url': 'mocked_userdata_url'
+ }
+ },
+ 'credentials': {
+ 'username': 'mocked_username',
+ 'password': 'mocked_password'
+ }
+ }
+ self.vnf = {
+ 'name': 'openims',
+ 'descriptor': {
+ 'url': 'mocked_descriptor_url'
+ },
+ 'requirements': {
+ 'flavor': {
+ 'name': 'mocked_flavor',
+ 'ram_min': 2048,
+ 'disk': 5,
+ 'vcpus': 2}
+ }
+ }
+ self.vIMS = {
+ 'scscf': {
+ 'ports': [3870, 6060]
+ },
+ 'pcscf': {
+ 'ports': [4060]
+ },
+ 'icscf': {
+ 'ports': [3869, 5060]
+ },
+ 'fhoss': {
+ 'ports': [3868]
+ },
+ 'bind9': {
+ 'ports': []
+ }
+ }
+ with mock.patch('functest.opnfv_tests.vnf.ims.orchestra_ims.'
+ 'os.makedirs'),\
+ mock.patch('functest.opnfv_tests.vnf.ims.orchestra_ims.'
+ 'get_config', return_value={
+ 'orchestrator': self.orchestrator,
+ 'name': self.orchestrator['name'],
+ 'version': self.orchestrator['version'],
+ 'requirements': self.orchestrator['requirements'],
+ 'credentials': self.orchestrator['credentials'],
+ 'bootstrap': self.orchestrator['bootstrap'],
+ 'gvnfm': self.orchestrator['gvnfm'],
+ 'os_image':
+ self.orchestrator['requirements']['os_image'],
+ 'flavor':
+ self.orchestrator['requirements']['flavor'],
+ 'url': self.orchestrator['bootstrap']['url'],
+ 'config': self.orchestrator['bootstrap']['config'],
+ 'tenant_images': self.tenant_images,
+ 'vnf': self.vnf,
+ 'vIMS': self.vIMS}):
+ self.ims_vnf = orchestra_ims.ImsVnf()
+
+ self.details = {'orchestrator': {'status': 'PASS', 'duration': 120},
+ 'vnf': {},
+ 'test_vnf': {}}
+
+ @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
+ return_value='test')
+ @mock.patch('functest.core.vnf.os_utils.get_or_create_tenant_for_vnf',
+ return_value=True)
+ @mock.patch('functest.core.vnf.os_utils.get_or_create_user_for_vnf',
+ return_value=True)
+ @mock.patch('functest.core.vnf.os_utils.get_credentials',
+ return_value={'auth_url': 'test/v1'})
+ @mock.patch(
+ 'functest.utils.openstack_utils.get_tenant_id',
+ return_value={'mocked_tenant_id'})
+ @mock.patch(
+ 'functest.utils.openstack_utils.get_floating_ips',
+ return_value=[])
+ @mock.patch('snaps.openstack.create_image.OpenStackImage.create')
+ @mock.patch('snaps.openstack.create_flavor.OpenStackFlavor.create')
+ @mock.patch(
+ 'snaps.openstack.create_security_group.OpenStackSecurityGroup.create')
+ @mock.patch('snaps.openstack.create_network.OpenStackNetwork.create')
+ @mock.patch('snaps.openstack.create_router.OpenStackRouter.create')
+ @mock.patch(
+ 'functest.opnfv_tests.openstack.snaps.snaps_utils.get_ext_net_name')
+ @mock.patch(
+ 'functest.opnfv_tests.openstack.snaps.snaps_utils.'
+ 'neutron_utils.create_floating_ip')
+ def test_prepare_default(self, *args):
+ """Testing prepare function without any exceptions expected"""
+ self.assertIsNone(self.ims_vnf.prepare())
+ args[4].assert_called_once_with()
+
+ @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
+ return_value='test')
+ @mock.patch('functest.core.vnf.os_utils.get_or_create_tenant_for_vnf',
+ return_value=True)
+ @mock.patch('functest.core.vnf.os_utils.get_or_create_user_for_vnf',
+ return_value=True)
+ @mock.patch('functest.core.vnf.os_utils.get_credentials',
+ return_value={'auth_url': 'test/no_v'})
+ @mock.patch('snaps.openstack.create_image.OpenStackImage.create')
+ def test_prepare_bad_auth_url(self, *args):
+ """Testing prepare function with bad auth url"""
+ with self.assertRaises(Exception):
+ self.ims_vnf.prepare()
+ args[0].assert_not_called()
+
+ def test_prepare_missing_param(self):
+ """Testing prepare function with missing param"""
+ with self.assertRaises(vnf.VnfPreparationException):
+ self.ims_vnf.prepare()
+
+ @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
+ side_effect=Exception)
+ def test_prepare_keystone_exception(self, *args):
+ """Testing prepare function with keystone exception"""
+ with self.assertRaises(vnf.VnfPreparationException):
+ self.ims_vnf.prepare()
+ args[0].assert_called_once_with()
+
+ @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
+ return_value='test')
+ @mock.patch('functest.core.vnf.os_utils.get_or_create_tenant_for_vnf',
+ side_effect=Exception)
+ def test_prepare_tenant_exception(self, *args):
+ """Testing prepare function with tenant exception"""
+ with self.assertRaises(vnf.VnfPreparationException):
+ self.ims_vnf.prepare()
+ args[1].assert_called_once_with()
+
+ @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
+ return_value='test')
+ @mock.patch('functest.core.vnf.os_utils.get_or_create_tenant_for_vnf',
+ return_value=True)
+ @mock.patch('functest.core.vnf.os_utils.get_or_create_user_for_vnf',
+ side_effect=Exception)
+ def test_prepare_user_exception(self, *args):
+ """Testing prepare function with user exception"""
+ with self.assertRaises(vnf.VnfPreparationException):
+ self.ims_vnf.prepare()
+ args[2].assert_called_once_with()
+
+ @mock.patch('functest.core.vnf.os_utils.get_keystone_client',
+ return_value='test')
+ @mock.patch('functest.core.vnf.os_utils.get_or_create_tenant_for_vnf',
+ return_value=True)
+ @mock.patch('functest.core.vnf.os_utils.get_or_create_user_for_vnf',
+ return_value=True)
+ @mock.patch('functest.core.vnf.os_utils.get_credentials',
+ side_effect=Exception)
+ def test_prepare_credentials_exception(self, *args):
+ """Testing prepare function with credentials exception"""
+ with self.assertRaises(vnf.VnfPreparationException):
+ self.ims_vnf.prepare()
+ args[0].assert_called_once_with()
+
+ # # @mock.patch('functest.opnfv_tests.vnf.ims.orchestra_ims.get_userdata')
+ # def test_deploy_orchestrator(self, *args):
+ # floating_ip = FloatingIp
+ # floating_ip.ip = 'mocked_ip'
+ # details = {'fip':floating_ip,'flavor':{'name':'mocked_name'}}
+ # self.orchestrator['details'] = details
+ # with mock.patch.dict(self.orchestrator, {'details':
+ # {'fip':floating_ip,'flavor':{'name':'mocked_name'}}}):
+ # # with mock.patch.dict(self.orchestrator, details):
+ # orchestra_ims.get_userdata(self.orchestrator)
+ # self.assertIsNone(self.ims_vnf.deploy_orchestrator())
+ # args[4].assert_called_once_with()
+
+
+if __name__ == "__main__":
+ logging.disable(logging.CRITICAL)
+ unittest.main(verbosity=2)
diff --git a/functest/tests/unit/vnf/rnc/__init__.py b/functest/tests/unit/vnf/rnc/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/functest/tests/unit/vnf/rnc/__init__.py
+++ /dev/null