Skip to content

Commit d3455f1

Browse files
committed
WIP
1 parent e0bf903 commit d3455f1

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

tests/bwc/test_upgrade.py

+27-13
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
VersionDef('5.6.x', []),
4444
VersionDef('5.7.x', []),
4545
VersionDef('5.8.x', []),
46-
VersionDef('5.9.x', []),
46+
VersionDef('5.9.11', []),
4747
VersionDef('5.10.x', []),
4848
),
4949
(
@@ -56,7 +56,7 @@
5656
VersionDef('5.6.x', []),
5757
VersionDef('5.7.x', []),
5858
VersionDef('5.8.x', []),
59-
VersionDef('5.9.x', []),
59+
VersionDef('5.9.11', []),
6060
VersionDef('5.10.x', []),
6161
VersionDef('5.10', []),
6262
VersionDef('latest-nightly', [])
@@ -258,20 +258,22 @@ def _do_upgrade(self,
258258
assert_busy(lambda: self.assert_green(conn, 'blob', 'b1'))
259259
self.assertIsNotNone(container.get(digest))
260260

261+
accumulated_dynamic_column_names: list[str] = []
261262
self._process_on_stop()
262263
for version_def in versions[1:]:
263264
timestamp = datetime.utcnow().isoformat(timespec='seconds')
264265
print(f"{timestamp} Upgrade to: {version_def.version}")
265-
self.assert_data_persistence(version_def, nodes, digest, paths)
266+
self.assert_data_persistence(version_def, nodes, digest, paths, accumulated_dynamic_column_names)
266267
# restart with latest version
267268
version_def = versions[-1]
268-
self.assert_data_persistence(version_def, nodes, digest, paths)
269+
self.assert_data_persistence(version_def, nodes, digest, paths, accumulated_dynamic_column_names)
269270

270271
def assert_data_persistence(self,
271272
version_def: VersionDef,
272273
nodes: int,
273274
digest: str,
274-
paths: Iterable[str]):
275+
paths: Iterable[str],
276+
accumulated_dynamic_column_names: list[str]):
275277
env = prepare_env(version_def.java_home)
276278
version = version_def.version
277279
cluster = self._new_cluster(version, nodes, data_paths=paths, settings=self.CLUSTER_SETTINGS, env=env)
@@ -303,15 +305,27 @@ def assert_data_persistence(self,
303305
cursor.execute(f'select * from versioned."{table}"')
304306
cursor.execute(f'insert into versioned."{table}" (id, col_int) values (?, ?)', [str(uuid4()), 1])
305307

308+
# to trigger `alter` stmt bug(https://github.com/crate/crate/pull/17178) that falsely updated the table's
309+
# version created setting
310+
cursor.execute('ALTER TABLE doc.parted SET ("refresh_interval" = 900)')
311+
306312
# older versions had a bug that caused this to fail
307-
if version in ('latest-nightly', '3.2'):
308-
# Test that partition and dynamic columns can be created
309-
obj = {"t_" + version.replace('.', '_'): True}
310-
args = (str(uuid4()), version, obj)
311-
cursor.execute(
312-
'INSERT INTO doc.parted (id, version, cols) values (?, ?, ?)',
313-
args
314-
)
313+
# Test that partition and dynamic columns can be created
314+
key = "t_" + version.replace('.', '_')
315+
obj = {key: True}
316+
args = (str(uuid4()), version, obj)
317+
cursor.execute(
318+
'INSERT INTO doc.parted (id, version, cols) values (?, ?, ?)',
319+
args
320+
)
321+
assert_busy(lambda: self.assert_green(conn, 'doc', 'parted'))
322+
accumulated_dynamic_column_names.append(key)
323+
cursor.execute('SELECT cols from doc.parted')
324+
result = cursor.fetchall()
325+
for row in result:
326+
if row[0] is not None:
327+
for name in row[0].keys():
328+
self.assertIn(name, accumulated_dynamic_column_names)
315329
self._process_on_stop()
316330

317331
def assert_green(self, conn: Connection, schema: str, table_name: str):

0 commit comments

Comments
 (0)