-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Add SPM integration tests #5640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
bfa5532
added SPM test
hellspawn679 ba9d928
Merge branch 'jaegertracing:main' into spm
hellspawn679 acac74b
updated build-spm.sh
hellspawn679 5a54021
Merge branch 'main' into spm
hellspawn679 c822621
minor fix
hellspawn679 78f26bb
minor changes
hellspawn679 5dc699f
Merge branch 'main' into spm
yurishkuro 320f8b2
fix
yurishkuro eda16cd
Update .github/workflows/ci-build-spm.yml
yurishkuro 0b190ae
fix
hellspawn679 e863844
minor fix
hellspawn679 6d9c135
fixed
hellspawn679 54fc0c8
fixed
hellspawn679 bdb5205
Merge branch 'main' into spm
hellspawn679 b88b887
fixed
hellspawn679 b736d52
fixed
hellspawn679 95cf12f
fixed
hellspawn679 c9d150b
fixed
hellspawn679 d7f76c9
removed test file
hellspawn679 ca63817
Merge branch 'jaegertracing:main' into spm
hellspawn679 7342d03
fixed
e9be6c6
fixed
50ce07a
clean-up
yurishkuro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,133 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -e -uxf -o pipefail | ||
|
|
||
| compose_file=docker-compose/monitor/docker-compose.yml | ||
|
|
||
| dump_logs(){ | ||
| echo "::group:: docker logs" | ||
| docker compose -f $compose_file logs | ||
| echo "::endgroup::" | ||
| } | ||
|
|
||
| # Function to check if a service is healthy | ||
| check_service_health() { | ||
| local service_name=$1 | ||
| local url=$2 | ||
| local wait_seconds=5 | ||
| local retry_count=10 | ||
| echo "Checking health of service: $service_name at $url" | ||
| for i in $(seq 1 $retry_count); do | ||
| if curl -s -L --head --request GET "$url" | grep "200 OK" > /dev/null; then | ||
| echo "$service_name is healthy" | ||
| return 0 | ||
| else | ||
| echo "Waiting for $service_name to be healthy... ($i/$retry_count)" | ||
| sleep $wait_seconds | ||
| fi | ||
| done | ||
|
|
||
| echo "Error: $service_name did not become healthy in time" | ||
| return 1 | ||
| } | ||
|
|
||
| # Function to check if all services are healthy | ||
| wait_for_services() { | ||
| echo "Waiting for services to be up and running..." | ||
| check_service_health "Jaeger" "http://localhost:16686" | ||
| check_service_health "Prometheus" "http://localhost:9090/graph" | ||
| check_service_health "Grafana" "http://localhost:3000" | ||
| } | ||
| # Function to validate the service metrics | ||
| service_metrics_valider(){ | ||
| local service=$1 | ||
| local non_zero_count=0 | ||
| local all_non_zero=true | ||
| # Check if the service is up and running | ||
| response=$(curl -s "http://localhost:16686/api/metrics/calls?service=$service&endTs=$(date +%s)000&lookback=1000&step=100&ratePer=60000") | ||
| service_name=$(echo "$response" | jq -r 'if .metrics and .metrics[0] then .metrics[0].labels[] | select(.name=="service_name") | .value else empty end') | ||
| if [ "$service_name" != "$service" ]; then | ||
| echo "Service name does not match '$service'" | ||
| return 1 | ||
| else | ||
| echo "Service name matched with '$service'" | ||
| fi | ||
| #stores the gauge values in an array and make sure that there are at least 3 gauge values | ||
| mapfile -t metric_points < <(echo "$response" | jq -r '.metrics[0].metricPoints[].gaugeValue.doubleValue') | ||
| while [ ${#metric_points[@]} -lt 3 ]; do | ||
| echo "Metric points for service $service are less than 3" | ||
| mapfile -t metric_points < <(echo "$response" | jq -r '.metrics[0].metricPoints[].gaugeValue.doubleValue') | ||
| done | ||
| #check if all gauge values are non-zero and count is greater than 3 | ||
| for value in "${metric_points[@]}"; do | ||
| if [[ "$value" == "0" || "$value" == "0.0" ]]; then | ||
yurishkuro marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| all_non_zero=false | ||
| break | ||
| else | ||
| non_zero_count=$((non_zero_count + 1)) | ||
| fi | ||
| done | ||
| if [ "$all_non_zero" = true ] && [ $non_zero_count -gt 3 ]; then | ||
| echo "All gauge values are non-zero and count is greater than 3 for $service" | ||
| return 0 | ||
| else | ||
| echo "Some gauge values are zero or count is not greater than 3 for $service" | ||
| return 1 | ||
| fi | ||
| } | ||
|
|
||
|
|
||
| # Function to check SPM | ||
| check_spm() { | ||
| local timeout=180 | ||
| local interval=5 | ||
| local end_time=$((SECONDS + timeout)) | ||
| local successful_service=0 | ||
| echo "Checking SPM" | ||
| #list of services to check | ||
| services_list=("driver" "customer" "mysql" "redis" "frontend" "route" "ui") | ||
| for service in "${services_list[@]}"; do | ||
| echo "Processing service: $service" | ||
| while [ $SECONDS -lt $end_time ]; do | ||
| #check if the service metrics are returned by the API | ||
| if service_metrics_valider "$service"; then | ||
| successful_service=$((successful_service + 1)) | ||
| break | ||
| else | ||
| #timeout condition | ||
| if [ $SECONDS -gt $end_time ]; then | ||
| echo "Error: no metrics returned by the API for service $service" | ||
| exit 1 | ||
| fi | ||
| echo "Waiting for metrics to be returned by the API for service $service..." | ||
| sleep $interval | ||
| fi | ||
| done | ||
| done | ||
| if [ $successful_service -lt ${#services_list[@]} ]; then | ||
| echo "All services metrics are not returned by the API" | ||
| exit 1 | ||
| else | ||
| echo "All services metrics are returned by the API" | ||
| fi | ||
|
|
||
| } | ||
|
|
||
| # Function to tear down Docker Compose services | ||
| teardown_services() { | ||
| dump_logs | ||
| docker compose -f $compose_file down | ||
| } | ||
|
|
||
| # Main function | ||
| main() { | ||
| (cd docker-compose/monitor && make build && make dev DOCKER_COMPOSE_ARGS="-d") | ||
| wait_for_services | ||
| check_spm | ||
yurishkuro marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| echo "All services are running correctly" | ||
| } | ||
|
|
||
| trap teardown_services EXIT INT | ||
|
|
||
| # Run the main function | ||
| main | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.