Skip to content

Commit a65e68f

Browse files
committed
test(binding-kafka): add regression coverage for bootstrap reconnect after broker failure
Adds CacheBootstrapIT scenarios simulating a broker that rejects the bootstrap's describe/fetch connection once (e.g. not ready yet at Zilla startup) then accepts on retry. Both already pass against unmodified code: the bootstrap's internal describe/meta/fetch streams route through the same per-topic KafkaCacheServerDescribeFactory/MetaFactory/FetchFactory fanouts used by regular cache_client reads, and inherit their existing SIGNAL_RECONNECT exponential-backoff retry for free, since the bootstrap stream stays registered as a fanout member. Locks in this previously untested resilience behavior referenced in #2116.
1 parent 1eceea6 commit a65e68f

3 files changed

Lines changed: 356 additions & 0 deletions

File tree

  • runtime/binding-kafka/src/test/java/io/aklivity/zilla/runtime/binding/kafka/internal/stream
  • specs/binding-kafka.spec/src/main/scripts/io/aklivity/zilla/specs/binding/kafka/streams/application/merged

‎runtime/binding-kafka/src/test/java/io/aklivity/zilla/runtime/binding/kafka/internal/stream/CacheBootstrapIT.java‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import static io.aklivity.zilla.runtime.binding.kafka.internal.KafkaConfiguration.KAFKA_CACHE_SEGMENT_BYTES;
1919
import static io.aklivity.zilla.runtime.binding.kafka.internal.KafkaConfiguration.KAFKA_CACHE_SEGMENT_INDEX_BYTES;
20+
import static io.aklivity.zilla.runtime.binding.kafka.internal.KafkaConfigurationTest.KAFKA_CACHE_SERVER_RECONNECT_DELAY_NAME;
2021
import static io.aklivity.zilla.runtime.engine.EngineConfiguration.ENGINE_BUFFER_SLOT_CAPACITY;
2122
import static io.aklivity.zilla.runtime.engine.EngineConfiguration.ENGINE_DRAIN_ON_CLOSE;
2223
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -32,6 +33,7 @@
3233
import io.aklivity.k3po.runtime.junit.rules.K3poRule;
3334
import io.aklivity.zilla.runtime.engine.test.EngineRule;
3435
import io.aklivity.zilla.runtime.engine.test.annotation.Configuration;
36+
import io.aklivity.zilla.runtime.engine.test.annotation.Configure;
3537

