Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 378
#391 build test fixes#392
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
575cbb9bc0ecc1e01d326248bc2afd682bfd79270f401389696afdf6b1a1ea12bd20c6ef80351File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -12,7 +12,7 @@ | ||
| # under the License. | ||
| import logging | ||
| import re | ||
| import urllib | ||
| import urllib.request | ||
alexanderankin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| from typing import Dict | ||
| from urllib.error import URLError | ||
| @@ -88,7 +88,7 @@ def __init__(self, image: str = "elasticsearch", port: int = 9200, **kwargs) -> | ||
| @wait_container_is_ready(URLError) | ||
| def _connect(self) -> None: | ||
| res = urllib.request.urlopen(self.get_url()) | ||
| res = urllib.request.urlopen(self.get_url(), timeout=1) | ||
kiview marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| if res.status != 200: | ||
| raise Exception() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import json | ||
| import urllib | ||
| import urllib.request | ||
alexanderankin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| import pytest | ||
| from testcontainers.elasticsearch import ElasticSearchContainer | ||
| @@ -8,6 +8,8 @@ | ||
| # 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: | ||
| # adding the mem_limit as per: https://stackoverflow.com/a/75701019 | ||
| # could also add (but not necessary): .with_env('discovery.type', 'single-node') | ||
| with ElasticSearchContainer(f'elasticsearch:{version}', mem_limit='3G') as es: | ||
alexanderankin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| resp = urllib.request.urlopen(es.get_url()) | ||
| assert json.loads(resp.read().decode())['version']['number'] == version | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -10,8 +10,13 @@ | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for the specific language governing permissions and limitations | ||
| # under the License. | ||
| import urllib.error | ||
| import urllib.parse | ||
| import urllib.request | ||
| from testcontainers.core.container import DockerContainer | ||
| from testcontainers.core.utils import raise_for_deprecated_parameter | ||
| from testcontainers.core.waiting_utils import wait_container_is_ready | ||
| class NginxContainer(DockerContainer): | ||
| @@ -20,3 +25,17 @@ def __init__(self, image: str = "nginx:latest", port: int = 80, **kwargs) -> Non | ||
| super(NginxContainer, self).__init__(image, **kwargs) | ||
| self.port = port | ||
| self.with_exposed_ports(self.port) | ||
| def start(self) -> 'NginxContainer': | ||
kiview marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| super().start() | ||
| host = self.get_container_host_ip() | ||
| port = str(self.get_exposed_port(self.port)) | ||
| self._connect(host, port) | ||
| return self | ||
| @wait_container_is_ready(urllib.error.URLError) | ||
| def _connect(self, host: str, port: str) -> None: | ||
| url = urllib.parse.urlunsplit(('http', f'{host}:{port}', '', '', '')) | ||
| urllib.request.urlopen(url, timeout=1) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -138,8 +138,6 @@ docker[ssh]==6.1.3 | ||
| # via | ||
| # docker-compose | ||
| # testcontainers-core | ||
| docker-compose==1.29.2 | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think these files should be manually edited, since they contain the following comment: MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is true but I cannot auto generate this with the required os/env. | ||
| # via testcontainers-compose | ||
| dockerpty==0.4.1 | ||
| # via docker-compose | ||
| docopt==0.6.2 | ||
| @@ -317,8 +315,6 @@ pytz==2023.3 | ||
| # via | ||
| # clickhouse-driver | ||
| # neo4j | ||
| pyyaml==5.4.1 | ||
| # via docker-compose | ||
| readme-renderer==37.3 | ||
| # via twine | ||
| redis==4.5.5 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -12,10 +12,11 @@ | ||
| # under the License. | ||
| from selenium import webdriver | ||
| from selenium.webdriver.common.options import ArgOptions | ||
| from testcontainers.core.container import DockerContainer | ||
| from testcontainers.core.waiting_utils import wait_container_is_ready | ||
| from typing import Optional | ||
| import urllib3 | ||
| from typing import Any, Dict, Optional | ||
| import urllib3.exceptions | ||
| IMAGES = { | ||
| @@ -24,7 +25,7 @@ | ||
| } | ||
| def get_image_name(capabilities: str) -> str: | ||
| def get_image_name(capabilities: Dict[str, Any]) -> str: | ||
alexanderankin marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return IMAGES[capabilities['browserName']] | ||
kiview marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| @@ -45,9 +46,9 @@ class BrowserWebDriverContainer(DockerContainer): | ||
| You can easily change browser by passing :code:`DesiredCapabilities.FIREFOX` instead. | ||
| """ | ||
| def __init__(self, capabilities: str, image: Optional[str] = None, port: int = 4444, | ||
| def __init__(self, capabilities: Dict[str, Any], image: Optional[str] = None, port: int = 4444, | ||
| vnc_port: int = 5900, **kwargs) -> None: | ||
| self.capabilities = capabilities | ||
| self.capabilities = capabilities or webdriver.DesiredCapabilities.CHROME | ||
| self.image = image or get_image_name(capabilities) | ||
| self.port = port | ||
| self.vnc_port = vnc_port | ||
| @@ -60,9 +61,13 @@ def _configure(self) -> None: | ||
| @wait_container_is_ready(urllib3.exceptions.HTTPError) | ||
| def _connect(self) -> webdriver.Remote: | ||
| options = ArgOptions() | ||
| caps = options.capabilities | ||
| for k, v in self.capabilities.items(): caps[k] = v # noqa | ||
| return webdriver.Remote( | ||
| command_executor=(self.get_connection_url()), | ||
| desired_capabilities=self.capabilities) | ||
| options=options) | ||
| def get_driver(self) -> webdriver.Remote: | ||
| return self._connect() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4,7 +4,9 @@ | ||
| from testcontainers.core.utils import is_arm | ||
| @pytest.mark.parametrize("caps", [DesiredCapabilities.CHROME, DesiredCapabilities.FIREFOX]) | ||
| @pytest.mark.parametrize("caps", | ||
| [DesiredCapabilities.CHROME, DesiredCapabilities.FIREFOX], | ||
| ids=['chrome', 'ff']) | ||
kiview marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| def test_webdriver_container_container(caps): | ||
| if is_arm(): | ||
| pytest.skip('https://github.com/SeleniumHQ/docker-selenium/issues/1076') | ||
Uh oh!
There was an error while loading. Please reload this page.