[Sheepdog] [RFC PATCH 4/4] tests: add sample testcases
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Fri Oct 28 06:08:28 CEST 2011
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
tests/test_membership.py | 70 ++++++++++++++++++++++++++++++++++++++++++++++
tests/test_vdi.py | 26 +++++++++++++++++
2 files changed, 96 insertions(+), 0 deletions(-)
create mode 100644 tests/test_membership.py
create mode 100644 tests/test_vdi.py
diff --git a/tests/test_membership.py b/tests/test_membership.py
new file mode 100644
index 0000000..a670278
--- /dev/null
+++ b/tests/test_membership.py
@@ -0,0 +1,70 @@
+from sheepdog_test import *
+import time
+
+
+def test_simultaneous_startup():
+ """Start multiple sheep daemons at the same time"""
+
+ nr_nodes = 8
+ sdog = Sheepdog(nr_nodes)
+
+ # start 8 daemons at the same time
+ for n in sdog.nodes:
+ n.start()
+
+ for n in sdog.nodes:
+ n.wait()
+
+ for n in sdog.nodes:
+ p = n.run_collie('node list -r')
+ (out, _) = p.communicate()
+ assert len(out.splitlines()) == nr_nodes
+
+
+def test_mastership():
+ """Check master transfer."""
+
+ nr_nodes = 3
+ sdog = Sheepdog(nr_nodes)
+
+ sdog.nodes[0].start()
+ sdog.nodes[0].wait()
+
+ # start Sheepdog with one node
+ p = sdog.format()
+ p.wait()
+
+ sdog.nodes[1].start()
+ sdog.nodes[1].wait()
+
+ # give mastership to nodes[1]
+ sdog.nodes[0].stop()
+
+ sdog.nodes[2].start()
+ sdog.nodes[2].wait()
+
+ # give mastership to nodes[2]
+ sdog.nodes[1].stop()
+
+ # FIXME: wait until nodes[2] updates membership
+ time.sleep(0.5)
+ sdog.nodes[2].stop()
+
+ for n in sdog.nodes:
+ n.start()
+ n.wait()
+
+ # only nodes[2] should be in the cluster
+ p = sdog.nodes[2].run_collie('node list -r')
+ (out, _) = p.communicate()
+ assert len(out.splitlines()) == 1
+
+ sdog.nodes[0].start()
+ sdog.nodes[0].wait()
+ sdog.nodes[1].start()
+ sdog.nodes[1].wait()
+
+ for n in sdog.nodes:
+ p = n.run_collie('node list -r')
+ (out, _) = p.communicate()
+ assert len(out.splitlines()) == nr_nodes
diff --git a/tests/test_vdi.py b/tests/test_vdi.py
new file mode 100644
index 0000000..b77562d
--- /dev/null
+++ b/tests/test_vdi.py
@@ -0,0 +1,26 @@
+from sheepdog_test import *
+import time
+
+
+def test_create_vdi():
+ """Create many VDIs at the same time."""
+
+ nr_vdis = 5
+ sdog = Sheepdog()
+
+ for n in sdog.nodes:
+ n.start()
+ n.wait()
+
+ p = sdog.format()
+ p.wait()
+
+ # create VDIs at the same time
+ vdis = [sdog.create_vdi(str(i), 4 * 1024 ** 3) for i in range(nr_vdis)]
+ for v in vdis:
+ v.wait()
+
+ time.sleep(1)
+ p = n.run_collie('vdi list -r')
+ (out, _) = p.communicate()
+ assert len(out.splitlines()) == nr_vdis
--
1.7.2.5
More information about the sheepdog
mailing list