Skip to content

Commit 7d31f74

Browse files
committed
adjust test
1 parent 0279675 commit 7d31f74

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

services/autoscaling/tests/unit/test_utils_cluster_scaling.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,27 @@ def ec2_instances_boot_ami_pre_pull(
195195
return app_environment | envs
196196

197197

198+
@pytest.fixture
199+
def ec2_instances_cold_start_docker_images_pre_pulling(
200+
app_environment: EnvVarsDict, monkeypatch: pytest.MonkeyPatch, faker: Faker
201+
) -> EnvVarsDict:
202+
images = TypeAdapter(list[DockerGenericTag]).validate_python(
203+
[
204+
"nginx:latest",
205+
"itisfoundation/my-very-nice-service:latest",
206+
"simcore/services/dynamic/another-nice-one:2.4.5",
207+
"asd",
208+
]
209+
)
210+
envs = setenvs_from_dict(
211+
monkeypatch,
212+
{
213+
"EC2_INSTANCES_COLD_START_DOCKER_IMAGES_PRE_PULLING": json.dumps(images),
214+
},
215+
)
216+
return app_environment | envs
217+
218+
198219
@pytest.fixture
199220
def disabled_registry(monkeypatch: pytest.MonkeyPatch) -> None:
200221
monkeypatch.delenv("REGISTRY_AUTH")
@@ -203,6 +224,7 @@ def disabled_registry(monkeypatch: pytest.MonkeyPatch) -> None:
203224
async def test_ec2_startup_script_with_pre_pulling(
204225
minimal_configuration: None,
205226
ec2_instances_boot_ami_pre_pull: EnvVarsDict,
227+
ec2_instances_cold_start_docker_images_pre_pulling: EnvVarsDict,
206228
app_settings: ApplicationSettings,
207229
):
208230
assert app_settings.AUTOSCALING_EC2_INSTANCES
@@ -213,9 +235,9 @@ async def test_ec2_startup_script_with_pre_pulling(
213235
)
214236
assert instance_boot_specific.pre_pull_images
215237
startup_script = await ec2_startup_script(instance_boot_specific, app_settings)
216-
assert len(startup_script.split("&&")) == 7
238+
assert len(startup_script.split("&&")) == 6
217239
assert re.fullmatch(
218-
r"^(docker swarm join [^&&]+) && (echo [^\s]+ \| docker login [^&&]+) && (echo [^&&]+) && (echo [^&&]+) && (chmod \+x [^&&]+) && (./docker-pull-script.sh) && (echo .+)$",
240+
r"^(docker swarm join [^&&]+) && (echo [^\s]+ \| docker login [^&&]+) && (echo [^&&]+) && (echo [^&&]+) && (chmod \+x [^&&]+) && (./docker-pull-script.sh)$",
219241
startup_script,
220242
), f"{startup_script=}"
221243

0 commit comments

Comments
 (0)