forked from rethinkdb/rethinkdb
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetect_dead.py
More file actions
executable file
·45 lines (42 loc) · 2.13 KB
/
detect_dead.py
File metadata and controls
executable file
·45 lines (42 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# Copyright 2010-2012 RethinkDB, all rights reserved.
import sys, os, time
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir, 'common')))
import driver, http_admin, scenario_common
from vcoptparse import *
op = OptParser()
scenario_common.prepare_option_parser_mode_flags(op)
opts = op.parse(sys.argv)
with driver.Metacluster() as metacluster:
cluster1 = driver.Cluster(metacluster)
executable_path, command_prefix, serve_options = scenario_common.parse_mode_flags(opts)
print "Spinning up two processes..."
files1 = driver.Files(metacluster, log_path = "create-output-1",
executable_path = executable_path, command_prefix = command_prefix)
proc1 = driver.Process(cluster1, files1,
executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options)
files2 = driver.Files(metacluster, log_path = "create-output-2",
executable_path = executable_path, command_prefix = command_prefix)
proc2 = driver.Process(cluster1, files2,
executable_path = executable_path, command_prefix = command_prefix, extra_options = serve_options)
proc1.wait_until_started_up()
proc2.wait_until_started_up()
cluster1.check()
access1 = http_admin.ClusterAccess([("localhost", proc1.http_port)])
access2 = http_admin.ClusterAccess([("localhost", proc2.http_port)])
assert len(access1.get_directory()) == len(access2.get_directory()) == 2
print "Splitting cluster, then waiting 20s..."
cluster2 = driver.Cluster(metacluster)
metacluster.move_processes(cluster1, cluster2, [proc2])
time.sleep(20)
print "Checking that they detected the netsplit..."
assert len(access1.get_directory()) == len(access2.get_directory()) == 1
cluster1.check()
cluster2.check()
print "Joining cluster, then waiting 10s..."
metacluster.move_processes(cluster2, cluster1, [proc2])
time.sleep(10)
print "Checking that they detected the resolution..."
assert len(access1.get_directory()) == len(access2.get_directory()) == 2
cluster1.check_and_stop()
print "Done."