Skip to content

Commit 26832c8

Browse files
committed
tests: fix test_bad_contact_point
since recent changes to metadata, on first round we remove all host that we creating with unkown host_ids, so this test is failing cause it's expects all the corrent hosts to be available in the, metadata, they would be available, but they were missing. seems like we didn't update the peers with thier newly found host_ids and hence they were remove (only a new phase of `refresh_node_list_and_token_map()` would add them back to the hosts list), now that we update them same as we update the local (control_connection host), test is working.
1 parent 17b2dca commit 26832c8

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

cassandra/cluster.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3921,6 +3921,8 @@ def _refresh_node_list_and_token_map(self, connection, preloaded_results=None,
39213921
tokens = row.get("tokens", None)
39223922
if partitioner and tokens and self._token_meta_enabled:
39233923
token_map[host] = tokens
3924+
self._cluster.metadata.update_host(host, old_endpoint=endpoint)
3925+
39243926
for old_host_id, old_host in self._cluster.metadata.all_hosts_items():
39253927
if old_host_id not in found_host_ids:
39263928
should_rebuild_token_map = True

tests/integration/standard/test_metadata.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
greaterthanorequaldse67, lessthancass40,
4242
TestCluster, DSE_VERSION)
4343

44+
from tests.util import wait_until
4445

4546
log = logging.getLogger(__name__)
4647

@@ -124,7 +125,12 @@ def test_bad_contact_point(self):
124125
125126
@test_category metadata
126127
"""
127-
self.assertEqual(len(self.cluster.metadata.all_hosts()), 3)
128+
# wait until we have only 3 hosts
129+
wait_until(condition=lambda: len(self.cluster.metadata.all_hosts()) == 3, delay=0.5, max_attempts=5)
130+
131+
# verify the un-existing host was filtered
132+
for host in self.cluster.metadata.all_hosts():
133+
self.assertNotEquals(host.endpoint.address, '126.0.0.186')
128134

129135

130136
class SchemaMetadataTests(BasicSegregatedKeyspaceUnitTestCase):

0 commit comments

Comments
 (0)