Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingrismore committed Jan 22, 2024
1 parent 61c6abc commit d02502a
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/workers/test_ecs_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,51 @@ async def test_deregister_task_definition_does_not_apply_to_linked_arn(
describe_task_definition(ecs_client, task)["status"] == "ACTIVE"


@pytest.mark.usefixtures("ecs_mocks")
async def test_match_latest_revision_in_family(
aws_credentials: AwsCredentials, flow_run: FlowRun
):
session = aws_credentials.get_boto3_session()
ecs_client = session.client("ecs")

configuration_1 = await construct_configuration(
aws_credentials=aws_credentials,
match_latest_revision_in_family=True,
)

configuration_2 = await construct_configuration(
aws_credentials=aws_credentials,
execution_role_arn="test",
)

configuration_3 = await construct_configuration(
aws_credentials=aws_credentials,
match_latest_revision_in_family=True,
execution_role_arn="test",
)

# Let the first worker run and register two task definitions
async with ECSWorker(work_pool_name="test") as worker:
await run_then_stop_task(worker, configuration_1, flow_run)
result_1 = await run_then_stop_task(worker, configuration_2, flow_run)

# Start a new worker with an empty cache
async with ECSWorker(work_pool_name="test") as worker:
result_2 = await run_then_stop_task(worker, configuration_3, flow_run)

assert result_1.status_code == 0
_, task_arn_1 = parse_identifier(result_1.identifier)

assert result_2.status_code == 0
_, task_arn_2 = parse_identifier(result_2.identifier)

task_1 = describe_task(ecs_client, task_arn_1)
task_2 = describe_task(ecs_client, task_arn_2)

assert task_1["taskDefinitionArn"] == task_2["taskDefinitionArn"]
assert task_2["taskDefinitionArn"].endswith(":2")


@pytest.mark.usefixtures("ecs_mocks")
async def test_worker_caches_registered_task_definitions(
aws_credentials: AwsCredentials, flow_run: FlowRun
Expand Down

0 comments on commit d02502a

Please sign in to comment.