Exemplo n.º 1
0
def test_client(mock_ecs_client, mock_ecs_cluster):  # pylint: disable=unused-argument
    return client.ECSClient(
        key_id="Testing",
        access_key="Testing",
        starter_client=mock_ecs_client,
        starter_log_client=boto3.client("logs", region_name="us-east-2"),
    )
Exemplo n.º 2
0
def test_set_cluster():
    log_client = boto3.client("logs", region_name="us-east-2")
    ecs_client = boto3.client("ecs", region_name="us-east-2")
    ecs_client.create_cluster(clusterName="test_clust")
    testclient = client.ECSClient(
        key_id="Testing",
        access_key="Testing",
        starter_client=ecs_client,
        starter_log_client=log_client,
    )
    assert "test_clust" in testclient.cluster
Exemplo n.º 3
0
def test_set_cluster():
    log_client = boto3.client('logs', region_name='us-east-2')
    ecs_client = boto3.client('ecs', region_name='us-east-2')
    ecs_client.create_cluster(clusterName="test_clust")
    testclient = client.ECSClient(
        key_id='Testing',
        access_key='Testing',
        starter_client=ecs_client,
        starter_log_client=log_client,
    )
    assert 'test_clust' in testclient.cluster
Exemplo n.º 4
0
def test_one_run():
    testclient = client.ECSClient()
    testclient.set_and_register_task(
        ["echo start"], ["/bin/bash", "-c"], family="multimessage",
    )
    networkConfiguration = {
        "awsvpcConfiguration": {
            "subnets": ["subnet-0f3b1467",],
            "securityGroups": ["sg-08627da7435350fa6",],
            "assignPublicIp": "ENABLED",
        }
    }
    testclient.run_task(networkConfiguration=networkConfiguration)
    testclient.spin_all()
    assert testclient.logs_messages == {0: ["start"]}
Exemplo n.º 5
0
def test_entry():
    log_client = boto3.client("logs", region_name="us-east-2")
    ecs_client = boto3.client("ecs", region_name="us-east-2")
    ecs_client.create_cluster(clusterName="test_ecs_cluster")
    testclient = client.ECSClient(
        key_id="Testing",
        access_key="Testing",
        starter_client=ecs_client,
        starter_log_client=log_client,
    )
    testclient.set_and_register_task(
        [" "], ["entries"], family=" ",
    )
    taskdef = ecs_client.describe_task_definition(taskDefinition=testclient.task_definition_arn)[
        "taskDefinition"
    ]
    assert taskdef["containerDefinitions"][0]["entryPoint"][0] == "entries"
Exemplo n.º 6
0
def test_entry():
    log_client = boto3.client('logs', region_name='us-east-2')
    ecs_client = boto3.client('ecs', region_name='us-east-2')
    ecs_client.create_cluster(clusterName="test_ecs_cluster")
    testclient = client.ECSClient(
        key_id='Testing',
        access_key='Testing',
        starter_client=ecs_client,
        starter_log_client=log_client,
    )
    testclient.set_and_register_task(
        [" "],
        ["entries"],
        family=' ',
    )
    taskdef = ecs_client.describe_task_definition(
        taskDefinition=testclient.task_definition_arn)['taskDefinition']
    assert taskdef['containerDefinitions'][0]['entryPoint'][0] == "entries"
Exemplo n.º 7
0
def test_region():
    log_client = boto3.client("logs", region_name="us-east-2")
    ecs_client = boto3.client("ecs", region_name="us-east-2")
    ecs_client.create_cluster(clusterName="test_ecs_cluster")
    testclient = client.ECSClient(
        key_id="Testing",
        access_key="Testing",
        starter_client=ecs_client,
        starter_log_client=log_client,
    )
    testclient.set_and_register_task(
        ["echoes"], [""], family="basefam",
    )
    taskdef = ecs_client.describe_task_definition(taskDefinition=testclient.task_definition_arn)[
        "taskDefinition"
    ]
    assert taskdef["family"] == "basefam"
    logger = taskdef["containerDefinitions"][0]["logConfiguration"]["options"]
    assert "us-east-2" in logger["awslogs-region"]
Exemplo n.º 8
0
def test_region():
    log_client = boto3.client('logs', region_name='us-east-2')
    ecs_client = boto3.client('ecs', region_name='us-east-2')
    ecs_client.create_cluster(clusterName="test_ecs_cluster")
    testclient = client.ECSClient(
        key_id='Testing',
        access_key='Testing',
        starter_client=ecs_client,
        starter_log_client=log_client,
    )
    testclient.set_and_register_task(
        ["echoes"],
        [""],
        family='basefam',
    )
    taskdef = ecs_client.describe_task_definition(
        taskDefinition=testclient.task_definition_arn)['taskDefinition']
    assert taskdef['family'] == "basefam"
    logger = taskdef['containerDefinitions'][0]['logConfiguration']['options']
    assert 'us-east-2' in logger['awslogs-region']
Exemplo n.º 9
0
def test_one_run():
    testclient = client.ECSClient()
    testclient.set_and_register_task(
        ["echo start"],
        ["/bin/bash", "-c"],
        family='multimessage',
    )
    networkConfiguration = {
        'awsvpcConfiguration': {
            'subnets': [
                'subnet-0f3b1467',
            ],
            'securityGroups': [
                'sg-08627da7435350fa6',
            ],
            'assignPublicIp': 'ENABLED',
        }
    }
    testclient.run_task(networkConfiguration=networkConfiguration)
    testclient.spin_all()
    assert testclient.logs_messages == {0: ['start']}
Exemplo n.º 10
0
def test_full_run():
    testclient = client.ECSClient()
    testclient.set_and_register_task(
        ["echo $TEST; echo start; echo middle"],
        ["/bin/bash", "-c"],
        family='multimessage',
    )
    networkConfiguration = {
        'awsvpcConfiguration': {
            'subnets': [
                'subnet-0f3b1467',
            ],
            'securityGroups': [
                'sg-08627da7435350fa6',
            ],
            'assignPublicIp': 'ENABLED',
        }
    }
    testclient.run_task(networkConfiguration=networkConfiguration)
    testclient.spin_til_done()
    assert " ".join(testclient.logs_messages) == '\"end\" start middle'