Test the dev command — developer-role overlay for inner-loop iteration.
(c: Composition, parser: WorkflowArgumentParser)
| 1037 | |
| 1038 | |
| 1039 | def workflow_dev(c: Composition, parser: WorkflowArgumentParser) -> None: |
| 1040 | """Test the dev command — developer-role overlay for inner-loop iteration.""" |
| 1041 | setup_base(c) |
| 1042 | |
| 1043 | # Apply v1 for infrastructure, then stage + wait + promote so the ops |
| 1044 | # schema's MV is tracked as a production deployment on the `compute` |
| 1045 | # cluster. That promotion is what the dev-time cluster guard reads from. |
| 1046 | result = run_mz_deploy(c, "dev-basic/v1", "apply") |
| 1047 | assert result.returncode == 0, f"apply v1 failed: {result.stderr}" |
| 1048 | |
| 1049 | result = run_mz_deploy( |
| 1050 | c, "dev-basic/v1", "stage", "--deploy-id", "v1", "--allow-dirty" |
| 1051 | ) |
| 1052 | assert result.returncode == 0, f"stage v1 failed: {result.stderr}" |
| 1053 | |
| 1054 | result = run_mz_deploy( |
| 1055 | c, |
| 1056 | "dev-basic/v1", |
| 1057 | "wait", |
| 1058 | "v1", |
| 1059 | "--timeout", |
| 1060 | "300", |
| 1061 | "--allowed-lag", |
| 1062 | "86400", |
| 1063 | ) |
| 1064 | assert result.returncode == 0, f"wait v1 failed: {result.stderr}" |
| 1065 | |
| 1066 | result = run_mz_deploy(c, "dev-basic/v1", "promote", "v1", "--no-ready-check") |
| 1067 | assert result.returncode == 0, f"promote v1 failed: {result.stderr}" |
| 1068 | |
| 1069 | # Grant dev_user privileges on the app database so it can read production |
| 1070 | # tables when building the overlay MV (CREATEDB is already granted by |
| 1071 | # setup_base; only schema/table access needs to be added here). |
| 1072 | # Use mz_system (port 6877) because app is owned by deploy_user, not |
| 1073 | # materialize, so the default superuser cannot grant on it directly. |
| 1074 | c.sql( |
| 1075 | "GRANT USAGE ON DATABASE app TO dev_user", |
| 1076 | user="mz_system", |
| 1077 | port=6877, |
| 1078 | ) |
| 1079 | rows = c.sql_query( |
| 1080 | "SELECT name FROM mz_schemas WHERE database_id = " |
| 1081 | "(SELECT id FROM mz_databases WHERE name = 'app')", |
| 1082 | ) |
| 1083 | for (schema,) in rows: |
| 1084 | c.sql( |
| 1085 | f"GRANT USAGE ON SCHEMA app.{schema} TO dev_user", |
| 1086 | user="mz_system", |
| 1087 | port=6877, |
| 1088 | ) |
| 1089 | c.sql( |
| 1090 | f"GRANT SELECT ON ALL TABLES IN SCHEMA app.{schema} TO dev_user", |
| 1091 | user="mz_system", |
| 1092 | port=6877, |
| 1093 | ) |
| 1094 | |
| 1095 | # Provision a dedicated dev cluster that the `dev` profile routes to |
| 1096 | # via [dev.variables].compute_cluster = "compute_dev". The |
nothing calls this directly
no test coverage detected