Skip to content

Commit 5170034

Browse files
author
Sean Loiselle
committed
test: add dedicated ALTER SYSTEM RESET ALL test
1 parent 4c43c9d commit 5170034

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/sql-feature-flags/mzcompose.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ def alter_system_reset(name: str) -> str:
100100
).strip()
101101

102102

103+
def alter_system_reset_all() -> str:
104+
"""Generate a TD command that reset all system parameters."""
105+
return dedent(
106+
"""
107+
$ postgres-execute connection=mz_system
108+
ALTER SYSTEM RESET ALL;
109+
"""
110+
).strip()
111+
112+
103113
class FeatureTestScenario:
104114
"""
105115
A base class for all feature test scenarios.
@@ -166,6 +176,19 @@ def phase3(cls) -> str:
166176
]
167177
)
168178

179+
@classmethod
180+
def reset_all(cls) -> str:
181+
return "\n\n".join(
182+
[
183+
cls.initialize(),
184+
# The feature is immediately turned on because it's a default parameter.
185+
statement_ok(cls.create_item(ordinal=1)),
186+
query_ok(cls.query_item(ordinal=1)),
187+
# We can drop item #1.
188+
statement_ok(cls.drop_item(ordinal=1)),
189+
]
190+
)
191+
169192
@classmethod
170193
def feature_name(cls) -> str:
171194
"""The name of the feature flag under test."""
@@ -314,6 +337,37 @@ def run_test(c: Composition, args: argparse.Namespace) -> None:
314337
tmp.flush()
315338
c.exec("testdrive", os.path.basename(tmp.name))
316339

340+
# Dedicated test for ALTER SYSTEM RESET ALL
341+
with tempfile.NamedTemporaryFile(
342+
mode="w",
343+
dir=c.path,
344+
prefix="phase-reset-all-",
345+
) as tmp:
346+
tmp_buf = [header("(phase reset-all)", drop_schema=False)]
347+
for scenario in scenarios:
348+
# Turn all features off.
349+
tmp_buf.append(alter_system_set(scenario.feature_name(), "off"))
350+
351+
# Run ALTER SYSTEM RESET ALL
352+
tmp_buf.append(alter_system_reset_all())
353+
for scenario in scenarios:
354+
# Write each scenarios reset all data
355+
tmp_buf.append(scenario.reset_all())
356+
357+
# Create MZ config with all features set on by default
358+
materialized = Materialized(
359+
unsafe_mode=False,
360+
additional_system_parameter_defaults=list(
361+
map(lambda scenario: "{}=on".format(scenario.feature_name()), scenarios)
362+
),
363+
)
364+
with c.override(materialized):
365+
c.stop("materialized")
366+
c.up("materialized")
367+
tmp.write("\n\n".join(tmp_buf))
368+
tmp.flush()
369+
c.exec("testdrive", os.path.basename(tmp.name))
370+
317371

318372
def workflow_default(c: Composition, parser: WorkflowArgumentParser) -> None:
319373
parser.add_argument(

0 commit comments

Comments
 (0)