|
| 1 | +# Copyright Materialize, Inc. and contributors. All rights reserved. |
| 2 | +# |
| 3 | +# Use of this software is governed by the Business Source License |
| 4 | +# included in the LICENSE file at the root of this repository. |
| 5 | +# |
| 6 | +# As of the Change Date specified in that file, in accordance with |
| 7 | +# the Business Source License, use of this software will be governed |
| 8 | +# by the Apache License, Version 2.0. |
| 9 | + |
| 10 | + |
| 11 | +from materialize.mzcompose import get_default_system_parameters |
| 12 | +from materialize.mzcompose.composition import Composition |
| 13 | +from materialize.mzcompose.services.materialized import DeploymentStatus, Materialized |
| 14 | +from materialize.mzcompose.services.postgres import CockroachOrPostgresMetadata |
| 15 | + |
| 16 | +BASE_VERSION = "v0.140.0" |
| 17 | + |
| 18 | +SYSTEM_PARAMETER_DEFAULTS = get_default_system_parameters() |
| 19 | + |
| 20 | +SERVICES = [ |
| 21 | + CockroachOrPostgresMetadata(), |
| 22 | + Materialized( |
| 23 | + name="mz_old", |
| 24 | + sanity_restart=False, |
| 25 | + image=f"materialize/materialized:{BASE_VERSION}", |
| 26 | + deploy_generation=0, |
| 27 | + system_parameter_defaults=SYSTEM_PARAMETER_DEFAULTS, |
| 28 | + external_metadata_store=True, |
| 29 | + default_replication_factor=2, |
| 30 | + ), |
| 31 | + Materialized( |
| 32 | + name="mz_new", |
| 33 | + sanity_restart=False, |
| 34 | + deploy_generation=1, |
| 35 | + system_parameter_defaults=SYSTEM_PARAMETER_DEFAULTS, |
| 36 | + restart="on-failure", |
| 37 | + external_metadata_store=True, |
| 38 | + default_replication_factor=2, |
| 39 | + ), |
| 40 | +] |
| 41 | + |
| 42 | + |
| 43 | +def workflow_default(c: Composition): |
| 44 | + c.down(destroy_volumes=True) |
| 45 | + |
| 46 | + c.up("mz_old") |
| 47 | + c.sql("SELECT * FROM mz_tables LIMIT 1", service="mz_old") |
| 48 | + |
| 49 | + c.up("mz_new") |
| 50 | + c.await_mz_deployment_status(DeploymentStatus.READY_TO_PROMOTE, "mz_new") |
| 51 | + c.promote_mz("mz_new") |
| 52 | + c.await_mz_deployment_status(DeploymentStatus.IS_LEADER, "mz_new") |
| 53 | + |
| 54 | + c.sql("SELECT * FROM mz_tables LIMIT 1", service="mz_new") |
0 commit comments