1
0
Fork 0

Add end-to-end Boot test

master
Philip O'Toole 9 months ago
parent b70212cffc
commit ad97bd74f8

@ -502,7 +502,7 @@ class Node(object):
raise_for_status(r)
def restore(self, file, fmt=None):
# This is the one API that doesn't expect JSON.
# This is an API that doesn't expect JSON.
if fmt != "binary":
conn = sqlite3.connect(file)
r = requests.post(self._load_url(), data='\n'.join(conn.iterdump()))
@ -515,6 +515,13 @@ class Node(object):
r = requests.post(self._load_url(), data=data, headers={'Content-Type': 'application/octet-stream'})
raise_for_status(r)
def boot(self, file):
# This is an API that doesn't expect JSON.
with open(file, 'rb') as f:
data = f.read()
r = requests.post(self._boot_url(), data=data, headers={'Content-Type': 'application/octet-stream'})
raise_for_status(r)
def redirect_addr(self):
r = requests.post(self._execute_url(redirect=True), data=json.dumps(['nonsense']), allow_redirects=False)
raise_for_status(r)
@ -568,6 +575,8 @@ class Node(object):
return 'http://' + self.APIAddr() + '/db/backup'
def _load_url(self):
return 'http://' + self.APIAddr() + '/db/load'
def _boot_url(self):
return 'http://' + self.APIAddr() + '/boot'
def _remove_url(self):
return 'http://' + self.APIAddr() + '/remove'
def __eq__(self, other):

@ -192,10 +192,32 @@ class TestSingleNodeLoadRestart(unittest.TestCase):
j = self.n.query('SELECT COUNT(*) from test')
self.assertEqual(j, d_("{'results': [{'values': [[1000]], 'types': ['integer'], 'columns': ['COUNT(*)']}]}"))
# Ensure node can restart after loading
# Ensure node can restart after loading and that the data is correct.
self.n.stop()
self.n.start()
self.n.wait_for_leader()
j = self.n.query('SELECT COUNT(*) from test')
self.assertEqual(j, d_("{'results': [{'values': [[1000]], 'types': ['integer'], 'columns': ['COUNT(*)']}]}"))
def tearDown(self):
deprovision_node(self.n)
class TestSingleNodeBootRestart(unittest.TestCase):
''' Test that a node can boot using a SQLite data set'''
def test(self):
self.n = Node(RQLITED_PATH, '0', raft_snap_threshold=8192, raft_snap_int="30s")
self.n.start()
n = self.n.wait_for_leader()
j = self.n.boot('system_test/e2e/testdata/1000-numbers.db')
j = self.n.query('SELECT COUNT(*) from test')
self.assertEqual(j, d_("{'results': [{'values': [[1000]], 'types': ['integer'], 'columns': ['COUNT(*)']}]}"))
# Ensure node can restart after booting and that the data is correct.
self.n.stop()
self.n.start()
self.n.wait_for_leader()
j = self.n.query('SELECT COUNT(*) from test')
self.assertEqual(j, d_("{'results': [{'values': [[1000]], 'types': ['integer'], 'columns': ['COUNT(*)']}]}"))
def tearDown(self):
deprovision_node(self.n)

Loading…
Cancel
Save