-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add end-2-end tests for metrics service
Issue: COSI-46
- Loading branch information
1 parent
d46982a
commit e477885
Showing
2 changed files
with
61 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
LOG_FILE=".github/e2e_tests/artifacts/logs/e2e_tests/metrics_service.log" | ||
mkdir -p "$(dirname "$LOG_FILE")" | ||
|
||
NAMESPACE="scality-object-storage" | ||
SERVICE="scality-cosi-metrics" | ||
LOCAL_PORT=8080 | ||
TARGET_PORT=8080 | ||
|
||
# Error handling function | ||
error_handler() { | ||
echo "An error occurred during bucket creation tests. Check the log file for details." | tee -a "$LOG_FILE" | ||
echo "Failed command: $BASH_COMMAND" | tee -a "$LOG_FILE" | ||
exit 1 | ||
} | ||
|
||
# Trap errors and call the error handler | ||
trap 'error_handler' ERR | ||
|
||
# Log command execution to the log file for debugging | ||
log_and_run() { | ||
"$@" 2>&1 | tee -a "$LOG_FILE" | ||
} | ||
|
||
kubectl port-forward svc/$SERVICE -n $NAMESPACE $LOCAL_PORT:$TARGET_PORT & | ||
PORT_FORWARD_PID=$! | ||
|
||
if ps -p $PORT_FORWARD_PID > /dev/null; then | ||
log_and_run echo "Port-forwarding established. Querying metrics..." | ||
|
||
log_and_run curl -f http://localhost:$LOCAL_PORT/metrics > metrics_output.txt | ||
|
||
if [ $? -eq 0 ]; then | ||
log_and_run echo "Metrics fetched successfully. Metrics output:" | ||
log_and_run cat metrics_output.txt | ||
METRICS_WORKING=true | ||
else | ||
log_and_run echo "Failed to fetch metrics from http://localhost:$LOCAL_PORT/metrics" | ||
METRICS_WORKING=false | ||
fi | ||
|
||
log_and_run kill $PORT_FORWARD_PID | ||
else | ||
log_and_run echo "Port-forwarding failed to establish." | ||
METRICS_WORKING=false | ||
fi | ||
|
||
if [ "$METRICS_WORKING" = true ]; then | ||
log_and_run echo "Metrics service is working as expected." | ||
exit 0 | ||
else | ||
log_and_run echo "Metrics service is not working as expected." | ||
exit 1 | ||
fi | ||
|
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 |
---|---|---|
|
@@ -104,6 +104,10 @@ jobs: | |
run: | | ||
.github/scripts/e2e_tests_brownfield_use_case.sh | ||
- name: E2E tests for brownfield use case using kustomize | ||
run: | | ||
.github/scripts/e2e_tests_metrics_service.sh | ||
- name: "Delay completion" | ||
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} | ||
uses: scality/actions/[email protected] | ||
|