[sheepdog] [PATCH] dog/vdi: bug fix for voting majority, add test case to test it

Ruoyu liangry at ucweb.com
Thu Apr 3 12:27:58 CEST 2014


There is a critical error in the function vote_majority_object.
When all the three copies are different, the original logic still
choose the last one as majority.
---
 tests/functional/091     | 34 ++++++++++++++++++++++++++++++++++
 tests/functional/091.out |  7 +++++++
 2 files changed, 41 insertions(+)
 create mode 100755 tests/functional/091
 create mode 100644 tests/functional/091.out

diff --git a/tests/functional/091 b/tests/functional/091
new file mode 100755
index 0000000..77c1f4d
--- /dev/null
+++ b/tests/functional/091
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# Test vote majority
+
+. ./common
+
+for i in 0 1 2; do
+    _start_sheep $i
+done
+_wait_for_sheep 3
+
+$DOG cluster format -c 3
+$DOG vdi create test 4M
+echo "hello, copy0" | $DOG vdi write test 0 12
+cp $STORE/0/obj/007c2b2500000000 $STORE/copy0
+echo "hello, copy1" | $DOG vdi write test 0 12
+cp $STORE/1/obj/007c2b2500000000 $STORE/copy1
+echo "hello, copy2" | $DOG vdi write test 0 12
+cp $STORE/2/obj/007c2b2500000000 $STORE/copy2
+
+cp $STORE/copy0 $STORE/0/obj/007c2b2500000000
+cp $STORE/copy1 $STORE/1/obj/007c2b2500000000
+
+$DOG vdi read test 0 12 -p 7000
+echo ""
+$DOG vdi read test 0 12 -p 7001
+echo ""
+$DOG vdi read test 0 12 -p 7002
+echo ""
+
+$DOG vdi check test
+
+$DOG cluster shutdown
+
diff --git a/tests/functional/091.out b/tests/functional/091.out
new file mode 100644
index 0000000..5b430a7
--- /dev/null
+++ b/tests/functional/091.out
@@ -0,0 +1,7 @@
+QA output created by 091
+using backend plain store
+hello, copy0
+hello, copy1
+hello, copy2
+no majority of 7c2b2500000000
+finish check&repair test
-- 
1.8.1.2





More information about the sheepdog mailing list