From 370632cc02a711289f9830616d4ded2f6a9341be Mon Sep 17 00:00:00 2001 From: JingLu5 Date: Sat, 6 May 2017 01:10:27 +0000 Subject: Bugfix: Support HA test cases in TripleO Change-Id: Ib1f6f45677e66ca88fb546ea0662f52588e9d336 Signed-off-by: JingLu5 (cherry picked from commit 67da8f2ddb5cbf14bbf0df48b10240ba6ebadbe9) --- tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml | 2 +- .../availability/attacker/attacker_baremetal.py | 8 ++++---- .../scenarios/availability/attacker/attacker_general.py | 8 ++++---- .../scenarios/availability/attacker/attacker_process.py | 6 +++--- .../scenarios/availability/ha_tools/start_service.bash | 14 ++++++++++++-- .../scenarios/availability/ha_tools/stop_service.bash | 17 ++++++++++++++++- .../scenarios/availability/monitor/monitor_general.py | 4 ++-- .../scenarios/availability/monitor/monitor_process.py | 2 +- .../availability/operation/operation_general.py | 8 ++++---- .../result_checker/result_checker_general.py | 4 ++-- 10 files changed, 49 insertions(+), 24 deletions(-) diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml index a5a89e418..9b720e17e 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml @@ -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: - diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py index f7683fd84..22de0b645 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py @@ -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")) diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py index 35cbccd6e..48863af93 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_general.py @@ -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) diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py index 93375a6dc..bff4a6dc3 100644 --- a/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py +++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_process.py @@ -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) diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/start_service.bash b/yardstick/benchmark/scenarios/availability/ha_tools/start_service.bash index 3164c44df..858d86ca0 100755 --- a/yardstick/benchmark/scenarios/availability/ha_tools/start_service.bash +++ b/yardstick/benchmark/scenarios/availability/ha_tools/start_service.bash @@ -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 diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/stop_service.bash b/yardstick/benchmark/scenarios/availability/ha_tools/stop_service.bash index a8901784e..fd8534e24 100755 --- a/yardstick/benchmark/scenarios/availability/ha_tools/stop_service.bash +++ b/yardstick/benchmark/scenarios/availability/ha_tools/stop_service.bash @@ -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 diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py index c6c5a75a1..c16765fe0 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_general.py @@ -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: diff --git a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py index ca5cac1ff..31526b011 100644 --- a/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py +++ b/yardstick/benchmark/scenarios/availability/monitor/monitor_process.py @@ -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) diff --git a/yardstick/benchmark/scenarios/availability/operation/operation_general.py b/yardstick/benchmark/scenarios/availability/operation/operation_general.py index 6ec8601af..8fd387e47 100644 --- a/yardstick/benchmark/scenarios/availability/operation/operation_general.py +++ b/yardstick/benchmark/scenarios/availability/operation/operation_general.py @@ -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( diff --git a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py index 0f2e382ae..454338175 100644 --- a/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py +++ b/yardstick/benchmark/scenarios/availability/result_checker/result_checker_general.py @@ -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( -- cgit 1.2.3-korg