MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / workflow_default

Function workflow_default

test/gcp/mzcompose.py:279–353  ·  view source on GitHub ↗
(c: Composition)

Source from the content-addressed store, hash-verified

277
278
279def workflow_default(c: Composition) -> None:
280 bucket = _require_env("ICEBERG_GCS_BUCKET")
281 project = _require_env("ICEBERG_GCP_PROJECT")
282 sa_json_b64 = _require_env("ICEBERG_GCP_SA_JSON_B64")
283
284 service_account = json.loads(base64.b64decode(sa_json_b64))
285
286 # Per-run namespace so concurrent / repeated runs against the shared
287 # bucket don't collide on table state. The embedded date lets the pre-test
288 # sweep age out namespaces left behind by killed runs.
289 seed = random.getrandbits(32)
290 today = datetime.now(timezone.utc).strftime(NAMESPACE_DATE_FORMAT)
291 namespace = f"{NAMESPACE_PREFIX}_{today}_{seed:08x}"
292 table = "demo_table"
293 # The .td inserts these three rows; verification asserts the table's live
294 # row count matches.
295 expected_rows = 3
296
297 materialized = Materialized()
298 with c.override(materialized):
299 c.down()
300 c.up("materialized")
301 c.sql(
302 port=6877,
303 user="mz_system",
304 sql="""
305 ALTER SYSTEM SET enable_connection_validation_syntax = true;
306 """,
307 )
308
309 # Mint once and reuse for verification + cleanup. Tokens last an hour;
310 # minting up front also fails fast if the service-account key is broken.
311 token = mint_gcp_access_token(service_account)
312 # Bootstrap the catalog if absent; /v1/config 403s otherwise.
313 ensure_catalog(token, project, bucket)
314 # Discover the per-warehouse catalog prefix once; it's identical for
315 # the verify and cleanup paths.
316 prefix = resolve_warehouse_prefix(token, project, bucket)
317 # Garbage-collect namespaces from previous runs that were killed before
318 # their `finally` could run. Best-effort; logged failures don't block.
319 _sweep_stale_biglake_namespaces(token, project, prefix)
320 # BigLake doesn't auto-create namespaces on first commit, so we have to
321 # pre-create (matching how the AWS test pre-creates the S3 Tables namespace).
322 create_namespace(token, project, prefix, namespace)
323
324 try:
325 c.run_testdrive_files(
326 "--no-reset",
327 f"--var=gcp-sa-json-b64={sa_json_b64}",
328 f"--var=gcs-bucket={bucket}",
329 f"--var=namespace={namespace}",
330 f"--var=table={table}",
331 "gcp-iceberg-e2e.td",
332 )
333
334 try:
335 _verify_sink_committed(
336 token, project, prefix, namespace, table, expected_rows

Callers

nothing calls this directly

Calls 15

MaterializedClass · 0.90
mint_gcp_access_tokenFunction · 0.90
ensure_catalogFunction · 0.90
resolve_warehouse_prefixFunction · 0.90
create_namespaceFunction · 0.90
table_urlFunction · 0.90
namespace_urlFunction · 0.90
_require_envFunction · 0.85
_verify_sink_committedFunction · 0.85
_delete_biglakeFunction · 0.85
overrideMethod · 0.80

Tested by

no test coverage detected