-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split AWS tests into unit and integration tests
- Loading branch information
Showing
22 changed files
with
482 additions
and
387 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import pytest | ||
|
||
from exasol.ds.sandbox.lib.tags import DEFAULT_TAG_KEY | ||
from exasol.ds.sandbox.lib.asset_id import AssetId | ||
from exasol.ds.sandbox.lib.vm_bucket.vm_dss_bucket import create_vm_bucket_cf_template | ||
from exasol.ds.sandbox.lib.vm_bucket.vm_dss_bucket_waf import get_cloudformation_template | ||
from exasol.ds.sandbox.lib.render_template import render_template | ||
from test.aws.local_stack_access import AwsLocalStackAccess | ||
|
||
TEST_DUMMY_AMI_ID = "ami-123" | ||
DEFAULT_ASSET_ID = AssetId("test", stack_prefix="test-stack", ami_prefix="test-ami") | ||
TEST_ACL_ARN = "TEST-DOWNLOAD-ACL" | ||
TEST_IP = "1.1.1.1" | ||
|
||
|
||
@pytest.fixture | ||
def default_asset_id(): | ||
return DEFAULT_ASSET_ID | ||
|
||
|
||
@pytest.fixture() | ||
def test_dummy_ami_id(): | ||
return TEST_DUMMY_AMI_ID | ||
|
||
|
||
def vm_bucket_template(): | ||
return create_vm_bucket_cf_template(TEST_ACL_ARN) | ||
|
||
|
||
@pytest.fixture | ||
def vm_bucket_cloudformation_yml(): | ||
return vm_bucket_template() | ||
|
||
|
||
def ec2_template(): | ||
return render_template( | ||
"ec2_cloudformation.jinja.yaml", | ||
key_name="test_key", | ||
user_name="test_user", | ||
trace_tag=DEFAULT_TAG_KEY, | ||
trace_tag_value=DEFAULT_ASSET_ID.tag_value, | ||
ami_id=TEST_DUMMY_AMI_ID, | ||
) | ||
|
||
|
||
@pytest.fixture | ||
def ec2_cloudformation_yml(): | ||
return ec2_template() | ||
|
||
|
||
def waf_template(): | ||
return get_cloudformation_template(TEST_IP) | ||
|
||
|
||
@pytest.fixture | ||
def waf_cloudformation_yml(): | ||
return waf_template() | ||
|
||
|
||
def ci_codebuild_template(): | ||
return render_template( | ||
"ci_code_build.jinja.yaml", | ||
vm_bucket="test-bucket-123", | ||
) | ||
|
||
|
||
def release_codebuild_template(): | ||
return render_template( | ||
"release_code_build.jinja.yaml", | ||
vm_bucket="test-bucket-123", | ||
path_in_bucket=AssetId.BUCKET_PREFIX, | ||
dockerhub_secret_arn="secret_arn", | ||
) | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def local_stack_aws_access(local_stack): | ||
return AwsLocalStackAccess().with_user("default_user") |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
import pytest | ||
import subprocess | ||
import shlex | ||
|
||
from importlib.metadata import version | ||
|
||
@pytest.fixture(scope="session") | ||
def local_stack(): | ||
""" | ||
This fixture starts/stops localstack as a context manager. | ||
""" | ||
command = "localstack start -d" | ||
|
||
image_version = version('localstack') | ||
# See https://github.com/localstack/localstack/issues/8254 | ||
# and https://github.com/localstack/localstack/issues/9939 | ||
# | ||
# Until an official release of localstack Docker image with a concrete | ||
# version is available incl. a fix for issue 9939 we only can use version | ||
# "latest". | ||
# | ||
# See https://github.com/exasol/ai-lab/issues/200 for replacing this with | ||
# a concrete version in order to make CI tests more robust. | ||
image_version = "3.2.0" | ||
image_name = {"IMAGE_NAME": f"localstack/localstack:{image_version}"} | ||
env_variables = {**os.environ, **image_name} | ||
|
||
process = subprocess.run(shlex.split(command), env=env_variables) | ||
assert process.returncode == 0 | ||
|
||
command = "localstack wait -t 30" | ||
|
||
process = subprocess.run(shlex.split(command), env=env_variables) | ||
assert process.returncode == 0 | ||
yield None | ||
|
||
command = "localstack stop" | ||
subprocess.run(shlex.split(command), env=env_variables) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.