bugfix: tc025 should use ipmi to poweroff 09/42609/1
authorroot <limingjiang@huawei.com>
Thu, 21 Sep 2017 03:40:59 +0000 (03:40 +0000)
committerroot <limingjiang@huawei.com>
Thu, 21 Sep 2017 03:40:59 +0000 (03:40 +0000)
if it use shutdown, it'll take several minutes to shutdown,
leads to the ipmi power on command fails

Change-Id: I74b61325cbcc3a6ec070d2fa103accf84f29b0fa
Signed-off-by: root <limingjiang@huawei.com>
tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py
yardstick/benchmark/scenarios/availability/attacker_conf.yaml

index a37f83b..3e630ca 100644 (file)
@@ -19,7 +19,7 @@ description: >
 {% set file = file or '/etc/yardstick/pod.yaml' %}
 {% set jump_host = jump_host or 'node0' %}
 {% set attack_host = attack_host or 'node1' %}
-{% set monitor_time = monitor_time or 180 %}
+{% set monitor_time = monitor_time or 30 %}
 
 scenarios:
 -
index 50d44c1..979e3ab 100644 (file)
@@ -40,6 +40,21 @@ class BaremetalAttacker(BaseAttacker):
         self.connection = ssh.SSH.from_node(host, defaults={"user": "root"})
         self.connection.wait(timeout=600)
         LOG.debug("ssh host success!")
+
+        jump_host_name = self._config.get("jump_host", None)
+        self.jump_connection = None
+        if jump_host_name is not None:
+            jump_host = self._context.get(jump_host_name, None)
+
+            LOG.debug("jump_host ip:%s user:%s", jump_host['ip'], jump_host['user'])
+            self.jump_connection = ssh.SSH.from_node(
+                jump_host,
+                # why do we allow pwd for password?
+                defaults={"user": "root", "password": jump_host.get("pwd")}
+            )
+            self.jump_connection.wait(timeout=600)
+            LOG.debug("ssh jump host success!")
+
         self.host_ip = host['ip']
 
         self.ipmi_ip = host.get("ipmi_ip", None)
@@ -49,6 +64,7 @@ class BaremetalAttacker(BaseAttacker):
         self.fault_cfg = BaseAttacker.attacker_cfgs.get('bare-metal-down')
         self.check_script = self.get_script_fullpath(
             self.fault_cfg['check_script'])
+        self.inject_script = self.get_script_fullpath(self.fault_cfg['inject_script'])
         self.recovery_script = self.get_script_fullpath(
             self.fault_cfg['recovery_script'])
 
@@ -70,39 +86,27 @@ class BaremetalAttacker(BaseAttacker):
         return True
 
     def inject_fault(self):
-        exit_status, stdout, stderr = self.connection.execute(
-            "sudo shutdown -h now")
-        LOG.debug("inject fault ret: %s out:%s err:%s",
-                  exit_status, stdout, stderr)
-        if not exit_status:
-            LOG.info("inject fault success")
+        LOG.info("Inject fault START")
+        cmd = "sudo /bin/bash -s {0} {1} {2} {3}".format(
+            self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "off")
+        with open(self.inject_script, "r") as stdin_file:
+            if self.jump_connection is not None:
+                LOG.info("Power off node via IPMI")
+                self.jump_connection.execute(cmd, stdin=stdin_file)
+            else:
+                _execute_shell_command(cmd, stdin=stdin_file)
+        LOG.info("Inject fault END")
 
     def recover(self):
-        jump_host_name = self._config.get("jump_host", None)
-        self.jump_connection = None
-        if jump_host_name is not None:
-            host = self._context.get(jump_host_name, None)
-
-            LOG.debug("jump_host ip:%s user:%s", host['ip'], host['user'])
-            self.jump_connection = ssh.SSH.from_node(
-                host,
-                # why do we allow pwd for password?
-                defaults={"user": "root", "password": host.get("pwd")}
-            )
-            self.jump_connection.wait(timeout=600)
-            LOG.debug("ssh jump host success!")
-
-        if self.jump_connection is not None:
-            with open(self.recovery_script, "r") as stdin_file:
-                self.jump_connection.execute(
-                    "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(
-                "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"))
+        LOG.info("Recover fault START")
+        cmd = "sudo /bin/bash -s {0} {1} {2} {3}".format(
+            self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "on")
+        with open(self.recovery_script, "r") as stdin_file:
+            if self.jump_connection is not None:
+                self.jump_connection.execute(cmd, stdin=stdin_file)
+            else:
+                _execute_shell_command(cmd, stdin=stdin_file)
+        LOG.info("Recover fault END")
 
 
 def _test():  # pragma: no cover
index ee7ea7d..5f43a70 100644 (file)
@@ -23,6 +23,7 @@ kill-lxc-process:
 
 bare-metal-down:
   check_script: ha_tools/check_host_ping.bash
+  inject_script: ha_tools/ipmi_power.bash
   recovery_script: ha_tools/ipmi_power.bash
 
 stop-service: