@@ -22,279 +22,27 @@ jobs:
2222 go-version-file : ' go.mod'
2323
2424 - name : Start Kafka 4 with KRaft
25- run : |
26- docker run -d \
27- --name broker \
28- --network host \
29- -e KAFKA_NODE_ID=1 \
30- -e KAFKA_PROCESS_ROLES=broker,controller \
31- -e KAFKA_LISTENERS=PLAINTEXT://localhost:9092,CONTROLLER://localhost:9093 \
32- -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 \
33- -e KAFKA_CONTROLLER_LISTENER_NAMES=CONTROLLER \
34- -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT \
35- -e KAFKA_CONTROLLER_QUORUM_VOTERS=1@localhost:9093 \
36- -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 \
37- -e KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR=1 \
38- -e KAFKA_TRANSACTION_STATE_LOG_MIN_ISR=1 \
39- -e KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS=0 \
40- -e KAFKA_NUM_PARTITIONS=3 \
41- apache/kafka:4.1.0
42-
43- # Wait for Kafka to be ready
44- echo "Waiting for Kafka to start..."
45- for i in {1..60}; do
46- # Check if Kafka is listening on port 9092
47- if nc -z localhost 9092 2>/dev/null; then
48- echo "Kafka port 9092 is open!"
49- # Give it a couple more seconds to fully initialize
50- sleep 3
51- # Try to get broker API versions
52- if docker exec broker /opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092 > /dev/null 2>&1; then
53- echo "Kafka is ready and responding to requests!"
54- break
55- fi
56- fi
57- if [ $i -eq 60 ]; then
58- echo "Kafka failed to start within 60 seconds"
59- echo "=== Kafka logs ==="
60- docker logs broker
61- exit 1
62- fi
63- echo "Attempt $i/60: Kafka not ready yet, waiting..."
64- sleep 1
65- done
66-
67- # Verify Kafka is running
68- echo "Verifying Kafka cluster..."
69- docker exec broker /opt/kafka/bin/kafka-broker-api-versions.sh --bootstrap-server localhost:9092
70- echo "Kafka cluster is up and running!"
71-
72- - name : Create KMinion configuration
73- run : |
74- cat > kminion-config.yaml << 'EOF'
75- kafka:
76- brokers:
77- - localhost:9092
78- clientId: kminion-e2e-test
79-
80- minion:
81- endToEnd:
82- enabled: true
83- probeInterval: 500ms
84- topicManagement:
85- enabled: true
86- name: kminion-end-to-end
87- replicationFactor: 1
88- partitionsPerBroker: 1
89- reconciliationInterval: 10s
90- producer:
91- ackSla: 5s
92- requiredAcks: all
93- consumer:
94- groupIdPrefix: kminion-end-to-end
95- deleteStaleConsumerGroups: false
96- roundtripSla: 10s
97- commitSla: 5s
98-
99- exporter:
100- namespace: kminion
101- port: 8080
102-
103- logger:
104- level: info
105- EOF
25+ run : make e2e-setup
10626
10727 - name : Build KMinion
108- run : |
109- go build -o kminion .
28+ run : make build
11029
11130 - name : Start KMinion with E2E tests
112- run : |
113- export CONFIG_FILEPATH=kminion-config.yaml
114- ./kminion > kminion.log 2>&1 &
115- KMINION_PID=$!
116- echo "KMINION_PID=$KMINION_PID" >> $GITHUB_ENV
117-
118- # Wait for KMinion to start
119- echo "Waiting for KMinion to start..."
120- for i in {1..30}; do
121- if curl -s http://localhost:8080/metrics > /dev/null 2>&1; then
122- echo "KMinion is ready!"
123- break
124- fi
125- if [ $i -eq 30 ]; then
126- echo "KMinion failed to start within 30 seconds"
127- cat kminion.log
128- exit 1
129- fi
130- echo "Attempt $i/30: KMinion not ready yet, waiting..."
131- sleep 1
132- done
133-
134- - name : Wait for E2E tests to run
135- run : |
136- echo "Waiting for E2E tests to produce metrics..."
137- sleep 30
138-
139- - name : Validate E2E metrics
140- run : |
141- echo "Fetching metrics from KMinion..."
142- METRICS=$(curl -s http://localhost:8080/metrics)
143-
144- echo "=== KMinion Metrics Output ==="
145- echo "$METRICS" | grep -E "kminion_end_to_end_" || true
146- echo "=============================="
147-
148- # Check for essential E2E metrics
149- REQUIRED_METRICS=(
150- "kminion_end_to_end_messages_produced_total"
151- "kminion_end_to_end_messages_received_total"
152- "kminion_end_to_end_produce_latency_seconds"
153- "kminion_end_to_end_roundtrip_latency_seconds"
154- "kminion_end_to_end_offset_commit_latency_seconds"
155- )
156-
157- MISSING_METRICS=()
158- for metric in "${REQUIRED_METRICS[@]}"; do
159- if ! echo "$METRICS" | grep -q "^${metric}"; then
160- MISSING_METRICS+=("$metric")
161- fi
162- done
163-
164- if [ ${#MISSING_METRICS[@]} -ne 0 ]; then
165- echo "ERROR: Missing required E2E metrics:"
166- printf '%s\n' "${MISSING_METRICS[@]}"
167- echo ""
168- echo "=== Full KMinion logs ==="
169- cat kminion.log
170- exit 1
171- fi
172-
173- # Verify messages were produced and received
174- PRODUCED=$(echo "$METRICS" | grep "^kminion_end_to_end_messages_produced_total" | awk '{print $2}')
175- RECEIVED=$(echo "$METRICS" | grep "^kminion_end_to_end_messages_received_total" | awk '{print $2}')
176-
177- echo "Messages produced: $PRODUCED"
178- echo "Messages received: $RECEIVED"
179-
180- if [ -z "$PRODUCED" ] || [ "$PRODUCED" = "0" ]; then
181- echo "ERROR: No messages were produced"
182- cat kminion.log
183- exit 1
184- fi
185-
186- if [ -z "$RECEIVED" ] || [ "$RECEIVED" = "0" ]; then
187- echo "ERROR: No messages were received"
188- cat kminion.log
189- exit 1
190- fi
191-
192- echo "✅ E2E tests passed successfully!"
193- echo " - Messages produced: $PRODUCED"
194- echo " - Messages received: $RECEIVED"
195-
196- - name : Validate built-in KMinion metrics
197- run : |
198- echo "Validating built-in KMinion metrics..."
199- METRICS=$(curl -s http://localhost:8080/metrics)
200-
201- # Core exporter metrics
202- CORE_METRICS=(
203- "kminion_exporter_up"
204- "kminion_exporter_offset_consumer_records_consumed_total"
205- )
31+ run : make e2e-start
20632
207- # Kafka cluster metrics
208- KAFKA_METRICS=(
209- "kminion_kafka_cluster_info"
210- "kminion_kafka_broker_info"
211- )
212-
213- # Topic metrics
214- TOPIC_METRICS=(
215- "kminion_kafka_topic_info"
216- "kminion_kafka_topic_partition_count"
217- "kminion_kafka_topic_partition_high_water_mark"
218- "kminion_kafka_topic_high_water_mark_sum"
219- )
220-
221- MISSING_METRICS=()
222-
223- # Check core metrics
224- for metric in "${CORE_METRICS[@]}"; do
225- if ! echo "$METRICS" | grep -q "^${metric}"; then
226- MISSING_METRICS+=("$metric")
227- fi
228- done
229-
230- # Check Kafka metrics
231- for metric in "${KAFKA_METRICS[@]}"; do
232- if ! echo "$METRICS" | grep -q "^${metric}"; then
233- MISSING_METRICS+=("$metric")
234- fi
235- done
236-
237- # Check topic metrics
238- for metric in "${TOPIC_METRICS[@]}"; do
239- if ! echo "$METRICS" | grep -q "^${metric}"; then
240- MISSING_METRICS+=("$metric")
241- fi
242- done
243-
244- if [ ${#MISSING_METRICS[@]} -ne 0 ]; then
245- echo "ERROR: Missing required built-in metrics:"
246- printf '%s\n' "${MISSING_METRICS[@]}"
247- echo ""
248- echo "=== Available metrics ==="
249- echo "$METRICS" | grep "^kminion_" | head -20
250- exit 1
251- fi
252-
253- # Validate specific metric values
254- EXPORTER_UP=$(echo "$METRICS" | grep "^kminion_exporter_up" | awk '{print $2}')
255- if [ "$EXPORTER_UP" != "1" ]; then
256- echo "ERROR: kminion_exporter_up should be 1, got: $EXPORTER_UP"
257- exit 1
258- fi
259-
260- # Check that cluster info has broker_count label
261- if ! echo "$METRICS" | grep "kminion_kafka_cluster_info" | grep -q "broker_count"; then
262- echo "ERROR: kminion_kafka_cluster_info missing broker_count label"
263- exit 1
264- fi
265-
266- # Check that we have broker info for at least one broker
267- BROKER_COUNT=$(echo "$METRICS" | grep "^kminion_kafka_broker_info" | wc -l)
268- if [ "$BROKER_COUNT" -lt 1 ]; then
269- echo "ERROR: No broker info metrics found"
270- exit 1
271- fi
272-
273- echo "✅ Built-in KMinion metrics validation passed!"
274- echo " - Exporter up: $EXPORTER_UP"
275- echo " - Brokers detected: $BROKER_COUNT"
33+ - name : Run integration tests
34+ run : make e2e-test
27635
27736 - name : Show logs on failure
27837 if : failure()
27938 run : |
28039 echo "=== Kafka logs ==="
281- docker logs broker || echo "No Kafka logs found"
40+ docker logs broker 2>&1 | tail -100 || echo "No Kafka logs found"
28241 echo ""
28342 echo "=== KMinion logs ==="
28443 cat kminion.log || echo "No KMinion logs found"
28544
28645 - name : Cleanup
28746 if : always()
288- run : |
289- # Stop KMinion
290- if [ ! -z "$KMINION_PID" ]; then
291- kill $KMINION_PID || true
292- fi
293-
294- # Stop and remove Kafka container
295- docker stop broker || true
296- docker rm broker || true
297-
298- # Wait a bit for graceful shutdown
299- sleep 2
47+ run : make e2e-cleanup
30048
0 commit comments