Open
Description
Expected Behavior or Use Case
- Missing an HTTP endpoint to ensure the Presto Docker Container is ready. This caused a bit of trouble in the use of
testscontainers-java
. https://prestodb.io/docs/current/installation/deploy-docker.html mentions that you only need to check if======= SERVER STARTED ========
is output. But this still seems insufficient to indicate that the Presto Docker Container is ready. I wrote a simple unit test at https://github.com/linghengqian/testcontainers-presto-health-check-test . Just execute the following command to verify. Execute the following command on the Ubuntu 22.04.4 LTS instance withSDKMAN!
and Docker.
sdk install java 17.0.11-ms
sdk use java 17.0.11-ms
git clone [email protected]:linghengqian/testcontainers-presto-health-check-test.git
cd ./testcontainers-presto-health-check-test/
./mvnw clean test
- Logically, this unit test is very simple.
@Testcontainers
public class PrestoTest {
@Container
public GenericContainer<?> container = new GenericContainer<>(DockerImageName.parse("prestodb/presto:0.288"))
.withCopyFileToContainer(
MountableFile.forClasspathResource("default", Transferable.DEFAULT_DIR_MODE),
"/opt/presto-server/etc"
)
.withExposedPorts(8080)
.waitingFor(
new LogMessageWaitStrategy().withRegEx(".*======== SERVER STARTED ========.*")
.withStartupTimeout(Duration.of(60, ChronoUnit.SECONDS))
);
@Test
void test() throws SQLException {
Properties props = new Properties();
props.setProperty("user", "test");
try (Connection connection = DriverManager.getConnection("jdbc:presto://" + container.getHost() + ":" + container.getMappedPort(8080) + "/", props);
Statement statement = connection.createStatement()) {
statement.execute("""
CREATE TABLE memory.default.table_with_array AS SELECT 1 id, ARRAY[1, 42, 2, 42, 4, 42] my_array
""");
try (ResultSet resultSet = statement.executeQuery(
"""
SELECT nationkey, element
FROM tpch.tiny.nation
JOIN memory.default.table_with_array twa ON nationkey = twa.id
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, is(Arrays.asList(2, 4, 42)));
}
}
}
}
- This unit test can easily trigger the Error Log of
com.facebook.presto.spi.PrestoException: No nodes available to run query
. Although sometimes this unit test can be executed successfully.
java.sql.SQLException: Query failed (#20240716_105708_00000_xzrms): No nodes available to run query
at com.facebook.presto.jdbc.PrestoResultSet.resultsException(PrestoResultSet.java:1841)
- It would be nice if there was a simple HTTP endpoint that could be used to replace the following logic to verify that the Presto Server is running.
.waitingFor(
new LogMessageWaitStrategy().withRegEx(".*======== SERVER STARTED ========.*")
.withStartupTimeout(Duration.of(60, ChronoUnit.SECONDS))
)
Presto Component, Service, or Connector
- Presto Component.
Possible Implementation
- To be honest I'm not sure.
Example Screenshots (if appropriate):
- Normally this wouldn't require any screenshots.
Context
- This relates to the findings from Change the Docker Image used by the Presto module to
prestodb/presto
testcontainers/testcontainers-java#8946. Earlier investigation came from Improve GraalVM Reachability Metadata and corresponding nativeTest related unit tests apache/shardingsphere#29052 .
Activity