Skip to content

Commit

Permalink
index_already_exists_exception was renamed to resource_already_exists…
Browse files Browse the repository at this point in the history
  • Loading branch information
AmitPhulera committed Nov 29, 2023
1 parent c721a2d commit 34e3c99
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
19 changes: 6 additions & 13 deletions corehq/apps/es/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,21 +267,14 @@ def _clear_cluster_routing(self, verify=False):
a transient setting once its set without restarting the cluster, so we
explicitly set the default value (`all`) instead.
"""
self.adapter.cluster_routing(enabled=True) # default value
try:
self.adapter._cluster_put_settings({"cluster.routing.allocation.enable": None})
except TransportError:
# TransportError(400, 'action_request_validation_exception', 'Validation Failed: 1: no settings to update;') # noqa: E501
pass
if verify:
settings = self.adapter._es.cluster.get_settings(flat_settings=True)
self.assertEqual(settings["transient"]["cluster.routing.allocation.enable"], "all")
#
# The code below is better. Use it instead when able Elastic v5+
#
#try:
# self.adapter._cluster_put_settings({"cluster.routing.allocation.enable": None})
#except TransportError:
# # TransportError(400, 'action_request_validation_exception', 'Validation Failed: 1: no settings to update;') # noqa: E501
# pass
#if verify:
# settings = self.adapter._es.cluster.get_settings(flat_settings=True)
# self.assertIsNone(settings["transient"].get("cluster.routing.allocation.enable"))
self.assertIsNone(settings["transient"].get("cluster.routing.allocation.enable"))

def test_get_node_info(self):
info = self.adapter._es.nodes.info()
Expand Down
10 changes: 8 additions & 2 deletions corehq/apps/es/tests/test_migration_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def test_fails_if_index_exists(self):
migration = TestMigration(CreateIndex(*self.create_index_args))
with self.assertRaises(RequestError) as context:
migration.apply()
self.assertEqual(context.exception.error, "index_already_exists_exception")
if manager.elastic_major_version >= 6:
self.assertEqual(context.exception.error, "resource_already_exists_exception")
else:
self.assertEqual(context.exception.error, "index_already_exists_exception")

def test_reverse_deletes_index(self):
migration = TestMigration(CreateIndex(*self.create_index_args))
Expand Down Expand Up @@ -443,7 +446,10 @@ def test_reverse_fails_if_index_exists(self):
)
with self.assertRaises(RequestError) as context:
migration.unapply()
self.assertEqual(context.exception.error, "index_already_exists_exception")
if manager.elastic_major_version >= 6:
self.assertEqual(context.exception.error, "resource_already_exists_exception")
else:
self.assertEqual(context.exception.error, "index_already_exists_exception")

def test_describe(self):
operation = DeleteIndex(self.index)
Expand Down

0 comments on commit 34e3c99

Please sign in to comment.