Skip to content

Commit 2049745

Browse files
committed
Change the Docker Image used by the Presto module to prestodb/presto
1 parent 18a7c27 commit 2049745

File tree

10 files changed

+46
-25
lines changed

10 files changed

+46
-25
lines changed

docs/modules/databases/presto.md

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# Presto Module
22

3-
!!! note
4-
This module is deprecated, use Trino module.
5-
63
See [Database containers](./index.md) for documentation and usage that is common to all database container types.
74

85
## Usage example
@@ -84,6 +81,6 @@ Add the following dependency to your `pom.xml`/`build.gradle` file:
8481
!!! hint
8582
Adding this Testcontainers library JAR will not automatically add the Presto JDBC driver JAR to your project.
8683
You should ensure that your project has the Presto JDBC driver as a dependency, if you plan on using it.
87-
Refer to [Presto project download page](https://prestosql.io/download.html) for instructions.
84+
Refer to [Presto project download page](https://prestodb.io/getting-started/) for instructions.
8885

8986

modules/presto/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ dependencies {
44
api project(':jdbc')
55

66
testImplementation project(':jdbc-test')
7-
testRuntimeOnly 'io.prestosql:presto-jdbc:350'
7+
testRuntimeOnly 'com.facebook.presto:presto-jdbc:0.288'
88
compileOnly 'org.jetbrains:annotations:24.1.0'
99
}

modules/presto/src/main/java/org/testcontainers/containers/PrestoContainer.java

+15-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import com.google.common.base.Strings;
44
import org.jetbrains.annotations.NotNull;
55
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
6+
import org.testcontainers.images.builder.Transferable;
67
import org.testcontainers.utility.DockerImageName;
8+
import org.testcontainers.utility.MountableFile;
79

810
import java.sql.Connection;
911
import java.sql.SQLException;
@@ -12,18 +14,21 @@
1214
import java.util.Set;
1315

1416
/**
15-
* @deprecated Use {@code TrinoContainer} instead.
17+
* Testcontainers implementation for Presto.
18+
* <p>
19+
* Supported image: {@code prestodb/presto}
20+
* <p>
21+
* Exposed ports: 8080
1622
*/
17-
@Deprecated
1823
public class PrestoContainer<SELF extends PrestoContainer<SELF>> extends JdbcDatabaseContainer<SELF> {
1924

2025
public static final String NAME = "presto";
2126

22-
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("ghcr.io/trinodb/presto");
27+
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("prestodb/presto");
2328

24-
public static final String IMAGE = "ghcr.io/trinodb/presto";
29+
public static final String IMAGE = "prestodb/presto";
2530

26-
public static final String DEFAULT_TAG = "344";
31+
public static final String DEFAULT_TAG = "0.288";
2732

2833
public static final Integer PRESTO_PORT = 8080;
2934

@@ -53,6 +58,10 @@ public PrestoContainer(final DockerImageName dockerImageName) {
5358
.withStartupTimeout(Duration.of(60, ChronoUnit.SECONDS));
5459

5560
addExposedPort(PRESTO_PORT);
61+
withCopyFileToContainer(
62+
MountableFile.forClasspathResource("default", Transferable.DEFAULT_DIR_MODE),
63+
"/opt/presto-server/etc"
64+
);
5665
}
5766

5867
/**
@@ -68,7 +77,7 @@ protected Set<Integer> getLivenessCheckPorts() {
6877

6978
@Override
7079
public String getDriverClassName() {
71-
return "io.prestosql.jdbc.PrestoDriver";
80+
return "com.facebook.presto.jdbc.PrestoDriver";
7281
}
7382

7483
@Override
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
connector.name=memory
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
connector.name=tpch
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
coordinator=true
2+
node-scheduler.include-coordinator=true
3+
http-server.http.port=8080
4+
discovery-server.enabled=true
5+
discovery.uri=http://localhost:8080
6+
offset-clause-enabled=true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-server
2+
-Xmx1G
3+
-XX:+UseG1GC
4+
-XX:G1HeapRegionSize=32M
5+
-XX:+UseGCOverheadLimit
6+
-XX:+ExplicitGCInvokesConcurrent
7+
-XX:+HeapDumpOnOutOfMemoryError
8+
-XX:+ExitOnOutOfMemoryError
9+
-Djdk.attach.allowAttachSelf=true

modules/presto/src/test/java/org/testcontainers/PrestoTestImages.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
import org.testcontainers.utility.DockerImageName;
44

55
public interface PrestoTestImages {
6-
DockerImageName PRESTO_TEST_IMAGE = DockerImageName.parse("ghcr.io/trinodb/presto:344");
7-
DockerImageName PRESTO_PREVIOUS_VERSION_TEST_IMAGE = DockerImageName.parse("ghcr.io/trinodb/presto:343");
6+
DockerImageName PRESTO_TEST_IMAGE = DockerImageName.parse("prestodb/presto:0.288");
7+
DockerImageName PRESTO_PREVIOUS_VERSION_TEST_IMAGE = DockerImageName.parse("prestodb/presto:0.287");
88
}

modules/presto/src/test/java/org/testcontainers/containers/PrestoContainerTest.java

+9-11
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public void testSimple() throws Exception {
2828
assertThat(resultSet.next()).as("has result").isTrue();
2929
assertThat(resultSet.getString("node_version"))
3030
.as("Presto version")
31-
.isEqualTo(PrestoContainer.DEFAULT_TAG);
31+
.startsWith(PrestoContainer.DEFAULT_TAG);
3232
assertHasCorrectExposedAndLivenessCheckPorts(prestoSql);
3333
}
3434
}
@@ -48,7 +48,7 @@ public void testSpecificVersion() throws Exception {
4848
assertThat(resultSet.next()).as("has result").isTrue();
4949
assertThat(resultSet.getString("node_version"))
5050
.as("Presto version")
51-
.isEqualTo(PrestoTestImages.PRESTO_PREVIOUS_VERSION_TEST_IMAGE.getVersionPart());
51+
.startsWith(PrestoTestImages.PRESTO_PREVIOUS_VERSION_TEST_IMAGE.getVersionPart());
5252
}
5353
}
5454
}
@@ -73,15 +73,15 @@ public void testQueryMemoryAndTpch() throws SQLException {
7373
"SELECT nationkey, element " +
7474
"FROM tpch.tiny.nation " +
7575
"JOIN memory.default.table_with_array twa ON nationkey = twa.id " +
76-
"LEFT JOIN UNNEST(my_array) a(element) ON true " +
77-
"ORDER BY element OFFSET 1 FETCH NEXT 3 ROWS WITH TIES "
76+
"CROSS JOIN UNNEST(my_array) a(element) " +
77+
"ORDER BY element OFFSET 1 FETCH FIRST 3 ROWS ONLY "
7878
)
7979
) {
8080
List<Integer> actualElements = new ArrayList<>();
8181
while (resultSet.next()) {
8282
actualElements.add(resultSet.getInt("element"));
8383
}
84-
assertThat(actualElements).isEqualTo(Arrays.asList(2, 4, 42, 42, 42));
84+
assertThat(actualElements).isEqualTo(Arrays.asList(2, 4, 42));
8585
}
8686
}
8787
}
@@ -112,8 +112,7 @@ public void testTcJdbcUri() throws Exception {
112112
)
113113
) {
114114
// Verify metadata with tc: JDBC connection URI
115-
assertThat(Integer.parseInt(PrestoContainer.DEFAULT_TAG))
116-
.isEqualTo(connection.getMetaData().getDatabaseMajorVersion());
115+
assertThat(0).isEqualTo(connection.getMetaData().getDatabaseMajorVersion());
117116

118117
// Verify transactions with tc: JDBC connection URI
119118
assertThat(connection.getAutoCommit()).as("Is autocommit").isTrue();
@@ -129,19 +128,18 @@ public void testTcJdbcUri() throws Exception {
129128
.isEqualTo(0);
130129
try (
131130
ResultSet resultSet = statement.executeQuery(
132-
"SELECT sum(cast(node_version AS bigint)) AS v FROM system.runtime.nodes"
131+
"SELECT node_version AS v FROM system.runtime.nodes"
133132
)
134133
) {
135134
assertThat(resultSet.next()).isTrue();
136-
assertThat(resultSet.getString("v")).isEqualTo(PrestoContainer.DEFAULT_TAG);
135+
assertThat(resultSet.getString("v")).startsWith(PrestoContainer.DEFAULT_TAG);
137136
assertThat(resultSet.next()).isFalse();
138137
}
139138
connection.commit();
140139
} finally {
141140
connection.rollback();
142141
}
143-
connection.setAutoCommit(true);
144-
assertThat(connection.getAutoCommit()).as("Is autocommit").isTrue();
142+
assertThat(connection.getAutoCommit()).as("Is autocommit").isFalse();
145143
assertThat(connection.getTransactionIsolation())
146144
.as("Transaction isolation should be retained")
147145
.isEqualTo(Connection.TRANSACTION_READ_UNCOMMITTED);

modules/presto/src/test/java/org/testcontainers/jdbc/presto/PrestoJDBCDriverTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class PrestoJDBCDriverTest extends AbstractJDBCDriverTest {
1414
public static Iterable<Object[]> data() {
1515
return Arrays.asList(
1616
new Object[][] { //
17-
{ "jdbc:tc:presto:344://hostname/", EnumSet.of(Options.PmdKnownBroken) },
17+
{ "jdbc:tc:presto:0.288://hostname/", EnumSet.of(Options.PmdKnownBroken) },
1818
}
1919
);
2020
}

0 commit comments

Comments
 (0)