Create config_functest patch to update the conf with scenario
authorboucherv <valentin.boucher@orange.com>
Wed, 10 Aug 2016 16:59:41 +0000 (18:59 +0200)
committerboucherv <valentin.boucher@orange.com>
Wed, 10 Aug 2016 17:06:19 +0000 (19:06 +0200)
Adding support of LXD scenario

JIRA: FUNCTEST-268

Change-Id: I5891ff9de674d99d32d8db747be501ee8a2e6609
Signed-off-by: boucherv <valentin.boucher@orange.com>
ci/config_patch.yaml [new file with mode: 0644]
ci/prepare_env.py
docker/Dockerfile
testcases/OpenStack/rally/run_rally-cert.py
testcases/OpenStack/tempest/run_tempest.py
testcases/OpenStack/vPing/vPing_ssh.py
testcases/OpenStack/vPing/vPing_userdata.py
utils/functest_utils.py

diff --git a/ci/config_patch.yaml b/ci/config_patch.yaml
new file mode 100644 (file)
index 0000000..467a83c
--- /dev/null
@@ -0,0 +1,9 @@
+lxd:
+    general:
+        openstack:
+            image_name: Cirros-0.3.4
+            image_file_name:  cirros-0.3.4-x86_64-lxc.tar.gz
+            image_disk_format:  raw
+
+    healthcheck:
+        disk_image: /home/opnfv/functest/data/cirros-0.3.4-x86_64-lxc.tar.gz
index e31afd4..116b1a6 100755 (executable)
@@ -46,10 +46,16 @@ CI_SCENARIO = ""
 CI_DEBUG = False
 REPOS_DIR = os.getenv('repos_dir')
 FUNCTEST_REPO = REPOS_DIR + '/functest/'
+CONFIG_FUNCTEST_PATH = os.environ["CONFIG_FUNCTEST_YAML"]
+CONFIG_PATCH_PATH = os.path.join(os.path.dirname(
+    CONFIG_FUNCTEST_PATH), "config_patch.yaml")
 
-with open(os.environ["CONFIG_FUNCTEST_YAML"]) as f:
+with open(CONFIG_FUNCTEST_PATH) as f:
     functest_yaml = yaml.safe_load(f)
 
+with open(CONFIG_PATCH_PATH) as f:
+    functest_patch_yaml = yaml.safe_load(f)
+
 FUNCTEST_CONF_DIR = functest_yaml.get("general").get(
     "directories").get("dir_functest_conf")
 
@@ -183,6 +189,21 @@ def source_rc_file():
     logger.debug("Used credentials: %s" % str)
 
 
+def patch_config_file():
+    updated = False
+    for key in functest_patch_yaml:
+        if key in CI_SCENARIO:
+            new_functest_yaml = dict(ft_utils.merge_dicts(
+                functest_yaml, functest_patch_yaml[key]))
+            updated = True
+
+    if updated:
+        os.remove(CONFIG_FUNCTEST_PATH)
+        with open(CONFIG_FUNCTEST_PATH, "w") as f:
+            f.write(yaml.dump(new_functest_yaml, default_style='"'))
+        f.close()
+
+
 def verify_deployment():
     print_separator()
     logger.info("Verifying OpenStack services...")
@@ -262,6 +283,7 @@ def main():
         check_env_variables()
         create_directories()
         source_rc_file()
+        patch_config_file()
         verify_deployment()
         install_rally()
 
index bc6d039..218e25f 100644 (file)
@@ -97,6 +97,7 @@ RUN cd ${repos_dir}/parser/tosca2heat/heat-translator && python setup.py install
 RUN ${repos_dir}/rally/install_rally.sh --yes
 
 ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img /home/opnfv/functest/data/
+ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-lxc.tar.gz /home/opnfv/functest/data/
 ADD http://205.177.226.237:9999/onosfw/firewall_block_image.img /home/opnfv/functest/data/
 
 RUN gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
index 1f1214e..92dbddf 100755 (executable)
@@ -410,7 +410,8 @@ def main():
                                                            GLANCE_IMAGE_PATH))
         image_id = os_utils.create_glance_image(glance_client,
                                                 GLANCE_IMAGE_NAME,
-                                                GLANCE_IMAGE_PATH)
+                                                GLANCE_IMAGE_PATH,
+                                                GLANCE_IMAGE_FORMAT)
         if not image_id:
             logger.error("Failed to create the Glance image...")
             exit(-1)
index 845c588..b3c4436 100755 (executable)
@@ -165,7 +165,8 @@ def create_tempest_resources():
                                                           GLANCE_IMAGE_PATH))
         image_id = os_utils.create_glance_image(glance_client,
                                                 GLANCE_IMAGE_NAME,
-                                                GLANCE_IMAGE_PATH)
+                                                GLANCE_IMAGE_PATH,
+                                                GLANCE_IMAGE_FORMAT)
         if not image_id:
             logger.error("Failed to create a Glance image...")
             exit(-1)
index 4aab619..810f286 100755 (executable)
@@ -192,7 +192,8 @@ def main():
                                                           GLANCE_IMAGE_PATH))
         image_id = os_utils.create_glance_image(glance_client,
                                                 GLANCE_IMAGE_NAME,
-                                                GLANCE_IMAGE_PATH)
+                                                GLANCE_IMAGE_PATH,
+                                                GLANCE_IMAGE_FORMAT)
         if not image_id:
             logger.error("Failed to create a Glance image...")
             exit(EXIT_CODE)
index b6e3fe1..dd707bc 100755 (executable)
@@ -192,7 +192,8 @@ def main():
                                                           GLANCE_IMAGE_PATH))
         image_id = os_utils.create_glance_image(glance_client,
                                                 GLANCE_IMAGE_NAME,
-                                                GLANCE_IMAGE_PATH)
+                                                GLANCE_IMAGE_PATH,
+                                                GLANCE_IMAGE_FORMAT)
         if not image_id:
             logger.error("Failed to create a Glance image...")
             exit(EXIT_CODE)
index cb2333d..d020eba 100644 (file)
@@ -212,10 +212,10 @@ def push_results_to_db(project, case_name, logger,
             logger.debug(r)
         return True
     except Exception, e:
-        print ("Error [push_results_to_db('%s', '%s', '%s', " +
-               "'%s', '%s', '%s', '%s', '%s', '%s')]:" %
-               (url, project, case_name, pod_name, version,
-                scenario, criteria, build_tag, details)), e
+        print("Error [push_results_to_db('%s', '%s', '%s', " +
+              "'%s', '%s', '%s', '%s', '%s', '%s')]:" %
+              (url, project, case_name, pod_name, version,
+               scenario, criteria, build_tag, details)), e
         return False
 
 
@@ -372,6 +372,19 @@ def check_success_rate(case_name, success_rate):
     return status
 
 
+def merge_dicts(dict1, dict2):
+    for k in set(dict1.keys()).union(dict2.keys()):
+        if k in dict1 and k in dict2:
+            if isinstance(dict1[k], dict) and isinstance(dict2[k], dict):
+                yield (k, dict(merge_dicts(dict1[k], dict2[k])))
+            else:
+                yield (k, dict2[k])
+        elif k in dict1:
+            yield (k, dict1[k])
+        else:
+            yield (k, dict2[k])
+
+
 def check_test_result(test_name, ret, start_time, stop_time):
     def get_criteria_value():
         return get_criteria_by_test(test_name).split('==')[1].strip()