Skip to content

Commit 1abe5aa

Browse files
committed
Split director-v2 02 into 02 and 03
1 parent b01bc0d commit 1abe5aa

File tree

5 files changed

+776
-0
lines changed

5 files changed

+776
-0
lines changed

.github/workflows/ci-testing-deploy.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,6 +1614,52 @@ jobs:
16141614
with:
16151615
flags: integrationtests #optional
16161616

1617+
integration-test-director-v2-03:
1618+
needs: [changes, build-test-images]
1619+
if: ${{ needs.changes.outputs.anything-py == 'true' || needs.changes.outputs.director-v2 == 'true' || github.event_name == 'push' }}
1620+
timeout-minutes: 30 # if this timeout gets too small, then split the tests
1621+
name: "[int] director-v2 02"
1622+
runs-on: ${{ matrix.os }}
1623+
strategy:
1624+
matrix:
1625+
python: ["3.11"]
1626+
os: [ubuntu-24.04]
1627+
fail-fast: false
1628+
env:
1629+
# NOTE: DIRECTOR_DEFAULT_MAX_* used for integration-tests that include `director` service
1630+
DIRECTOR_DEFAULT_MAX_MEMORY: 268435456
1631+
DIRECTOR_DEFAULT_MAX_NANO_CPUS: 10000000
1632+
steps:
1633+
- uses: actions/checkout@v5
1634+
- name: Setup SimCore environment
1635+
uses: ./.github/actions/setup-simcore-env
1636+
with:
1637+
python-version: ${{ matrix.python }}
1638+
cache-dependency-glob: "**/director-v2/requirements/ci.txt"
1639+
- name: setup rclone docker volume plugin
1640+
run: sudo ./ci/github/helpers/install_rclone_docker_volume_plugin.bash
1641+
- name: Download and load Docker images
1642+
uses: ./.github/actions/download-load-docker-images
1643+
with:
1644+
artifact-name-pattern: 'backend'
1645+
- name: install rclone
1646+
run: sudo ./ci/github/helpers/install_rclone.bash
1647+
- name: install
1648+
run: ./ci/github/integration-testing/director-v2.bash install
1649+
- name: test
1650+
run: ./ci/github/integration-testing/director-v2.bash test 03
1651+
- name: upload failed tests logs
1652+
if: ${{ failure() }}
1653+
uses: actions/upload-artifact@v4
1654+
with:
1655+
name: ${{ github.job }}_docker_logs
1656+
path: ./services/director-v2/test_failures
1657+
- uses: codecov/codecov-action@v5
1658+
env:
1659+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1660+
with:
1661+
flags: integrationtests #optional
1662+
16171663
integration-test-dynamic-sidecar:
16181664
needs: [changes, build-test-images]
16191665
if: ${{ needs.changes.outputs.anything-py == 'true' || needs.changes.outputs.dynamic-sidecar == 'true' || github.event_name == 'push'}}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# pylint: disable=redefined-outer-name
2+
# pylint: disable=unused-argument
3+
4+
from collections.abc import AsyncIterator
5+
from uuid import uuid4
6+
7+
import aiodocker
8+
import pytest
9+
from models_library.api_schemas_resource_usage_tracker.pricing_plans import (
10+
RutPricingPlanGet,
11+
)
12+
from models_library.projects_networks import ProjectsNetworks
13+
from models_library.services_resources import (
14+
ServiceResourcesDict,
15+
ServiceResourcesDictHelpers,
16+
)
17+
from pydantic import TypeAdapter
18+
from pytest_mock.plugin import MockerFixture
19+
20+
21+
@pytest.fixture(scope="session")
22+
def network_name() -> str:
23+
return "pytest-simcore_interactive_services_subnet"
24+
25+
26+
@pytest.fixture
27+
async def ensure_swarm_and_networks(
28+
network_name: str, docker_swarm: None
29+
) -> AsyncIterator[None]:
30+
"""
31+
Make sure to always have a docker swarm network.
32+
If one is not present crete one. There can not be more then one.
33+
"""
34+
35+
async with aiodocker.Docker() as docker_client:
36+
# if network dose not exist create and remove it
37+
create_and_remove_network = True
38+
for network_data in await docker_client.networks.list():
39+
if network_data["Name"] == network_name:
40+
create_and_remove_network = False
41+
break
42+
docker_network = None
43+
if create_and_remove_network:
44+
network_config = {
45+
"Name": network_name,
46+
"Driver": "overlay",
47+
"Attachable": True,
48+
"Internal": False,
49+
"Scope": "swarm",
50+
}
51+
docker_network = await docker_client.networks.create(network_config)
52+
53+
yield
54+
55+
if create_and_remove_network and docker_network:
56+
network = await docker_client.networks.get(docker_network.id)
57+
assert await network.delete() is True
58+
59+
60+
@pytest.fixture
61+
def mock_projects_networks_repository(mocker: MockerFixture) -> None:
62+
mocker.patch(
63+
(
64+
"simcore_service_director_v2.modules.db.repositories."
65+
"projects_networks.ProjectsNetworksRepository.get_projects_networks"
66+
),
67+
return_value=ProjectsNetworks.model_validate(
68+
{"project_uuid": uuid4(), "networks_with_aliases": {}}
69+
),
70+
)
71+
72+
73+
@pytest.fixture
74+
def service_resources() -> ServiceResourcesDict:
75+
return TypeAdapter(ServiceResourcesDict).validate_python(
76+
ServiceResourcesDictHelpers.model_config["json_schema_extra"]["examples"][0],
77+
)
78+
79+
80+
@pytest.fixture
81+
def mock_resource_usage_tracker(mocker: MockerFixture) -> None:
82+
base_module = "simcore_service_director_v2.modules.resource_usage_tracker_client"
83+
service_pricing_plan = RutPricingPlanGet.model_validate(
84+
RutPricingPlanGet.model_config["json_schema_extra"]["examples"][1]
85+
)
86+
for unit in service_pricing_plan.pricing_units:
87+
unit.specific_info.aws_ec2_instances.clear()
88+
mocker.patch(
89+
f"{base_module}.ResourceUsageTrackerClient.get_default_service_pricing_plan",
90+
return_value=service_pricing_plan,
91+
)

0 commit comments

Comments
 (0)