Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/ci-testing-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1614,6 +1614,52 @@ jobs:
with:
flags: integrationtests #optional

integration-test-director-v2-03:
needs: [changes, build-test-images]
if: ${{ needs.changes.outputs.anything-py == 'true' || needs.changes.outputs.director-v2 == 'true' || github.event_name == 'push' }}
timeout-minutes: 30 # if this timeout gets too small, then split the tests
name: "[int] director-v2 02"
runs-on: ${{ matrix.os }}
strategy:
matrix:
python: ["3.11"]
os: [ubuntu-24.04]
fail-fast: false
env:
# NOTE: DIRECTOR_DEFAULT_MAX_* used for integration-tests that include `director` service
DIRECTOR_DEFAULT_MAX_MEMORY: 268435456
DIRECTOR_DEFAULT_MAX_NANO_CPUS: 10000000
steps:
- uses: actions/checkout@v5
- name: Setup SimCore environment
uses: ./.github/actions/setup-simcore-env
with:
python-version: ${{ matrix.python }}
cache-dependency-glob: "**/director-v2/requirements/ci.txt"
- name: setup rclone docker volume plugin
run: sudo ./ci/github/helpers/install_rclone_docker_volume_plugin.bash
- name: Download and load Docker images
uses: ./.github/actions/download-load-docker-images
with:
artifact-name-pattern: 'backend'
- name: install rclone
run: sudo ./ci/github/helpers/install_rclone.bash
- name: install
run: ./ci/github/integration-testing/director-v2.bash install
- name: test
run: ./ci/github/integration-testing/director-v2.bash test 03
- name: upload failed tests logs
if: ${{ failure() }}
uses: actions/upload-artifact@v4
with:
name: ${{ github.job }}_docker_logs
path: ./services/director-v2/test_failures
- uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
flags: integrationtests #optional

integration-test-dynamic-sidecar:
needs: [changes, build-test-images]
if: ${{ needs.changes.outputs.anything-py == 'true' || needs.changes.outputs.dynamic-sidecar == 'true' || github.event_name == 'push'}}
Expand Down Expand Up @@ -1740,6 +1786,7 @@ jobs:
[
integration-test-director-v2-01,
integration-test-director-v2-02,
integration-test-director-v2-03,
integration-test-dynamic-sidecar,
integration-test-docker-api-proxy,
integration-test-simcore-sdk,
Expand Down
91 changes: 91 additions & 0 deletions services/director-v2/tests/integration/03/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument

from collections.abc import AsyncIterator
from uuid import uuid4

import aiodocker
import pytest
from models_library.api_schemas_resource_usage_tracker.pricing_plans import (
RutPricingPlanGet,
)
from models_library.projects_networks import ProjectsNetworks
from models_library.services_resources import (
ServiceResourcesDict,
ServiceResourcesDictHelpers,
)
from pydantic import TypeAdapter
from pytest_mock.plugin import MockerFixture


@pytest.fixture(scope="session")
def network_name() -> str:
return "pytest-simcore_interactive_services_subnet"


@pytest.fixture
async def ensure_swarm_and_networks(
network_name: str, docker_swarm: None
) -> AsyncIterator[None]:
"""
Make sure to always have a docker swarm network.
If one is not present crete one. There can not be more then one.
"""

async with aiodocker.Docker() as docker_client:
# if network dose not exist create and remove it
create_and_remove_network = True
for network_data in await docker_client.networks.list():
if network_data["Name"] == network_name:
create_and_remove_network = False
break
docker_network = None
if create_and_remove_network:
network_config = {
"Name": network_name,
"Driver": "overlay",
"Attachable": True,
"Internal": False,
"Scope": "swarm",
}
docker_network = await docker_client.networks.create(network_config)

yield

if create_and_remove_network and docker_network:
network = await docker_client.networks.get(docker_network.id)
assert await network.delete() is True


@pytest.fixture
def mock_projects_networks_repository(mocker: MockerFixture) -> None:
mocker.patch(
(
"simcore_service_director_v2.modules.db.repositories."
"projects_networks.ProjectsNetworksRepository.get_projects_networks"
),
return_value=ProjectsNetworks.model_validate(
{"project_uuid": uuid4(), "networks_with_aliases": {}}
),
)


@pytest.fixture
def service_resources() -> ServiceResourcesDict:
return TypeAdapter(ServiceResourcesDict).validate_python(
ServiceResourcesDictHelpers.model_config["json_schema_extra"]["examples"][0],
)


@pytest.fixture
def mock_resource_usage_tracker(mocker: MockerFixture) -> None:
base_module = "simcore_service_director_v2.modules.resource_usage_tracker_client"
service_pricing_plan = RutPricingPlanGet.model_validate(
RutPricingPlanGet.model_config["json_schema_extra"]["examples"][1]
)
for unit in service_pricing_plan.pricing_units:
unit.specific_info.aws_ec2_instances.clear()
mocker.patch(
f"{base_module}.ResourceUsageTrackerClient.get_default_service_pricing_plan",
return_value=service_pricing_plan,
)
Loading
Loading