summaryrefslogtreecommitdiffstats
path: root/sdnvpn/test/functest
diff options
context:
space:
mode:
authornikoskarandreas <nick@intracom-telecom.com>2018-05-29 16:00:47 +0300
committernikoskarandreas <nick@intracom-telecom.com>2018-06-13 17:41:56 +0300
commitc6fbfb9651f5293c544351d3c9c549dfa24fafc6 (patch)
treece8c0a85a157eb06235b8a93394643218e13a5ee /sdnvpn/test/functest
parentc8f970e5b5968952f9c1fea5c7c63bddb12a7b73 (diff)
Create and pass references of flavor and image to tempest
When invoked from SDNVPN, Tempest scenario functest test cases try to use flavor and image references from the tempest.conf file which are currently empty. This patch uses the default flavor that is created by the test suite and the creates an image using the availabe cirros image, which is deleted at the end. JIRA: SDNVPN-209 Change-Id: I6a6fd636fec2c0fa7d35981ca51d59f06a4d9d69 Signed-off-by: nikoskarandreas <nick@intracom-telecom.com>
Diffstat (limited to 'sdnvpn/test/functest')
-rw-r--r--sdnvpn/test/functest/config.yaml1
-rw-r--r--sdnvpn/test/functest/run_tempest.py33
2 files changed, 31 insertions, 3 deletions
diff --git a/sdnvpn/test/functest/config.yaml b/sdnvpn/test/functest/config.yaml
index 777db86..360d88f 100644
--- a/sdnvpn/test/functest/config.yaml
+++ b/sdnvpn/test/functest/config.yaml
@@ -6,6 +6,7 @@ testcases:
enabled: true
order: 0
description: Neutron BGPVPN tests in tempest
+ image_name: bgpvpn-tempest-image
sdnvpn.test.functest.testcase_1:
enabled: true
diff --git a/sdnvpn/test/functest/run_tempest.py b/sdnvpn/test/functest/run_tempest.py
index a1ef004..15d4eda 100644
--- a/sdnvpn/test/functest/run_tempest.py
+++ b/sdnvpn/test/functest/run_tempest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
-# Copyright (c) 2017 All rights reserved
+# Copyright (c) 2018 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
@@ -16,8 +16,16 @@ import shutil
import functest.opnfv_tests.openstack.tempest.conf_utils as tempest_utils
+from sdnvpn.lib import config as sdnvpn_config
+from sdnvpn.lib import openstack_utils as os_utils
+
+
logger = logging.getLogger('sdnvpn-tempest')
+COMMON_CONFIG = sdnvpn_config.CommonConfig()
+TESTCASE_CONFIG = sdnvpn_config.TestcaseConfig(
+ 'sdnvpn.test.functest.run_tempest')
+
def main():
verifier_id = tempest_utils.get_verifier_id()
@@ -39,18 +47,35 @@ def main():
exit(-1)
shutil.copy(src_tempest_conf, bgpvpn_tempest_conf)
+ glance_client = os_utils.get_glance_client()
+ img_ref = os_utils.create_glance_image(glance_client,
+ TESTCASE_CONFIG.image_name,
+ COMMON_CONFIG.image_path,
+ disk=COMMON_CONFIG.image_format,
+ container="bare", public='public')
+
+ nova_client = os_utils.get_nova_client()
+ flav_ref = os_utils.get_flavor_id(nova_client,
+ COMMON_CONFIG.default_flavor)
+
logger.info("Copying tempest.conf to %s." % bgpvpn_tempest_conf)
config = ConfigParser.RawConfigParser()
config.read(bgpvpn_tempest_conf)
config.set('service_available', 'bgpvpn', 'True')
logger.debug("Updating %s with bgpvpn=True" % bgpvpn_tempest_conf)
+ config.set('compute', 'flavor_ref', flav_ref)
+ logger.debug("Updating %s with flavor_id %s"
+ % (bgpvpn_tempest_conf, flav_ref))
+ config.set('compute', 'image_ref', img_ref)
+ logger.debug("Updating %s with image_id %s"
+ % (bgpvpn_tempest_conf, img_ref))
with open(bgpvpn_tempest_conf, 'wb') as tempest_conf:
config.write(tempest_conf)
# TODO: Though --config-file parameter is set during the tempest run,
# it looks for tempest.conf at /etc/tempest/ directory. so applying
# the following workaround. Will remove it when the root cause is found.
- cmd = ("mkdir /etc/tempest;"
+ cmd = ("mkdir -p /etc/tempest;"
"cp {0} /etc/tempest/tempest.conf".format(bgpvpn_tempest_conf))
logger.info("Configuring default tempest conf file")
os.popen(cmd)
@@ -94,7 +119,9 @@ def main():
return {"status": status, "details": results}
except Exception as e:
logger.error("Problem when parsing the results: %s", e)
-
+ finally:
+ os_utils.delete_glance_image(glance_client, img_ref)
+ logger.debug("Deleted image %s" % img_ref)
if __name__ == '__main__':
main()