3638
public class CacheBootstrapIT
3739
{
@@ -98,4 +100,30 @@ public void shouldReceiveGroupMessageValue() throws Exception
98100
{
99101
k3po.finish();
100102
}
103+
104+
@Test
105+
@Configuration("cache.options.bootstrap.yaml")
106+
@Configure(name = KAFKA_CACHE_SERVER_RECONNECT_DELAY_NAME, value = "1")
107+
@Specification({
108+
"${app}/bootstrap.reconnect.after.describe.error/server"})
109+
public void shouldReconnectBootstrapAfterDescribeError() throws Exception
110+
{
111+
Thread.sleep(500);
112+
k3po.start();
113+
k3po.awaitBarrier("RECEIVED_MESSAGE");
114+
k3po.finish();
115+
}
116+
117+
@Test
118+
@Configuration("cache.options.bootstrap.yaml")
119+
@Configure(name = KAFKA_CACHE_SERVER_RECONNECT_DELAY_NAME, value = "1")
120+
@Specification({
121+
"${app}/bootstrap.reconnect.after.fetch.error/server"})
122+
public void shouldReconnectBootstrapAfterFetchError() throws Exception
123+
{
124+
Thread.sleep(500);
125+
k3po.start();
126+
k3po.awaitBarrier("RECEIVED_MESSAGE");
127+
k3po.finish();
128+
}
101129
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
#
2+
# Copyright 2021-2024 Aklivity Inc.
3+
#
4+
# Aklivity licenses this file to you under the Apache License,
5+
# version 2.0 (the "License"); you may not use this file except in compliance
6+
# with the License. You may obtain a copy of the License at:
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations
14+
# under the License.
15+
#
16+
17+
property deltaMillis 0L
18+
property newTimestamp ${kafka:timestamp() + deltaMillis}
19+
20+
accept "zilla://streams/app1"
21+
option zilla:window 8192
22+
option zilla:transmission "half-duplex"
23+
24+
accepted
25+
26+
read zilla:begin.ext ${kafka:beginEx()
27+
.typeId(zilla:id("kafka"))
28+
.describe()
29+
.topic("test")
30+
.config("cleanup.policy")
31+
.config("max.message.bytes")
32+
.config("segment.bytes")
33+
.config("segment.index.bytes")
34+
.config("segment.ms")
35+
.config("retention.bytes")
36+
.config("retention.ms")
37+
.config("delete.retention.ms")
38+
.config("min.compaction.lag.ms")
39+
.config("max.compaction.lag.ms")
40+
.config("min.cleanable.dirty.ratio")
41+
.build()
42+
.build()}
43+
44+
connected
45+
46+
write zilla:reset.ext ${kafka:resetEx()
47+
.typeId(zilla:id("kafka"))
48+
.error(-1)
49+
.build()}
50+
read abort
51+
write aborted
52+
53+
accepted
54+
55+
read zilla:begin.ext ${kafka:beginEx()
56+
.typeId(zilla:id("kafka"))
57+
.describe()
58+
.topic("test")
59+
.config("cleanup.policy")
60+
.config("max.message.bytes")
61+
.config("segment.bytes")
62+
.config("segment.index.bytes")
63+
.config("segment.ms")
64+
.config("retention.bytes")
65+
.config("retention.ms")
66+
.config("delete.retention.ms")
67+
.config("min.compaction.lag.ms")
68+
.config("max.compaction.lag.ms")
69+
.config("min.cleanable.dirty.ratio")
70+
.build()
71+
.build()}
72+
73+
connected
74+
75+
write zilla:begin.ext ${kafka:beginEx()
76+
.typeId(zilla:id("kafka"))
77+
.describe()
78+
.topic("test")
79+
.config("cleanup.policy")
80+
.config("max.message.bytes")
81+
.config("segment.bytes")
82+
.config("segment.index.bytes")
83+
.config("segment.ms")
84+
.config("retention.bytes")
85+
.config("retention.ms")
86+
.config("delete.retention.ms")
87+
.config("min.compaction.lag.ms")
88+
.config("max.compaction.lag.ms")
89+
.config("min.cleanable.dirty.ratio")
90+
.build()
91+
.build()}
92+
write flush
93+
94+
write zilla:data.ext ${kafka:dataEx()
95+
.typeId(zilla:id("kafka"))
96+
.describe()
97+
.config("cleanup.policy", "delete")
98+
.config("max.message.bytes", 1000012)
99+
.config("segment.bytes", 1073741824)
100+
.config("segment.index.bytes", 10485760)
101+
.config("segment.ms", 604800000)
102+
.config("retention.bytes", -1)
103+
.config("retention.ms", 604800000)
104+
.config("delete.retention.ms", 86400000)
105+
.config("min.compaction.lag.ms", 0)
106+
.config("max.compaction.lag.ms", 9223372036854775807)
107+
.config("min.cleanable.dirty.ratio", 0.5)
108+
.build()
109+
.build()}
110+
write flush
111+
112+
accepted
113+
114+
read zilla:begin.ext ${kafka:beginEx()
115+
.typeId(zilla:id("kafka"))
116+
.meta()
117+
.topic("test")
118+
.build()
119+
.build()}
120+
121+
connected
122+
123+
write zilla:begin.ext ${kafka:beginEx()
124+
.typeId(zilla:id("kafka"))
125+
.meta()
126+
.topic("test")
127+
.build()
128+
.build()}
129+
write flush
130+
131+
write zilla:data.ext ${kafka:dataEx()
132+
.typeId(zilla:id("kafka"))
133+
.meta()
134+
.partition(0, 1)
135+
.build()
136+
.build()}
137+
write flush
138+
139+
accepted
140+
141+
read zilla:begin.ext ${kafka:beginEx()
142+
.typeId(zilla:id("kafka"))
143+
.fetch()
144+
.topic("test")
145+
.partition(0, -2)
146+
.build()
147+
.build()}
148+
149+
connected
150+
151+
write zilla:begin.ext ${kafka:beginEx()
152+
.typeId(zilla:id("kafka"))
153+
.fetch()
154+
.topic("test")
155+
.partition(0, 1, 1)
156+
.build()
157+
.build()}
158+
write flush
159+
160+
write zilla:data.ext ${kafka:dataEx()
161+
.typeId(zilla:id("kafka"))
162+
.fetch()
163+
.timestamp(newTimestamp)
164+
.partition(0, 1, 1)
165+
.build()
166+
.build()}
167+
write "Hello, world"
168+
write flush
169+
write notify RECEIVED_MESSAGE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
#
2+
# Copyright 2021-2024 Aklivity Inc.
3+
#
4+
# Aklivity licenses this file to you under the Apache License,
5+
# version 2.0 (the "License"); you may not use this file except in compliance
6+
# with the License. You may obtain a copy of the License at:
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
# License for the specific language governing permissions and limitations
14+
# under the License.
15+
#
16+
17+
property deltaMillis 0L
18+
property newTimestamp ${kafka:timestamp() + deltaMillis}
19+
20+
accept "zilla://streams/app1"
21+
option zilla:window 8192
22+
option zilla:transmission "half-duplex"
23+
24+
accepted
25+
26+
read zilla:begin.ext ${kafka:beginEx()
27+
.typeId(zilla:id("kafka"))
28+
.describe()
29+
.topic("test")
30+
.config("cleanup.policy")
31+
.config("max.message.bytes")
32+
.config("segment.bytes")
33+
.config("segment.index.bytes")
34+
.config("segment.ms")
35+
.config("retention.bytes")
36+
.config("retention.ms")
37+
.config("delete.retention.ms")
38+
.config("min.compaction.lag.ms")
39+
.config("max.compaction.lag.ms")
40+
.config("min.cleanable.dirty.ratio")
41+
.build()
42+
.build()}
43+
44+
connected
45+
46+
write zilla:begin.ext ${kafka:beginEx()
47+
.typeId(zilla:id("kafka"))
48+
.describe()
49+
.topic("test")
50+
.config("cleanup.policy")
51+
.config("max.message.bytes")
52+
.config("segment.bytes")
53+
.config("segment.index.bytes")
54+
.config("segment.ms")
55+
.config("retention.bytes")
56+
.config("retention.ms")
57+
.config("delete.retention.ms")
58+
.config("min.compaction.lag.ms")
59+
.config("max.compaction.lag.ms")
60+
.config("min.cleanable.dirty.ratio")
61+
.build()
62+
.build()}
63+
write flush
64+
65+
write zilla:data.ext ${kafka:dataEx()
66+
.typeId(zilla:id("kafka"))
67+
.describe()
68+
.config("cleanup.policy", "delete")
69+
.config("max.message.bytes", 1000012)
70+
.config("segment.bytes", 1073741824)
71+
.config("segment.index.bytes", 10485760)
72+
.config("segment.ms", 604800000)
73+
.config("retention.bytes", -1)
74+
.config("retention.ms", 604800000)
75+
.config("delete.retention.ms", 86400000)
76+
.config("min.compaction.lag.ms", 0)
77+
.config("max.compaction.lag.ms", 9223372036854775807)
78+
.config("min.cleanable.dirty.ratio", 0.5)
79+
.build()
80+
.build()}
81+
write flush
82+
83+
accepted
84+
85+
read zilla:begin.ext ${kafka:beginEx()
86+
.typeId(zilla:id("kafka"))
87+
.meta()
88+
.topic("test")
89+
.build()
90+
.build()}
91+
92+
connected
93+
94+
write zilla:begin.ext ${kafka:beginEx()
95+
.typeId(zilla:id("kafka"))
96+
.meta()
97+
.topic("test")
98+
.build()
99+
.build()}
100+
write flush
101+
102+
write zilla:data.ext ${kafka:dataEx()
103+
.typeId(zilla:id("kafka"))
104+
.meta()
105+
.partition(0, 1)
106+
.build()
107+
.build()}
108+
write flush
109+
110+
accepted
111+
112+
read zilla:begin.ext ${kafka:beginEx()
113+
.typeId(zilla:id("kafka"))
114+
.fetch()
115+
.topic("test")
116+
.partition(0, -2)
117+
.build()
118+
.build()}
119+
120+
connected
121+
122+
write zilla:reset.ext ${kafka:resetEx()
123+
.typeId(zilla:id("kafka"))
124+
.error(-1)
125+
.build()}
126+
read abort
127+
write aborted
128+
129+
accepted
130+
131+
read zilla:begin.ext ${kafka:beginEx()
132+
.typeId(zilla:id("kafka"))
133+
.fetch()
134+
.topic("test")
135+
.partition(0, -2)
136+
.build()
137+
.build()}
138+
139+
connected
140+
141+
write zilla:begin.ext ${kafka:beginEx()
142+
.typeId(zilla:id("kafka"))
143+
.fetch()
144+
.topic("test")
145+
.partition(0, 1, 1)
146+
.build()
147+
.build()}
148+
write flush
149+
150+
write zilla:data.ext ${kafka:dataEx()
151+
.typeId(zilla:id("kafka"))
152+
.fetch()
153+
.timestamp(newTimestamp)
154+
.partition(0, 1, 1)
155+
.build()
156+
.build()}
157+
write "Hello, world"
158+
write flush
159+
write notify RECEIVED_MESSAGE

0 commit comments

Comments
 (0)