Skip to content

Commit c4d608d

Browse files
committed
Fix _test_relocation_with_concurrent_indexing
1 parent bb93bd2 commit c4d608d

File tree

1 file changed

+28
-26
lines changed

1 file changed

+28
-26
lines changed

tests/bwc/test_recovery.py

+28-26
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ def test(self):
1515
self._run_tests(
1616
[
1717
UpgradePath('4.2.x', '4.3.x'),
18-
# UpgradePath('4.3.0', 'latest-nightly'),
18+
UpgradePath('4.3.0', 'latest-nightly'),
1919
],
2020
[
21-
self._test_recovery_with_concurrent_indexing,
22-
#self._test_recovery,
23-
#self._test_update_docs,
24-
#self._test_recovery_closed_index,
25-
#self._test_closed_index_during_rolling_upgrade,
26-
#self._test_auto_expand_indices_during_rolling_upgrade,
27-
#self._test_retention_leases_established_when_promoting_primary,
28-
#self._test_closed_index_noop_recovery,
29-
# self._test_relocation_with_concurrent_indexing
21+
self._test_relocation_with_concurrent_indexing,
22+
self._test_recovery,
23+
self._test_update_docs,
24+
self._test_recovery_closed_index,
25+
self._test_closed_index_during_rolling_upgrade,
26+
self._test_auto_expand_indices_during_rolling_upgrade,
27+
self._test_retention_leases_established_when_promoting_primary,
28+
self._test_closed_index_noop_recovery,
29+
self._test_relocation_with_concurrent_indexing
3030
]
3131
)
3232

@@ -206,41 +206,43 @@ def _test_relocation_with_concurrent_indexing(self, path, nodes):
206206
# remove the replica and guaranteed the primary is placed on the old node
207207
c.execute('''alter table doc.test set (
208208
"number_of_replicas"=0,
209-
"routing.allocation.enable"='NONE',
209+
"routing.allocation.enable"='all',
210210
"routing.allocation.include._id"=?
211211
)''', (old_node_id, ))
212212

213213
self._assert_is_green(conn, 'doc', 'test')
214214

215215
c.execute('''alter table doc.test set ("routing.allocation.include._id"=?)''', (new_node_id, ))
216-
217216
insert_data(conn, 'doc', 'test', 50)
218-
self._assert_is_green(conn, 'doc', 'test')
219217

218+
# ensure the relocation from old node to new node has occurred; otherwise ensureGreen can
219+
# return true even though shards haven't moved to the new node yet (allocation was throttled).
220+
time.sleep(3)
221+
c.execute('select current_state from sys.allocations where node_id =?', (new_node_id,))
222+
current_state = c.fetchone()[0]
223+
self.assertEqual(current_state, 'STARTED')
224+
self._assert_is_green(conn, 'doc', 'test')
220225
c.execute('refresh table doc.test')
221-
222-
c.execute('select count(*) from doc.test')
223-
res = c.fetchone()
224-
self.assertEqual(res[0], 60)
226+
self._assert_count_by_node_id(conn, 'doc', 'test', new_node_id, 60)
225227

226228
# upgrade the whole cluster to the new version
227229
self._upgrade_cluster(cluster, path.to_version, nodes)
228230

229-
c.execute('''
230-
alter table doc.test set(
231-
"number_of_replicas"=2,
232-
"routing.allocation.include._id"='null')
233-
''')
231+
c.execute('''alter table doc.test set("number_of_replicas"=2)''')
232+
c.execute('''alter table doc.test reset("routing.allocation.include._id")''')
234233

235234
insert_data(conn, 'doc', 'test', 45)
236235

237-
time.sleep(30)
236+
time.sleep(10)
238237
self._assert_is_green(conn, 'doc', 'test')
239238
c.execute('refresh table doc.test')
239+
time.sleep(5)
240+
c.execute('select id from sys.nodes')
241+
node_ids = c.fetchall()
242+
self.assertEqual(len(node_ids), 3)
240243

241-
c.execute('select count(*) from doc.test')
242-
res = c.fetchone()
243-
self.assertEqual(res[0], 105)
244+
for node_id in node_ids:
245+
self._assert_count_by_node_id(conn, 'doc', 'test', node_id[0], 105)
244246

245247
def _test_recovery(self, path, nodes):
246248
"""

0 commit comments

Comments
 (0)