Skip to content

Change the Docker Image used by the Presto module to prestodb/presto #8946

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
5 changes: 1 addition & 4 deletions docs/modules/databases/presto.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# Presto Module

!!! note
This module is deprecated, use Trino module.

See [Database containers](./index.md) for documentation and usage that is common to all database container types.

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


2 changes: 1 addition & 1 deletion modules/presto/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ dependencies {
api project(':jdbc')

testImplementation project(':jdbc-test')
testRuntimeOnly 'io.prestosql:presto-jdbc:350'
testRuntimeOnly 'com.facebook.presto:presto-jdbc:0.290'
compileOnly 'org.jetbrains:annotations:24.1.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,32 @@

import com.google.common.base.Strings;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
import org.testcontainers.images.builder.Transferable;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;

import java.sql.Connection;
import java.sql.SQLException;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Set;

/**
* @deprecated Use {@code TrinoContainer} instead.
* Testcontainers implementation for Presto.
* <p>
* Supported image: {@code prestodb/presto}
* <p>
* Exposed ports: 8080
*/
@Deprecated
public class PrestoContainer<SELF extends PrestoContainer<SELF>> extends JdbcDatabaseContainer<SELF> {

public static final String NAME = "presto";

private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("ghcr.io/trinodb/presto");
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("prestodb/presto");

public static final String IMAGE = "ghcr.io/trinodb/presto";
public static final String IMAGE = "prestodb/presto";

public static final String DEFAULT_TAG = "344";
public static final String DEFAULT_TAG = "0.290";

public static final Integer PRESTO_PORT = 8080;

Expand All @@ -46,13 +50,18 @@ public PrestoContainer(final String dockerImageName) {
public PrestoContainer(final DockerImageName dockerImageName) {
super(dockerImageName);
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);

this.waitStrategy =
new LogMessageWaitStrategy()
.withRegEx(".*======== SERVER STARTED ========.*")
.withStartupTimeout(Duration.of(60, ChronoUnit.SECONDS));

waitingFor(new WaitAllStrategy()
.withStrategy(Wait.forHttp("/v1/info/state").forPort(8080).forResponsePredicate("\"ACTIVE\""::equals))
.withStrategy(new PrestoWaitStrategy(this)));
addExposedPort(PRESTO_PORT);
withCopyFileToContainer(
MountableFile.forClasspathResource("default/catalog", Transferable.DEFAULT_DIR_MODE),
"/opt/presto-server/etc/catalog"
);
withCopyFileToContainer(
MountableFile.forClasspathResource("default/config.properties", Transferable.DEFAULT_DIR_MODE),
"/opt/presto-server/etc/config.properties"
);
}

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

@Override
public String getDriverClassName() {
return "io.prestosql.jdbc.PrestoDriver";
return "com.facebook.presto.jdbc.PrestoDriver";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.testcontainers.containers;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.rnorth.ducttape.unreliables.Unreliables;
import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy;
import org.testcontainers.containers.wait.strategy.WaitStrategyTarget;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.TimeUnit;

/**
* Custom wait strategy for Presto.
*/
@RequiredArgsConstructor
@Slf4j
public final class PrestoWaitStrategy extends AbstractWaitStrategy {

private final WaitStrategyTarget target;

@SuppressWarnings("SqlNoDataSourceInspection")
@Override
public void waitUntilReady(WaitStrategyTarget target) {
PrestoContainer<?> container = (PrestoContainer<?>) target;
Unreliables.retryUntilSuccess(
(int) startupTimeout.getSeconds(),
TimeUnit.SECONDS,
() -> {
getRateLimiter().doWhenReady(() -> {
try (Connection con = container.createConnection(); Statement stmt = con.createStatement()) {
stmt.execute("SHOW SCHEMAS");
} catch (SQLException e) {
throw new RuntimeException(e);
}
});
return true;
}
);
}

@Override
public void waitUntilReady() {
waitUntilReady(target);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
connector.name=memory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
connector.name=tpch
7 changes: 7 additions & 0 deletions modules/presto/src/main/resources/default/config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
coordinator=true
node-scheduler.include-coordinator=true
http-server.http.port=8080
discovery-server.enabled=true
discovery.uri=http://localhost:8080
offset-clause-enabled=true
cluster.required-workers-active=1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.testcontainers.utility.DockerImageName;

public interface PrestoTestImages {
DockerImageName PRESTO_TEST_IMAGE = DockerImageName.parse("ghcr.io/trinodb/presto:344");
DockerImageName PRESTO_TEST_IMAGE = DockerImageName.parse("prestodb/presto:0.290");

DockerImageName PRESTO_PREVIOUS_VERSION_TEST_IMAGE = DockerImageName.parse("ghcr.io/trinodb/presto:343");
DockerImageName PRESTO_PREVIOUS_VERSION_TEST_IMAGE = DockerImageName.parse("prestodb/presto:0.290");
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void testSimple() throws Exception {
assertThat(resultSet.next()).as("has result").isTrue();
assertThat(resultSet.getString("node_version"))
.as("Presto version")
.isEqualTo(PrestoContainer.DEFAULT_TAG);
.startsWith(PrestoContainer.DEFAULT_TAG);
assertHasCorrectExposedAndLivenessCheckPorts(prestoSql);
}
}
Expand All @@ -48,7 +48,7 @@ public void testSpecificVersion() throws Exception {
assertThat(resultSet.next()).as("has result").isTrue();
assertThat(resultSet.getString("node_version"))
.as("Presto version")
.isEqualTo(PrestoTestImages.PRESTO_PREVIOUS_VERSION_TEST_IMAGE.getVersionPart());
.startsWith(PrestoTestImages.PRESTO_PREVIOUS_VERSION_TEST_IMAGE.getVersionPart());
}
}
}
Expand All @@ -73,15 +73,15 @@ public void testQueryMemoryAndTpch() throws SQLException {
"SELECT nationkey, element " +
"FROM tpch.tiny.nation " +
"JOIN memory.default.table_with_array twa ON nationkey = twa.id " +
"LEFT JOIN UNNEST(my_array) a(element) ON true " +
"ORDER BY element OFFSET 1 FETCH NEXT 3 ROWS WITH TIES "
"CROSS JOIN UNNEST(my_array) a(element) " +
"ORDER BY element OFFSET 1 FETCH FIRST 3 ROWS ONLY "
)
) {
List<Integer> actualElements = new ArrayList<>();
while (resultSet.next()) {
actualElements.add(resultSet.getInt("element"));
}
assertThat(actualElements).isEqualTo(Arrays.asList(2, 4, 42, 42, 42));
assertThat(actualElements).isEqualTo(Arrays.asList(2, 4, 42));
}
}
}
Expand Down Expand Up @@ -112,8 +112,7 @@ public void testTcJdbcUri() throws Exception {
)
) {
// Verify metadata with tc: JDBC connection URI
assertThat(Integer.parseInt(PrestoContainer.DEFAULT_TAG))
.isEqualTo(connection.getMetaData().getDatabaseMajorVersion());
assertThat(0).isEqualTo(connection.getMetaData().getDatabaseMajorVersion());

// Verify transactions with tc: JDBC connection URI
assertThat(connection.getAutoCommit()).as("Is autocommit").isTrue();
Expand All @@ -128,12 +127,10 @@ public void testTcJdbcUri() throws Exception {
.as("Update result")
.isEqualTo(0);
try (
ResultSet resultSet = statement.executeQuery(
"SELECT sum(cast(node_version AS bigint)) AS v FROM system.runtime.nodes"
)
ResultSet resultSet = statement.executeQuery("SELECT node_version AS v FROM system.runtime.nodes")
) {
assertThat(resultSet.next()).isTrue();
assertThat(resultSet.getString("v")).isEqualTo(PrestoContainer.DEFAULT_TAG);
assertThat(resultSet.getString("v")).startsWith(PrestoContainer.DEFAULT_TAG);
assertThat(resultSet.next()).isFalse();
}
connection.commit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class PrestoJDBCDriverTest extends AbstractJDBCDriverTest {
public static Iterable<Object[]> data() {
return Arrays.asList(
new Object[][] { //
{ "jdbc:tc:presto:344://hostname/", EnumSet.of(Options.PmdKnownBroken) },
{ "jdbc:tc:presto:0.290://hostname/", EnumSet.of(Options.PmdKnownBroken) },
}
);
}
Expand Down
Loading