-
Notifications
You must be signed in to change notification settings - Fork 82
/
bootstrap_test.py
47 lines (35 loc) · 1.21 KB
/
bootstrap_test.py
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
45
46
47
import random, time
from dtest import Tester
from tools import *
from assertions import *
from ccmlib.node import Node
class TestBoostrap(Tester):
def simple_bootstrap_test(self):
cluster = self.cluster
keys = 100000
# Create a single node cluster
cluster.populate(1, tokens=[0]).start()
node1 = cluster.nodes["node1"]
time.sleep(.5)
cursor = self.cql_connection(node1).cursor()
self.create_ks(cursor, 'ks', 1)
self.create_cf(cursor, 'cf')
for n in xrange(0, keys):
insert_c1c2(cursor, n, "ONE")
node1.flush()
initial_size = node1.data_size()
# Reads inserted data all during the boostrap process. We shouldn't
# get any error
reader = self.go(lambda _: query_c1c2(cursor, random.randint(0, keys-1), "ONE"))
# Boostraping a new node
node2 = new_node(cluster, token=2**126)
node2.start()
time.sleep(.5)
reader.check()
node1.cleanup()
time.sleep(.5)
reader.check()
size1 = node1.data_size()
size2 = node2.data_size()
assert_almost_equal(size1, size2)
assert_almost_equal(initial_size, 2 * size1)