Skip to content

Commit

Permalink
fix network isolation test (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
zubenkoivan authored Mar 28, 2024
1 parent c67954e commit b2accff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/setup-automerge.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Enable auto-merge
on:
pull_request_target:
pull_request:
types: [opened]

permissions:
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ include_package_data = True
packages = find:
platforms = any
install_requires =
aiohttp==3.9.3
aiobotocore==2.12.0
neuro-cli==24.2.0
neuro-auth-client==22.6.1
neuro-admin-client==23.5.0
yarl==1.9.4
yarl==1.8.2
jose==1.0.0
pytest==8.1.0
pytest-dependency==0.5.1
pytest-timeout==2.3.1
pytest-aiohttp==1.0.5
pytest-asyncio==0.21.1

[options.entry_points]
pytest11 =
Expand Down
34 changes: 12 additions & 22 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from uuid import uuid4

import pytest
import pytest_asyncio
from jose import jwt
from neuro_admin_client import AdminClient, ClusterUserRoleType
from neuro_auth_client import AuthClient
Expand Down Expand Up @@ -140,12 +139,7 @@ def _get_user_name_from_token(token: str) -> str:


@pytest.fixture(scope="session")
async def project_name(cluster_name: str) -> str:
return f"neuro-e2e-{_hash(cluster_name)}"


@pytest.fixture(scope="session")
async def user_name(cluster_name: str) -> str:
def user_name(cluster_name: str) -> str:
if "CLIENT_TEST_E2E_USER_TOKEN" in os.environ:
token = os.environ["CLIENT_TEST_E2E_USER_TOKEN"]
return _get_user_name_from_token(token)
Expand All @@ -164,7 +158,7 @@ async def user_token(


@pytest.fixture(scope="session")
async def user_name_alt(cluster_name: str) -> str:
def user_name_alt(cluster_name: str) -> str:
if "CLIENT_TEST_E2E_USER_TOKEN_ALT" in os.environ:
token = os.environ["CLIENT_TEST_E2E_USER_TOKEN_ALT"]
return _get_user_name_from_token(token)
Expand All @@ -184,7 +178,7 @@ async def user_token_alt(
return user_token


@pytest_asyncio.fixture(scope="session")
@pytest.fixture(scope="session")
async def config_path(
tmp_path_factory: Any,
api_url: URL,
Expand All @@ -203,7 +197,7 @@ async def config_path(
return path


@pytest_asyncio.fixture(scope="session")
@pytest.fixture(scope="session")
async def config_path_alt(
tmp_path_factory: Any, api_url: URL, user_name_alt: str, user_token_alt: str
) -> Path:
Expand All @@ -218,16 +212,17 @@ async def config_path_alt(
return path


@pytest_asyncio.fixture(scope="session")
@pytest.fixture(scope="session")
async def helper(
config_path: Path,
tmp_path_factory: Any,
cluster_name: str,
project_name: str,
user_name: str,
) -> AsyncIterator[Helper]:
client = await get(path=config_path)
print("API URL", client.config.api_url)
await client.config.switch_cluster(cluster_name)
project_name = f"{user_name}-default"
try:
await client._admin.create_project(
project_name, cluster_name=cluster_name, org_name=None
Expand All @@ -246,34 +241,29 @@ async def helper(
await client.close()


@pytest_asyncio.fixture(scope="session")
@pytest.fixture(scope="session")
async def helper_alt(
config_path_alt: Path,
tmp_path_factory: Any,
helper: Helper,
cluster_name: str,
project_name: str,
user_name_alt: str,
) -> AsyncIterator[Helper]:
client = await get(path=config_path_alt)
print("Alt API URL", client.config.api_url)
await client.config.switch_cluster(cluster_name)
project_name = f"{user_name_alt}-default"
try:
await helper.client._admin.create_project_user(
project_name=project_name,
cluster_name=cluster_name,
org_name=None,
user_name=user_name_alt,
await client._admin.create_project(
project_name, cluster_name=cluster_name, org_name=None
)
await client.config.fetch()
except Exception as ex:
LOGGER.info("Project user %s creation failed: %s", user_name, ex)
# Check project user exists
await helper.client._admin.get_project_user(
await client._admin.get_project(
project_name=project_name,
cluster_name=cluster_name,
org_name=None,
user_name=user_name_alt,
)
await client.config.switch_project(project_name)
yield Helper(client, tmp_path_factory.mktemp("helper_alt"), config_path_alt)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from uuid import uuid4 as uuid

import pytest
import pytest_asyncio
from neuro_sdk import JobStatus, RemoteImage, ResourceNotFound

from platform_e2e import Helper, shell
Expand All @@ -32,7 +31,7 @@ def _build_image(image: RemoteImage) -> Iterator[None]:
shell(f"docker rmi {image_url}")


@pytest_asyncio.fixture(scope="session")
@pytest.fixture(scope="session")
async def image(helper: Helper) -> AsyncIterator[RemoteImage]:
image = RemoteImage(
name="platform-e2e",
Expand Down

0 comments on commit b2accff

Please sign in to comment.