Skip to content

Commit

Permalink
🐛 SIMCORE_SERVICES_NETWORK_NAME now allows dashes (#2447)
Browse files Browse the repository at this point in the history
* added failing test
* network name now allows dashes
  • Loading branch information
GitHK authored Jul 28, 2021
1 parent fc2f5d3 commit b5ab4b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/models-library/src/models_library/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
DYNAMIC_SERVICE_KEY_RE = r"^(simcore)/(services)/dynamic(/[\w/-]+)+$"
COMPUTATIONAL_SERVICE_KEY_RE = r"^(simcore)/(services)/comp(/[\w/-]+)+$"
KEY_RE = SERVICE_KEY_RE # TODO: deprecate this global constant by SERVICE_KEY_RE
SERVICE_NETWORK_RE = r"^([a-zA-Z0-9_]+)$"
SERVICE_NETWORK_RE = r"^([a-zA-Z0-9_-]+)$"

PROPERTY_TYPE_RE = r"^(number|integer|boolean|string|data:([^/\s,]+/[^/\s,]+|\[[^/\s,]+/[^/\s,]+(,[^/\s]+/[^/,\s]+)*\]))$"
PROPERTY_KEY_RE = r"^[-_a-zA-Z0-9]+$"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from uuid import UUID, uuid4

import pytest
from _pytest.monkeypatch import MonkeyPatch
from models_library.projects import ProjectID
from models_library.projects_nodes_io import NodeID
from settings_library.docker_registry import RegistrySettings
Expand Down Expand Up @@ -48,10 +49,8 @@


@pytest.fixture
def dynamic_sidecar_settings(monkeypatch) -> DynamicSidecarSettings:
monkeypatch.setenv(
"DYNAMIC_SIDECAR_IMAGE", "local/dynamic-sidecar:TEST_MOCKED_TAG_NOT_PRESENT"
)
def dynamic_sidecar_settings(monkeypatch: MonkeyPatch) -> DynamicSidecarSettings:
monkeypatch.setenv("DYNAMIC_SIDECAR_IMAGE", "local/dynamic-sidecar:MOCKED")
return DynamicSidecarSettings(REGISTRY=RegistrySettings())


Expand Down Expand Up @@ -253,6 +252,19 @@ async def _count_services_in_stack(
# TESTS


@pytest.mark.parametrize(
"simcore_services_network_name",
("n", "network", "with_underscore", "with-dash", "with-dash_with_underscore"),
)
def test_valid_network_names(
simcore_services_network_name: str, monkeypatch: MonkeyPatch
) -> None:
monkeypatch.setenv("DYNAMIC_SIDECAR_IMAGE", "local/dynamic-sidecar:MOCKED")
monkeypatch.setenv("SIMCORE_SERVICES_NETWORK_NAME", simcore_services_network_name)
dynamic_sidecar_settings = DynamicSidecarSettings(REGISTRY=RegistrySettings())
assert dynamic_sidecar_settings


async def test_failed_docker_client_request(
missing_network_name: str, docker_swarm: None
) -> None:
Expand Down

0 comments on commit b5ab4b4

Please sign in to comment.