HA testcase containerized Compass support 45/37245/12
authorJingLu5 <lvjing5@huawei.com>
Wed, 12 Jul 2017 07:35:30 +0000 (07:35 +0000)
committerJing Lu <lvjing5@huawei.com>
Thu, 20 Jul 2017 04:45:04 +0000 (04:45 +0000)
Compass will be containerized in Euphrates release.
This work is about support HA testcase in a containerized environment.

Change-Id: Ibb668c81f046d6400293f8cd58181b9f20aeebe3
Signed-off-by: JingLu5 <lvjing5@huawei.com>
yardstick/benchmark/scenarios/availability/attacker_conf.yaml
yardstick/benchmark/scenarios/availability/ha_tools/check_lxc_process_python.bash [new file with mode: 0755]
yardstick/benchmark/scenarios/availability/ha_tools/fault_lxc_process_kill.bash [new file with mode: 0755]
yardstick/benchmark/scenarios/availability/ha_tools/nova/create_flavor.bash
yardstick/benchmark/scenarios/availability/ha_tools/nova/delete_flavor.bash
yardstick/benchmark/scenarios/availability/ha_tools/nova/show_flavors.bash
yardstick/benchmark/scenarios/availability/ha_tools/start_lxc_service.bash [new file with mode: 0755]
yardstick/benchmark/scenarios/availability/monitor_conf.yaml

index b8c34ad..aa144ab 100644 (file)
@@ -16,6 +16,11 @@ kill-process:
   inject_script: ha_tools/fault_process_kill.bash
   recovery_script: ha_tools/start_service.bash
 
+kill-lxc-process:
+  check_script: ha_tools/check_lxc_process_python.bash
+  inject_script: ha_tools/fault_lxc_process_kill.bash
+  recovery_script: ha_tools/start_lxc_service.bash
+
 bare-metal-down:
   check_script: ha_tools/check_host_ping.bash
   recovery_script: ha_tools/ipmi_power.bash
@@ -34,4 +39,4 @@ stress-cpu:
 
 block-io:
   inject_script: ha_tools/disk/block_io.bash
-  recovery_script: ha_tools/disk/recovery_disk_io.bash
\ No newline at end of file
+  recovery_script: ha_tools/disk/recovery_disk_io.bash
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/check_lxc_process_python.bash b/yardstick/benchmark/scenarios/availability/ha_tools/check_lxc_process_python.bash
new file mode 100755 (executable)
index 0000000..6d2f4dd
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# check the status of a service
+
+set -e
+
+NOVA_API_PROCESS_1="nova-api-os-compute"
+NOVA_API_PROCESS_2="nova-api-metadata"
+NOVA_API_LXC_FILTER_1="nova_api_os_compute"
+NOVA_API_LXC_FILTER_2="nova_api_metadata"
+
+process_name=$1
+
+lxc_filter=$(echo "${process_name}" | sed 's/-/_/g')
+
+if [ "${lxc_filter}" = "glance_api" ]; then
+    lxc_filter="glance"
+fi
+
+if [ "${process_name}" = "nova-api" ]; then
+    container_1=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_1}")
+    container_2=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_2}")
+
+   echo $(($(lxc-attach -n "${container_1}" -- ps aux | grep -e "${NOVA_API_PROCESS_1}" | grep -v grep | grep -cv /bin/sh) + $(lxc-attach -n "${container_2}" -- ps aux | grep -e "${NOVA_API_PROCESS_2}" | grep -v grep | grep -cv /bin/sh)))
+else
+    container=$(lxc-ls -1 --filter="${lxc_filter}")
+
+    if [ "${process_name}" = "haproxy" ]; then
+        ps aux | grep -e "/usr/.*/${process_name}" | grep -v grep | grep -cv /bin/sh
+    else
+        lxc-attach -n "${container}" -- ps aux | grep -e "${process_name}" | grep -v grep | grep -cv /bin/sh
+    fi
+fi
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/fault_lxc_process_kill.bash b/yardstick/benchmark/scenarios/availability/ha_tools/fault_lxc_process_kill.bash
new file mode 100755 (executable)
index 0000000..b0b86ab
--- /dev/null
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# Stop process by process name
+
+set -e
+
+NOVA_API_PROCESS_1="nova-api-os-compute"
+NOVA_API_PROCESS_2="nova-api-metadata"
+NOVA_API_LXC_FILTER_1="nova_api_os_compute"
+NOVA_API_LXC_FILTER_2="nova_api_metadata"
+
+process_name=$1
+
+lxc_filter=$(echo "${process_name}" | sed 's/-/_/g')
+
+if [ "${lxc_filter}" = "glance_api" ]; then
+    lxc_filter="glance"
+fi
+
+if [ "${process_name}" = "nova-api" ]; then
+    container_1=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_1}")
+    container_2=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_2}")
+
+    pids_1=$(lxc-attach -n "${container_1}" -- pgrep -f "/openstack/.*/${NOVA_API_PROCESS_1}")
+    for pid in ${pids_1};
+        do
+            lxc-attach -n "${container_1}" -- kill -9 "${pid}"
+        done
+
+    pids_2=$(lxc-attach -n "${container_2}" -- pgrep -f "/openstack/.*/${NOVA_API_PROCESS_2}")
+    for pid in ${pids_2};
+        do
+            lxc-attach -n "${container_2}" -- kill -9 "${pid}"
+        done
+else
+    container=$(lxc-ls -1 --filter="${lxc_filter}")
+
+    if [ "${process_name}" = "haproxy" ]; then
+        for pid in $(pgrep -cf "/usr/.*/${process_name}");
+            do
+                kill -9 "${pid}"
+            done
+    elif [ "${process_name}" = "keystone" ]; then
+        pids=$(lxc-attach -n "${container}" -- ps aux | grep "keystone" | grep -iv heartbeat | grep -iv monitor | grep -v grep | grep -v /bin/sh | awk '{print $2}')
+        for pid in ${pids};
+            do
+                lxc-attach -n "${container}" -- kill -9 "${pid}"
+            done
+    else
+        pids=$(lxc-attach -n "${container}" -- pgrep -f "/openstack/.*/${process_name}")
+        for pid in ${pids};
+            do
+                lxc-attach -n "${container}" -- kill -9 "${pid}"
+            done
+    fi
+fi
index aee516e..7408409 100644 (file)
@@ -20,4 +20,4 @@ else
     SECURE=""
 fi
 
