-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Use dockerized Cassandra in tests #2377
Conversation
@bsideup am I correct
let's stay with generic container then, thanks @ebyhr for trying this out |
@@ -160,8 +160,8 @@ | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>io.prestosql.cassandra</groupId> | |||
<artifactId>cassandra-server</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When this is merged, we should archive the https://github.com/prestosql/presto-cassandra-server repository.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -44,16 +44,16 @@ public static synchronized DistributedQueryRunner createCassandraQueryRunner() | |||
|
|||
queryRunner.installPlugin(new CassandraPlugin()); | |||
queryRunner.createCatalog("cassandra", "cassandra", ImmutableMap.of( | |||
"cassandra.contact-points", EmbeddedCassandra.getHost(), | |||
"cassandra.native-protocol-port", Integer.toString(EmbeddedCassandra.getPort()), | |||
"cassandra.contact-points", CassandraServer.getHost(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am thinking it could make sense to convert CassandraServer to normal object, rather than having it a static instance.
-- are we benefiting from the reuse of single cassandra instance across test classes?
FWIW cassandra module runs tests single threaded today (https://github.com/prestosql/presto/blob/7aaa0f5fac1454b23e4bd2ac3a511d749bd00fbe/presto-cassandra/pom.xml#L17)
- this means we don't need to worry about increased mem usage from multiple tests runs now
- having CassandraServer as an object could allow us to run the tests in 2 threads (memory permitting)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how long does it take to start cassandra?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It takes about:
- 37s when the image does not exist in the environment (+data load)
- 17s when the image already exist in the environment (+data load)
Let me check the performance with normal object version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making CassandraServer non-static with 2 threads will extend the test time for a few minutes.
14m 34s → 16m 58s
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's worth it, since it brings more isolation.
17 minutes is still a decent run time for a test configuration.
(BTW Are there any test classes that could be easily merged?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so too. Let me push the additional commit.
Currently, dockerized CassandraServer is called from 4 places.
- TestCassandraDistributedQueries
- TestCassandraIntegrationSmokeTest
- TestCassandraConnector
- TestCassandraTokenSplitManager
We could merge 3 & 4 technically, but I would keep the current implementation.
80450d4
to
b18fff0
Compare
@@ -32,7 +32,7 @@ | |||
protected QueryRunner createQueryRunner() | |||
throws Exception | |||
{ | |||
return CassandraQueryRunner.createCassandraQueryRunner(); | |||
return new CassandraQueryRunner().createCassandraQueryRunner(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You want to retain ref to CassandraServer
so that you close the docker container in @AfterClass
it may be simpler to write if CassandraQueryRunner
remains a utility class and simply takes the server as a param:
protected QueryRunner createQueryRunner()
{
this.server = new CassandraServer();
return CassandraQueryRunner.createCassandraQueryRunner(server);
}
@AfterClass(alwaysRun=true)
public void tearDown()
{
this.server.close();
}
private CassandraSession session; | ||
private CassandraTokenSplitManager splitManager; | ||
|
||
@BeforeClass | ||
public void setUp() | ||
throws Exception | ||
{ | ||
CassandraServer.start(); | ||
session = CassandraServer.getSession(); | ||
cassandraServer = new CassandraServer(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add @AfterClass(alwaysRun=true)
to clean this up
b18fff0
to
8d65d7f
Compare
Updated:
|
I'm checking the CI failure. |
8d65d7f
to
2c9eb36
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@@ -160,8 +160,8 @@ | |||
</dependency> | |||
|
|||
<dependency> | |||
<groupId>io.prestosql.cassandra</groupId> | |||
<artifactId>cassandra-server</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -70,18 +68,16 @@ public static synchronized void start() | |||
|
|||
log.info("Starting cassandra..."); | |||
|
|||
System.setProperty("cassandra.config", "file:" + prepareCassandraYaml()); | |||
System.setProperty("cassandra-foreground", "true"); | |||
System.setProperty("cassandra.native.epoll.enabled", "false"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was cassandra-foreground
and cassandra.native.epoll.enabled
something important?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we couldn't run tests without these properties on EmbeddedCassandra.
} | ||
tpchLoaded = true; | ||
createKeyspace(server.getSession(), "tpch"); | ||
List<TpchTable<?>> tables = TpchTable.getTables(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably save some time by limiting this to only the tables we need (some test classes need 1-2 tables). This is how we do for eg Postgres.
(no change requested; might be a follow-up)
@@ -132,7 +132,7 @@ public static void createTableClusteringKeysInequality(CassandraSession session, | |||
|
|||
public static void insertIntoTableClusteringKeysInequality(CassandraSession session, SchemaTableName table, Date date, int rowsCount) | |||
{ | |||
for (Integer rowNumber = 1; rowNumber <= rowsCount; rowNumber++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄
|
||
import static io.prestosql.spi.type.VarcharType.VARCHAR; | ||
import static io.prestosql.testing.MaterializedResult.resultBuilder; | ||
import static io.prestosql.testing.assertions.Assert.assertEquals; | ||
|
||
//Integrations tests fail when parallel, due to a bug or configuration error in the embedded | ||
//cassandra instance. This problem results in either a hang in Thrift calls or broken sockets. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's see if this comment is still applicable.
2c9eb36
to
f79bb44
Compare
snakeyaml 1.x version causing mend scan CVEs. Cherry-pick of trinodb/trino#2377 Co-authored-by: Yuya Ebihara <[email protected]> Review comments
snakeyaml 1.x version causing mend scan CVEs. Cherry-pick of trinodb/trino#2377 Co-authored-by: Yuya Ebihara <[email protected]>
snakeyaml 1.x version causing mend scan CVEs. Cherry-pick of trinodb/trino#2377 Co-authored-by: Yuya Ebihara <[email protected]>
snakeyaml 1.x version causing mend scan CVEs. Cherry-pick of trinodb/trino#2377 Co-authored-by: Yuya Ebihara <[email protected]>
snakeyaml 1.x version causing mend scan CVEs. Cherry-pick of trinodb/trino#2377 Co-authored-by: Yuya Ebihara <[email protected]>
snakeyaml 1.x version causing mend scan CVEs. Cherry-pick of trinodb/trino#2377 Co-authored-by: Yuya Ebihara <[email protected]>
…\n\nCherry-pick of trinodb/trino#2377 \n\nCo-authored-by: Yuya Ebihara <[email protected]>
… \n\n Cherry-pick of trinodb/trino#2377 \n\n Co-authored-by: Yuya Ebihara <[email protected]>
\n\n snakeyaml 1.x version causing mend scan CVEs. Cherry-pick of trinodb/trino#2377 Co-authored-by: Yuya Ebihara <[email protected]>
snakeyaml 1.x version causing mend scan CVEs. Cherry-pick of trinodb/trino#2377 Co-authored-by: Yuya Ebihara <[email protected]>
snakeyaml 1.x version causing mend scan CVEs. Cherry-pick of trinodb/trino#2377 Co-authored-by: Yuya Ebihara <[email protected]>
snakeyaml 1.x version causing mend scan CVEs. Cherry-pick of trinodb/trino#2377 Co-authored-by: Yuya Ebihara <[email protected]>
Fixes #2182
I tried org.testcontainers:cassandra at first, but it conflicted with the existing library and I couldn't find the benefit to use
CassandraContainer
instead ofGenericContainer
. I mean, even if we use CassandraContainer, the code will be almost the same in our test code.