@@ -100,6 +100,16 @@ def alter_system_reset(name: str) -> str:
100
100
).strip ()
101
101
102
102
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
+
103
113
class FeatureTestScenario :
104
114
"""
105
115
A base class for all feature test scenarios.
@@ -166,6 +176,19 @@ def phase3(cls) -> str:
166
176
]
167
177
)
168
178
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
+
169
192
@classmethod
170
193
def feature_name (cls ) -> str :
171
194
"""The name of the feature flag under test."""
@@ -314,6 +337,37 @@ def run_test(c: Composition, args: argparse.Namespace) -> None:
314
337
tmp .flush ()
315
338
c .exec ("testdrive" , os .path .basename (tmp .name ))
316
339
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
+
317
371
318
372
def workflow_default (c : Composition , parser : WorkflowArgumentParser ) -> None :
319
373
parser .add_argument (
0 commit comments