-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(e2e): refactor e2e test case for test coverage (#131)
* build: update Dockerfile base image and go versions * refactor(e2e): refacor e2e test * fix: fix issue of e2e * ci: add product version matrix and update resource limits
- Loading branch information
Showing
27 changed files
with
441 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/zncdatadev/kafka-operator | ||
|
||
go 1.23.2 | ||
go 1.23.4 | ||
|
||
require ( | ||
emperror.dev/errors v0.8.1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: logging | ||
spec: | ||
bindings: | ||
steps: | ||
- name: install vector-aggregator | ||
try: | ||
- script: | ||
content: >- | ||
helm upgrade --install vector-aggregator vector | ||
--namespace $NAMESPACE | ||
--version 0.36.1 | ||
--repo https://helm.vector.dev | ||
--values vector-aggregator-values.yaml | ||
- apply: | ||
file: vector-aggregator.yaml | ||
- assert: | ||
file: vector-aggregator-assert.yaml | ||
- name: install zookeeper cluster | ||
try: | ||
- apply: | ||
file: ../setup/zookeeper.yaml | ||
- assert: | ||
file: ../setup/zookeeper-assert.yaml | ||
cleanup: | ||
- sleep: | ||
duration: 30s | ||
- name: install kakfka cluster | ||
try: | ||
- apply: | ||
file: kafka.yaml | ||
- assert: | ||
file: kafka-assert.yaml | ||
- name: assert kafka logs | ||
try: | ||
- sleep: | ||
duration: 50s | ||
- script: | ||
env: | ||
- name: NAMESPACE | ||
value: ($namespace) | ||
content: | | ||
#!/bin/bash | ||
# Get logs from vector-aggregator-0 and check for specific log pattern | ||
kubectl -n $NAMESPACE logs statefulset/vector-aggregator -c vector | \ | ||
grep -q '"cluster":"kafkacluster-sample","container":"kafka","errors":\[\],"file":"kafka.log4j.xml"' | ||
exit_code=$? | ||
if [ $exit_code -eq 0 ]; then | ||
echo "Found expected log pattern" | ||
exit 0 | ||
else | ||
echo "Did not find expected log pattern" | ||
exit 1 | ||
fi | ||
cleanup: | ||
- sleep: | ||
duration: 50s | ||
- name: access kafka | ||
try: | ||
- apply: | ||
file: client-access-configmap.yaml | ||
- script: | ||
env: | ||
- name: NAMESPACE | ||
value: ($namespace) | ||
content: | | ||
export KAFKA_IMAGE=$( | ||
kubectl -n $NAMESPACE get statefulset kafkacluster-sample-default-broker \ | ||
-o jsonpath='{.spec.template.spec.containers[?(.name=="kafka")].image}' | ||
) | ||
export KAFKA_DISCOVERY=$( | ||
kubectl -n $NAMESPACE get kafkaclusters.kafka.kubedoop.dev \ | ||
-o jsonpath='{.items[0].metadata.name}' | ||
) | ||
echo "KAFKA_IMAGE=$KAFKA_IMAGE" | ||
echo "KAFKA_DISCOVERY=$KAFKA_DISCOVERY" | ||
envsubst '${KAFKA_IMAGE} ${KAFKA_DISCOVERY}' < client-access-pod.txt | kubectl -n $NAMESPACE apply -f - | ||
- assert: | ||
timeout: 150s | ||
resource: | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: client-access | ||
status: | ||
phase: Succeeded | ||
catch: | ||
- podLogs: | ||
name: client-access | ||
container: client-access | ||
- describe: | ||
apiVersion: v1 | ||
kind: Pod | ||
name: client-access | ||
- script: | ||
env: | ||
- name: NAMESPACE | ||
value: ($namespace) | ||
content: | | ||
kubectl -n $NAMESPACE get pod client-access -o yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: client-access | ||
data: | ||
client-access.sh: | | ||
#!/usr/bin/env bash | ||
# to be safe | ||
unset TOPIC | ||
unset BAD_TOPIC | ||
echo "Connecting to boostrap address $KAFKA" | ||
echo "Start client access testing..." | ||
############################################################################ | ||
# Test the secured connection | ||
############################################################################ | ||
# create random topics | ||
TOPIC=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20 ; echo '') | ||
BAD_TOPIC=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 20 ; echo '') | ||
if /kubedoop/kafka/bin/kafka-topics.sh --create --topic "$TOPIC" --bootstrap-server "$KAFKA" | ||
then | ||
echo "[SUCCESS] client topic created!" | ||
else | ||
echo "[ERROR] client topic creation failed!" | ||
exit 1 | ||
fi | ||
if /kubedoop/kafka/bin/kafka-topics.sh --list --topic "$TOPIC" --bootstrap-server "$KAFKA" | grep "$TOPIC" | ||
then | ||
echo "[SUCCESS] client topic read!" | ||
else | ||
echo "[ERROR] client topic read failed!" | ||
exit 1 | ||
fi | ||
############################################################################ | ||
# Test the connection with bad host name | ||
############################################################################ | ||
if /kubedoop/kafka/bin/kafka-topics.sh --create --topic "$BAD_TOPIC" --bootstrap-server localhost:9093 &> /dev/null | ||
then | ||
echo "[ERROR] client topic created with bad host name!" | ||
exit 1 | ||
else | ||
echo "[SUCCESS] client topic creation failed with bad host name - 'localhost:9093' !" | ||
fi | ||
############################################################################ | ||
# Test producer and consumer | ||
############################################################################ | ||
# echo "Start producer and consumer testing..." | ||
# echo "Hello, World!" | /kubedoop/kafka/bin/kafka-console-producer.sh --topic "$TOPIC" --bootstrap-server "$KAFKA" | ||
# if /kubedoop/kafka/bin/kafka-console-consumer.sh --topic "$TOPIC" --from-beginning --bootstrap-server "$KAFKA" --max-messages 1 --timeout-ms 20000 | grep "Hello, World!" | ||
# then | ||
# echo "[SUCCESS] producer and consumer testing!" | ||
# else | ||
# echo "[ERROR] producer and consumer testing failed!" | ||
# exit 1 | ||
# fi | ||
echo "All tests successful!" | ||
exit 0 |
Oops, something went wrong.