Skip to content

Commit cb268b1

Browse files
committed
Change the Docker Image used by the Presto module to prestodb/presto
1 parent 2e0ef57 commit cb268b1

File tree

7 files changed

+40
-37
lines changed

7 files changed

+40
-37
lines changed

docs/modules/databases/presto.md

Lines changed: 4 additions & 7 deletions
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
@@ -50,13 +47,13 @@ public class SomeTest {
5047
"SELECT nationkey, element " +
5148
"FROM tpch.tiny.nation " +
5249
"JOIN memory.default.table_with_array twa ON nationkey = twa.id " +
53-
"LEFT JOIN UNNEST(my_array) a(element) ON true " +
54-
"ORDER BY element OFFSET 1 FETCH NEXT 3 ROWS WITH TIES ")) {
50+
"CROSS JOIN UNNEST(my_array) a(element) " +
51+
"ORDER BY element OFFSET 1 FETCH FIRST 3 ROWS ONLY ")) {
5552
List<Integer> actualElements = new ArrayList<>();
5653
while (resultSet.next()) {
5754
actualElements.add(resultSet.getInt("element"));
5855
}
59-
Assert.assertEquals(Arrays.asList(2, 4, 42, 42, 42), actualElements);
56+
Assert.assertEquals(Arrays.asList(2, 4, 42), actualElements);
6057
}
6158
}
6259
}
@@ -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

Lines changed: 1 addition & 1 deletion
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.292'
88
compileOnly 'org.jetbrains:annotations:24.1.0'
99
}

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

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,31 @@
22

33
import com.google.common.base.Strings;
44
import org.jetbrains.annotations.NotNull;
5-
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
5+
import org.testcontainers.containers.wait.strategy.Wait;
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;
10-
import java.time.Duration;
11-
import java.time.temporal.ChronoUnit;
1212
import java.util.Set;
1313

1414
/**
15-
* @deprecated Use {@code TrinoContainer} instead.
15+
* Testcontainers implementation for Presto.
16+
* <p>
17+
* Supported image: {@code prestodb/presto}
18+
* <p>
19+
* Exposed ports: 8080
1620
*/
17-
@Deprecated
1821
public class PrestoContainer<SELF extends PrestoContainer<SELF>> extends JdbcDatabaseContainer<SELF> {
1922

2023
public static final String NAME = "presto";
2124

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

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

26-
public static final String DEFAULT_TAG = "344";
29+
public static final String DEFAULT_TAG = "0.292";
2730

2831
public static final Integer PRESTO_PORT = 8080;
2932

@@ -46,13 +49,12 @@ public PrestoContainer(final String dockerImageName) {
4649
public PrestoContainer(final DockerImageName dockerImageName) {
4750
super(dockerImageName);
4851
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);
49-
50-
this.waitStrategy =
51-
new LogMessageWaitStrategy()
52-
.withRegEx(".*======== SERVER STARTED ========.*")
53-
.withStartupTimeout(Duration.of(60, ChronoUnit.SECONDS));
54-
52+
waitingFor(Wait.forHttp("/v1/info/state").forPort(8080).forResponsePredicate("\"ACTIVE\""::equals));
5553
addExposedPort(PRESTO_PORT);
54+
withCopyFileToContainer(
55+
MountableFile.forClasspathResource("default/config.properties", Transferable.DEFAULT_DIR_MODE),
56+
"/opt/presto-server/etc/config.properties"
57+
);
5658
}
5759

5860
/**
@@ -68,7 +70,7 @@ protected Set<Integer> getLivenessCheckPorts() {
6870

6971
@Override
7072
public String getDriverClassName() {
71-
return "io.prestosql.jdbc.PrestoDriver";
73+
return "com.facebook.presto.jdbc.PrestoDriver";
7274
}
7375

7476
@Override
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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
7+
cluster.required-workers-active=1

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.testcontainers.utility.DockerImageName;
44

55
public interface PrestoTestImages {
6-
DockerImageName PRESTO_TEST_IMAGE = DockerImageName.parse("ghcr.io/trinodb/presto:344");
6+
DockerImageName PRESTO_TEST_IMAGE = DockerImageName.parse("prestodb/presto:0.292");
77

8-
DockerImageName PRESTO_PREVIOUS_VERSION_TEST_IMAGE = DockerImageName.parse("ghcr.io/trinodb/presto:343");
8+
DockerImageName PRESTO_PREVIOUS_VERSION_TEST_IMAGE = DockerImageName.parse("prestodb/presto:0.291");
99
}

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

Lines changed: 8 additions & 11 deletions
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();
@@ -128,12 +127,10 @@ public void testTcJdbcUri() throws Exception {
128127
.as("Update result")
129128
.isEqualTo(0);
130129
try (
131-
ResultSet resultSet = statement.executeQuery(
132-
"SELECT sum(cast(node_version AS bigint)) AS v FROM system.runtime.nodes"
133-
)
130+
ResultSet resultSet = statement.executeQuery("SELECT node_version AS v FROM system.runtime.nodes")
134131
) {
135132
assertThat(resultSet.next()).isTrue();
136-
assertThat(resultSet.getString("v")).isEqualTo(PrestoContainer.DEFAULT_TAG);
133+
assertThat(resultSet.getString("v")).startsWith(PrestoContainer.DEFAULT_TAG);
137134
assertThat(resultSet.next()).isFalse();
138135
}
139136
connection.commit();

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

Lines changed: 1 addition & 1 deletion
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.292://hostname/", EnumSet.of(Options.PmdKnownBroken) },
1818
}
1919
);
2020
}

0 commit comments

Comments
 (0)