Skip to content

Commit 643b815

Browse files
authored
Add QuestDB module (#5995)
Introduce Testcontainers implementation for `QuestDB`, `QuestDBContainer`.
1 parent f9edf87 commit 643b815

File tree

14 files changed

+253
-0
lines changed

14 files changed

+253
-0
lines changed

.github/ISSUE_TEMPLATE/bug_report.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ body:
4141
- PostgreSQL
4242
- Presto
4343
- Pulsar
44+
- QuestDB
4445
- RabbitMQ
4546
- Redpanda
4647
- Selenium

.github/ISSUE_TEMPLATE/enhancement.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ body:
4141
- PostgreSQL
4242
- Presto
4343
- Pulsar
44+
- QuestDB
4445
- RabbitMQ
4546
- Redpanda
4647
- Selenium

.github/ISSUE_TEMPLATE/feature.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ body:
3939
- Oracle-XE
4040
- OrientDB
4141
- PostgreSQL
42+
- QuestDB
4243
- Presto
4344
- Pulsar
4445
- RabbitMQ

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ updates:
195195
schedule:
196196
interval: "monthly"
197197
open-pull-requests-limit: 10
198+
- package-ecosystem: "gradle"
199+
directory: "/modules/questdb"
200+
schedule:
201+
interval: "monthly"
202+
open-pull-requests-limit: 10
198203
- package-ecosystem: "gradle"
199204
directory: "/modules/r2dbc"
200205
schedule:

.github/labeler.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
- modules/presto/*
6666
"modules/pulsar":
6767
- modules/pulsar/*
68+
"modules/questdb":
69+
- modules/questdb/*
6870
"modules/r2dbc":
6971
- modules/r2dbc/*
7072
"modules/rabbitmq":

docs/modules/databases/questdb.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# QuestDB Module
2+
3+
Testcontainers module for [QuestDB](https://github.com/questdb/questdb). QuestDB is a high-performance, open-source SQL
4+
database for applications in financial services, IoT, machine learning, DevOps and observability.
5+
6+
See [Database containers](./index.md) for documentation and usage that is common to all relational database container
7+
types.
8+
9+
## Adding this module to your project dependencies
10+
11+
Add the following dependency to your `pom.xml`/`build.gradle` file:
12+
13+
=== "Gradle"
14+
15+
```groovy
16+
testImplementation "org.testcontainers:questdb:{{latest_version}}"
17+
```
18+
19+
=== "Maven"
20+
21+
```xml
22+
23+
<dependency>
24+
<groupId>org.testcontainers</groupId>
25+
<artifactId>questdb</artifactId>
26+
<version>{{latest_version}}</version>
27+
<scope>test</scope>
28+
</dependency>
29+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ nav:
6363
- modules/databases/orientdb.md
6464
- modules/databases/postgres.md
6565
- modules/databases/presto.md
66+
- modules/databases/questdb.md
6667
- modules/databases/tidb.md
6768
- modules/databases/trino.md
6869
- modules/azure.md

modules/questdb/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
description = "Testcontainers :: QuestDB"
2+
3+
dependencies {
4+
api project(':testcontainers')
5+
api project(':jdbc')
6+
7+
testImplementation 'org.postgresql:postgresql:42.5.0'
8+
testImplementation project(':jdbc-test')
9+
testImplementation 'org.assertj:assertj-core:3.23.1'
10+
testImplementation 'org.questdb:questdb:6.4.3-jdk8'
11+
testImplementation 'org.awaitility:awaitility:4.2.0'
12+
testImplementation 'org.apache.httpcomponents:httpclient:4.5.13'
13+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
package org.testcontainers.containers;
2+
3+
import lombok.NonNull;
4+
import org.testcontainers.containers.wait.strategy.Wait;
5+
import org.testcontainers.utility.DockerImageName;
6+
7+
/**
8+
* Testcontainers implementation for QuestDB.
9+
*
10+
* @author vangreen
11+
* @author jerrinot
12+
*/
13+
public class QuestDBContainer extends JdbcDatabaseContainer<QuestDBContainer> {
14+
15+
static final String DATABASE_PROVIDER = "postgresql";
16+
17+
private static final String DEFAULT_DATABASE_NAME = "qdb";
18+
19+
private static final int DEFAULT_COMMIT_LAG_MS = 1000;
20+
21+
private static final String DEFAULT_USERNAME = "admin";
22+
23+
private static final String DEFAULT_PASSWORD = "quest";
24+
25+
private static final Integer POSTGRES_PORT = 8812;
26+
27+
private static final Integer REST_PORT = 9000;
28+
29+
private static final Integer ILP_PORT = 9009;
30+
31+
static final String TEST_QUERY = "SELECT 1";
32+
33+
static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("questdb/questdb");
34+
35+
public QuestDBContainer(@NonNull String dockerImageName) {
36+
this(DockerImageName.parse(dockerImageName));
37+
}
38+
39+
public QuestDBContainer(DockerImageName dockerImageName) {
40+
super(dockerImageName);
41+
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);
42+
withExposedPorts(POSTGRES_PORT, REST_PORT, ILP_PORT);
43+
addEnv("QDB_CAIRO_COMMIT_LAG", String.valueOf(DEFAULT_COMMIT_LAG_MS));
44+
waitingFor(Wait.forLogMessage("(?i).*A server-main enjoy.*", 1));
45+
}
46+
47+
@Override
48+
public String getDriverClassName() {
49+
return "org.postgresql.Driver";
50+
}
51+
52+
@Override
53+
public String getJdbcUrl() {
54+
return String.format("jdbc:postgresql://%s:%d/%s", getHost(), getMappedPort(8812), getDefaultDatabaseName());
55+
}
56+
57+
@Override
58+
public String getUsername() {
59+
return DEFAULT_USERNAME;
60+
}
61+
62+
@Override
63+
public String getPassword() {
64+
return DEFAULT_PASSWORD;
65+
}
66+
67+
@Override
68+
public String getTestQueryString() {
69+
return TEST_QUERY;
70+
}
71+
72+
@Override
73+
protected void waitUntilContainerStarted() {
74+
getWaitStrategy().waitUntilReady(this);
75+
}
76+
77+
public String getDefaultDatabaseName() {
78+
return DEFAULT_DATABASE_NAME;
79+
}
80+
81+
public String getIlpUrl() {
82+
return getHost() + ":" + getMappedPort(ILP_PORT);
83+
}
84+
85+
public String getHttpUrl() {
86+
return "http://" + getHost() + ":" + getMappedPort(REST_PORT);
87+
}
88+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.testcontainers.containers;
2+
3+
public class QuestDBProvider extends JdbcDatabaseContainerProvider {
4+
5+
@Override
6+
public boolean supports(String databaseType) {
7+
return databaseType.equals(QuestDBContainer.DATABASE_PROVIDER);
8+
}
9+
10+
@Override
11+
public JdbcDatabaseContainer newInstance(String tag) {
12+
return new QuestDBContainer(QuestDBContainer.DEFAULT_IMAGE_NAME.withTag(tag));
13+
}
14+
}

0 commit comments

Comments
 (0)