示例#1
0
def test_handle_stopped_cancelled_task():
    executor = AmazonECSExecutorStub(
        job_id="algorithms-job-00000000-0000-0000-0000-000000000000",
        exec_image_sha256="",
        exec_image_repo_tag="",
        memory_limit=4,
        time_limit=60,
        requires_gpu=False,
    )
    event = {
        "taskDefinitionArn": "arn:aws:ecs:region:123456789012:task-definition/algorithms-job-00000000-0000-0000-0000-000000000000:1",
        "group": "components-gpu",
        "stopCode": "UserInitiated",
        "containers": [
            {
                # No container exit in this case
                "name": "algorithms-job-00000000-0000-0000-0000-000000000000-timeout"
            },
            {
                # No container exit in this case
                "name": "algorithms-job-00000000-0000-0000-0000-000000000000"
            },
        ],
        "createdAt": "2021-09-25T10:50:24.248Z",  # No startedAt in this case
        "stoppedAt": "2021-09-25T11:02:30.776Z",
    }

    with pytest.raises(TaskCancelled):
        # Task should be retried
        executor._get_container_exit_codes(event=event)
示例#2
0
def test_handle_stopped_successful_fast_task():
    executor = AmazonECSExecutorStub(
        job_id="algorithms-job-00000000-0000-0000-0000-000000000000",
        exec_image_sha256="",
        exec_image_repo_tag="",
        memory_limit=4,
        time_limit=60,
        requires_gpu=False,
    )
    event = {
        "taskDefinitionArn": "arn:aws:ecs:region:123456789012:task-definition/algorithms-job-00000000-0000-0000-0000-000000000000:1",
        "group": "components-gpu",
        "stopCode": "TaskFailedToStart",  # as not all container had time to start
        "containers": [
            {
                # No container exit in this case
                "name": "algorithms-job-00000000-0000-0000-0000-000000000000-timeout"
            },
            {
                "exitCode": 0,
                "name": "algorithms-job-00000000-0000-0000-0000-000000000000",
            },
        ],
        "createdAt": "2021-09-25T10:50:24.248Z",  # No startedAt in this case
        "stoppedAt": "2021-09-25T11:02:30.776Z",
    }

    assert executor._get_container_exit_codes(event=event) == {
        "algorithms-job-00000000-0000-0000-0000-000000000000": 0
    }
def test_handle_stopped_successful_task():
    executor = AmazonECSExecutorStub(
        job_id="algorithms-job-00000000-0000-0000-0000-000000000000",
        exec_image_sha256="",
        exec_image_repo_tag="",
        exec_image_file=None,
        memory_limit=4,
        requires_gpu=False,
    )
    event = {
        "taskDefinitionArn":
        "arn:aws:ecs:region:123456789012:task-definition/algorithms-job-00000000-0000-0000-0000-000000000000:1",
        "group":
        "components-gpu",
        "stopCode":
        "EssentialContainerExited",
        "containers": [
            {
                "exitCode":
                143,
                "name":
                "algorithms-job-00000000-0000-0000-0000-000000000000-timeout",
            },
            {
                "exitCode": 0,
                "name": "algorithms-job-00000000-0000-0000-0000-000000000000",
            },
        ],
        "startedAt":
        "2021-09-25T10:50:24.248Z",
        "stoppedAt":
        "2021-09-25T11:02:30.776Z",
    }
    assert executor._get_container_exit_codes(event=event) == {
        "algorithms-job-00000000-0000-0000-0000-000000000000": 0,
        "algorithms-job-00000000-0000-0000-0000-000000000000-timeout": 143,
    }