OpenLIT Testcontainers
A Testcontainers module providing OpenLitContainer, which runs OpenLIT, an AI engineering platform based on OpenTelemetry, together with the ClickHouse database it stores the telemetry in.
Dependencies
Add the module to your project.
-
Gradle
-
Maven
dependencies {
testImplementation "io.arconia:arconia-testcontainers-openlit"
}
<dependency>
<groupId>io.arconia</groupId>
<artifactId>arconia-testcontainers-openlit</artifactId>
<scope>test</scope>
</dependency>
Usage
var openLit = new OpenLitContainer("ghcr.io/openlit/openlit:latest");
openLit.start();
OpenLIT accepts logs, metrics, and traces via OTLP, with the HTTP/Protobuf protocol at getOtlpHttpUrl() and the gRPC protocol at getOtlpGrpcUrl(). The container requires OpenLIT 2.1.1 or later, which receives OTLP data with its built-in receiver.
The UI is available at getOpenLitUrl(), where you’re signed in automatically with the demo account created by OpenLIT: user@openlit.io (email) and openlituser (password). OpenLIT restricts a few operations for the demo account, such as changing the database configuration. To sign in yourself instead, set the DEMO_ACCOUNT_EMAIL environment variable to an empty value.
var openLit = new OpenLitContainer("ghcr.io/openlit/openlit:latest")
.withEnv("DEMO_ACCOUNT_EMAIL", "");
The ClickHouse container starts before OpenLIT and stops together with it. Set its image via withClickHouseImage().
var openLit = new OpenLitContainer("ghcr.io/openlit/openlit:latest")
.withClickHouseImage("clickhouse/clickhouse-server:latest");
OpenLIT and ClickHouse join the network set via withNetwork(). Otherwise, the container creates a network for them and removes it when it stops. The ClickHouse container has the fixed network alias openlit-clickhouse, so run one OpenLIT container per network.
With withReuse(true), the ClickHouse container is reused too. Unless a network is set, both join the arconia-openlit network, which stays after the containers stop so that they find it again on the next run. Remove it once you no longer need the containers.
Spring Boot Service Connections
With Arconia OpenTelemetry and the Spring Boot Testcontainers support (org.springframework.boot:spring-boot-testcontainers), the application sends its logs, metrics, and traces to an OpenLitContainer bean annotated with @ServiceConnection.
@TestConfiguration(proxyBeanMethods = false)
public class TestcontainersConfiguration {
@Bean
@ServiceConnection
OpenLitContainer openLitContainer() {
return new OpenLitContainer("ghcr.io/openlit/openlit:latest");
}
}
| In Spring Boot applications, the OpenLIT Dev Service runs this container with no code and sends the telemetry of the application to it. |