From 58be850d5caac561ce40da5c35d7928e020bbf47 Mon Sep 17 00:00:00 2001 From: Ivan Paljak Date: Mon, 2 Sep 2019 15:08:53 +0200 Subject: [PATCH] Fix HA log compaction test Summary: The test now checks if the cluster is alive at the end of the test. Reviewers: mferencevic Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2343 --- tests/integration/ha/ha_test.py | 7 +++++++ tests/integration/ha/log_compaction/runner.py | 10 ++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/integration/ha/ha_test.py b/tests/integration/ha/ha_test.py index 0dc72f5bf..611b07ab0 100644 --- a/tests/integration/ha/ha_test.py +++ b/tests/integration/ha/ha_test.py @@ -76,6 +76,13 @@ class HaTestBase: self._wait_for_server(7687 + worker_id) + def is_worker_alive(self, worker_id): + assert worker_id >= 0 and worker_id < self.cluster_size, \ + "Invalid worker ID {}".format(worker_id) + return self.workers[worker_id] is None or \ + self.workers[worker_id].poll() is None + + def execute(self): raise NotImplementedError() diff --git a/tests/integration/ha/log_compaction/runner.py b/tests/integration/ha/log_compaction/runner.py index f2a31f0c8..ea14d11c2 100755 --- a/tests/integration/ha/log_compaction/runner.py +++ b/tests/integration/ha/log_compaction/runner.py @@ -45,7 +45,7 @@ class HaLogCompactionTest(HaTestBase): snapshots = os.listdir(dur) assert len(snapshots) == 1, \ - "More than one snapshot on worker {}!".format(worker_id) + "More than one snapshot on worker {}!".format(worker_id + 1) return os.path.join(dur, snapshots[0]) @@ -55,7 +55,8 @@ class HaLogCompactionTest(HaTestBase): self.start_worker(worker_id) time.sleep(5) - self.execute_step("CREATE (:Node)\n" * 128) + assert self.execute_step("CREATE (:Node)\n" * 128) == 0, \ + "Error while executing create query" self.start_worker(0) @@ -69,6 +70,11 @@ class HaLogCompactionTest(HaTestBase): success = True break + # Check if the cluster is alive + for worker_id in range(self.cluster_size): + assert self.is_worker_alive(worker_id), \ + "Worker {} died prematurely".format(worker_id + 1) + assert success, "Snapshot didn't transfer successfully"