Skip to content

Commit

Permalink
Before all tests refresh and delete indices
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Aug 8, 2024
1 parent a2c0a8d commit 04e03c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ def run_test_benchmarks(cluster: Cluster):

# As a default we exclude system indices and searchguard indices
def clear_indices(cluster: Cluster):
try:
cluster.call_api("/_refresh", method=HttpMethod.POST, params={"ignore_unavailable": "true"})
except Exception as e:
logging.debug(f"Ignoring error received when attempting to refresh indexes: {e}")

clear_indices_path = "/*,-.*,-searchguard*,-sg7*,.migrations_working_state"
r = cluster.call_api(clear_indices_path, method=HttpMethod.DELETE, params={"ignore_unavailable": "true"})
return r.content
try:
r = cluster.call_api(clear_indices_path, method=HttpMethod.DELETE, params={"ignore_unavailable": "true"})
return r.content
except Exception as e:
logging.debug(f"Ignoring error recieved when attempting to delete indexes: {e}")
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ def setup_replayer(request):
wait_for_running_replayer(replayer=replayer)


@pytest.fixture(scope="function", autouse=True)
def clear_cluster():
logger.info("Clearing out all cluster contents")

source_cluster: Cluster = pytest.console_env.source_cluster
target_cluster: Cluster = pytest.console_env.target_cluster

clear_indices(source_cluster)
clear_indices(target_cluster)


@pytest.fixture(scope="session", autouse=True)
def cleanup_after_tests():
# Setup code
Expand Down Expand Up @@ -94,7 +105,6 @@ def test_replayer_0001_empty_index(self):
get_index(cluster=target_cluster, index_name=index_name, expected_status_code=HTTPStatus.NOT_FOUND,
test_case=self)

@unittest.skip("Flaky test - https://opensearch.atlassian.net/browse/MIGRATIONS-1925")
def test_replayer_0002_single_document(self):
# This test will verify that a document will be created (then deleted) on the target cluster when one is created
# on the source cluster by going through the proxy first. It will verify that the traffic is captured by the
Expand Down

0 comments on commit 04e03c0

Please sign in to comment.