-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
PrestoContainer.java
130 lines (104 loc) · 3.39 KB
/
PrestoContainer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package org.testcontainers.containers;
import com.google.common.base.Strings;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.utility.DockerImageName;
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.
*/
@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");
public static final String IMAGE = "ghcr.io/trinodb/presto";
public static final String DEFAULT_TAG = "344";
public static final Integer PRESTO_PORT = 8080;
private String username = "test";
private String catalog = null;
/**
* @deprecated use {@link PrestoContainer(DockerImageName)} instead
*/
@Deprecated
public PrestoContainer() {
this(DEFAULT_IMAGE_NAME.withTag(DEFAULT_TAG));
}
public PrestoContainer(final String dockerImageName) {
this(DockerImageName.parse(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));
addExposedPort(PRESTO_PORT);
}
/**
* @return the ports on which to check if the container is ready
* @deprecated use {@link #getLivenessCheckPortNumbers()} instead
*/
@NotNull
@Override
@Deprecated
protected Set<Integer> getLivenessCheckPorts() {
return super.getLivenessCheckPorts();
}
@Override
public String getDriverClassName() {
return "io.prestosql.jdbc.PrestoDriver";
}
@Override
public String getJdbcUrl() {
return String.format(
"jdbc:presto://%s:%s/%s",
getHost(),
getMappedPort(PRESTO_PORT),
Strings.nullToEmpty(catalog)
);
}
@Override
public String getUsername() {
return username;
}
@Override
public String getPassword() {
return "";
}
@Override
public String getDatabaseName() {
return catalog;
}
@Override
public String getTestQueryString() {
return "SELECT count(*) FROM tpch.tiny.nation";
}
@Override
public SELF withUsername(final String username) {
this.username = username;
return self();
}
/**
* @deprecated This operation is not supported.
*/
@Override
@Deprecated
public SELF withPassword(final String password) {
// ignored, Presto does not support password authentication without TLS
// TODO: make JDBCDriverTest not pass a password unconditionally and remove this method
return self();
}
@Override
public SELF withDatabaseName(String dbName) {
this.catalog = dbName;
return self();
}
public Connection createConnection() throws SQLException, NoDriverFoundException {
return createConnection("");
}
}