Skip to content

Commit

Permalink
chore: fixed issue with running integration tests in the core package…
Browse files Browse the repository at this point in the history
… for SonarCloud check (#961)

added a prefix to integration tests, enabling them to be executed independently using the -run flag with coverage.
  • Loading branch information
nithinputhenveettil authored Dec 3, 2024
1 parent e214a57 commit b53c47b
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/coverage_run_and_upload_sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,26 @@ jobs:
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'mysecretpassword'"
echo "After starting Postgres"
echo "unit tests - core package"
go test -v -coverpkg=./... -cover -covermode atomic -coverprofile $TRACER_PATH/coverage/coverage.out ./... -json > $TRACER_PATH/coverage/coverage.json
echo "integration tests - core package"
INTEGRATION_TESTS_TAGS=("fargate" "gcr" "lambda" "azure" "generic_serverless" "azureContainerApps")
for str in ${INTEGRATION_TESTS_TAGS[@]}; do
go test -v -coverpkg=./... -cover -covermode atomic -coverprofile $TRACER_PATH/coverage/coverage_$(date +%s%N)_$RANDOM.out -tags="$str integration" ./... -run TestIntegration -json > $TRACER_PATH/coverage/coverage_$(date +%s%N)_$RANDOM.json
done
DEPRECATED_PKGS=".*instaamqp$"
LIB_LIST=$(find ./instrumentation -name go.mod -exec dirname {} \; | grep -E -v "$DEPRECATED_PKGS")

echo "unit tests - instrumentation packages"
for lib in $LIB_LIST
do echo "Generating test coverage for $lib" && cd "$lib" && go mod tidy && go test -v -coverpkg=./... -cover -covermode atomic -coverprofile $TRACER_PATH/coverage/coverage_$(date +%s%N)_$RANDOM.out ./... -json > $TRACER_PATH/coverage/coverage_$(date +%s%N)_$RANDOM.json && cd -;
done

echo "integration tests - instrumentation packages"
INTEGRATIONS_TESTS=("instagocb" "instapgx" "instacosmos" "instapgx/v2")

for str in ${INTEGRATIONS_TESTS[@]}; do
dir=./instrumentation/$str
echo "Generating test coverage for $dir"
Expand Down
6 changes: 3 additions & 3 deletions azure_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}

func TestAzureAgent_SendSpans(t *testing.T) {
func TestIntegration_AzureAgent_SendSpans(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestAzureAgent_SendSpans(t *testing.T) {
assert.JSONEq(t, `{"hl": true, "cp": "azure", "e": "/subscriptions/testgh05-3f0d-4bf9-8f53-209408003632/resourceGroups/test-resourcegroup/providers/Microsoft.Web/sites/test-funcname"}`, string(spans[0]["f"]))
}

func TestAzureAgent_SpanDetails(t *testing.T) {
func TestIntegration_AzureAgent_SpanDetails(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down Expand Up @@ -109,7 +109,7 @@ func TestAzureAgent_SpanDetails(t *testing.T) {
}}`, string(spans[0]["data"]))
}

func TestAzureAgent_SendSpans_Error(t *testing.T) {
func TestIntegration_AzureAgent_SendSpans_Error(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down
4 changes: 2 additions & 2 deletions azure_container_apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}

func TestAzureContainerApps_SendSpans(t *testing.T) {
func TestIntegration_AzureContainerApps_SendSpans(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestAzureContainerApps_SendSpans(t *testing.T) {
assert.JSONEq(t, `{"hl": true, "cp": "azure", "e": "/subscriptions/testgh05-3f0d-4bf9-8f53-209408003632/resourceGroups/testresourcegroup/providers/Microsoft.App/containerapps/azureapp"}`, string(spans[0]["f"]))
}

func TestAzureAgent_SendSpans_Error(t *testing.T) {
func TestIntegration_AzureAgent_SendSpans_Error(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down
6 changes: 3 additions & 3 deletions fargate_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}

func TestFargateAgent_SendMetrics(t *testing.T) {
func TestIntegration_FargateAgent_SendMetrics(t *testing.T) {
defer agent.Reset()

require.Eventually(t, func() bool { return len(agent.Bundles) > 0 }, 2*time.Second, 500*time.Millisecond)
Expand Down Expand Up @@ -204,7 +204,7 @@ func TestFargateAgent_SendMetrics(t *testing.T) {
})
}

func TestFargateAgent_SendSpans(t *testing.T) {
func TestIntegration_FargateAgent_SendSpans(t *testing.T) {
defer agent.Reset()

sensor := instana.NewSensor("testing")
Expand Down Expand Up @@ -246,7 +246,7 @@ func TestFargateAgent_SendSpans(t *testing.T) {
assert.JSONEq(t, `{"hl": true, "cp": "aws", "e": "arn:aws:ecs:us-east-2:012345678910:task/9781c248-0edd-4cdb-9a93-f63cb662a5d3::nginx-curl"}`, string(spans[0]["f"]))
}

func TestFargateAgent_FlushSpans(t *testing.T) {
func TestIntegration_FargateAgent_FlushSpans(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down
6 changes: 3 additions & 3 deletions gcr_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}

func TestGCRAgent_SendMetrics(t *testing.T) {
func TestIntegration_GCRAgent_SendMetrics(t *testing.T) {
defer agent.Reset()

require.Eventually(t, func() bool { return len(agent.Bundles) > 0 }, 2*time.Second, 500*time.Millisecond)
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestGCRAgent_SendMetrics(t *testing.T) {
})
}

func TestGCRAgent_SendSpans(t *testing.T) {
func TestIntegration_GCRAgent_SendSpans(t *testing.T) {
defer agent.Reset()

sensor := instana.NewSensor("testing")
Expand Down Expand Up @@ -177,7 +177,7 @@ func TestGCRAgent_SendSpans(t *testing.T) {
assert.JSONEq(t, `{"hl": true, "cp": "gcp", "e": "id1"}`, string(spans[0]["f"]))
}

func TestGCRAgent_FlushSpans(t *testing.T) {
func TestIntegration_GCRAgent_FlushSpans(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down
4 changes: 2 additions & 2 deletions generic_serverless_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}

func TestLocalServerlessAgent_SendSpans(t *testing.T) {
func TestIntegration_LocalServerlessAgent_SendSpans(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down Expand Up @@ -61,7 +61,7 @@ func TestLocalServerlessAgent_SendSpans(t *testing.T) {
require.Len(t, spans, 1)
}

func TestLocalServerlessAgent_SendSpans_Error(t *testing.T) {
func TestIntegration_LocalServerlessAgent_SendSpans_Error(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down
4 changes: 2 additions & 2 deletions lambda_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}

func TestLambdaAgent_SendSpans(t *testing.T) {
func TestIntegration_LambdaAgent_SendSpans(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down Expand Up @@ -85,7 +85,7 @@ func TestLambdaAgent_SendSpans(t *testing.T) {
assert.JSONEq(t, `{"hl": true, "cp": "aws", "e": "aws::test-lambda::$LATEST"}`, string(spans[0]["f"]))
}

func TestLambdaAgent_SendSpans_Error(t *testing.T) {
func TestIntegration_LambdaAgent_SendSpans_Error(t *testing.T) {
defer agent.Reset()

tracer := instana.NewTracer()
Expand Down

0 comments on commit b53c47b

Please sign in to comment.