1
0
Fork 0

Add end-to-end test of dealing with chunked loads

This test is to ensure that if an older system with this type of
commands present in the log can be handled OK.
master
Philip O'Toole 9 months ago
parent a56f2aca6f
commit 13da479048

@ -60,6 +60,11 @@ def temp_file():
f.close()
return f.name
def copy_dir(src):
temp_dir = tempfile.mkdtemp()
shutil.copytree(src, temp_dir, dirs_exist_ok=True)
return temp_dir
def write_random_file(data, mode='w'):
f = tempfile.NamedTemporaryFile(mode, delete=False)
f.write(data)

Binary file not shown.

Binary file not shown.

@ -2,20 +2,23 @@
import os
import unittest
from helpers import Node, Cluster, d_
from helpers import Node, Cluster, d_, deprovision_node, copy_dir
RQLITED_PATH = os.environ['RQLITED_PATH']
class TestUpgrade_v7(unittest.TestCase):
'''Test that a v7 cluster can be upgraded to this version code'''
def test(self):
n0 = Node(RQLITED_PATH, '1', api_addr='localhost:4001', raft_addr='localhost:4002', dir='testdata/v7/data.1')
dir1 = copy_dir('testdata/v7/data.1')
n0 = Node(RQLITED_PATH, '1', api_addr='localhost:4001', raft_addr='localhost:4002', dir=dir1)
n0.start()
n1 = Node(RQLITED_PATH, '2', api_addr='localhost:4003', raft_addr='localhost:4004', dir='testdata/v7/data.2')
dir2 = copy_dir('testdata/v7/data.2')
n1 = Node(RQLITED_PATH, '2', api_addr='localhost:4003', raft_addr='localhost:4004', dir=dir2)
n1.start()
n2 = Node(RQLITED_PATH, '3', api_addr='localhost:4005', raft_addr='localhost:4006', dir='testdata/v7/data.3')
dir3 = copy_dir('testdata/v7/data.3')
n2 = Node(RQLITED_PATH, '3', api_addr='localhost:4005', raft_addr='localhost:4006', dir=dir3)
n2.start()
self.cluster = Cluster([n0, n1, n2])
@ -23,7 +26,7 @@ class TestUpgrade_v7(unittest.TestCase):
# Check that each node upgraded a snapshot.
for n in self.cluster.nodes:
self.assertTrue(n.expvar()['snapshot']['upgrade_ok'] == 1)
self.assertEqual(n.expvar()['snapshot']['upgrade_ok'], 1)
# Check that each node has the right data.
for n in self.cluster.nodes:
@ -32,5 +35,17 @@ class TestUpgrade_v7(unittest.TestCase):
def tearDown(self):
self.cluster.deprovision()
class TestUpgrade_v8_LoadChunk(unittest.TestCase):
'''Test that a v8 node with chunked load commands in the log can be upgraded to this version code'''
def test(self):
dir = copy_dir('testdata/v8/chunked')
self.n = Node(RQLITED_PATH, 'localhost:4002', api_addr='localhost:4001', raft_addr='localhost:4002', dir=dir)
self.n.start()
l = self.n.wait_for_leader()
self.assertEqual(self.n.query('SELECT COUNT(*) FROM foo', level='none'), d_("{'results': [{'values': [[1]], 'types': ['integer'], 'columns': ['COUNT(*)']}]}"))
def tearDown(self):
deprovision_node(self.n)
if __name__ == "__main__":
unittest.main(verbosity=2)

Loading…
Cancel
Save