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

Function workflow_default

test/launchdarkly/mzcompose.py:109–284  ·  view source on GitHub ↗
(c: Composition)

Source from the content-addressed store, hash-verified

107
108
109def workflow_default(c: Composition) -> None:
110 if LAUNCHDARKLY_API_TOKEN is None:
111 raise UIError("Missing LAUNCHDARKLY_API_TOKEN environment variable")
112 if LAUNCHDARKLY_SDK_KEY is None:
113 raise UIError("Missing LAUNCHDARKLY_SDK_KEY environment variable")
114
115 # Create a LaunchDarkly client that simulates somebody interacting
116 # with the LaunchDarkly frontend.
117 ld_client = LaunchDarklyClient(
118 configuration=launchdarkly_api.Configuration(
119 api_key=dict(ApiKey=LAUNCHDARKLY_API_TOKEN),
120 ),
121 project_key=environ.get("LAUNCHDARKLY_PROJECT_KEY", "default"),
122 environment_key=environ.get("LAUNCHDARKLY_ENVIRONMENT_KEY", "ci-cd"),
123 )
124
125 try:
126 c.up(Service("testdrive", idle=True))
127
128 # Assert that the default max_result_size is served when sync is disabled.
129 with c.override(Materialized(external_metadata_store=True)):
130 c.up("materialized")
131 c.testdrive("\n".join(["> SHOW max_result_size", "1GB"]))
132 c.stop("materialized")
133
134 # Create a test feature flag unique for this test run. Based on the
135 # MZ_LAUNCHDARKLY_KEY_MAP value, the test feature will be mapped to the
136 # max_result_size system parameter.
137 ld_client.create_flag(
138 LD_FEATURE_FLAG_KEY,
139 tags=(
140 ["ci-test", f"gh-{BUILDKITE_PULL_REQUEST}"]
141 if BUILDKITE_PULL_REQUEST
142 else ["ci-test"]
143 ),
144 )
145 # Turn on targeting. The default rule will now serve 2GiB for the test
146 # feature.
147 ld_client.update_targeting(
148 LD_FEATURE_FLAG_KEY,
149 on=True,
150 )
151
152 # 3 seconds should be enough to avoid race conditions between the update
153 # above and the query below.
154 sleep(3)
155
156 # Assert that the value is as expected after the initial parameter sync.
157 with c.override(
158 Materialized(
159 environment_extra=[
160 f"MZ_LAUNCHDARKLY_SDK_KEY={LAUNCHDARKLY_SDK_KEY}",
161 f"MZ_LAUNCHDARKLY_KEY_MAP=max_result_size={LD_FEATURE_FLAG_KEY}",
162 ],
163 additional_system_parameter_defaults={
164 "log_filter": "mz_adapter::catalog=debug,mz_adapter::config=debug",
165 },
166 external_metadata_store=True,

Callers

nothing calls this directly

Calls 15

create_flagMethod · 0.95
update_targetingMethod · 0.95
delete_flagMethod · 0.95
UIErrorClass · 0.90
ServiceClass · 0.90
MaterializedClass · 0.90
LaunchDarklyClientClass · 0.85
sleepFunction · 0.85
sysFunction · 0.85
overrideMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected