Skip to content

Commit

Permalink
combine tc with tc-core and pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderankin committed Jan 23, 2024
1 parent 7799d86 commit 94c16ac
Show file tree
Hide file tree
Showing 8 changed files with 356 additions and 640 deletions.
6 changes: 0 additions & 6 deletions core/README.rst

This file was deleted.

298 changes: 0 additions & 298 deletions core/poetry.lock

This file was deleted.

34 changes: 0 additions & 34 deletions core/pyproject.toml

This file was deleted.

2 changes: 2 additions & 0 deletions core/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@


def test_raise_timeout():
import pathlib
pathlib.Path('/tmp/YESS').write_text('abc')
with pytest.raises(TimeoutError):
with DockerContainer("alpine").with_command("sleep 2") as container:
wait_for_logs(container, "Hello from Docker!", timeout=1e-3)
Expand Down
4 changes: 2 additions & 2 deletions modules/elasticsearch/tests/test_elasticsearch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
import urllib
import urllib.request
import pytest

from testcontainers.elasticsearch import ElasticSearchContainer
Expand All @@ -8,6 +8,6 @@
# The versions below were the current supported versions at time of writing (2022-08-11)
@pytest.mark.parametrize('version', ['6.8.23', '7.17.5', '8.3.3'])
def test_docker_run_elasticsearch(version):
with ElasticSearchContainer(f'elasticsearch:{version}') as es:
with ElasticSearchContainer(f'elasticsearch:{version}', mem_limit='3G') as es:
resp = urllib.request.urlopen(es.get_url())
assert json.loads(resp.read().decode())['version']['number'] == version
8 changes: 7 additions & 1 deletion modules/opensearch/testcontainers/opensearch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from opensearchpy import OpenSearch
from opensearchpy.exceptions import ConnectionError, TransportError
from urllib3.exceptions import ProtocolError

from testcontainers.core.container import DockerContainer
from testcontainers.core.utils import raise_for_deprecated_parameter
Expand Down Expand Up @@ -84,7 +85,12 @@ def get_client(self, verify_certs: bool = False, **kwargs) -> OpenSearch:
**kwargs,
)

@wait_container_is_ready(ConnectionError, TransportError)
@wait_container_is_ready(
ConnectionError,
TransportError,
ProtocolError,
ConnectionResetError
)
def _healthcheck(self) -> None:
"""This is an internal method used to check if the OpenSearch container
is healthy and ready to receive requests."""
Expand Down
637 changes: 340 additions & 297 deletions poetry.lock

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ classifiers = [
]
# testcontainers-core is a proper package dependency - only modules needed here
packages = [
{ include = "testcontainers", from = "core" },
{ include = "testcontainers", from = "modules/arangodb" },
{ include = "testcontainers", from = "modules/azurite" },
{ include = "testcontainers", from = "modules/clickhouse" },
Expand Down Expand Up @@ -56,7 +57,9 @@ packages = [

[tool.poetry.dependencies]
python = ">=3.9,<3.12"
testcontainers-core = "4.0.0" # x-release-please-version
docker = "*" # ">=4.0"
urllib3 = "*" # "<2.0"
wrapt = "*" # "^1.16.0"

# community modules
python-arango = { version = "^7.8", optional = true }
Expand Down Expand Up @@ -103,11 +106,11 @@ redis = ["redis"]
selenium = ["selenium"]

[tool.poetry.group.dev.dependencies]
testcontainers-core = { path = "core", develop = true }
pytest = "7.4.3"
pytest-cov = "4.1.0"
sphinx = "^7.2.6"
flake8 = "^6.1.0"
pg8000 = "*"

[[tool.poetry.source]]
name = "PyPI"
Expand Down

0 comments on commit 94c16ac

Please sign in to comment.