Skip to content
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

Add test for unsupported Go #490

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions test/integration/docker-compose-1.16.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
version: '3.8'

services:
testserver:
image: ghcr.io/grafana/beyla-test/testserver-go-1.16/0.0.1
ports:
- "8080:8080"
- "8081:8081"
- "8082:8082"
- "8083:8083"
- "8087:8087"
- "50051:50051"
environment:
LOG_LEVEL: DEBUG

autoinstrumenter:
build:
context: ../..
dockerfile: ./test/integration/components/beyla/Dockerfile
command:
- /beyla
- --config=/configs/instrumenter-config-java.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be the Java one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's fine :). The java one doesn't have jaeger in, so I just stole one that existed to avoid making yet another config file.

volumes:
- ./configs/:/configs
- ../../testoutput:/coverage
- ../../testoutput/run:/var/run/beyla
image: hatest-autoinstrumenter
privileged: true # in some environments (not GH Pull Requests) you can set it to false and then cap_add: [ SYS_ADMIN ]
pid: "service:testserver"
environment:
GOCOVERDIR: "/coverage"
BEYLA_PRINT_TRACES: "true"
BEYLA_OPEN_PORT: 8080
BEYLA_DISCOVERY_POLL_INTERVAL: 500ms
BEYLA_SERVICE_NAMESPACE: "integration-test"
BEYLA_METRICS_INTERVAL: "10ms"
BEYLA_BPF_BATCH_TIMEOUT: "10ms"
BEYLA_LOG_LEVEL: "DEBUG"
BEYLA_BPF_DEBUG: "TRUE"
BEYLA_METRICS_REPORT_TARGET: "true"
BEYLA_METRICS_REPORT_PEER: "true"
BEYLA_INTERNAL_METRICS_PROMETHEUS_PORT: 8999
BEYLA_HOSTNAME: "beyla"
BEYLA_SKIP_GO_SPECIFIC_TRACERS: "true"
ports:
- "8999:8999" # Prometheus scrape port, if enabled via config

# OpenTelemetry Collector for Metrics. For Traces, we use directly Jaeger
otelcol:
image: otel/opentelemetry-collector-contrib:0.77.0
container_name: otel-col
deploy:
resources:
limits:
memory: 125M
restart: unless-stopped
command: [ "--config=/etc/otelcol-config/otelcol-config.yml" ]
volumes:
- ./configs/:/etc/otelcol-config
ports:
- "4317" # OTLP over gRPC receiver
- "4318" # OTLP over HTTP receiver
- "9464" # Prometheus exporter
- "8888" # metrics endpoint
depends_on:
autoinstrumenter:
condition: service_started
prometheus:
condition: service_started

# Prometheus
prometheus:
image: quay.io/prometheus/prometheus:v2.34.0
container_name: prometheus
command:
- --storage.tsdb.retention.time=1m
- --config.file=/etc/prometheus/prometheus-config${PROM_CONFIG_SUFFIX}.yml
- --storage.tsdb.path=/prometheus
- --web.enable-lifecycle
- --web.route-prefix=/
volumes:
- ./configs/:/etc/prometheus
ports:
- "9090:9090"
53 changes: 53 additions & 0 deletions test/integration/red_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -541,3 +541,56 @@ func testREDMetricsHTTPNoRoute(t *testing.T) {
})
}
}

func testREDMetricsUnsupportedHTTP(t *testing.T) {
for _, testCaseURL := range []string{
instrumentedServiceStdURL,
} {
t.Run(testCaseURL, func(t *testing.T) {
waitForTestComponents(t, testCaseURL)
testREDMetricsForGoBasicOnly(t, testCaseURL, "testserver")
})
}
}

func testREDMetricsForGoBasicOnly(t *testing.T, url string, comm string) {
path := "/old"

// Call 3 times the instrumented service, forcing it to:
// - take at least 30ms to respond
// - returning a 204 code
for i := 0; i < 4; i++ {
doHTTPGet(t, url+path+"?delay=30", 200)
}

commMatch := `service_name="` + comm + `",`
namespaceMatch := `service_namespace="integration-test",`
if comm == "" {
commMatch = ""
namespaceMatch = ""
}

// Eventually, Prometheus would make this query visible
pq := prom.Client{HostPort: prometheusHostPort}
var results []prom.Result
test.Eventually(t, testTimeout, func(t require.TestingT) {
var err error
results, err = pq.Query(`http_server_duration_seconds_count{` +
`http_request_method="GET",` +
`http_response_status_code="200",` +
namespaceMatch +
commMatch +
`url_path="` + path + `"}`)
require.NoError(t, err)
// check duration_count has 3 calls and all the arguments
enoughPromResults(t, results)
if len(results) > 0 {
val := totalPromCount(t, results)
assert.LessOrEqual(t, 3, val)

res := results[0]
addr := net.ParseIP(res.Metric["client_address"])
assert.NotNil(t, addr)
}
})
}
10 changes: 10 additions & 0 deletions test/integration/suites_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ func TestSuite_OldestGoVersion(t *testing.T) {
t.Run("BPF pinning folder unmounted", testBPFPinningUnmounted)
}

func TestSuite_UnsupportedGoVersion(t *testing.T) {
compose, err := docker.ComposeSuite("docker-compose-1.16.yml", path.Join(pathOutput, "test-suite-unsupported-go.log"))
require.NoError(t, err)
require.NoError(t, compose.Up())
t.Run("RED metrics", testREDMetricsUnsupportedHTTP)
t.Run("BPF pinning folder mounted", testBPFPinningMounted)
require.NoError(t, compose.Close())
t.Run("BPF pinning folder unmounted", testBPFPinningUnmounted)
}

func TestSuite_SkipGoTracers(t *testing.T) {
compose, err := docker.ComposeSuite("docker-compose.yml", path.Join(pathOutput, "test-suite-skip-go-tracers.log"))
compose.Env = append(compose.Env, `BEYLA_SKIP_GO_SPECIFIC_TRACERS=1`)
Expand Down