Techdebt: Parallellize ACM/AMP tests (#5911)
This commit is contained in:
parent
06baff01d1
commit
f78ced59b3
4
Makefile
4
Makefile
@ -6,9 +6,9 @@ TEST_NAMES = "*"
|
|||||||
ifeq ($(TEST_SERVER_MODE), true)
|
ifeq ($(TEST_SERVER_MODE), true)
|
||||||
# exclude test_kinesisvideoarchivedmedia
|
# exclude test_kinesisvideoarchivedmedia
|
||||||
# because testing with moto_server is difficult with data-endpoint
|
# because testing with moto_server is difficult with data-endpoint
|
||||||
TEST_EXCLUDE := --ignore tests/test_kinesisvideoarchivedmedia --ignore tests/test_awslambda --ignore tests/test_batch --ignore tests/test_ec2 --ignore tests/test_sqs
|
TEST_EXCLUDE := --ignore tests/test_kinesisvideoarchivedmedia --ignore tests/test_acm --ignore tests/test_amp --ignore tests/test_awslambda --ignore tests/test_batch --ignore tests/test_ec2 --ignore tests/test_sqs
|
||||||
# Parallel tests will be run separate
|
# Parallel tests will be run separate
|
||||||
PARALLEL_TESTS := ./tests/test_awslambda ./tests/test_batch ./tests/test_ec2 ./tests/test_sqs
|
PARALLEL_TESTS := ./tests/test_acm/ ./tests/test_acmpca/ ./tests/test_amp/ ./tests/test_awslambda ./tests/test_batch ./tests/test_ec2 ./tests/test_sqs
|
||||||
else
|
else
|
||||||
TEST_EXCLUDE := --ignore tests/test_batch --ignore tests/test_ec2 --ignore tests/test_sqs
|
TEST_EXCLUDE := --ignore tests/test_batch --ignore tests/test_ec2 --ignore tests/test_sqs
|
||||||
PARALLEL_TESTS := ./tests/test_batch ./tests/test_ec2 ./tests/test_sqs
|
PARALLEL_TESTS := ./tests/test_batch ./tests/test_ec2 ./tests/test_sqs
|
||||||
|
@ -90,40 +90,37 @@ def test_import_bad_certificate():
|
|||||||
|
|
||||||
@mock_acm
|
@mock_acm
|
||||||
def test_list_certificates():
|
def test_list_certificates():
|
||||||
client = boto3.client("acm", region_name="eu-central-1")
|
|
||||||
arn = _import_cert(client)
|
|
||||||
|
|
||||||
resp = client.list_certificates()
|
|
||||||
len(resp["CertificateSummaryList"]).should.equal(1)
|
|
||||||
|
|
||||||
resp["CertificateSummaryList"][0]["CertificateArn"].should.equal(arn)
|
|
||||||
resp["CertificateSummaryList"][0]["DomainName"].should.equal(SERVER_COMMON_NAME)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_acm
|
|
||||||
def test_list_certificates_by_status():
|
|
||||||
client = boto3.client("acm", region_name="eu-central-1")
|
client = boto3.client("acm", region_name="eu-central-1")
|
||||||
issued_arn = _import_cert(client)
|
issued_arn = _import_cert(client)
|
||||||
pending_arn = client.request_certificate(DomainName="google.com")["CertificateArn"]
|
pending_arn = client.request_certificate(DomainName="google.com")["CertificateArn"]
|
||||||
|
|
||||||
resp = client.list_certificates()
|
moto_arn = {"CertificateArn": issued_arn, "DomainName": SERVER_COMMON_NAME}
|
||||||
len(resp["CertificateSummaryList"]).should.equal(2)
|
google_arn = {"CertificateArn": pending_arn, "DomainName": "google.com"}
|
||||||
|
|
||||||
|
certs = client.list_certificates()["CertificateSummaryList"]
|
||||||
|
certs.should.contain(moto_arn)
|
||||||
|
certs.should.contain(google_arn)
|
||||||
|
|
||||||
resp = client.list_certificates(CertificateStatuses=["EXPIRED", "INACTIVE"])
|
resp = client.list_certificates(CertificateStatuses=["EXPIRED", "INACTIVE"])
|
||||||
len(resp["CertificateSummaryList"]).should.equal(0)
|
len(resp["CertificateSummaryList"]).should.equal(0)
|
||||||
resp = client.list_certificates(CertificateStatuses=["PENDING_VALIDATION"])
|
|
||||||
len(resp["CertificateSummaryList"]).should.equal(1)
|
|
||||||
resp["CertificateSummaryList"][0]["CertificateArn"].should.equal(pending_arn)
|
|
||||||
|
|
||||||
resp = client.list_certificates(CertificateStatuses=["ISSUED"])
|
certs = client.list_certificates(CertificateStatuses=["PENDING_VALIDATION"])[
|
||||||
len(resp["CertificateSummaryList"]).should.equal(1)
|
"CertificateSummaryList"
|
||||||
resp["CertificateSummaryList"][0]["CertificateArn"].should.equal(issued_arn)
|
]
|
||||||
resp = client.list_certificates(
|
certs.should.contain(google_arn)
|
||||||
|
certs.shouldnt.contain(moto_arn)
|
||||||
|
|
||||||
|
certs = client.list_certificates(CertificateStatuses=["ISSUED"])[
|
||||||
|
"CertificateSummaryList"
|
||||||
|
]
|
||||||
|
certs.shouldnt.contain(google_arn)
|
||||||
|
certs.should.contain(moto_arn)
|
||||||
|
|
||||||
|
certs = client.list_certificates(
|
||||||
CertificateStatuses=["ISSUED", "PENDING_VALIDATION"]
|
CertificateStatuses=["ISSUED", "PENDING_VALIDATION"]
|
||||||
)
|
)["CertificateSummaryList"]
|
||||||
len(resp["CertificateSummaryList"]).should.equal(2)
|
certs.should.contain(google_arn)
|
||||||
arns = {cert["CertificateArn"] for cert in resp["CertificateSummaryList"]}
|
certs.should.contain(moto_arn)
|
||||||
arns.should.contain(issued_arn)
|
|
||||||
arns.should.contain(pending_arn)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_acm
|
@mock_acm
|
||||||
@ -690,7 +687,7 @@ def test_elb_acm_in_use_by():
|
|||||||
certificate_arn = acm_request_response["CertificateArn"]
|
certificate_arn = acm_request_response["CertificateArn"]
|
||||||
|
|
||||||
create_load_balancer_request = elb_client.create_load_balancer(
|
create_load_balancer_request = elb_client.create_load_balancer(
|
||||||
LoadBalancerName="test",
|
LoadBalancerName=str(uuid.uuid4()),
|
||||||
Listeners=[
|
Listeners=[
|
||||||
{
|
{
|
||||||
"Protocol": "https",
|
"Protocol": "https",
|
||||||
|
@ -4,6 +4,7 @@ import sure # noqa # pylint: disable=unused-import
|
|||||||
|
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
from moto import mock_amp
|
from moto import mock_amp
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
# See our Development Tips on writing tests for hints on how to write good tests:
|
# See our Development Tips on writing tests for hints on how to write good tests:
|
||||||
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
|
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
|
||||||
@ -40,18 +41,19 @@ def test_describe_workspace():
|
|||||||
|
|
||||||
@mock_amp
|
@mock_amp
|
||||||
def test_list_workspaces():
|
def test_list_workspaces():
|
||||||
|
my_alias = str(uuid4())[0:6]
|
||||||
client = boto3.client("amp", region_name="ap-southeast-1")
|
client = boto3.client("amp", region_name="ap-southeast-1")
|
||||||
client.create_workspace(alias="test")
|
client.create_workspace(alias="test")
|
||||||
client.create_workspace(alias="another")
|
client.create_workspace(alias=my_alias)
|
||||||
client.create_workspace()
|
|
||||||
|
|
||||||
resp = client.list_workspaces()
|
spaces = client.list_workspaces(maxResults=1000)["workspaces"]
|
||||||
resp.should.have.key("workspaces").length_of(3)
|
assert len(spaces) >= 2
|
||||||
resp.shouldnt.have.key("nextToken")
|
[sp.get("alias") for sp in spaces].should.contain("test")
|
||||||
|
[sp.get("alias") for sp in spaces].should.contain(my_alias)
|
||||||
|
|
||||||
resp = client.list_workspaces(alias="another")
|
resp = client.list_workspaces(alias=my_alias)
|
||||||
resp.should.have.key("workspaces").length_of(1)
|
resp.should.have.key("workspaces").length_of(1)
|
||||||
resp["workspaces"][0].should.have.key("alias").equals("another")
|
resp["workspaces"][0].should.have.key("alias").equals(my_alias)
|
||||||
|
|
||||||
|
|
||||||
@mock_amp
|
@mock_amp
|
||||||
@ -70,14 +72,11 @@ def test_list_workspaces__paginated():
|
|||||||
page2.should.have.key("workspaces").length_of(15)
|
page2.should.have.key("workspaces").length_of(15)
|
||||||
page2.should.have.key("nextToken")
|
page2.should.have.key("nextToken")
|
||||||
|
|
||||||
page3 = client.list_workspaces(maxResults=15, nextToken=page2["nextToken"])
|
|
||||||
page3.should.have.key("workspaces").length_of(10)
|
|
||||||
page3.shouldnt.have.key("nextToken")
|
|
||||||
|
|
||||||
# We could request all of them in one go
|
# We could request all of them in one go
|
||||||
full_page = client.list_workspaces(maxResults=150)
|
all_workspaces = client.list_workspaces(maxResults=1000)["workspaces"]
|
||||||
full_page.should.have.key("workspaces").length_of(125)
|
length = len(all_workspaces)
|
||||||
full_page.shouldnt.have.key("nextToken")
|
# We don't know exactly how much workspaces there are, because we are running multiple tests at the same time
|
||||||
|
assert length >= 125
|
||||||
|
|
||||||
|
|
||||||
@mock_amp
|
@mock_amp
|
||||||
|
Loading…
Reference in New Issue
Block a user