diff options
author | 2017-09-21 03:40:59 +0000 | |
---|---|---|
committer | 2017-09-21 03:40:59 +0000 | |
commit | 2a7734e9f1ecc6834bd88a788edc7e48905ce365 (patch) | |
tree | d9d49f2ee17b8c25d18b09accef01c18b6d5ac4a /yardstick | |
parent | 173c6ad6f464c514185efc0b5a608ceb6cc118ae (diff) |
bugfix: tc025 should use ipmi to poweroff
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>
Diffstat (limited to 'yardstick')
-rw-r--r-- | yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py | 66 | ||||
-rw-r--r-- | yardstick/benchmark/scenarios/availability/attacker_conf.yaml | 1 |
2 files changed, 36 insertions, 31 deletions
diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py index 50d44c1ca..979e3ab14 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py @@ -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 diff --git a/yardstick/benchmark/scenarios/availability/attacker_conf.yaml b/yardstick/benchmark/scenarios/availability/attacker_conf.yaml index ee7ea7d83..5f43a701a 100644 --- a/yardstick/benchmark/scenarios/availability/attacker_conf.yaml +++ b/yardstick/benchmark/scenarios/availability/attacker_conf.yaml @@ -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: |