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

Class KafkaDisruption

test/source-sink-errors/mzcompose.py:130–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

128
129@dataclass
130class KafkaDisruption:
131 name: str
132 breakage: Callable
133 expected_error: str
134 fixage: Callable | None
135
136 def run_test(self, c: Composition) -> None:
137 print(f"+++ Running disruption scenario {self.name}")
138 seed = random.randint(0, 256**4)
139
140 c.up(
141 "redpanda",
142 "materialized",
143 "clusterd",
144 Service("testdrive", idle=True),
145 )
146
147 with c.override(
148 Testdrive(
149 no_reset=True,
150 seed=seed,
151 entrypoint_extra=["--initial-backoff=1s", "--backoff-factor=0"],
152 )
153 ):
154 self.populate(c)
155 self.breakage(c, seed)
156 self.assert_error(c, self.expected_error)
157
158 if self.fixage:
159 self.fixage(c, seed)
160 self.assert_recovery(c)
161
162 def populate(self, c: Composition) -> None:
163 # Create a source and a sink
164 c.testdrive(dedent("""
165 # We specify the progress topic explicitly so we can delete it in a test later,
166 # and confirm that the sink stalls. (Deleting the output topic is not enough if
167 # we're not actively publishing new messages to the sink.)
168 > CREATE CONNECTION kafka_conn
169 TO KAFKA (
170 BROKER '${testdrive.kafka-addr}',
171 SECURITY PROTOCOL PLAINTEXT,
172 PROGRESS TOPIC 'testdrive-progress-topic-${testdrive.seed}'
173 );
174
175 > CREATE CONNECTION IF NOT EXISTS csr_conn TO CONFLUENT SCHEMA REGISTRY (
176 URL '${testdrive.schema-registry-url}'
177 );
178
179 $ kafka-create-topic topic=source-topic
180
181 $ kafka-ingest topic=source-topic format=bytes
182 ABC
183
184 > CREATE SOURCE source1
185 FROM KAFKA CONNECTION kafka_conn (TOPIC 'testdrive-source-topic-${testdrive.seed}')
186
187 > CREATE TABLE source1_tbl FROM SOURCE source1 (REFERENCE "testdrive-source-topic-${testdrive.seed}")

Callers 1

mzcompose.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected