Exemplo n.º 1
0
def test_start_task(mock_ecs_client, mock_ecs_cluster,
                    mock_ecs_task_definition, mock_subnets):
    client = FakeECSClient(cluster=mock_ecs_cluster,
                           client=mock_ecs_client,
                           subnets=mock_subnets)
    task_arn = client.start_task(mock_ecs_task_definition)
    assert client.start_task(mock_ecs_task_definition) != task_arn
Exemplo n.º 2
0
def test_run_task(mock_ecs_client, mock_ecs_cluster, mock_ecs_task_definition,
                  mock_subnets, expected_statuses):
    client = FakeECSClient(cluster=mock_ecs_cluster,
                           client=mock_ecs_client,
                           subnets=mock_subnets)
    client.run_task(mock_ecs_task_definition,
                    expected_statuses=expected_statuses)
Exemplo n.º 3
0
def test_stop_task_timeout(mock_ecs_client, mock_ecs_cluster, mock_subnets):
    client = FakeECSClient(cluster=mock_ecs_cluster,
                           client=mock_ecs_client,
                           subnets=mock_subnets,
                           max_polls=1)
    with pytest.raises(ECSTimeout):
        client.stop_task("task arn", expected_statuses=["RUNNING", "RUNNING"])
Exemplo n.º 4
0
def test_stop_task(mock_ecs_client, mock_ecs_cluster, mock_subnets):
    client = FakeECSClient(cluster=mock_ecs_cluster,
                           subnets=mock_subnets,
                           client=mock_ecs_client)

    assert client.stop_task("running task arn")
    assert not client.stop_task("already stopped task arn",
                                expected_statuses=["STOPPED"])
Exemplo n.º 5
0
def test_run_task_fails(mock_ecs_client, mock_ecs_cluster,
                        mock_ecs_task_definition, mock_subnets):
    client = FakeECSClient(cluster=mock_ecs_cluster,
                           subnets=mock_subnets,
                           client=mock_ecs_client)
    with pytest.raises(ECSError, match="OutOfMemoryError"):
        client.run_task(mock_ecs_task_definition,
                        expected_stop_code="OutOfMemoryError")
Exemplo n.º 6
0
def test_run_task_timeout(mock_ecs_client, mock_ecs_cluster,
                          mock_ecs_task_definition, mock_subnets):
    client = FakeECSClient(cluster=mock_ecs_cluster,
                           client=mock_ecs_client,
                           subnets=mock_subnets,
                           max_polls=1)
    with pytest.raises(ECSTimeout):
        client.run_task(mock_ecs_task_definition)
Exemplo n.º 7
0
def test_set_task(mock_ecs_client, mock_ecs_cluster, mock_subnets):
    client = FakeECSClient(cluster=mock_ecs_cluster,
                           client=mock_ecs_client,
                           subnets=mock_subnets)
    definition = dict(
        family="dagster",
        requiresCompatibilities=["FARGATE"],
        containerDefinitions=[
            {
                "name": "HelloWorld",
                "image": "hello-world:latest",
                "cpu": 256
            },
        ],
        networkMode="awsvpc",
        cpu="256",
        memory="512",
    )

    assert not mock_ecs_client.list_task_definitions()["taskDefinitionArns"]
    task_definition_arn = client.set_task(**definition)
    assert mock_ecs_client.list_task_definitions()["taskDefinitionArns"] == [
        task_definition_arn
    ]