forked from thepaul/cassandra-dtest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsstablesplit_test.py
67 lines (59 loc) · 2.7 KB
/
sstablesplit_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from dtest import Tester, debug
from os.path import getsize
import time
class TestSSTableSplit(Tester):
def split_test(self):
"""
Check that after running compaction, sstablessplit can succesfully split
The resultant sstable. Check that split is reversable and that data is readable
after carrying out these operations.
"""
cluster = self.cluster
cluster.populate(1).start()
node = cluster.nodelist()[0]
version = cluster.version()
# Here we need to wait to connect
# to the node. This is required for windows
# to prevent stress starting before the node
# is ready for connections
node.watch_log_for('thrift clients...')
debug("Run stress to insert data")
if version < "2.1":
node.stress( ['-o', 'insert'] )
else:
node.stress( ['write', 'n=1000000', '-rate', 'threads=50'] )
self._do_compaction(node)
self._do_split(node, version)
self._do_compaction(node)
self._do_split(node, version)
debug("Run stress to ensure data is readable")
if version < "2.1":
node.stress( ['-o', 'read'] )
else:
node.stress( ['read', 'n=1000000', '-rate', 'threads=25'] )
def _do_compaction(self, node):
debug("Compact sstables.")
node.flush()
node.compact()
node.flush()
keyspace = 'keyspace1' if self.cluster.version() >= '2.1' else 'Keyspace1'
sstables = node.get_sstables(keyspace, '')
debug("Number of sstables after compaction: %s" % len(sstables))
def _do_split(self, node, version):
debug("Run sstablesplit")
time.sleep(5.0)
node.stop()
keyspace = 'keyspace1' if self.cluster.version() >= '2.1' else 'Keyspace1'
origsstable = node.get_sstables(keyspace, '')
debug("Original sstable before split: %s" % origsstable)
node.run_sstablesplit( keyspace=keyspace )
sstables = node.get_sstables(keyspace, '')
debug("Number of sstables after split: %s" % len(sstables))
if version < "2.1":
assert len(sstables) == 6, "Incorrect number of sstables after running sstablesplit."
assert max( [ getsize( sstable ) for sstable in sstables ] ) <= 52428960, "Max sstables size should be 52428960."
else:
assert len(sstables) == 7, "Incorrect number of sstables after running sstablesplit."
sstables.remove(origsstable[0]) # newer sstablesplit does not remove the original sstable after split
assert max( [ getsize( sstable ) for sstable in sstables ] ) <= 52428980, "Max sstables size should be 52428980."
node.start()