-
Notifications
You must be signed in to change notification settings - Fork 347
Fix tests on Apple Silicon / M1 #357
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
Closed
santi
wants to merge
17
commits into
testcontainers:main
from
santi:feat/elasticsearch-tests-on-apple-silicon
Closed
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
ae3f494
Bump ArangoDB test to v3.10 which supports ARM64/v8 architecture
santi 755fafe
Drop unsupported ElasticSearch container. Now all tests use ARM64/v8 …
santi bd78b17
Use latest nginx container, which supports ARM64/v8
santi fda8692
Pin Redis image version. Wait for logs to avoid race conditions
santi e18b27f
Update docstrings
santi d9c601f
Merge branch 'main' into feat/elasticsearch-tests-on-apple-silicon
santi 22a006f
Bump tests to latest arangodb image
santi f1b2f15
Use latest versions of ElasticSearch in tests
santi cf55818
Wait for nginx to startup. Add supported versions to README
santi 82ab6a2
Add supported version range for Redis and wait for logs during startup
santi fafd2b3
Simplify Redis tests
santi 2b3f99f
Use Apple Silicon compatible image in arangodb doctest
santi a8dad63
Switch to maintained KeyCloak image to support Apple Silicon. Wait fo…
santi 97a3e82
Add dev startup command to default Keycloak container
santi 8841110
Use azure-sql-edge in example to enable doctests on Apple Silicon. Ad…
santi 450a2db
Pin image used during tests. Increase timeout due to longer startup t…
santi 8a74ac8
Fix lint
santi 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1 +1,7 @@ | ||
| .. autoclass:: testcontainers.nginx.NginxContainer | ||
|
|
||
| Creates a container with the `nginx <https://hub.docker.com/_/nginx/>`_ image | ||
| and waits for the container to accept connections. | ||
|
|
||
| Defaults to the latest release of nginx, and supports version 1.20+. | ||
| For older versions, use the generic DockerContainer class from `testcontainers-core`. |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1 +1,9 @@ | ||
| .. autoclass:: testcontainers.redis.RedisContainer | ||
|
|
||
|
|
||
|
|
||
| Creates a container with the `redis <https://hub.docker.com/_/redis>`_ image | ||
| and waits for the container to accept connections. | ||
|
|
||
| Defaults to the latest release of redis, and supports version 6.0+. | ||
| For older versions, use the generic DockerContainer class from `testcontainers-core`. |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,36 +1,12 @@ | ||
| import time | ||
| import pytest | ||
|
|
||
| from testcontainers.redis import RedisContainer | ||
|
|
||
|
|
||
| def test_docker_run_redis(): | ||
| config = RedisContainer() | ||
| with config as redis: | ||
| client = redis.get_client() | ||
| p = client.pubsub() | ||
| p.subscribe('test') | ||
| client.publish('test', 'new_msg') | ||
| msg = wait_for_message(p) | ||
| assert 'data' in msg | ||
| assert b'new_msg', msg['data'] | ||
|
|
||
|
|
||
| def test_docker_run_redis_with_password(): | ||
| config = RedisContainer(password="mypass") | ||
| with config as redis: | ||
| @pytest.mark.parametrize('version', ['7.0.11', '6.2.12']) | ||
| def test_redis_container(version: str): | ||
| image_name = f'redis:{version}' | ||
| with RedisContainer(image_name, password="mypass") as redis: | ||
| client = redis.get_client(decode_responses=True) | ||
| client.set("hello", "world") | ||
| assert client.get("hello") == "world" | ||
|
|
||
|
|
||
| def wait_for_message(pubsub, timeout=1, ignore_subscribe_messages=True): | ||
| now = time.time() | ||
| timeout = now + timeout | ||
| while now < timeout: | ||
| message = pubsub.get_message( | ||
| ignore_subscribe_messages=ignore_subscribe_messages) | ||
| if message is not None: | ||
| return message | ||
| time.sleep(0.01) | ||
| now = time.time() | ||
| return None |
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.
I haven't tried this yet, but by passing
KC_HEALTH_ENABLED=trueas a environment variable I believe it might be possible to keep theself._connect()if instead of pooling{url}/authwe pool{url}/health.