Create Bash Sheel Utilities 37/17637/2
authortjuyinkanglin <14_ykl@tongji.edu.cn>
Wed, 27 Jul 2016 15:49:35 +0000 (23:49 +0800)
committertjuyinkanglin <14_ykl@tongji.edu.cn>
Fri, 29 Jul 2016 05:22:34 +0000 (13:22 +0800)
JIRA: YARDSTICK-277

Change-Id: I7379d4fe375d22e544ab93b48d56a017a60c4b9f
Signed-off-by: tjuyinkanglin <14_ykl@tongji.edu.cn>
yardstick/benchmark/scenarios/availability/attacker_conf.yaml
yardstick/benchmark/scenarios/availability/ha_tools/disk/block_io.bash [new file with mode: 0644]
yardstick/benchmark/scenarios/availability/ha_tools/disk/recovery_disk_io.bash [new file with mode: 0644]
yardstick/benchmark/scenarios/availability/ha_tools/network/close_interface.bash [new file with mode: 0644]
yardstick/benchmark/scenarios/availability/ha_tools/network/open_interface.bash [new file with mode: 0644]
yardstick/benchmark/scenarios/availability/ha_tools/node/release_cpu.bash [new file with mode: 0644]
yardstick/benchmark/scenarios/availability/ha_tools/node/stress_cpu.bash [new file with mode: 0644]

index e5d1b9f..d37d669 100644 (file)
@@ -15,3 +15,15 @@ bare-metal-down:
 stop-service:
   inject_script: ha_tools/stop_service.bash
   recovery_script: ha_tools/start_service.bash
+
+close-interface:
+ inject_script: ha_tools/network/close_interface.bash
+ recovery_script: ha_tools/network/open_interface.bash
+
+stress-cpu:
+ inject_script: ha_tools/node/stress_cpu.bash
+ recovery_script: ha_tools/node/release_cpu.bash
+
+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
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/disk/block_io.bash b/yardstick/benchmark/scenarios/availability/ha_tools/disk/block_io.bash
new file mode 100644 (file)
index 0000000..2ccf7ee
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# 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
+##############################################################################
+
+# make a disk IO jam
+
+sudo dd if=/dev/zero of=/test.dbf bs=8k count=30000000 &
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/disk/recovery_disk_io.bash b/yardstick/benchmark/scenarios/availability/ha_tools/disk/recovery_disk_io.bash
new file mode 100644 (file)
index 0000000..dbe8519
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# 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
+##############################################################################
+
+# recover a node from disk io block status
+
+sudo kill `pidof dd`
+
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/network/close_interface.bash b/yardstick/benchmark/scenarios/availability/ha_tools/network/close_interface.bash
new file mode 100644 (file)
index 0000000..02c8d47
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# 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
+##############################################################################
+
+# close a network interface.
+# parameter: $1 - interface-name
+
+ifconfig $1 down
\ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/network/open_interface.bash b/yardstick/benchmark/scenarios/availability/ha_tools/network/open_interface.bash
new file mode 100644 (file)
index 0000000..953d5d3
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# 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
+##############################################################################
+
+# open a network interface.
+# parameter: $1 - interfaced-name
+
+ifconfig $1 up
\ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/node/release_cpu.bash b/yardstick/benchmark/scenarios/availability/ha_tools/node/release_cpu.bash
new file mode 100644 (file)
index 0000000..8e25fae
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# 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
+##############################################################################
+
+# release CPU stress.
+
+ps -ef|grep "dd if=/dev/zero of=/dev/null"|awk '{print$2}'|xargs kill -9
\ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/node/stress_cpu.bash b/yardstick/benchmark/scenarios/availability/ha_tools/node/stress_cpu.bash
new file mode 100644 (file)
index 0000000..30aa707
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# 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
+##############################################################################
+
+# stress CPU usage to 100%.
+
+for i in `seq 1 $(cat /proc/cpuinfo |grep "physical id" |wc -l)`; do dd if=/dev/zero of=/dev/null & done
\ No newline at end of file