-openstack "${SECURE}" flavor create $1 --id $2 --ram $3 --disk $4 --vcpus $5
+openstack ${SECURE} flavor create $1 --id $2 --ram $3 --disk $4 --vcpus $5
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/start_lxc_service.bash b/yardstick/benchmark/scenarios/availability/ha_tools/start_lxc_service.bash
new file mode 100755 (executable)
index 0000000..36a6739
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/bash
+
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# Start a service and check the service is started
+
+set -e
+
+NOVA_API_SERVICE_1="nova-api-os-compute"
+NOVA_API_SERVICE_2="nova-api-metadata"
+NOVA_API_LXC_FILTER_1="nova_api_os_compute"
+NOVA_API_LXC_FILTER_2="nova_api_metadata"
+
+service_name=$1
+
+if [ "${service_name}" = "haproxy" ]; then
+    if which systemctl 2>/dev/null; then
+        systemctl start $service_name
+    else
+        service $service_name start
+    fi
+else
+    lxc_filter=${service_name//-/_}
+
+    if [ "${lxc_filter}" = "glance_api" ]; then
+        lxc_filter="glance"
+    fi
+
+    if [ "${service_name}" = "nova-api" ]; then
+        container_1=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_1}")
+        container_2=$(lxc-ls -1 --filter="${NOVA_API_LXC_FILTER_2}")
+
+        if lxc-attach -n "${container_1}" -- which systemctl 2>/dev/null; then
+            lxc-attach -n "${container_1}" -- systemctl start "${NOVA_API_SERVICE_1}"
+        else
+            lxc-attach -n "${container_1}" -- service "${NOVA_API_SERVICE_1}" start
+        fi
+
+        if lxc-attach -n "${container_2}" -- which systemctl 2>/dev/null; then
+            lxc-attach -n "${container_2}" -- systemctl start "${NOVA_API_SERVICE_2}"
+        else
+            lxc-attach -n "${container_2}" -- service "${NOVA_API_SERVICE_2}" start
+        fi
+    else
+        container=$(lxc-ls -1 --filter="${lxc_filter}")
+
+        Distributor=$(lxc-attach -n "${container}" -- lsb_release -a | grep "Distributor ID" | awk '{print $3}')
+
+        if [ "${Distributor}" != "Ubuntu" -a "${service_name}" != "keystone" -a "${service_name}" != "neutron-server" ]; 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 lxc-attach -n "${container}" -- which systemctl 2>/dev/null; then
+            lxc-attach -n "${container}" -- systemctl start "${service_name}"
+        else
+            lxc-attach -n "${container}" -- service "${service_name}" start
+        fi
+    fi
+fi
index 5114492..a08347d 100644 (file)
@@ -13,6 +13,8 @@ schema: "yardstick:task:0.1"
 
 process-status:
   monitor_script: ha_tools/check_process_python.bash
+lxc_process-status:
+  monitor_script: ha_tools/check_lxc_process_python.bash
 nova-image-list:
   monitor_script: ha_tools/nova_image_list.bash
 service-status: