Пример #1
0
def test_get_latest_image_wrong(server):
    server.data = {
        "aws-region": region,
        "aws-ami-criteria": GET_LATEST_IMAGE_WRONG_CRITERIA
    }

    client = zebr0_aws.Client(zebr0.Client("http://localhost:8000"))

    assert client.get_latest_image() is None
Пример #2
0
def test_get_latest_image_fixed(server):
    server.data = {
        "aws-region": region,
        "aws-ami-criteria": GET_LATEST_IMAGE_FIXED_CRITERIA
    }

    client = zebr0_aws.Client(zebr0.Client("http://localhost:8000"))

    assert client.get_latest_image().get("ImageId") == "ami-06ec8443c2a35b0ba"
Пример #3
0
def test_get_bucket(server):
    server.data = {
        "aws-region": region,
        "aws-stack-name": stack_name,
        "aws-stack-config": GET_BUCKET_CONFIG
    }

    client = zebr0_aws.Client(zebr0.Client("http://localhost:8000"))
    client.create_stack()

    assert client.get_bucket(
    ) is not None  # todo: obviously this is not enough, but it will do for now
Пример #4
0
def test_get_latest_image_rolling(server):
    server.data = {
        "aws-region": region,
        "aws-ami-criteria": GET_LATEST_IMAGE_ROLLING_CRITERIA
    }

    client = zebr0_aws.Client(zebr0.Client("http://localhost:8000"))

    one_week_ago = datetime.utcnow() - timedelta(weeks=1)
    creation_date = datetime.fromisoformat(client.get_latest_image().get(
        "CreationDate")[:-1])  # removes the "Z" at the end of aws dates
    assert creation_date > one_week_ago
Пример #5
0
def test_create_stack(server):
    server.data = {
        "aws-region": region,
        "aws-stack-name": stack_name,
        "aws-stack-config": CREATE_STACK_CONFIG
    }

    client = zebr0_aws.Client(zebr0.Client("http://localhost:8000"))
    client.create_stack()

    boto3_client = boto3.client(service_name="s3", region_name=region)
    assert any(bucket
               for bucket in boto3_client.list_buckets().get("Buckets", [])
               if bucket.get("Name").startswith(stack_name + "-bucket-"))
Пример #6
0
def test_create_instance(server):
    server.data = {
        "aws-region": region,
        "aws-stack-name": stack_name,
        "aws-stack-config": CREATE_INSTANCE_CONFIG,
        "aws-ami-criteria": GET_LATEST_IMAGE_ROLLING_CRITERIA,
        "aws-instance-type": "t3.micro",
        "aws-volume-size": "8",
        "aws-user-data": "#cloud-config"
    }

    client = zebr0_aws.Client(zebr0.Client("http://localhost:8000"))
    client.create_stack()

    assert client.create_instance(
    ) is not None  # todo: obviously this is not enough, but it will do for now
Пример #7
0
def test_full(server):
    server.data = {
        "aws-region": region,
        "aws-stack-name": stack_name,
        "aws-stack-config": FULL_CONFIG,
        "aws-ami-criteria": GET_LATEST_IMAGE_ROLLING_CRITERIA,
        "aws-instance-type": "t3.micro",
        "aws-volume-size": "8",
        "aws-user-data": FULL_USER_DATA
    }

    client = zebr0_aws.Client(zebr0.Client("http://localhost:8000"))
    client.create_stack()

    ip = client.create_instance()

    heal_check.warning_tolerant_check("http://" + ip + ":2501")