[sheepdog] [PATCH] test/func: add test case for changing replica number
Ruoyu
liangry at ucweb.com
Mon May 12 12:40:12 CEST 2014
Signed-off-by: Ruoyu <liangry at ucweb.com>
---
tests/functional/092 | 98 +++++++++++
tests/functional/092.out | 450 +++++++++++++++++++++++++++++++++++++++++++++++
tests/functional/group | 1 +
3 files changed, 549 insertions(+)
create mode 100755 tests/functional/092
create mode 100644 tests/functional/092.out
diff --git a/tests/functional/092 b/tests/functional/092
new file mode 100755
index 0000000..cfa7b10
--- /dev/null
+++ b/tests/functional/092
@@ -0,0 +1,98 @@
+#!/bin/bash
+
+# Test changing replica number
+
+num=6
+
+. ./common
+
+execute_vdi_copies()
+{
+ echo -e "\n### $2 REPLICA\n"
+ echo -e "\$ $DOG vdi copies $1 $2"
+ echo yes | $DOG vdi copies $1 $2
+ _wait_for_sheep_recovery 0
+
+ echo -e "\n\$ $DOG vdi list"
+ $DOG vdi list | _filter_short_date
+ echo -e "\n#### VDI OBJECT LIST\n"
+ ls $STORE/[0-9]/obj/807c2b25*
+ echo -e "\n#### DATA OBJECT LIST\n"
+ ls $STORE/[0-9]/obj/007c2b25*
+}
+
+for i in `seq 0 $(($num-1))`; do
+ _start_sheep $i
+done
+_wait_for_sheep $num
+
+echo -e "\n## EC NOT SUPPORTED\n"
+echo -e "\$ $DOG cluster format -c 4:2"
+$DOG cluster format -c 4:2
+echo -e "\n\$ $DOG cluster copies 3"
+$DOG cluster copies 3
+echo -e "\n\$ $DOG vdi create test 4M"
+$DOG vdi create test 4M
+echo -e "\n\$ $DOG vdi copies test 3"
+$DOG vdi copies test 3
+echo -e "\n-----\n"
+
+echo -e "## INITIAL STATUS\n"
+echo -e "\$ $DOG cluster format -c 3"
+echo "yes" | $DOG cluster format -c 3
+echo -e "\n\$ $DOG cluster info -s | _filter_cluster_info"
+$DOG cluster info -s | _filter_cluster_info
+echo -e "\n-----\n"
+
+echo -e "## CLUSTER REPLICA ERROR\n"
+echo -e "\$ $DOG cluster copies something"
+$DOG cluster copies something
+echo -e "\n\$ $DOG cluster copies 0"
+$DOG cluster copies 0
+echo -e "\n\$ $DOG cluster copies 3"
+$DOG cluster copies 3
+echo -e "\n\$ $DOG cluster copies 4:2"
+$DOG cluster copies 4:2
+echo -e "\n-----\n"
+
+echo -e "## CLUSTER REPLICA OK\n"
+echo -e "\$ $DOG cluster copies 2"
+echo yes | $DOG cluster copies 2
+echo -e "\n\$ $DOG cluster info -s | _filter_cluster_info"
+$DOG cluster info -s | _filter_cluster_info
+
+echo -e "\n\$ $DOG vdi create test 12M -P"
+$DOG vdi create test 12M -P
+echo -e "\n\$ $DOG vdi list"
+$DOG vdi list | _filter_short_date
+echo -e "\n### VDI OBJECT LIST\n"
+ls $STORE/[0-9]/obj/807c2b25*
+echo -e "\n### DATA OBJECT LIST\n"
+ls $STORE/[0-9]/obj/007c2b25*
+echo -e "\n-----\n"
+
+echo -e "## VDI REPLICA ERROR\n"
+echo -e "\$ $DOG vdi copies test something"
+$DOG vdi copies test something
+echo -e "\n\$ $DOG vdi copies test 0"
+$DOG vdi copies test 0
+echo -e "\n\$ $DOG vdi copies test 2"
+$DOG vdi copies test 2
+echo -e "\n\$ $DOG vdi copies test 4:2"
+$DOG vdi copies test 4:2
+echo -e "\n-----\n"
+
+echo -e "## VDI REPLICA INCREASE OK"
+for i in `seq 3 $num`; do
+ execute_vdi_copies test $i
+done
+echo -e "\n-----\n"
+
+echo -e "## VDI REPLICA DECREASE OK"
+for i in `seq $(($num-1)) -1 1`; do
+ execute_vdi_copies test $i
+done
+echo -e "\n-----\n"
+
+$DOG cluster shutdown
+
diff --git a/tests/functional/092.out b/tests/functional/092.out
new file mode 100644
index 0000000..dc0caf3
--- /dev/null
+++ b/tests/functional/092.out
@@ -0,0 +1,450 @@
+QA output created by 092
+
+## EC NOT SUPPORTED
+
+$ ../../dog/dog cluster format -c 4:2
+using backend plain store
+
+$ ../../dog/dog cluster copies 3
+the cluster's copy policy is erasure code, changing it is not supported yet.
+
+$ ../../dog/dog vdi create test 4M
+
+$ ../../dog/dog vdi copies test 3
+test's copy policy is erasure code, changing it is not supported yet.
+
+-----
+
+## INITIAL STATUS
+
+$ ../../dog/dog cluster format -c 3
+ __
+ ()'`;
+ /\|`
+ / | Caution! The cluster is not empty.
+(/_)_|_ Are you sure you want to continue? [yes/no]: using backend plain store
+
+$ ../../dog/dog cluster info -s | _filter_cluster_info
+Cluster status: running, auto-recovery enabled
+Cluster store: plain with 3 redundancy policy
+
+Cluster created at DATE
+
+Epoch Time Version
+DATE 1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004, 127.0.0.1:7005]
+
+-----
+
+## CLUSTER REPLICA ERROR
+
+$ ../../dog/dog cluster copies something
+invalid replica number.
+Usage: dog cluster copies [-a address] [-p port] [-h] <num>
+Options:
+ -a, --address specify the daemon address (default: localhost)
+ -p, --port specify the daemon port
+ -h, --help display this help and exit
+
+$ ../../dog/dog cluster copies 0
+invalid replica number.
+Usage: dog cluster copies [-a address] [-p port] [-h] <num>
+Options:
+ -a, --address specify the daemon address (default: localhost)
+ -p, --port specify the daemon port
+ -h, --help display this help and exit
+
+$ ../../dog/dog cluster copies 3
+the cluster's replica number is already set to 3.
+
+$ ../../dog/dog cluster copies 4:2
+changing the replica number to erasure code is not supported yet.
+Usage: dog cluster copies [-a address] [-p port] [-h] <num>
+Options:
+ -a, --address specify the daemon address (default: localhost)
+ -p, --port specify the daemon port
+ -h, --help display this help and exit
+
+-----
+
+## CLUSTER REPLICA OK
+
+$ ../../dog/dog cluster copies 2
+the cluster's replica number is set to 2, the old one was 3.
+ __
+ ()'`;
+ /\|` Caution! Changing the # of replica will affect
+ / | all the VDIs to be created later.
+(/_)_|_ Are you sure you want to continue? [yes/no]:
+$ ../../dog/dog cluster info -s | _filter_cluster_info
+Cluster status: running, auto-recovery enabled
+Cluster store: plain with 2 redundancy policy
+
+Cluster created at DATE
+
+Epoch Time Version
+DATE 1 [127.0.0.1:7000, 127.0.0.1:7001, 127.0.0.1:7002, 127.0.0.1:7003, 127.0.0.1:7004, 127.0.0.1:7005]
+
+$ ../../dog/dog vdi create test 12M -P
+
+$ ../../dog/dog vdi list
+ Name Id Size Used Shared Creation time VDI id Copies Tag
+ test 0 12 MB 12 MB 0.0 MB DATE 7c2b25 2
+
+### VDI OBJECT LIST
+
+/tmp/sheepdog/092/2/obj/807c2b2500000000
+/tmp/sheepdog/092/4/obj/807c2b2500000000
+
+### DATA OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/007c2b2500000001
+/tmp/sheepdog/092/0/obj/007c2b2500000002
+/tmp/sheepdog/092/1/obj/007c2b2500000000
+/tmp/sheepdog/092/1/obj/007c2b2500000001
+/tmp/sheepdog/092/3/obj/007c2b2500000000
+/tmp/sheepdog/092/5/obj/007c2b2500000002
+
+-----
+
+## VDI REPLICA ERROR
+
+$ ../../dog/dog vdi copies test something
+invalid replica number.
+Usage: dog vdi copies [-a address] [-p port] [-h] <vdiname> <num>
+Options:
+ -a, --address specify the daemon address (default: localhost)
+ -p, --port specify the daemon port
+ -h, --help display this help and exit
+
+$ ../../dog/dog vdi copies test 0
+invalid replica number.
+Usage: dog vdi copies [-a address] [-p port] [-h] <vdiname> <num>
+Options:
+ -a, --address specify the daemon address (default: localhost)
+ -p, --port specify the daemon port
+ -h, --help display this help and exit
+
+$ ../../dog/dog vdi copies test 2
+test's replica number is already set to 2.
+
+$ ../../dog/dog vdi copies test 4:2
+changing the replica number to erasure code is not supported yet.
+Usage: dog vdi copies [-a address] [-p port] [-h] <vdiname> <num>
+Options:
+ -a, --address specify the daemon address (default: localhost)
+ -p, --port specify the daemon port
+ -h, --help display this help and exit
+
+-----
+
+## VDI REPLICA INCREASE OK
+
+### 3 REPLICA
+
+$ ../../dog/dog vdi copies test 3
+test's replica number is set to 3, the old one was 2.
+ __
+ ()'`;
+ /\|` Caution! Changing the # of replica will affect
+ / | the specified VDI and trigger recovery.
+(/_)_|_ Are you sure you want to continue? [yes/no]:
+$ ../../dog/dog vdi list
+ Name Id Size Used Shared Creation time VDI id Copies Tag
+ test 0 12 MB 12 MB 0.0 MB DATE 7c2b25 3
+
+#### VDI OBJECT LIST
+
+/tmp/sheepdog/092/1/obj/807c2b2500000000
+/tmp/sheepdog/092/2/obj/807c2b2500000000
+/tmp/sheepdog/092/4/obj/807c2b2500000000
+
+#### DATA OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/007c2b2500000000
+/tmp/sheepdog/092/0/obj/007c2b2500000001
+/tmp/sheepdog/092/0/obj/007c2b2500000002
+/tmp/sheepdog/092/1/obj/007c2b2500000000
+/tmp/sheepdog/092/1/obj/007c2b2500000001
+/tmp/sheepdog/092/2/obj/007c2b2500000002
+/tmp/sheepdog/092/3/obj/007c2b2500000000
+/tmp/sheepdog/092/5/obj/007c2b2500000001
+/tmp/sheepdog/092/5/obj/007c2b2500000002
+
+### 4 REPLICA
+
+$ ../../dog/dog vdi copies test 4
+test's replica number is set to 4, the old one was 3.
+ __
+ ()'`;
+ /\|` Caution! Changing the # of replica will affect
+ / | the specified VDI and trigger recovery.
+(/_)_|_ Are you sure you want to continue? [yes/no]:
+$ ../../dog/dog vdi list
+ Name Id Size Used Shared Creation time VDI id Copies Tag
+ test 0 12 MB 12 MB 0.0 MB DATE 7c2b25 4
+
+#### VDI OBJECT LIST
+
+/tmp/sheepdog/092/1/obj/807c2b2500000000
+/tmp/sheepdog/092/2/obj/807c2b2500000000
+/tmp/sheepdog/092/4/obj/807c2b2500000000
+/tmp/sheepdog/092/5/obj/807c2b2500000000
+
+#### DATA OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/007c2b2500000000
+/tmp/sheepdog/092/0/obj/007c2b2500000001
+/tmp/sheepdog/092/0/obj/007c2b2500000002
+/tmp/sheepdog/092/1/obj/007c2b2500000000
+/tmp/sheepdog/092/1/obj/007c2b2500000001
+/tmp/sheepdog/092/2/obj/007c2b2500000002
+/tmp/sheepdog/092/3/obj/007c2b2500000000
+/tmp/sheepdog/092/3/obj/007c2b2500000001
+/tmp/sheepdog/092/4/obj/007c2b2500000000
+/tmp/sheepdog/092/4/obj/007c2b2500000002
+/tmp/sheepdog/092/5/obj/007c2b2500000001
+/tmp/sheepdog/092/5/obj/007c2b2500000002
+
+### 5 REPLICA
+
+$ ../../dog/dog vdi copies test 5
+test's replica number is set to 5, the old one was 4.
+ __
+ ()'`;
+ /\|` Caution! Changing the # of replica will affect
+ / | the specified VDI and trigger recovery.
+(/_)_|_ Are you sure you want to continue? [yes/no]:
+$ ../../dog/dog vdi list
+ Name Id Size Used Shared Creation time VDI id Copies Tag
+ test 0 12 MB 12 MB 0.0 MB DATE 7c2b25 5
+
+#### VDI OBJECT LIST
+
+/tmp/sheepdog/092/1/obj/807c2b2500000000
+/tmp/sheepdog/092/2/obj/807c2b2500000000
+/tmp/sheepdog/092/3/obj/807c2b2500000000
+/tmp/sheepdog/092/4/obj/807c2b2500000000
+/tmp/sheepdog/092/5/obj/807c2b2500000000
+
+#### DATA OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/007c2b2500000000
+/tmp/sheepdog/092/0/obj/007c2b2500000001
+/tmp/sheepdog/092/0/obj/007c2b2500000002
+/tmp/sheepdog/092/1/obj/007c2b2500000000
+/tmp/sheepdog/092/1/obj/007c2b2500000001
+/tmp/sheepdog/092/2/obj/007c2b2500000001
+/tmp/sheepdog/092/2/obj/007c2b2500000002
+/tmp/sheepdog/092/3/obj/007c2b2500000000
+/tmp/sheepdog/092/3/obj/007c2b2500000001
+/tmp/sheepdog/092/3/obj/007c2b2500000002
+/tmp/sheepdog/092/4/obj/007c2b2500000000
+/tmp/sheepdog/092/4/obj/007c2b2500000002
+/tmp/sheepdog/092/5/obj/007c2b2500000000
+/tmp/sheepdog/092/5/obj/007c2b2500000001
+/tmp/sheepdog/092/5/obj/007c2b2500000002
+
+### 6 REPLICA
+
+$ ../../dog/dog vdi copies test 6
+test's replica number is set to 6, the old one was 5.
+ __
+ ()'`;
+ /\|` Caution! Changing the # of replica will affect
+ / | the specified VDI and trigger recovery.
+(/_)_|_ Are you sure you want to continue? [yes/no]:
+$ ../../dog/dog vdi list
+ Name Id Size Used Shared Creation time VDI id Copies Tag
+ test 0 12 MB 12 MB 0.0 MB DATE 7c2b25 6
+
+#### VDI OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/807c2b2500000000
+/tmp/sheepdog/092/1/obj/807c2b2500000000
+/tmp/sheepdog/092/2/obj/807c2b2500000000
+/tmp/sheepdog/092/3/obj/807c2b2500000000
+/tmp/sheepdog/092/4/obj/807c2b2500000000
+/tmp/sheepdog/092/5/obj/807c2b2500000000
+
+#### DATA OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/007c2b2500000000
+/tmp/sheepdog/092/0/obj/007c2b2500000001
+/tmp/sheepdog/092/0/obj/007c2b2500000002
+/tmp/sheepdog/092/1/obj/007c2b2500000000
+/tmp/sheepdog/092/1/obj/007c2b2500000001
+/tmp/sheepdog/092/1/obj/007c2b2500000002
+/tmp/sheepdog/092/2/obj/007c2b2500000000
+/tmp/sheepdog/092/2/obj/007c2b2500000001
+/tmp/sheepdog/092/2/obj/007c2b2500000002
+/tmp/sheepdog/092/3/obj/007c2b2500000000
+/tmp/sheepdog/092/3/obj/007c2b2500000001
+/tmp/sheepdog/092/3/obj/007c2b2500000002
+/tmp/sheepdog/092/4/obj/007c2b2500000000
+/tmp/sheepdog/092/4/obj/007c2b2500000001
+/tmp/sheepdog/092/4/obj/007c2b2500000002
+/tmp/sheepdog/092/5/obj/007c2b2500000000
+/tmp/sheepdog/092/5/obj/007c2b2500000001
+/tmp/sheepdog/092/5/obj/007c2b2500000002
+
+-----
+
+## VDI REPLICA DECREASE OK
+
+### 5 REPLICA
+
+$ ../../dog/dog vdi copies test 5
+test's replica number is set to 5, the old one was 6.
+ __
+ ()'`;
+ /\|` Caution! Changing the # of replica will affect
+ / | the specified VDI and trigger recovery.
+(/_)_|_ Are you sure you want to continue? [yes/no]:
+$ ../../dog/dog vdi list
+ Name Id Size Used Shared Creation time VDI id Copies Tag
+ test 0 12 MB 12 MB 0.0 MB DATE 7c2b25 5
+
+#### VDI OBJECT LIST
+
+/tmp/sheepdog/092/1/obj/807c2b2500000000
+/tmp/sheepdog/092/2/obj/807c2b2500000000
+/tmp/sheepdog/092/3/obj/807c2b2500000000
+/tmp/sheepdog/092/4/obj/807c2b2500000000
+/tmp/sheepdog/092/5/obj/807c2b2500000000
+
+#### DATA OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/007c2b2500000000
+/tmp/sheepdog/092/0/obj/007c2b2500000001
+/tmp/sheepdog/092/0/obj/007c2b2500000002
+/tmp/sheepdog/092/1/obj/007c2b2500000000
+/tmp/sheepdog/092/1/obj/007c2b2500000001
+/tmp/sheepdog/092/2/obj/007c2b2500000001
+/tmp/sheepdog/092/2/obj/007c2b2500000002
+/tmp/sheepdog/092/3/obj/007c2b2500000000
+/tmp/sheepdog/092/3/obj/007c2b2500000001
+/tmp/sheepdog/092/3/obj/007c2b2500000002
+/tmp/sheepdog/092/4/obj/007c2b2500000000
+/tmp/sheepdog/092/4/obj/007c2b2500000002
+/tmp/sheepdog/092/5/obj/007c2b2500000000
+/tmp/sheepdog/092/5/obj/007c2b2500000001
+/tmp/sheepdog/092/5/obj/007c2b2500000002
+
+### 4 REPLICA
+
+$ ../../dog/dog vdi copies test 4
+test's replica number is set to 4, the old one was 5.
+ __
+ ()'`;
+ /\|` Caution! Changing the # of replica will affect
+ / | the specified VDI and trigger recovery.
+(/_)_|_ Are you sure you want to continue? [yes/no]:
+$ ../../dog/dog vdi list
+ Name Id Size Used Shared Creation time VDI id Copies Tag
+ test 0 12 MB 12 MB 0.0 MB DATE 7c2b25 4
+
+#### VDI OBJECT LIST
+
+/tmp/sheepdog/092/1/obj/807c2b2500000000
+/tmp/sheepdog/092/2/obj/807c2b2500000000
+/tmp/sheepdog/092/4/obj/807c2b2500000000
+/tmp/sheepdog/092/5/obj/807c2b2500000000
+
+#### DATA OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/007c2b2500000000
+/tmp/sheepdog/092/0/obj/007c2b2500000001
+/tmp/sheepdog/092/0/obj/007c2b2500000002
+/tmp/sheepdog/092/1/obj/007c2b2500000000
+/tmp/sheepdog/092/1/obj/007c2b2500000001
+/tmp/sheepdog/092/2/obj/007c2b2500000002
+/tmp/sheepdog/092/3/obj/007c2b2500000000
+/tmp/sheepdog/092/3/obj/007c2b2500000001
+/tmp/sheepdog/092/4/obj/007c2b2500000000
+/tmp/sheepdog/092/4/obj/007c2b2500000002
+/tmp/sheepdog/092/5/obj/007c2b2500000001
+/tmp/sheepdog/092/5/obj/007c2b2500000002
+
+### 3 REPLICA
+
+$ ../../dog/dog vdi copies test 3
+test's replica number is set to 3, the old one was 4.
+ __
+ ()'`;
+ /\|` Caution! Changing the # of replica will affect
+ / | the specified VDI and trigger recovery.
+(/_)_|_ Are you sure you want to continue? [yes/no]:
+$ ../../dog/dog vdi list
+ Name Id Size Used Shared Creation time VDI id Copies Tag
+ test 0 12 MB 12 MB 0.0 MB DATE 7c2b25 3
+
+#### VDI OBJECT LIST
+
+/tmp/sheepdog/092/1/obj/807c2b2500000000
+/tmp/sheepdog/092/2/obj/807c2b2500000000
+/tmp/sheepdog/092/4/obj/807c2b2500000000
+
+#### DATA OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/007c2b2500000000
+/tmp/sheepdog/092/0/obj/007c2b2500000001
+/tmp/sheepdog/092/0/obj/007c2b2500000002
+/tmp/sheepdog/092/1/obj/007c2b2500000000
+/tmp/sheepdog/092/1/obj/007c2b2500000001
+/tmp/sheepdog/092/2/obj/007c2b2500000002
+/tmp/sheepdog/092/3/obj/007c2b2500000000
+/tmp/sheepdog/092/5/obj/007c2b2500000001
+/tmp/sheepdog/092/5/obj/007c2b2500000002
+
+### 2 REPLICA
+
+$ ../../dog/dog vdi copies test 2
+test's replica number is set to 2, the old one was 3.
+ __
+ ()'`;
+ /\|` Caution! Changing the # of replica will affect
+ / | the specified VDI and trigger recovery.
+(/_)_|_ Are you sure you want to continue? [yes/no]:
+$ ../../dog/dog vdi list
+ Name Id Size Used Shared Creation time VDI id Copies Tag
+ test 0 12 MB 12 MB 0.0 MB DATE 7c2b25 2
+
+#### VDI OBJECT LIST
+
+/tmp/sheepdog/092/2/obj/807c2b2500000000
+/tmp/sheepdog/092/4/obj/807c2b2500000000
+
+#### DATA OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/007c2b2500000001
+/tmp/sheepdog/092/0/obj/007c2b2500000002
+/tmp/sheepdog/092/1/obj/007c2b2500000000
+/tmp/sheepdog/092/1/obj/007c2b2500000001
+/tmp/sheepdog/092/3/obj/007c2b2500000000
+/tmp/sheepdog/092/5/obj/007c2b2500000002
+
+### 1 REPLICA
+
+$ ../../dog/dog vdi copies test 1
+test's replica number is set to 1, the old one was 2.
+ __
+ ()'`;
+ /\|` Caution! Changing the # of replica will affect
+ / | the specified VDI and trigger recovery.
+(/_)_|_ Are you sure you want to continue? [yes/no]:
+$ ../../dog/dog vdi list
+ Name Id Size Used Shared Creation time VDI id Copies Tag
+ test 0 12 MB 12 MB 0.0 MB DATE 7c2b25 1
+
+#### VDI OBJECT LIST
+
+/tmp/sheepdog/092/2/obj/807c2b2500000000
+
+#### DATA OBJECT LIST
+
+/tmp/sheepdog/092/0/obj/007c2b2500000001
+/tmp/sheepdog/092/0/obj/007c2b2500000002
+/tmp/sheepdog/092/1/obj/007c2b2500000000
+
+-----
+
diff --git a/tests/functional/group b/tests/functional/group
index 7e747c3..2695f93 100644
--- a/tests/functional/group
+++ b/tests/functional/group
@@ -106,3 +106,4 @@
089 auto quick sheepfs
090 auto quick vdi md
091 auto quick cluster md
+092 auto quick cluster
--
1.8.3.2
More information about the sheepdog
mailing list