Skip to content

Commit d677497

Browse files
committed
fix tekton integration test.
Signed-off-by: Morven Cao <lcao@redhat.com>
1 parent 7f81be0 commit d677497

File tree

7 files changed

+230
-169
lines changed

7 files changed

+230
-169
lines changed

.tekton/integration-test.yaml

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ spec:
6262
TARGET_COMPONENT_NAME="maestro"
6363
REPO_URL=$(echo $SNAPSHOT | jq -r '.components[] | select(.name == "maestro").source.git.url')
6464
REPO_COMMIT=$(echo $SNAPSHOT | jq -r '.components[] | select(.name == "maestro").source.git.revision')
65-
test_output_file=${PWD}/test_output.json
65+
mqtt_test_output_file=${PWD}/mqtt_test_output.json
66+
pubsub_test_output_file=${PWD}/pubsub_test_output.json
67+
grpc_test_output_file=${PWD}/grpc_test_output.json
6668
6769
# Log Vars for Tracibility
6870
echo "REPO_URL: $REPO_URL"
@@ -84,16 +86,38 @@ spec:
8486
# Generate mqtt config file
8587
echo '{"brokerHost":"localhost:1883","username":"","password":"","topics":{"sourceEvents":"sources/maestro/consumers/+/sourceevents","agentEvents":"sources/maestro/consumers/+/agentevents"}}' > secrets/mqtt.config
8688
89+
# Generate pubsub config file
90+
echo '{"projectID":"maestro-test","endpoint":"localhost:8085","insecure":true,"topics":{"sourceEvents":"projects/maestro-test/topics/sourceevents","sourceBroadcast":"projects/maestro-test/topics/sourcebroadcast"},"subscriptions":{"agentEvents":"projects/maestro-test/subscriptions/agentevents-maestro","agentBroadcast":"projects/maestro-test/subscriptions/agentbroadcast-maestro"}}' > secrets/pubsub.config
91+
8792
# Generate db.password
8893
echo 'foobar-bizz-buzz' > secrets/db.password
8994
95+
# Wait for the pubsub emulator to be ready
96+
echo "[INFO] Waiting for pubsub emulator to be ready for connection"
97+
timeout 5m bash -c 'until curl -s http://localhost:8085 > /dev/null 2>&1; do sleep 2s; done'
98+
99+
# Initialize pubsub topics and subscriptions
100+
export PUBSUB_EMULATOR_HOST=localhost:8085
101+
export PUBSUB_PROJECT_ID=maestro-test
102+
bash hack/init-pubsub-emulator.sh
103+
90104
# Run integration tests with JSON output
91-
make test-integration integration_test_json_output="$test_output_file"
105+
make test-integration \
106+
mqtt_integration_test_json_output="$mqtt_test_output_file" \
107+
pubsub_integration_test_json_output="$pubsub_test_output_file" \
108+
grpc_integration_test_json_output="$grpc_test_output_file"
92109
93110
# Read, process, and write output in accepted format
94111
# Formatting docs: https://redhat-appstudio.github.io/book/ADR/0030-tekton-results-naming-convention.html#test_output-schema-validation
95-
FAILURES=$(cat $test_output_file | jq 'select(.Action == "fail")' | jq -r --slurp 'length')
96-
SUCCESSES=$(cat $test_output_file | jq 'select(.Action == "pass")' | jq -r --slurp 'length')
112+
# Combine results from all three broker tests
113+
MQTT_FAILURES=$(cat $mqtt_test_output_file | jq 'select(.Action == "fail")' | jq -r --slurp 'length')
114+
MQTT_SUCCESSES=$(cat $mqtt_test_output_file | jq 'select(.Action == "pass")' | jq -r --slurp 'length')
115+
PUBSUB_FAILURES=$(cat $pubsub_test_output_file | jq 'select(.Action == "fail")' | jq -r --slurp 'length')
116+
PUBSUB_SUCCESSES=$(cat $pubsub_test_output_file | jq 'select(.Action == "pass")' | jq -r --slurp 'length')
117+
GRPC_FAILURES=$(cat $grpc_test_output_file | jq 'select(.Action == "fail")' | jq -r --slurp 'length')
118+
GRPC_SUCCESSES=$(cat $grpc_test_output_file | jq 'select(.Action == "pass")' | jq -r --slurp 'length')
119+
FAILURES=$((MQTT_FAILURES + PUBSUB_FAILURES + GRPC_FAILURES))
120+
SUCCESSES=$((MQTT_SUCCESSES + PUBSUB_SUCCESSES + GRPC_SUCCESSES))
97121
# Hard-code warnings
98122
WARNINGS=0
99123
RESULT="$(if [[ $FAILURES == 0 ]]; then echo "SUCCESS"; else echo "FAILURE"; fi)"
@@ -129,6 +153,16 @@ spec:
129153
volumeMounts:
130154
- mountPath: /mosquitto/data
131155
name: mqttdata
156+
- image: gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators
157+
name: pubsub-test
158+
command:
159+
- gcloud
160+
- beta
161+
- emulators
162+
- pubsub
163+
- start
164+
- --host-port=0.0.0.0:8085
165+
- --project=maestro-test
132166
volumes:
133167
- name: pgdata
134168
emptyDir: {}

Makefile

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,17 @@ test-integration: test-integration-mqtt test-integration-pubsub test-integration
269269
.PHONY: test-integration
270270

271271
test-integration-mqtt:
272-
MESSAGE_BROKER_TYPE=mqtt MESSAGE_BROKER_CONFIG=$(PWD)/secrets/mqtt.config MAESTRO_ENV=testing gotestsum --jsonfile-timing-events=$(mqtt_integration_test_json_output) --format $(TEST_SUMMARY_FORMAT) -- -p 1 -ldflags -s -v -timeout 1h $(TESTFLAGS) \
272+
MESSAGE_DRIVER_TYPE=mqtt MESSAGE_DRIVER_CONFIG=$(PWD)/secrets/mqtt.config MAESTRO_ENV=testing gotestsum --jsonfile-timing-events=$(mqtt_integration_test_json_output) --format $(TEST_SUMMARY_FORMAT) -- -count=1 -p 1 -ldflags -s -v -timeout 1h $(TESTFLAGS) \
273273
./test/integration
274274
.PHONY: test-integration-mqtt
275275

276276
test-integration-pubsub:
277-
MESSAGE_BROKER_TYPE=pubsub MESSAGE_BROKER_CONFIG=$(PWD)/secrets/pubsub.config MAESTRO_ENV=testing gotestsum --jsonfile-timing-events=$(pubsub_integration_test_json_output) --format $(TEST_SUMMARY_FORMAT) -- -p 1 -ldflags -s -v -timeout 1h $(TESTFLAGS) \
277+
MESSAGE_DRIVER_TYPE=pubsub MESSAGE_DRIVER_CONFIG=$(PWD)/secrets/pubsub.config PUBSUB_EMULATOR_HOST=localhost:$(pubsub_port) MAESTRO_ENV=testing gotestsum --jsonfile-timing-events=$(pubsub_integration_test_json_output) --format $(TEST_SUMMARY_FORMAT) -- -count=1 -p 1 -ldflags -s -v -timeout 1h $(TESTFLAGS) \
278278
./test/integration
279279
.PHONY: test-integration-pubsub
280280

281281
test-integration-grpc:
282-
MESSAGE_BROKER_TYPE=grpc MAESTRO_ENV=testing gotestsum --jsonfile-timing-events=$(grpc_integration_test_json_output) --format $(TEST_SUMMARY_FORMAT) -- -count=1 -p 1 -ldflags -s -v -timeout 1h $(TESTFLAGS) \
282+
MESSAGE_DRIVER_TYPE=grpc MAESTRO_ENV=testing gotestsum --jsonfile-timing-events=$(grpc_integration_test_json_output) --format $(TEST_SUMMARY_FORMAT) -- -count=1 -p 1 -ldflags -s -v -timeout 1h $(TESTFLAGS) \
283283
./test/integration
284284
.PHONY: test-integration-grpc
285285

@@ -480,13 +480,8 @@ pubsub/teardown:
480480
$(container_tool) rm pubsub-maestro
481481

482482
.PHONY: pubsub/init
483-
pubsub/init: pubsub/setup
484-
@echo "Initializing Pub/Sub emulator topics and subscriptions..."
485-
@echo "Waiting for emulator to be ready..."
486-
@for i in {1..30}; do \
487-
curl -s http://localhost:$(pubsub_port) >/dev/null 2>&1 && break || sleep 1; \
488-
done
489-
@PUBSUB_EMULATOR_HOST=localhost:$(pubsub_port) PUBSUB_PROJECT_ID=$(pubsub_project_id) python3 hack/init-pubsub-emulator.py
483+
pubsub/init:
484+
@PUBSUB_EMULATOR_HOST=localhost:$(pubsub_port) PUBSUB_PROJECT_ID=$(pubsub_project_id) bash hack/init-pubsub-emulator.sh
490485

491486
crc/login:
492487
@echo "Logging into CRC"

hack/init-pubsub-emulator.py

Lines changed: 0 additions & 147 deletions
This file was deleted.

0 commit comments

Comments
 (0)