Skip to content
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
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ libsql-java/
- Maps SQLite dynamic typing to JDBC SQL types and translates Hrana error codes to `SQLException` hierarchies.

4. **`libsql-itests`**:
- All tests run against containerized `sqld` (`ghcr.io/tursodatabase/libsql-server:latest`).
- All tests run against a pinned `sqld` image (`ghcr.io/tursodatabase/libsql-server:v0.24.33`).
- The pin lives in the root `pom.xml` as the `libsql.image` property, and Maven passes it to both the integration and conformance test JVMs. Override it with `-Dlibsql.image=...` only for a deliberate version bump.
- Includes HikariCP connection pool churn tests and Toxiproxy network toxicity tests.

---
Expand Down
16 changes: 12 additions & 4 deletions TESTCONTAINERS-USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ This document explains how Testcontainers is configured and utilized in this pro
Testing a pure-Java JDBC driver for Turso requires verifying real SQLite behavior, lock contention, HTTP pipeline batons, and network edge cases over the wire. Rather than mocking HTTP endpoints, we run real `sqld` instances using Testcontainers.

### Container Image
* **Image**: `ghcr.io/tursodatabase/libsql-server:latest`
* **Image**: `ghcr.io/tursodatabase/libsql-server:v0.24.33`
* **Exposed Port**: `8080` (HTTP and Hrana pipeline endpoint)

The image can also be overridden via the system property `-Dlibsql.image=<custom_image>`.
The image is pinned to a released `sqld` version so that `latest` cannot silently change
the behavior under test. The pin is defined once in the root `pom.xml` as the
`libsql.image` property, and Maven passes it to both the integration and conformance
test JVMs. To test a different version, override the property:

```bash
./mvnw verify -Dlibsql.image=ghcr.io/tursodatabase/libsql-server:v0.24.33
```

---

Expand All @@ -35,7 +42,8 @@ import java.time.Duration;
@Testcontainers
public abstract class SqldContainerBase {

private static final String LIBSQL_IMAGE = System.getProperty("libsql.image", "ghcr.io/tursodatabase/libsql-server:latest");
// Supplied by the root pom's libsql.image property via surefire/failsafe.
private static final String LIBSQL_IMAGE = System.getProperty("libsql.image");
private static final int PORT = 8080;

@Container
Expand Down Expand Up @@ -105,7 +113,7 @@ public class NetworkToxicityIntegrationIT {

private static final Network NETWORK = Network.newNetwork();

private static final GenericContainer<?> LIBSQL = new GenericContainer<>("ghcr.io/tursodatabase/libsql-server:latest")
private static final GenericContainer<?> LIBSQL = new GenericContainer<>(SqldContainerBase.LIBSQL_IMAGE)
.withNetwork(NETWORK)
.withNetworkAliases("libsql-srv")
.withExposedPorts(8080)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@

public final class XerialTestServer {

private static final String IMAGE =
System.getProperty(
"libsql.image",
"ghcr.io/tursodatabase/libsql-server@sha256:6dd3eb276d9d3604e4a48ac4a999a2e267814732d57d7e94c04ba71482333a67");
private static final String IMAGE = requireLibsqlImage();
private static final int HTTP_PORT = 8080;
private static final int ADMIN_PORT = 9090;
private static final Duration REQUEST_TIMEOUT = Duration.ofSeconds(30);
Expand All @@ -52,6 +49,16 @@ public final class XerialTestServer {

private XerialTestServer() {}

private static String requireLibsqlImage() {
String image = System.getProperty("libsql.image");
if (image == null || image.isBlank()) {
throw new IllegalStateException(
"libsql.image is not set. Run the conformance tests with Maven so the"
+ " pinned sqld image from the root pom is used.");
}
return image;
}

public static synchronized void start() {
if (container != null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@
@Testcontainers
public class NamespacePathIT {

private static final String LIBSQL_IMAGE = System.getProperty("libsql.image", "ghcr.io/tursodatabase/libsql-server:latest");
private static final int HTTP_PORT = 8080;
private static final int ADMIN_PORT = 9090;

@Container
public static final GenericContainer<?> SQLD_CONTAINER = new GenericContainer<>(LIBSQL_IMAGE)
public static final GenericContainer<?> SQLD_CONTAINER = new GenericContainer<>(SqldContainerBase.LIBSQL_IMAGE)
.withExposedPorts(HTTP_PORT, ADMIN_PORT)
.withCommand(
"sqld",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public class NetworkToxicityIT {

private static final Network NETWORK = Network.newNetwork();

private static final GenericContainer<?> LIBSQL = new GenericContainer<>("ghcr.io/tursodatabase/libsql-server:latest")
private static final GenericContainer<?> LIBSQL =
new GenericContainer<>(SqldContainerBase.LIBSQL_IMAGE)
.withNetwork(NETWORK)
.withNetworkAliases("libsql-srv")
.withExposedPorts(8080)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,19 @@
@Testcontainers
public abstract class SqldContainerBase {

private static final String LIBSQL_IMAGE = System.getProperty("libsql.image", "ghcr.io/tursodatabase/libsql-server:latest");
static final String LIBSQL_IMAGE = requireLibsqlImage();
private static final int PORT = 8080;

private static String requireLibsqlImage() {
String image = System.getProperty("libsql.image");
if (image == null || image.isBlank()) {
throw new IllegalStateException(
"libsql.image is not set. Run the integration tests with Maven so the"
+ " pinned sqld image from the root pom is used.");
}
return image;
}

@Container
public static final GenericContainer<?> LIBSQL_CONTAINER = new GenericContainer<>(LIBSQL_IMAGE)
.withExposedPorts(PORT)
Expand Down
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
<testcontainers.version>2.0.5</testcontainers.version>
<hikaricp.version>7.1.0</hikaricp.version>
<protobuf.version>4.36.1</protobuf.version>
<!-- Pinned sqld image for the integration and conformance suites. Bump deliberately. -->
<libsql.image>ghcr.io/tursodatabase/libsql-server:v0.24.33</libsql.image>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -137,11 +139,21 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<systemPropertyVariables>
<libsql.image>${libsql.image}</libsql.image>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<systemPropertyVariables>
<libsql.image>${libsql.image}</libsql.image>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
Expand Down
Loading