Skip to content

Commit 5000967

Browse files
committed
Allow reusing SingleStore container
1 parent ab771de commit 5000967

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

plugin/trino-singlestore/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@
174174
<scope>test</scope>
175175
</dependency>
176176

177+
<dependency>
178+
<groupId>io.trino</groupId>
179+
<artifactId>trino-testing-containers</artifactId>
180+
<scope>test</scope>
181+
</dependency>
182+
177183
<dependency>
178184
<groupId>io.trino</groupId>
179185
<artifactId>trino-testing-services</artifactId>

plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/SingleStoreQueryRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public DistributedQueryRunner build()
8585
queryRunner.installPlugin(new SingleStorePlugin());
8686
queryRunner.createCatalog("singlestore", "singlestore", connectorProperties);
8787

88-
queryRunner.execute("CREATE SCHEMA tpch");
88+
queryRunner.execute("CREATE SCHEMA IF NOT EXISTS tpch");
8989
copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, initialTables);
9090

9191
return queryRunner;

plugin/trino-singlestore/src/test/java/io/trino/plugin/singlestore/TestingSingleStoreServer.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,17 @@
1717
import org.testcontainers.containers.JdbcDatabaseContainer;
1818
import org.testcontainers.utility.DockerImageName;
1919

20+
import java.io.Closeable;
21+
import java.io.IOException;
22+
import java.io.UncheckedIOException;
2023
import java.sql.Connection;
2124
import java.sql.DriverManager;
2225
import java.sql.SQLException;
2326
import java.sql.Statement;
2427
import java.util.Set;
2528

29+
import static io.trino.testing.containers.TestContainers.startOrReuse;
30+
2631
public class TestingSingleStoreServer
2732
extends JdbcDatabaseContainer<TestingSingleStoreServer>
2833
{
@@ -33,6 +38,8 @@ public class TestingSingleStoreServer
3338

3439
public static final Integer SINGLESTORE_PORT = 3306;
3540

41+
private final Closeable cleanup;
42+
3643
public TestingSingleStoreServer()
3744
{
3845
this(DEFAULT_VERSION);
@@ -43,7 +50,7 @@ public TestingSingleStoreServer(String version)
4350
super(DockerImageName.parse(DEFAULT_TAG));
4451
addEnv("ROOT_PASSWORD", "memsql_root_password");
4552
addEnv("SINGLESTORE_VERSION", version);
46-
start();
53+
cleanup = startOrReuse(this);
4754
}
4855

4956
@Override
@@ -89,6 +96,17 @@ public String getTestQueryString()
8996
return "SELECT 1";
9097
}
9198

99+
@Override
100+
public void close()
101+
{
102+
try {
103+
cleanup.close();
104+
}
105+
catch (IOException e) {
106+
throw new UncheckedIOException(e);
107+
}
108+
}
109+
92110
public void execute(String sql)
93111
{
94112
execute(sql, getUsername(), getPassword());

0 commit comments

Comments
 (0)