Bugfix: Support HA test cases in TripleO 91/34391/2
authorJingLu5 <lvjing5@huawei.com>
Sat, 6 May 2017 01:10:27 +0000 (01:10 +0000)
committerJingLu5 <lvjing5@huawei.com>
Sat, 6 May 2017 03:40:34 +0000 (03:40 +0000)
Change-Id: Ib1f6f45677e66ca88fb546ea0662f52588e9d336
Signed-off-by: JingLu5 <lvjing5@huawei.com>
tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml
yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py
yardstick/benchmark/scenarios/availability/attacker/attacker_general.py
yardstick/benchmark/scenarios/availability/attacker/attacker_process.py
yardstick/benchmark/scenarios/availability/ha_tools/start_service.bash
yardstick/benchmark/scenarios/availability/ha_tools/stop_service.bash
yardstick/benchmark/scenarios/availability/monitor/monitor_general.py
yardstick/benchmark/scenarios/availability/monitor/monitor_process.py
yardstick/benchmark/scenarios/availability/operation/operation_general.py
yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py

index a5a89e4..9b720e1 100644 (file)
@@ -12,7 +12,7 @@ schema: "yardstick:task:0.1"
 description: >
     Sample test case for the HA of controller node Openstack service.
 
-{% set file = file or 'etc/yardstick/nodes/fuel_virtual/pod.yaml' %}
+{% set file = file or 'etc/yardstick/nodes/fuel_baremetal/pod.yaml' %}
 
 scenarios:
 -
index f7683fd..22de0b6 100644 (file)
@@ -61,7 +61,7 @@ class BaremetalAttacker(BaseAttacker):
     def check(self):
         with open(self.check_script, "r") as stdin_file:
             exit_status, stdout, stderr = self.connection.execute(
-                "/bin/sh -s {0} -W 10".format(self.host_ip),
+                "sudo /bin/sh -s {0} -W 10".format(self.host_ip),
                 stdin=stdin_file)
 
         LOG.debug("check ret: %s out:%s err:%s",
@@ -74,7 +74,7 @@ class BaremetalAttacker(BaseAttacker):
 
     def inject_fault(self):
         exit_status, stdout, stderr = self.connection.execute(
-            "shutdown -h now")
+            "sudo shutdown -h now")
         LOG.debug("inject fault ret: %s out:%s err:%s",
                   exit_status, stdout, stderr)
         if not exit_status:
@@ -98,12 +98,12 @@ class BaremetalAttacker(BaseAttacker):
         if self.jump_connection is not None:
             with open(self.recovery_script, "r") as stdin_file:
                 self.jump_connection.execute(
-                    "/bin/bash -s {0} {1} {2} {3}".format(
+                    "sudo /bin/bash -s {0} {1} {2} {3}".format(
                         self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "on"),
                     stdin=stdin_file)
         else:
             _execute_shell_command(
-                "/bin/bash -s {0} {1} {2} {3}".format(
+                "sudo /bin/bash -s {0} {1} {2} {3}".format(
                     self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "on"),
                 stdin=open(self.recovery_script, "r"))
 
index 35cbccd..48863af 100644 (file)
@@ -64,12 +64,12 @@ class GeneralAttacker(BaseAttacker):
             LOG.debug("the shell command is: %s", self.action_param)
             with open(self.inject_script, "r") as stdin_file:
                 exit_status, stdout, stderr = self.connection.execute(
-                    self.action_param,
+                    "sudo {}".format(self.action_param),
                     stdin=stdin_file)
         else:
             with open(self.inject_script, "r") as stdin_file:
                 exit_status, stdout, stderr = self.connection.execute(
-                    "/bin/bash -s ",
+                    "sudo /bin/bash -s ",
                     stdin=stdin_file)
 
         LOG.debug("the inject_fault's exit status is: %s", exit_status)
@@ -85,10 +85,10 @@ class GeneralAttacker(BaseAttacker):
             LOG.debug("the shell command is: %s", self.rollback_param)
             with open(self.recovery_script, "r") as stdin_file:
                 exit_status, stdout, stderr = self.connection.execute(
-                    self.rollback_param,
+                    "sudo {}".format(self.rollback_param),
                     stdin=stdin_file)
         else:
             with open(self.recovery_script, "r") as stdin_file:
                 exit_status, stdout, stderr = self.connection.execute(
-                    "/bin/bash -s ",
+                    "sudo /bin/bash -s ",
                     stdin=stdin_file)
index 93375a6..bff4a6d 100644 (file)
@@ -44,7 +44,7 @@ class ProcessAttacker(BaseAttacker):
     def check(self):
         with open(self.check_script, "r") as stdin_file:
             exit_status, stdout, stderr = self.connection.execute(
-                "/bin/sh -s {0}".format(self.service_name),
+                "sudo /bin/sh -s {0}".format(self.service_name),
                 stdin=stdin_file)
 
         if stdout:
@@ -59,11 +59,11 @@ class ProcessAttacker(BaseAttacker):
     def inject_fault(self):
         with open(self.inject_script, "r") as stdin_file:
             exit_status, stdout, stderr = self.connection.execute(
-                "/bin/sh -s {0}".format(self.service_name),
+                "sudo /bin/sh -s {0}".format(self.service_name),
                 stdin=stdin_file)
 
     def recover(self):
         with open(self.recovery_script, "r") as stdin_file:
             exit_status, stdout, stderr = self.connection.execute(
-                "/bin/sh -s {0} ".format(self.service_name),
+                "sudo /bin/bash -s {0} ".format(self.service_name),
                 stdin=stdin_file)
index 3164c44..858d86c 100755 (executable)
@@ -15,8 +15,18 @@ set -e
 
 service_name=$1
 
-if [ "$service_name" = "keystone" ]; then
-    service apache2 start
+Distributor=$(lsb_release -a | grep "Distributor ID" | awk '{print $3}')
+
+if [ "$Distributor" != "Ubuntu" -a "$service_name" != "keystone" -a "$service_name" != "neutron-server" -a "$service_name" != "haproxy" ]; then
+    service_name="openstack-"${service_name}
+elif [ "$Distributor" = "Ubuntu" -a "$service_name" = "keystone" ]; then
+    service_name="apache2"
+elif [ "$service_name" = "keystone" ]; then
+    service_name="httpd"
+fi
+
+if which systemctl 2>/dev/null; then
+    systemctl start $service_name
 else
     service $service_name start
 fi
index a890178..fd8534e 100755 (executable)
@@ -15,7 +15,22 @@ set -e
 
 service_name=$1
 
-service $service_name stop
+Distributor=$(lsb_release -a | grep "Distributor ID" | awk '{print $3}')
+
+if [ "$Distributor" != "Ubuntu" -a "$service_name" != "keystone" -a "$service_name" != "neutron-server" -a "$service_name" != "haproxy" ]; then
+    service_name="openstack-"${service_name}
+elif [ "$Distributor" = "Ubuntu" -a "$service_name" = "keystone" ]; then
+    service_name="apache2"
+elif [ "$service_name" = "keystone" ]; then
+    service_name="httpd"
+fi
+
+if which systemctl 2>/dev/null; then
+    systemctl stop $service_name
+else
+    service $service_name stop
+fi
+
 
 # TODO
 # check the service status
index c6c5a75..c16765f 100644 (file)
@@ -46,12 +46,12 @@ class GeneralMonitor(basemonitor.BaseMonitor):
         if "parameter" in self._config:
             with open(self.monitor_script, "r") as stdin_file:
                 exit_status, stdout, stderr = self.connection.execute(
-                    self.cmd_param,
+                    "sudo {}".format(self.cmd_param),
                     stdin=stdin_file)
         else:
             with open(self.monitor_script, "r") as stdin_file:
                 exit_status, stdout, stderr = self.connection.execute(
-                    "/bin/bash -s ",
+                    "sudo /bin/bash -s ",
                     stdin=stdin_file)
 
         if exit_status:
index ca5cac1..31526b0 100644 (file)
@@ -33,7 +33,7 @@ class MonitorProcess(basemonitor.BaseMonitor):
     def monitor_func(self):
         with open(self.check_script, "r") as stdin_file:
             exit_status, stdout, stderr = self.connection.execute(
-                "/bin/sh -s {0}".format(self.process_name),
+                "sudo /bin/sh -s {0}".format(self.process_name),
                 stdin=stdin_file)
         if not stdout or int(stdout) <= 0:
             LOG.info("the process (%s) is not running!", self.process_name)
index 6ec8601..8fd387e 100644 (file)
@@ -64,7 +64,7 @@ class GeneralOperaion(BaseOperation):
             if self.connection:
                 with open(self.action_script, "r") as stdin_file:
                     exit_status, stdout, stderr = self.connection.execute(
-                        self.action_param,
+                        "sudo {}".format(self.action_param),
                         stdin=stdin_file)
             else:
                 exit_status, stdout = \
@@ -75,7 +75,7 @@ class GeneralOperaion(BaseOperation):
             if self.connection:
                 with open(self.action_script, "r") as stdin_file:
                     exit_status, stdout, stderr = self.connection.execute(
-                        "/bin/sh -s ",
+                        "sudo /bin/sh -s ",
                         stdin=stdin_file)
             else:
                 exit_status, stdout = execute_shell_command(
@@ -93,7 +93,7 @@ class GeneralOperaion(BaseOperation):
             if self.connection:
                 with open(self.rollback_script, "r") as stdin_file:
                     exit_status, stdout, stderr = self.connection.execute(
-                        self.rollback_param,
+                        "sudo {}".format(self.rollback_param),
                         stdin=stdin_file)
             else:
                 exit_status, stdout = \
@@ -104,7 +104,7 @@ class GeneralOperaion(BaseOperation):
             if self.connection:
                 with open(self.rollback_script, "r") as stdin_file:
                     exit_status, stdout, stderr = self.connection.execute(
-                        "/bin/sh -s ",
+                        "sudo /bin/sh -s ",
                         stdin=stdin_file)
             else:
                 exit_status, stdout = execute_shell_command(
index 0f2e382..4543381 100644 (file)
@@ -59,7 +59,7 @@ class GeneralResultChecker(BaseResultChecker):
             if self.connection:
                 with open(self.verify_script, "r") as stdin_file:
                     exit_status, stdout, stderr = self.connection.execute(
-                        self.shell_cmd,
+                        "sudo {}".format(self.shell_cmd),
                         stdin=stdin_file)
             else:
                 exit_status, stdout = \
@@ -76,7 +76,7 @@ class GeneralResultChecker(BaseResultChecker):
             if self.connection:
                 with open(self.verify_script, "r") as stdin_file:
                     exit_status, stdout, stderr = self.connection.execute(
-                        "/bin/bash -s ",
+                        "sudo /bin/bash -s ",
                         stdin=stdin_file)
             else:
                 exit_status, stdout = execute_shell_command(