X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=yardstick%2Fbenchmark%2Fscenarios%2Favailability%2Fattacker%2Fattacker_process.py;h=f7ab23dcd946b56463e10eef5dc9e838f0ddd75a;hb=5b99f1532ec4d15258ec86e970acd2904954b3bc;hp=dc94a0b17510be0a28c11a423cab258d48b1e984;hpb=50a5d0cb28d95d8edb47b1775569fcdf52dd1c96;p=yardstick.git diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py index dc94a0b17..f7ab23dcd 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py @@ -38,18 +38,17 @@ class ProcessAttacker(BaseAttacker): self.recovery_script = self.get_script_fullpath( self.fault_cfg['recovery_script']) - if self.check(): - self.setup_done = True + self.data[self.service_name] = self.check() 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 and "running" in stdout: + if stdout: LOG.info("check the envrioment success!") - return True + return int(stdout.strip('\n')) else: LOG.error( "the host envrioment is error, stdout:%s, stderr:%s", @@ -59,11 +58,13 @@ 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) + if exit_status: + LOG.info("Fail to restart service!")