Skip to content

Add support for multiple init scripts in CassandraContainer - #2720

Closed
sanderploegsma wants to merge 2 commits into
testcontainers:masterfrom
sanderploegsma:feature/cassandra-multiple-init-scripts
Closed

Add support for multiple init scripts in CassandraContainer#2720
sanderploegsma wants to merge 2 commits into
testcontainers:masterfrom
sanderploegsma:feature/cassandra-multiple-init-scripts

Conversation

@sanderploegsma

Copy link
Copy Markdown

When running multiple test suites against a Cassandra container, it makes sense to split the initialization scripts, so that you can always include a script that creates a keyspace and some tables, and another script per test suite that populates the tables with some test data.

This change allows you to chain the withInitScript function to load multiple scripts. The order of the chain also determines the order in which the scripts are applied.

@rnorth

rnorth commented May 15, 2020

Copy link
Copy Markdown
Member

This looks like it might be a duplicate (subset) of #2578 - have you seen that?

@sanderploegsma

Copy link
Copy Markdown
Author

Ah no, that one didn’t come up. It looks like the Cassandra container doesn’t use the mechanism used by the containers in that PR, but it makes sense to check it out. Thanks for bringing it up!

@sanderploegsma

Copy link
Copy Markdown
Author

Looking at the PR you mentioned it seems that although we are trying to achieve the same, the JdbcDatabaseContainer and the CassandraContainer don't share much code so unless we want to refactor the bunch to make use of an abstraction, I feel like both PRs are valid.

That being said, it of course makes sense to align on the approach we take w.r.t. handling multiple initialization scripts. Looking at #2578 it seems the favoured approach would be to use the following to keep binary compatibility:

public SELF withInitScript(String initScriptPath, String... extraInitScriptPaths) { /* ... */ }

Initially I chose to support chaining the withInitScript method to add multiple methods, which is also binary compatible, but a bit less flexible (you cannot override the script paths, only add to them, for instance). It makes sense to use the above approach instead.

When running multiple test suites against a Cassandra container, it makes sense to split the initialization scripts, so that you can always include a script that creates a keyspace and some tables, and another script per test suite that populates the tables with some test data.
@sanderploegsma
sanderploegsma force-pushed the feature/cassandra-multiple-init-scripts branch from 22da92d to 6a39845 Compare May 19, 2020 08:59
@stale

stale Bot commented Sep 27, 2020

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

@stale stale Bot added the stale label Sep 27, 2020
@stale

stale Bot commented Oct 17, 2020

Copy link
Copy Markdown

This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.

@stale stale Bot closed this Oct 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants