Adapt Yardstick to copy yardstick.conf to /etc/yardstick 37/37737/1
authorxudan <xudan16@huawei.com>
Wed, 19 Jul 2017 07:19:52 +0000 (03:19 -0400)
committerxudan <xudan16@huawei.com>
Wed, 19 Jul 2017 07:19:52 +0000 (03:19 -0400)
JIRA: DOVETAIL-466

1. Yardstick danube.3.1 needs a yardstick.conf file in /etc/yardstick
2. Copy the file /home/opnfv/repos/yardstick/etc/yardstick/yardstick.conf.sample
   to /etc/yardstick/yardstick.conf
3. If user wants to store the results in the local file, set the dispatcher to
   be 'file'.
4. If user wants to push the results into the DB, set the dispatcher to be 'http'
   and target to be the api url getting from the user.

Change-Id: I39c30883b471ab7cb29ed6d63ba8c232da39c135
Signed-off-by: xudan <xudan16@huawei.com>
dovetail/conf/cmd_config.yml
dovetail/conf/yardstick_config.yml
dovetail/container.py

index aa27f29..a5b262d 100644 (file)
@@ -50,7 +50,7 @@ cli:
         flags:
           - '--report'
           - '-r'
-        help: 'push results to DB (e.g. --report http://192.168.135.2:8000/api/v1)'
+        help: 'push results to DB (e.g. --report http://192.168.135.2:8000/api/v1/results)'
       offline:
         flags:
           - '--offline'
index 86a768d..56ad75a 100644 (file)
@@ -25,3 +25,6 @@ yardstick:
     file_path: 'yardstick.log'
     key_path: '/root/.ssh/id_rsa'
   openrc: '/etc/yardstick/openstack.creds'
+  yard_conf:
+    src_file: '/home/opnfv/repos/yardstick/etc/yardstick/yardstick.conf.sample'
+    dest_file: '/etc/yardstick/yardstick.conf'
index 2108cdc..c8a84eb 100644 (file)
@@ -76,8 +76,7 @@ class Container(object):
         if 'sdnvpn' in testcase_name:
             ins_type = "-e INSTALLER_TYPE=netvirt"
             scenario = " -e DEPLOY_SCENARIO=bgpvpn"
-        node = " -e NODE_NAME=master"
-        envs = "%s %s %s" % (ins_type, scenario, node)
+        envs = "%s %s" % (ins_type, scenario)
 
         dovetail_config = dt_cfg.dovetail_config
         if dovetail_config['report_dest'].startswith("http"):
@@ -103,11 +102,6 @@ class Container(object):
             cls.logger.error("Can't find any external network.")
             return None
 
-        if dovetail_config['report_dest'].startswith("http"):
-            envs = envs + " -e DISPATCHER=http"
-            envs = envs + " -e TARGET=%s" % dovetail_config['report_dest']
-            envs = envs + " -e NODE_NAME=master"
-
         log_vol = '-v %s:%s ' % (dovetail_config['result_dir'],
                                  dovetail_config["yardstick"]['result']['log'])
 
@@ -141,7 +135,7 @@ class Container(object):
 
         # CI_DEBUG is used for showing the debug logs of the upstream projects
         # BUILD_TAG is the unique id for this test
-        envs = ' -e CI_DEBUG=true'
+        envs = ' -e CI_DEBUG=true -e NODE_NAME=master'
         envs = envs + ' -e BUILD_TAG=%s-%s' % (dovetail_config['build_tag'],
                                                testcase_name)
 
@@ -212,6 +206,10 @@ class Container(object):
             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)
+
         return container_id
 
     @classmethod
@@ -306,3 +304,18 @@ class Container(object):
             return (1, 'src_path or dest_path is empty')
         cmd = 'cp %s %s' % (src_path, dest_path)
         return cls.exec_cmd(container_id, cmd, exit_on_error)
+
+    @classmethod
+    def set_yardstick_conf_file(cls, container_id):
+        valid_type = 'yardstick'
+        src = dt_cfg.dovetail_config[valid_type]['yard_conf']['src_file']
+        dest = dt_cfg.dovetail_config[valid_type]['yard_conf']['dest_file']
+        cls.pre_copy(container_id, src, dest)
+        url = dt_cfg.dovetail_config['report_dest']
+        if url.startswith("http"):
+            cmd = ("sed -i '16s#http://127.0.0.1:8000/results#{}#g' {}"
+                   .format(url, dest))
+            cls.exec_cmd(container_id, cmd)
+        if url.lower() == 'file':
+            cmd = ("sed -i '12s/http/file/g' {}".format(dest))
+            cls.exec_cmd(container_id, cmd)