-
Notifications
You must be signed in to change notification settings - Fork 13
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 testcontainers to improve platform coverage #408
Use testcontainers to improve platform coverage #408
Conversation
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.
Dear Vitaly,
this looks looks excellent, thank you very much.
CI says something about this:
ERROR: Could not find a version that satisfies the requirement click-aliases<2,>=1.0.3 (from cratedb-toolkit[test]) (from versions: 1.0.0, 1.0.1)
ERROR: No matching distribution found for click-aliases<2,>=1.0.3
-- https://github.com/crate/crash/actions/runs/6950117802/job/18922855944#step:4:124
... but that is totally not your fault. We recently needed to add crate/cratedb-toolkit@0a16a101cb45, and that will probably need some rebalancing we will take care about on behalf of the next iteration.
With kind regards,
Andreas.
@amotl yes, this is because of the Python version constraints in
|
urllib3 also just removed support, see https://github.com/urllib3/urllib3/releases/tag/2.1.0. |
cc142eb
to
0446f7d
Compare
setup.py
Outdated
@@ -76,7 +76,9 @@ def read(path): | |||
extras_require=dict( | |||
test=[ | |||
'crate[test]', | |||
'zc.customdoctests<2' | |||
'zc.customdoctests<2', | |||
# FIXME once tested and merged, fix the name |
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.
NB! Needs to be updated before the merge
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.
Thank you. See also #410 (comment):
- @pilosus: When following the (in my opinion) right strategy outlined at 2., I am humbly asking for your patience on this. It would need to wait a bit for the testcontainers code to be upstreamed beforehand, [...]
[ on which you have worked on behalf of crate/cratedb-toolkit#82 ].
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 observe that the test adapter may need a few more improvements, so we postponed the plan about the upstreaming. We released the most recent updates with cratedb-toolkit 0.0.4. Can I ask you to upgrade, and, while being at it, also rebase on top of master?
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.
Done
@amotl I think I am ready for the review, please let me know if I missed something. |
tests/test_integration.py
Outdated
|
||
|
||
node = CrateDBFixture(crate_version=EntrypointOpts.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.
With respect to your question on the other patch, could this spot also be used to optionally register table names for resetting, on behalf of a second argument to the fixture manager here? In this way, it can be managed by CrateDBFixture
, but the user has control about which tables need to be defined here, matching their test environment.
The list of tables could be supplied to the constructor, or optionally by using a dedicated method, or both. It is just an idea, I don't have any strong opinions about the "how", and I am also sure you will find a better way of "naming things". ;]
node.register_tables_for_reset(*tablenames: t.List[str])
node = CrateDBFixture(
crate_version=EntrypointOpts.version,
reset_tables=["foo", "bar", '"testdrive"."qux"'],
)
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 already responded to this at crate/cratedb-toolkit#82 (comment) while I was writing this down. Your proposed interface is perfectly lean. Thanks!
cratedb_service.reset(tables=RESET_TABLES)
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, I think passing the table list to the reset
method is even better than using it in the class constructor/class method, as you can adjust the list with more flexibility with no need to change the main fixture.
@@ -286,7 +292,7 @@ def test_multiple_hosts(self): | |||
output = output.getvalue() | |||
lines = output.split('\n') | |||
self.assertRegex(lines[3], r'^\| http://[\d\.:]+ .*\| NULL .*\| FALSE .*\| Server not available') | |||
self.assertRegex(lines[4], r'^\| http://[\d\.:]+. *\| crate .*\| TRUE .*\| OK') | |||
self.assertRegex(lines[4], r'^\| http://.*@?localhost:\d+ *\| crate .*\| TRUE .*\| OK') |
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.
Is this always localhost
because of testcontainers now?
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 really depends on two things:
- if you pass
host
explicitly or rely on the defaultNone
value, when invokingget_connection_url
method of theCrateDBTestAdapter
- where the code is running, on the host or Docker-in-Docker, see the logic here. In our case, both for local development and in the CI pipelines, it will always be
localhost
so, I'd say, it's safe to assume localhost
won't break anything, unless testcontainers
upstream or CI/CD pipelines in crash
repo will be changed
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 see, thx!
bff8dac
to
7e20b38
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.
Thank you! Please wait for other reviewers though.
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.
Nice work and thank you a lot for your efforts @pilosus!
But related to the discussion we had about adding dependencies to incubating projects and the future of the testcontainers, please do not merge this until the testcontainer is merged upstream.
See #410 (comment).
Hi. I just invoked the test harness, and while it succeeds:
.... it clutters the log with such messages:
There was also another error on a single build, at »Python 3.12, CrateDB 5.5.0 on macos-latest«:
Do you know where this might be coming from, @pilosus? With kind regards, |
7e20b38
to
4ab569c
Compare
7e55274
to
2ce2313
Compare
Hi @amotl My educated guess is that since the PR was open, a new major version of Since From what I see, it's not only I think it's better to use either:
or a module-wide fixtures like: def setUpModule():
import logging
logging.getLogger("urllib3").propagate = False
Not sure what's happening here, but again, probably it has something to do with the new docker-py. |
@amotl reg. MacOS tests failing. It's because Docker isn't pre-installed on the GitHub-runners! If you open a job, then click on So, |
Yeah right, thanks for the reminder. That's also why the code skip integration tests on all other OS than Linux, so it will fortunately not be a regression. crash/tests/test_integration.py Lines 28 to 29 in 78cf682
Apparently, the crash/tests/test_integration.py Lines 49 to 50 in 78cf682
Otherwise, it apparently tries to dial the Docker API, which goes south. |
Oh wow, thanks for digging into this. I hadn't expected that. Instead, I was expecting that the CrateDB HTTP driver might have a flaw, and is responsible for the log flodding coming from urllib3. Without reading docker/docker-py#3113 yet, can you rule out that the HTTP driver needs to be investigated, and that it's definitively coming from Docker? If so, I will be happy to disable corresponding warnings as you suggested. However, it would be nicer if this could only be masked for requests to the Docker API, if that is the culprit here, in order not to obfuscate any other warnings originating at urllib3. Do you see a chance to achieve this? |
|
@amotl hmm, all this flood of There's the same problem in some other, non-integration tests like |
Thank you very much for improving the test skipping on unsupported OS, and for tracking down the reason for the flood of urllib3 warnings, and fixing it. Excellent job! 💯 |
7dba3fc
to
b87f929
Compare
Hi @amotl let me know if there's anything else I need to do to get this PR 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.
Nice, thx!
I think some commits would makes sense to be squashed, but will leave that up to you.
GitHub Runner don't support Docker on MacOS for licensing issues. We want to skip integration tests that require Docker though testcontainers. We still may want to be able to run such test for local development.
CrateShell invocation in integration tests relied on the default localhost:4200 instead of the custom host urls used in Docker containers. That resulted in a flood of urllib3 warning logs coming from the crate client. This change fix the hosts urls.
b87f929
to
4640109
Compare
About
Use "Testcontainers" as framework for providing service fixtures.
References
Checklist