Skip to content

Testing: Use native Testcontainers adapter - #502

Closed
amotl wants to merge 3 commits into
crate:mainfrom
zerotired:testcontainers-native
Closed

amotl wants to merge 3 commits into
crate:mainfrom
zerotired:testcontainers-native

Conversation

@amotl

@amotl amotl commented Jun 18, 2026 •

Copy link
Copy Markdown
Contributor

About

Thanks to @surister and @florinutz, the upstream testcontainers package will include an adapter for CrateDB. With this patch, the test suite will start using it.

References

Comment thread setup.py Outdated
@amotl amotl mentioned this pull request Jun 18, 2026
@amotl
amotl force-pushed the testcontainers-native branch 2 times, most recently from f073808 to 8768c26 Compare June 18, 2026 15:59
@amotl
amotl force-pushed the testcontainers-native branch from 8768c26 to ee4f661 Compare July 26, 2026 22:30
Comment thread tests/util.py Fixed
@amotl
amotl force-pushed the testcontainers-native branch from ee4f661 to d834054 Compare July 26, 2026 22:32
@amotl
amotl requested a review from florinutz July 26, 2026 22:34
@amotl
amotl marked this pull request as ready for review July 26, 2026 22:35
@amotl

amotl commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor Author

@florinutz: I think the patch is ready to go now.

@florinutz

Copy link
Copy Markdown
Contributor

hey @amotl , thank you for the contribution, first, and sorry for the delayed response!

then, I see you drop the dependency on the toolkit here. My current plan is to have toolkit updated first, and only after this to proceed further with any new testcontainers-python work such as this here, or updating the examples

Let me get that released first, then it will unlock using the new testcontainers 4.15 (alongside toolkit and its testcontainer goodies) in the repos so we don't have to reimplement things such as you did here.

@amotl

amotl commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Hi, and thanks! Please proceed at your disposal.

@florinutz florinutz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey, I have some comments which I'd like addressed in this PR before we merge. I can do them if you ✅ "Allow edits by maintainers", or you can do them yourself if you so desire.

Or ofc you can hit back on any point

Comment thread tests/util.py
if "CRATEDB_VERSION" in os.environ:
cratedb_version = os.environ["CRATEDB_VERSION"]
if cratedb_version != "nightly" and Version(cratedb_version) < Version("6.2"):
warnings.warn("CrateDB earlier than 6.2 does not support DROP SCHEMA ... CASCADE")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this is actually 6.3, not 6.2

Comment thread tests/util.py
if schemas:
has_drop_schema_cascade = True
if "CRATEDB_VERSION" in os.environ:
cratedb_version = os.environ["CRATEDB_VERSION"]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the constructor already gets crate_version, so we should use that

Comment thread setup.py
],
argcompletion=['argcomplete']
),
python_requires='>=3.7',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

testcontainers needs python 3.10+, so this file should reflect that. It should also be in CHANGES

Comment thread devtools/ci.sh

isort --check --diff src/crate/ tests/ setup.py
flake8 src/crate/crash
export TESTCONTAINERS_RYUK_DISABLED=true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

with Ryuk off, a failed setup leaves the crate container running. Do we actually need this?

Comment thread DEVELOP.rst

The tests are run using the `unittest`_ module::

export TESTCONTAINERS_RYUK_DISABLED=true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

if we don't need ryuk, let's remove it from here too

Comment thread tests/util.py
return Mock(name='fake_connect', side_effect=make_connection)


def setup_logging(level=logging.INFO, verbose: bool = False):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

verbose is not used

Comment thread tests/util.py
"""
Return a URL for CrateDB's HTTP endpoint.

Used to stay backward compatible with the downstream code.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

which downstream code? 🤔

python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
cratedb-version: ['4.8.4', '5.9.2']
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
cratedb-version: ['4.8.4', '5.10.16', '6.3.3']

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

6.4.6 is the current release; worth bumping here and in the macOS and Windows slots below

Comment thread tests/util.py

def __init__(self, crate_version: str = "nightly", **kwargs) -> None:
self.cratedb: Optional[CrateDBContainer] = None
self.image: str = "crate/crate:{}".format(crate_version)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

crate/crate release tags are amd64-only, so on an arm Mac this fails or runs emulated; crate/crate:nightly for nightly and the official crate:<version> for releases works on both

@amotl

amotl commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Hey, I have some comments which I'd like addressed in this PR before we merge. I can do them if you ✅ "Allow edits by maintainers", or you can do them yourself if you so desire.

Hi. I received such requests multiple times in the past, but I've never been able to find the "Allow edits by maintainers" toggle. Can you provide relevant guidance?

Or ofc you can hit back on any point.

Can you explain what ofc means?

@florinutz

Copy link
Copy Markdown
Contributor

Allow edits by maintainers

I couldn't find it either when you asked it the other day 👀
Here, maybe? https://docs.github.com/en/pull-requests/how-tos/work-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork

Can you explain what ofc means?

of course I can

@amotl

amotl commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Ah, thanks. Well, this option does not exist on this PR. ;[

image

In this case, feel free to close the PR and stage my commits into another one. 🙇

@florinutz

Copy link
Copy Markdown
Contributor

ah, your fork is owned by the zerotired org. Seems gh shows "Allow edits from maintainers" only on pull requests from forks owned by a person

@florinutz

Copy link
Copy Markdown
Contributor

Thank you @amotl ! continuing this in #518

@florinutz florinutz closed this Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trim dependencies

4 participants