support HA test cases to run with key 63/33963/2
authorxudan <xudan16@huawei.com>
Thu, 27 Apr 2017 14:16:12 +0000 (14:16 +0000)
committerxudan <xudan16@huawei.com>
Thu, 27 Apr 2017 14:36:34 +0000 (14:36 +0000)
JIRA: DOVETAIL-409

1. HA test cases need a file pod.yaml, in this file it can use the password or the key.
2. If use key, Dovetail need to pass the key file $DOVETAIL_HOME/dovetail/userconfig/id_rsa
   to yardstick Container.
3. Add a directory $DOVETAIL_HOME/dovetail/userconfig and a sample_pod.yaml
4. ha.tc001 tc003 tc005 tc006 tc009 are ready.

Change-Id: I391cc211dba2cf0740dd0dcaee8a5c2d712eaee1
Signed-off-by: xudan <xudan16@huawei.com>
.gitignore
dovetail/compliance/proposed_tests.yml
dovetail/conf/yardstick_config.yml
dovetail/container.py
userconfig/sample_pod.yaml [new file with mode: 0644]

index a8b4a9f..82b83ef 100644 (file)
@@ -34,4 +34,3 @@ unittest_results.log
 docs_build/
 docs_output/
 results/
-userconfig/
index 173a9f2..fa9c5b8 100644 (file)
@@ -35,13 +35,13 @@ proposed_tests:
     - dovetail.nfvi.tc001
     - dovetail.nfvi.tc002
     # HA, ha.tc002, ha.tc012, will kill the host and can't restart, not ready yet, skip.
-    - dovetail.ha.tc001
-    - dovetail.ha.tc003
+    - dovetail.ha.tc001
+    - dovetail.ha.tc003
     # - dovetail.ha.tc004
-    - dovetail.ha.tc005
-    - dovetail.ha.tc006
+    - dovetail.ha.tc005
+    - dovetail.ha.tc006
     # - dovetail.ha.tc007
     # - dovetail.ha.tc008
-    - dovetail.ha.tc009
+    - dovetail.ha.tc009
     # - dovetail.ha.tc010
     # - dovetail.ha.tc011
index ac128fb..ae59a9e 100644 (file)
@@ -23,4 +23,5 @@ yardstick:
     dir: '/home/opnfv/yardstick/results'
     log: '/tmp/yardstick'
     file_path: 'yardstick.log'
+    key_path: '/root/.ssh/id_rsa'
   openrc: '/etc/yardstick/openstack.creds'
index 8e032c7..5c128c0 100644 (file)
@@ -76,7 +76,8 @@ class Container(object):
             file_path = os.path.join(func_res_conf['dir'],
                                      func_res_conf['file_path'])
             report = " -e TEST_DB_URL=file://%s " % file_path
-        return "%s %s" % (envs, report)
+        key_vol = " -v /root/.ssh/id_rsa:/root/.ssh/id_rsa "
+        return "%s %s %s" % (envs, report, key_vol)
 
     # set yardstick external network name and log volume for its container.
     # external network is necessary for yardstick.
@@ -97,11 +98,13 @@ class Container(object):
 
         log_vol = '-v %s:%s ' % (dovetail_config['result_dir'],
                                  dovetail_config["yardstick"]['result']['log'])
-        return "%s %s" % (envs, log_vol)
+        key_path = os.path.join(dovetail_config['userconfig_dir'], 'id_rsa')
+        key_con_path = dovetail_config["yardstick"]['result']['key_path']
+        key_vol = '-v %s:%s ' % (key_path, key_con_path)
+        return "%s %s %s" % (envs, log_vol, key_vol)
 
     @classmethod
     def create(cls, type, testcase_name):
-        sshkey = "-v /root/.ssh/id_rsa:/root/.ssh/id_rsa "
         dovetail_config = dt_cfg.dovetail_config
         docker_image = cls.get_docker_image(type)
         opts = dovetail_config[type]['opts']
@@ -131,14 +134,18 @@ class Container(object):
         if type.lower() == "yardstick" and not os.path.exists(pod_file):
             cls.logger.error("File %s doesn't exist.", pod_file)
             return None
+        key_file = os.path.join(dovetail_config['userconfig_dir'], 'id_rsa')
+        if type.lower() == "yardstick" and not os.path.exists(key_file):
+            cls.logger.debug("File %s doesn't exist.", key_file)
+            cls.logger.debug("Can just use password in %s.", pod_file)
         config_volume = \
             ' -v %s:%s ' % (dovetail_config['userconfig_dir'],
                             dovetail_config["functest"]['config']['dir'])
 
         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 /bin/bash' % \
-            (opts, envs, config, sshkey, openrc, config_volume,
+        cmd = 'sudo docker run %s %s %s %s %s %s %s /bin/bash' % \
+            (opts, envs, config, openrc, config_volume,
              result_volume, docker_image)
         dt_utils.exec_cmd(cmd, cls.logger)
         ret, container_id = \
diff --git a/userconfig/sample_pod.yaml b/userconfig/sample_pod.yaml
new file mode 100644 (file)
index 0000000..26636a6
--- /dev/null
@@ -0,0 +1,50 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# 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
+##############################################################################
+---
+# sample config file about the POD information, including the
+# name/IP/user/ssh key  and Controllers/Computes
+#
+# The options of this config file include:
+# name: the name of this node
+# role: node's role, support role: Master/Controller/Comupte/BareMetal
+# ip: the node's IP address
+# user: the username for login
+# key_filename:the path of the private key file for login
+
+nodes:
+-
+    name: node1
+    role: Controller
+    ip: 10.1.0.50
+    user: root
+    key_filename: /root/.ssh/id_rsa
+-
+    name: node2
+    role: Controller
+    ip: 10.1.0.51
+    user: root
+    key_filename: /root/.ssh/id_rsa
+-
+    name: node3
+    role: Controller
+    ip: 10.1.0.52
+    user: root
+    key_filename: /root/.ssh/id_rsa
+-
+    name: node4
+    role: Compute
+    ip: 10.1.0.53
+    user: root
+    key_filename: /root/.ssh/id_rsa
+-
+    name: node5
+    role: Compute
+    ip: 10.1.0.54
+    user: root
+    key_filename: /root/.ssh/id_rsa