-
Notifications
You must be signed in to change notification settings - Fork 4
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
Adapt testcontainers to be testing framework agnostic #82
Merged
amotl
merged 10 commits into
crate:main
from
pilosus:tech/18-adapt-testcontainers-to-unittest
Nov 24, 2023
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8cd73b2
Make testing infra based on testcontainers framework-agnostic
pilosus 40bdc7e
Allow to pass extra kwargs to CrateDBFixture and CrateDBContainer
pilosus 4a1c910
Bind port inside container to the same port on the host with testcont…
pilosus 3770849
Fix generic types for Python 3.7 and 3.8
pilosus 8bad275
Code review fixes
pilosus 59a5484
Remove logger
pilosus 7924b0d
Allow binding random ports on host for testcontainers
pilosus 2c643bd
Fix naming for testcontainers wrappers
pilosus 661370f
Remove unused args in CrateDBTestAdapter constructor; fix backward co…
pilosus 7ae9a4a
Improve readability
pilosus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
|
||
from cratedb_toolkit.testing.testcontainers.cratedb import CrateDBContainer | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"opts, expected", | ||
[ | ||
pytest.param( | ||
{"indices.breaker.total.limit": "90%"}, | ||
( | ||
"-Cdiscovery.type=single-node " | ||
"-Cnode.attr.storage=hot " | ||
"-Cpath.repo=/tmp/snapshots " | ||
"-Cindices.breaker.total.limit=90%" | ||
), | ||
id="add_cmd_option", | ||
), | ||
pytest.param( | ||
{"discovery.type": "zen", "indices.breaker.total.limit": "90%"}, | ||
( | ||
"-Cdiscovery.type=zen " | ||
"-Cnode.attr.storage=hot " | ||
"-Cpath.repo=/tmp/snapshots " | ||
"-Cindices.breaker.total.limit=90%" | ||
), | ||
id="override_defaults", | ||
), | ||
], | ||
) | ||
def test_build_command(opts, expected): | ||
db = CrateDBContainer(cmd_opts=opts) | ||
assert db._command == expected |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This looks like a partial hot/cold targeted custom setup which should be irrelevant for generic test clusters and especially in a single-node setup.
@amotl Any reason for this configuration? (as it was in the codebase already).
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.
Yeah, well spotted. It is indeed a configuration detail which is specific to the test cases for
cratedb_toolkit.retention
, where this code was initially conceived for.In this spirit, it should not be part of the generic startup parameters, but at the same time, it shows we need the capacity to configure those details when needed.
@pilosus: Do you think we can improve this spot, so that corresponding configuration settings can be defined on behalf of the snippet in
conftest.py
? This time, it will probably not be so easy, because the test adapter will already need this information at startup time. Maybe you have an idea how to handle this elegantly?While being at it: Of course, it would not just be about the specific
node.attr.storage
parameter, but about any other parameters as well.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.
Ah, I see you already added
cmd_opts
to the constructor. 🙇https://github.com/crate-workbench/cratedb-toolkit/blob/661370ffb0619e2a4c698c52627c99a1fb726bad/cratedb_toolkit/testing/testcontainers/cratedb.py#L94-L95
So,
{"node.attr.storage": "hot", "path.repo": "/tmp/snapshots"}
would just need to be moved over to the caller.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.
Exactly. And given that we use dict merge, you can even override the default settings
I'll remove the
node.attr.storage
from the default thoughThere 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. What do you think about
path.repo
, @seut? It could be convenient for testing to have it configured by default. Because you didn't mention it in your request, do you think it can stay?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.
@seut @amotl hmm, when I delete
node.attr.storage=hot
tests:
tests/retention/test_cli.py::test_run_delete_basic
tests/retention/test_cli.py::test_run_delete_dryrun
tests/retention/test_cli.py::test_run_reallocate
hang.
Here are the logs:
Interestingly enough,
test_run_delete_with_tags_match
works wellThere 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.
Yeah, the test cases defined for
cratedb_toolkit.retention
need this setting to be configured, so it will need to go intotests/conftest.py
somehow. On the other hand, it should not be part of the generic configuration. That's yet another cliff we need to take.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.
Given the whole chain of the nested fixtures with different scopes, it will either require some more time from me next week, or a simpler solution with
cratedb
override fortests/retention/conftest.py
that havenode.attr.storage=hot
in it.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 easily handle that on a later iteration, and/or discuss possible solutions beforehand. Thank you.