| 23 | |
| 24 | |
| 25 | def workflow_default(c: Composition) -> None: |
| 26 | # Create config file in MZ_ROOT directory |
| 27 | mz_root = Path(os.environ.get("MZ_ROOT", Path(__file__).parent.parent.parent)) |
| 28 | config_file = mz_root / "dyncfg-test-config.json" |
| 29 | |
| 30 | try: |
| 31 | system_params_1 = { |
| 32 | "max_connections": 1000, |
| 33 | } |
| 34 | |
| 35 | # Create a ConfigMap with the system parameters in JSON format |
| 36 | with open(config_file, "w", encoding="utf-8") as f: |
| 37 | f.write(json.dumps(system_params_1)) |
| 38 | f.flush() |
| 39 | os.fsync(f.fileno()) |
| 40 | |
| 41 | print(f"config file is {config_file}") |
| 42 | with c.override(Materialized(config_sync_file_path=str(config_file))): |
| 43 | c.up( |
| 44 | "materialized", |
| 45 | Service("testdrive", idle=True), |
| 46 | ) |
| 47 | |
| 48 | # Wait for dyncfg to sync |
| 49 | # Locally this works more or less immediately, but |
| 50 | # seems to be failing CI. |
| 51 | c.sleep(10) |
| 52 | c.testdrive( |
| 53 | input=dedent(""" |
| 54 | > SHOW max_connections |
| 55 | 1000 |
| 56 | """), |
| 57 | ) |
| 58 | |
| 59 | system_params_2 = { |
| 60 | "max_connections": 67, |
| 61 | # This is a bit awkward, but it works. |
| 62 | "allowed_cluster_replica_sizes": "'25cc','50cc'", |
| 63 | } |
| 64 | |
| 65 | # Write updated parameters to the file |
| 66 | with open(config_file, "w", encoding="utf-8") as f: |
| 67 | f.write(json.dumps(system_params_2)) |
| 68 | f.flush() |
| 69 | os.fsync(f.fileno()) |
| 70 | # Wait for dyncfg to sync |
| 71 | c.sleep(2) |
| 72 | c.testdrive( |
| 73 | input=dedent(""" |
| 74 | > SHOW max_connections |
| 75 | 67 |
| 76 | |
| 77 | > SHOW allowed_cluster_replica_sizes |
| 78 | "\\"25cc\\", \\"50cc\\"" |
| 79 | """), |
| 80 | ) |
| 81 | finally: |
| 82 | # Clean up the config file |