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

Function workflow_default

test/backup-restore/mzcompose.py:38–85  ·  view source on GitHub ↗
(c: Composition)

Source from the content-addressed store, hash-verified

36
37
38def workflow_default(c: Composition) -> None:
39 # TODO: extract common substrings
40
41 # Enable versioning for the Persist bucket
42 c.enable_minio_versioning()
43
44 # Start Materialize, and set up some basic state in it
45 c.up("materialized", Service("testdrive", idle=True))
46 c.testdrive(dedent("""
47 > DROP TABLE IF EXISTS numbers;
48 > CREATE TABLE IF NOT EXISTS numbers (id BIGINT);
49 > INSERT INTO numbers SELECT * from generate_series(1, 1);
50 > INSERT INTO numbers SELECT * from generate_series(1, 10);
51 > INSERT INTO numbers SELECT * from generate_series(1, 100);
52 """))
53
54 Cockroach.backup(c)
55
56 # Make further updates to Materialize's state
57 for i in range(0, 100):
58 # TODO: This seems to be enough to produce interesting shard state;
59 # ie. if we remove the restore-blob step we can see the restore fail.
60 # Is there any cheaper or more obvious way to do that?
61 c.testdrive(dedent("""
62 > INSERT INTO numbers SELECT * from generate_series(1, 1);
63 > INSERT INTO numbers SELECT * from generate_series(1, 10);
64 > INSERT INTO numbers SELECT * from generate_series(1, 100);
65 """))
66
67 # Restore CRDB from backup, run persistcli restore-blob and restart Mz
68 Cockroach.restore(c)
69
70 # Confirm that the database is readable / has shard data
71 c.exec(
72 "cockroach",
73 "cockroach",
74 "sql",
75 "--insecure",
76 "-e",
77 "SELECT shard, min(sequence_number), max(sequence_number) "
78 "FROM consensus.consensus GROUP BY 1 ORDER BY 2 DESC, 3 DESC, 1 ASC LIMIT 32;",
79 )
80
81 # Check that the cluster is up and that it answers queries as of the old state
82 c.testdrive(dedent("""
83 > SELECT count(*) FROM numbers;
84 111
85 """))

Callers

nothing calls this directly

Calls 7

ServiceClass · 0.90
execMethod · 0.80
upMethod · 0.45
testdriveMethod · 0.45
backupMethod · 0.45
restoreMethod · 0.45

Tested by

no test coverage detected