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:
-
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",
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:
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"))
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)
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)
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:
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)
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
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
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:
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)
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 = \
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(
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 = \
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(
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 = \
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(