Skip to content

Commit

Permalink
Merge branch 'master' of github.com:inspectIT/inspectit-ocelot into u…
Browse files Browse the repository at this point in the history
…pdate-dependencies-266
  • Loading branch information
EddeCCC committed Nov 12, 2024
2 parents 2919c53 + 7a8f734 commit 27e6b5d
Showing 1 changed file with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package rocks.inspectit.ocelot.core.exporter;

import de.flapdoodle.embed.process.runtime.Network;
import io.apisense.embed.influx.InfluxServer;
import io.apisense.embed.influx.configuration.InfluxConfigurationWriter;
import io.github.netmikey.logunit.api.LogCapturer;
import io.opencensus.common.Scope;
import io.opencensus.stats.*;
Expand All @@ -12,49 +9,53 @@
import org.influxdb.InfluxDB;
import org.influxdb.InfluxDBFactory;
import org.influxdb.InfluxDBIOException;
import org.influxdb.dto.Pong;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import org.springframework.test.annotation.DirtiesContext;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import rocks.inspectit.ocelot.core.SpringTestBase;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;

import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;

@Testcontainers
public class InfluxExporterServiceIntTest extends SpringTestBase {

private InfluxServer influx;

private String url;

private static final String DATABASE = "ocelot_test";

@RegisterExtension
LogCapturer warnLogs = LogCapturer.create().captureForType(InfluxExporterService.class, org.slf4j.event.Level.WARN);

@Container
private final GenericContainer influx = new GenericContainer(DockerImageName.parse("influxdb:1.8"))
.withExposedPorts(8086)
.withEnv("INFLUXDB_DB", DATABASE)
.withEnv("INFLUXDB_USER", "w00t")
.withEnv("INFLUXDB_USER_PASSWORD", "password");

@BeforeEach
void startInfluxDB() throws Exception {
InfluxServer.Builder builder = new InfluxServer.Builder();
int freeHttpPort = Network.getFreeServerPort();
InfluxConfigurationWriter influxConfig = new InfluxConfigurationWriter.Builder().setHttp(freeHttpPort) // by default auth is disabled
.build();
builder.setInfluxConfiguration(influxConfig);
influx = builder.build();
influx.start();
url = "http://localhost:" + freeHttpPort;
void startInfluxDB() {
String address = influx.getHost();
Integer port = influx.getFirstMappedPort();
this.url = "http://" + address + ":" + port;
}

@AfterEach
void shutdownInfluxDB() throws Exception {
influx.cleanup();
void shutdownInfluxDB() {
influx.stop();
}

private final String user = "w00t";
Expand All @@ -75,8 +76,7 @@ void verifyInfluxDataWritten() {

TagKey testTag = TagKey.create("my_tag");
Measure.MeasureDouble testMeasure = Measure.MeasureDouble.create("my/test/measure", "foo", "bars");
View testView = View.create(View.Name.create("my/test/measure/cool%data"), "", testMeasure, Aggregation.Sum.create(), Arrays
.asList(testTag));
View testView = View.create(View.Name.create("my/test/measure/cool%data"), "", testMeasure, Aggregation.Sum.create(), Collections.singletonList(testTag));
Stats.getViewManager().registerView(testView);

try (Scope tc = Tags.getTagger().emptyBuilder().putLocal(testTag, TagValue.create("myval")).buildScoped()) {
Expand Down

0 comments on commit 27e6b5d

Please sign in to comment.