From 68f61c4571f879e5a6ffb0cfbd038d350b7f075a Mon Sep 17 00:00:00 2001 From: Nikola Grcevski Date: Fri, 27 Sep 2024 14:54:29 -0400 Subject: [PATCH] add integration test --- test/integration/docker-compose-ruby.yml | 3 +++ test/integration/red_test_ruby.go | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/test/integration/docker-compose-ruby.yml b/test/integration/docker-compose-ruby.yml index b01fb83d5..a81501757 100644 --- a/test/integration/docker-compose-ruby.yml +++ b/test/integration/docker-compose-ruby.yml @@ -5,6 +5,9 @@ services: image: ghcr.io/grafana/beyla-test/greeting-rails${TESTSERVER_IMAGE_SUFFIX}/0.0.1 ports: - "${TEST_SERVICE_PORTS}" + environment: + OTEL_SERVICE_NAME: "my-ruby-app" + OTEL_RESOURCE_ATTRIBUTES: "data-center=ca,deployment-zone=to" depends_on: otelcol: condition: service_started diff --git a/test/integration/red_test_ruby.go b/test/integration/red_test_ruby.go index 3ceeafd94..29e88a736 100644 --- a/test/integration/red_test_ruby.go +++ b/test/integration/red_test_ruby.go @@ -48,6 +48,18 @@ func testREDMetricsForRubyHTTPLibrary(t *testing.T, url string, comm string) { } }) + // check that the resource attributes we passed made it for the service + test.Eventually(t, testTimeout, func(t require.TestingT) { + var err error + results, err = pq.Query(`target_info{` + + `data_center="ca",` + + `deployment_zone="to"}`) + require.NoError(t, err) + enoughPromResults(t, results) + val := totalPromCount(t, results) + assert.LessOrEqual(t, 1, val) + }) + // Call 4 times the instrumented service, forcing it to: // - process multiple calls in a row with, one more than we might need // - returning a 200 code @@ -83,7 +95,7 @@ func testREDMetricsRailsHTTP(t *testing.T) { } { t.Run(testCaseURL, func(t *testing.T) { waitForRubyTestComponents(t, testCaseURL) - testREDMetricsForRubyHTTPLibrary(t, testCaseURL, "ruby") + testREDMetricsForRubyHTTPLibrary(t, testCaseURL, "my-ruby-app") }) } } @@ -94,7 +106,7 @@ func testREDMetricsRailsHTTPS(t *testing.T) { } { t.Run(testCaseURL, func(t *testing.T) { waitForRubyTestComponents(t, testCaseURL) - testREDMetricsForRubyHTTPLibrary(t, testCaseURL, "ruby") + testREDMetricsForRubyHTTPLibrary(t, testCaseURL, "my-ruby-app") }) } }