Skip to content
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

Add new CassandraContainer implementation #8616

Merged
merged 17 commits into from
Aug 13, 2024

Conversation

maximevw
Copy link
Contributor

This allows a full support of Cassandra 5 without errors/warnings. Indeed, as explained in the discussion #7786, the Cassandra module is still using the deprecated version 3.x of the Java driver for Cassandra. Even if it works with Cassandra 5, it may lead to warnings/errors when using specific features of Cassandra 5. By upgrading the driver to the latest version, we remain compatible with all versions of Cassandra from 3 to 5 (note that version 3 is now reaching EoL).

I successfully tested a locally built version of the Cassandra module including the submitted changes in the tests of Cassandra JDBC wrapper without impact on the performance of the tests running testcontainers with Cassandra.

Few notes regarding the submitted changes:

  • In Java driver 4.x, JMX is not supported by default, contrary to the version 3.x, so I removed the method withJmxReporting(boolean).
  • To keep good performance when running initialisation script, some specific configuration need to be defined regarding the "debouncing" feature introduced by the Java driver 4.x. This is explained in details in the code.

maximevw added 2 commits May 14, 2024 22:32
This allows a full support of Cassandra 5 without errors/warnings
@maximevw maximevw force-pushed the upgrade-cassandra-driver branch from 1aaefd8 to 437abf6 Compare May 14, 2024 20:32
@eddumelendez
Copy link
Member

Hi @maximevw, thanks for submitting a PR and sorry for missing the discussion 😢 Currently, the CassandraContainer implementation relies on the Java client and that's something we are trying to avoid. Do you know if there is a way to execute scripts without using the Java Client? If so, I would propose adding a new implementation under org.testcontainers.cassandra.CassadraContainer that is free of Cassandra Java Driver and can run successfully with latest versions, would be great if works with versions since Cassandra 3. Of course, we will be deprecating org.testcontainers.container.CassandraContainer.

@maximevw
Copy link
Contributor Author

Hello @eddumelendez, thanks for your response.

Yes, it should be possible to run CQL scripts without using the Java driver thanks to cqlsh CLI provided with Cassandra server. And this should work with Cassandra 3+.

So, executing a cqlsh command at the container startup could be a solution to get rid of the Java driver dependency.

@kiview
Copy link
Member

kiview commented May 23, 2024

So, executing a cqlsh command at the container startup could be a solution to get rid of the Java driver dependency.

@maximevw Sounds like a great suggestion, do you want to have a stab at this approach?

@eddumelendez What is the motivation behind doing this in a new version, rather than in the old version? It is not really a breaking change, is it?

@maximevw
Copy link
Contributor Author

@kiview Sure, I'll take a look at this asap.

@eddumelendez
Copy link
Member

What is the motivation behind doing this in a new version, rather than in the old version? It is not really a breaking change, is it?

Current CassandraContainer implementation relies on Cluster class from cassandra java driver. So, the dependency could not be removed at all without causing breaking changes.

@kiview
Copy link
Member

kiview commented May 24, 2024

After discussing more with @eddumelendez, it seems indeed a good idea to deprecate org.testcontainers.container.CassandraContainer and do the proposed changes in a new class org.testcontainers.cassandra.CassadraContainer, so we can get our modules slowly ready for JPMS without suffering from split-package issues.

maximevw and others added 2 commits May 25, 2024 15:59
This implementation in the new package org.testcontainers.cassandra uses cqlsh command
inside the running Cassandra container to execute scripts. So, the dependency to the
Java driver is no more required.

The implementation in the package org.testcontainers.containers has been marked as deprecated.
@maximevw
Copy link
Contributor Author

maximevw commented May 25, 2024

Hello @kiview @eddumelendez,

As previously discussed, I updated this pull request to implement org.testcontainers.cassandra.CassandraContainer using cqlsh command instead of the Java driver to run script.
I also deprecated classes in org.testcontainers.containers package.

I let you review the changes.

@eddumelendez
Copy link
Member

Thanks for the quick update, @maximevw ! Can you please run ./gradlew spotlessApply for code formatting, please?

@maximevw
Copy link
Contributor Author

Sure @eddumelendez!
Done and pushed 🙂

Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! Existing implementation shouldn't be touched to support Cassandra 5. That's why the new implementation is added. The new implementation solved two issues:

  • implementation doesn't rely on cassandra driver
  • transitive dependency to cassandra driver could be removed

maximevw added 2 commits May 27, 2024 20:45
- revert changes on org.testcontainers.containers package except deprecation annotations
- remove unnecessary genericity on new implementation
@maximevw
Copy link
Contributor Author

maximevw commented May 27, 2024

Thanks for your contribution! Existing implementation shouldn't be touched to support Cassandra 5. That's why the new implementation is added. The new implementation solved two issues:

  • implementation doesn't rely on cassandra driver
  • transitive dependency to cassandra driver could be removed

@eddumelendez I pushed the changes following your review.

Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comments. Will perform a deep review later today.

@maximevw
Copy link
Contributor Author

@eddumelendez Changes done :)

@maximevw
Copy link
Contributor Author

Hello @eddumelendez,

Did you have time to finalize your review? 🙂

Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I've left a couple of comments.

@maximevw
Copy link
Contributor Author

maximevw commented Jul 4, 2024

@eddumelendez I pushed the requested changes and replied to your comment about the username/password. 🙂

@maximevw
Copy link
Contributor Author

Hello @eddumelendez,

I assume you're currently busy, but I'm still interested in finalizing this pull request. Do not hesitate to take a look to the latest updates and comments and let me know if any further changes are required.

@eddumelendez
Copy link
Member

@maximevw thanks for the understading, I'll take a look soon.

Copy link
Member

@eddumelendez eddumelendez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience, @maximevw! We are getting close, I left one important question in order to make the implementation simple for the users and avoid reasoning about adding wait strategies in certain scenarios, ofc sometimes it has to be done but in this case I think we can make it happen.

maximevw and others added 2 commits August 13, 2024 13:39
…assandraContainer.java

Co-authored-by: Eddú Meléndez Gonzales <eddu.melendez@gmail.com>
@eddumelendez eddumelendez added this to the next milestone Aug 13, 2024
@eddumelendez eddumelendez merged commit 88e4ac5 into testcontainers:main Aug 13, 2024
101 checks passed
@eddumelendez
Copy link
Member

Thanks for your contribution, @maximevw !

@eddumelendez eddumelendez changed the title Upgrade Java driver for Cassandra to latest version Add new CassandraContainer implementation Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants