Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
add oats test
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitlinger committed Dec 18, 2023
1 parent 9f97791 commit 7be5c13
Show file tree
Hide file tree
Showing 16 changed files with 1,161 additions and 66 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/acceptance-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Acceptance Tests

on:
pull_request:
branches:
- main
types:
- labeled
- opened
- synchronize
- reopened

jobs:
acceptance-tests:
# see https://stackoverflow.com/questions/62325286/run-github-actions-when-pull-requests-have-a-specific-label
if: contains(github.event.pull_request.labels.*.name, 'oats')
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Check out oats
uses: actions/checkout@v4
with:
repository: grafana/oats
ref: d2e59f9857d898f9d0f606714de3b22ee9d61804
path: oats
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache-dependency-path: oats/go.sum
- name: Validate Gradle wrapper
uses: gradle/[email protected]
- name: Setup Gradle and run build
uses: gradle/[email protected]
working-directory: integrationTests/oats
run: ./gradlew build
- name: Run acceptance tests
run: ./scripts/run-acceptance-tests.sh
- name: upload log file
uses: actions/upload-artifact@v3
if: failure()
with:
name: docker-compose.log
path: oats/yaml/build/**/output.log
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* gRPC not supported anymore
* Environment variables starting with "OTEL_" are not supported anymore, because they will only affect the trace and log exporter
* Application name and version are not read from MANIFEST.MF anymore, because this also wrongly reads information from dependencies
* support OTEL_EXPORTER_OTLP_ENDPOINT in addition to grafana.otlp.onprem.endpoint

## Version 1.4.0 (2023-12-07)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
@TestPropertySource(
properties = {
"grafana.otlp.onprem.endpoint = http://localhost:${mockServerPort}",
"grafana.otlp.onprem.protocol = http/protobuf",
})
public class Log4jIntegrationTest {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.grafana.opentelemetry;

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.Metrics;
Expand All @@ -17,13 +15,11 @@
import org.apache.commons.lang3.reflect.MethodUtils;
import org.junit.jupiter.api.Test;
import org.mockserver.client.MockServerClient;
import org.mockserver.model.HttpRequest;
import org.mockserver.springtest.MockServerTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.actuate.observability.AutoConfigureObservability;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.http.HttpMethod;
import org.springframework.test.context.TestPropertySource;

@SpringBootTest(
Expand All @@ -44,6 +40,10 @@ class IntegrationTest {

@Autowired private GrafanaProperties properties;

@SuppressWarnings("unused")
@Autowired
private ConnectionProperties connectionProperties;

@Autowired private Optional<AutoConfiguredOpenTelemetrySdk> sdk;

@Test
Expand Down Expand Up @@ -90,30 +90,4 @@ private static List<Map.Entry<String, String>> getMetricsResourceAttributes()
}
return Collections.emptyList();
}

@Test
void dataIsSent() {
restTemplate.getForEntity("/hello", String.class);

await()
.atMost(10, SECONDS)
.untilAsserted(
() -> {
verifyPath("/v1/traces");
verifyPath("/v1/metrics");
verifyPath("/v1/logs");
});
}

private void verifyPath(String path) {
// only assert that a request was received,
// because the goal of this test is to make sure that data is still sent when dependabot
// upgrades
// spring boot, which can also update the OpenTelemetry version
mockServerClient.verify(
HttpRequest.request()
.withMethod(HttpMethod.POST.name())
.withPath(path)
.withHeader("Content-Type", "application/x-protobuf"));
}
}
15 changes: 15 additions & 0 deletions integrationTests/oats/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.0'
id 'io.spring.dependency-management' version '1.1.4'
}

repositories {
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation rootProject
}
17 changes: 17 additions & 0 deletions integrationTests/oats/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.9'

services:
application:
image: eclipse-temurin:17-jre
volumes:
- ./build/libs:/libs
environment:
OTEL_EXPORTER_OTLP_ENDPOINT: "http://collector:4318"
OTEL_METRIC_EXPORT_INTERVAL: "5000" # so we don't have to wait 60s for metrics
command:
- /bin/bash
- -c
- java -jar /libs/*.jar
ports:
- 8080:8080

Loading

0 comments on commit 7be5c13

Please sign in to comment.