substitute image copy with docker volume 95/53395/4
authorSerenaFeng <feng.xiaowei@zte.com.cn>
Fri, 9 Mar 2018 10:46:27 +0000 (18:46 +0800)
committerDan Xu <xudan16@huawei.com>
Thu, 15 Mar 2018 03:44:15 +0000 (03:44 +0000)
Change-Id: Ie470d03bd168c909fd02c316523049c67a6bb095
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
dovetail/container.py
dovetail/run.py
dovetail/test_runner.py
etc/conf/bottlenecks_config.yml
etc/conf/functest_config.yml
etc/testcase/ha.tc011.yml
etc/userconfig/env_config.sh.sample [new file with mode: 0644]

index 63ce2db..9a90a48 100644 (file)
@@ -202,34 +202,23 @@ class Container(object):
                                  "insecure mode...")
                 return None
 
+        images_volume = ''
+        if dovetail_config[type]['config'].get('images', None):
+            images_volume = '-v {}:{}'.format(
+                dovetail_config['images_dir'],
+                dovetail_config[type]['config']['images'])
+
         result_volume = ' -v %s:%s ' % (dovetail_config['result_dir'],
                                         dovetail_config[type]['result']['dir'])
-        cmd = 'sudo docker run %s %s %s %s %s %s %s %s %s /bin/bash' % \
-            (opts, envs, config, hosts_config, openrc, cacert_volume,
-             config_volume, result_volume, docker_image)
+        cmd = 'sudo docker run {opts} {envs} {config} {hosts_config} ' \
+              '{openrc} {cacert_volume} {config_volume} {result_volume} ' \
+              '{images_volume} {docker_image} /bin/bash'.format(**locals())
         dt_utils.exec_cmd(cmd, cls.logger)
         ret, container_id = \
             dt_utils.exec_cmd("sudo docker ps | grep " + docker_image +
                               " | awk '{print $1}' | head -1", cls.logger)
         cls.container_list[type] = container_id
 
-        if 'sdnvpn' in str(testcase_name):
-            prefix_path = dt_cfg.dovetail_config[type]['config']['dir']
-            file_name = dt_cfg.dovetail_config['sdnvpn_image']
-            src_path = os.path.join(prefix_path, 'pre_config', file_name)
-            dest_path = '/home/opnfv/functest/images'
-            Container.pre_copy(container_id, src_path, dest_path)
-
-        if type.lower() == 'functest':
-            prefix_path = dt_cfg.dovetail_config[type]['config']['dir']
-            images = ['cirros_image', 'ubuntu14_image', 'cloudify_image',
-                      'trusty_image']
-            for image in images:
-                file_name = dt_cfg.dovetail_config[image]
-                src_path = os.path.join(prefix_path, 'pre_config', file_name)
-                dest_path = '/home/opnfv/functest/images'
-                Container.pre_copy(container_id, src_path, dest_path)
-
         if type.lower() == 'yardstick':
             cls.set_yardstick_conf_file(container_id)
 
index a615173..1537fb6 100755 (executable)
@@ -211,6 +211,8 @@ def get_result_path():
         return None
     result_path = os.path.join(dovetail_home, 'results')
     dt_cfg.dovetail_config['result_dir'] = result_path
+    dt_cfg.dovetail_config['images_dir'] = os.path.join(dovetail_home,
+                                                        'images')
     pre_config_path = os.path.join(dovetail_home, 'pre_config')
     patch_set_path = os.path.join(dovetail_home, 'patch')
     dt_cfg.dovetail_config['config_dir'] = pre_config_path
index 934efb7..c926041 100644 (file)
@@ -65,7 +65,7 @@ class DockerRunner(object):
         # in dovetail_config.yml first.
         if 'sdnvpn' in str(self.testcase.name()):
             img_name = dt_cfg.dovetail_config['sdnvpn_image']
-            img_file = os.path.join(dt_cfg.dovetail_config['config_dir'],
+            img_file = os.path.join(dt_cfg.dovetail_config['images_dir'],
                                     img_name)
             if not os.path.isfile(img_file):
                 self.logger.error('Image {} not found.'.format(img_name))
index f33e50f..005a04e 100644 (file)
@@ -10,7 +10,7 @@ bottlenecks:
        (openstack --insecure image list | grep cirros-0.3.5 ||
        openstack --insecure image create cirros-0.3.5
        --disk-format qcow2 --container-format bare
-       --file /home/opnfv/userconfig/pre_config/cirros-0.3.5-x86_64-disk.img)'
+       --file /home/opnfv/userconfig/images/cirros-0.3.5-x86_64-disk.img)'
     - 'source /tmp/admin_rc.sh &&
        (openstack --insecure flavor list | grep yardstick-flavor ||
        openstack --insecure flavor create --id 100
index 896aeb9..e34fa60 100644 (file)
@@ -5,6 +5,7 @@ functest:
   opts: '-id --privileged=true'
   config:
     dir: '/home/opnfv/userconfig'
+    images: '/home/opnfv/functest/images'
   pre_condition:
     - 'echo test for precondition in functest'
   cmds:
index d126882..e7e67e7 100644 (file)
@@ -8,7 +8,7 @@ dovetail.ha.tc011:
     pre_condition:
       - 'source /etc/yardstick/openstack.creds && openstack --insecure image create cirros-ha-11
          --disk-format qcow2 --container-format bare --public
-         --file /home/opnfv/userconfig/pre_config/cirros-0.3.5-x86_64-disk.img'
+         --file /home/opnfv/userconfig/images/cirros-0.3.5-x86_64-disk.img'
     cmds:
       - 'mkdir -p /home/opnfv/yardstick/results/'
       - "cd /home/opnfv/repos/yardstick && source /etc/yardstick/openstack.creds &&
diff --git a/etc/userconfig/env_config.sh.sample b/etc/userconfig/env_config.sh.sample
new file mode 100644 (file)
index 0000000..4bb77ab
--- /dev/null
@@ -0,0 +1,35 @@
+# Project-level authentication scope (name or ID), recommend admin project.
+export OS_PROJECT_NAME=admin
+
+# For identity v2, it uses OS_TENANT_NAME rather than OS_PROJECT_NAME.
+export OS_TENANT_NAME=admin
+
+# Authentication username, belongs to the project above, recommend admin user.
+export OS_USERNAME=admin
+
+# Authentication password. Use your own password
+export OS_PASSWORD=xxxxxxxx
+
+# Authentication URL, one of the endpoints of keystone service. If this is v3 version,
+# there need some extra variables as follows.
+export OS_AUTH_URL='http://xxx.xxx.xxx.xxx:5000/v3'
+
+# Default is 2.0. If use keystone v3 API, this should be set as 3.
+export OS_IDENTITY_API_VERSION=3
+
+# Domain name or ID containing the user above.
+# Command to check the domain: openstack user show <OS_USERNAME>
+export OS_USER_DOMAIN_NAME=default
+
+# Domain name or ID containing the project above.
+# Command to check the domain: openstack project show <OS_PROJECT_NAME>
+export OS_PROJECT_DOMAIN_NAME=default
+
+# Special environment parameters for https.
+# If using https + cacert, the path of cacert file should be provided.
+# The cacert file should be put at $DOVETAIL_HOME/pre_config.
+#export OS_CACERT=/path/to/pre_config/cacert.pem
+
+# If using https + no cacert, should add OS_INSECURE environment parameter.
+#export OS_INSECURE=True
+