Techdebt: Parallellize ACM/AMP tests (#5911)

This commit is contained in:
Bert Blommers 2023-02-08 21:56:51 -01:00 committed by GitHub
parent 06baff01d1
commit f78ced59b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 43 deletions

View File

@ -6,9 +6,9 @@ TEST_NAMES = "*"
ifeq ($(TEST_SERVER_MODE), true)
# exclude test_kinesisvideoarchivedmedia
# 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 := ./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
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

View File

@ -90,40 +90,37 @@ def test_import_bad_certificate():
@mock_acm
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")
issued_arn = _import_cert(client)
pending_arn = client.request_certificate(DomainName="google.com")["CertificateArn"]
resp = client.list_certificates()
len(resp["CertificateSummaryList"]).should.equal(2)
moto_arn = {"CertificateArn": issued_arn, "DomainName": SERVER_COMMON_NAME}
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"])
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"])
len(resp["CertificateSummaryList"]).should.equal(1)
resp["CertificateSummaryList"][0]["CertificateArn"].should.equal(issued_arn)
resp = client.list_certificates(
certs = client.list_certificates(CertificateStatuses=["PENDING_VALIDATION"])[
"CertificateSummaryList"
]
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"]
)
len(resp["CertificateSummaryList"]).should.equal(2)
arns = {cert["CertificateArn"] for cert in resp["CertificateSummaryList"]}
arns.should.contain(issued_arn)
arns.should.contain(pending_arn)
)["CertificateSummaryList"]
certs.should.contain(google_arn)
certs.should.contain(moto_arn)
@mock_acm
@ -690,7 +687,7 @@ def test_elb_acm_in_use_by():
certificate_arn = acm_request_response["CertificateArn"]
create_load_balancer_request = elb_client.create_load_balancer(
LoadBalancerName="test",
LoadBalancerName=str(uuid.uuid4()),
Listeners=[
{
"Protocol": "https",

View File

@ -4,6 +4,7 @@ import sure # noqa # pylint: disable=unused-import
from botocore.exceptions import ClientError
from moto import mock_amp
from uuid import uuid4
# 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
@ -40,18 +41,19 @@ def test_describe_workspace():
@mock_amp
def test_list_workspaces():
my_alias = str(uuid4())[0:6]
client = boto3.client("amp", region_name="ap-southeast-1")
client.create_workspace(alias="test")
client.create_workspace(alias="another")
client.create_workspace()
client.create_workspace(alias=my_alias)
resp = client.list_workspaces()
resp.should.have.key("workspaces").length_of(3)
resp.shouldnt.have.key("nextToken")
spaces = client.list_workspaces(maxResults=1000)["workspaces"]
assert len(spaces) >= 2
[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["workspaces"][0].should.have.key("alias").equals("another")
resp["workspaces"][0].should.have.key("alias").equals(my_alias)
@mock_amp
@ -70,14 +72,11 @@ def test_list_workspaces__paginated():
page2.should.have.key("workspaces").length_of(15)
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
full_page = client.list_workspaces(maxResults=150)
full_page.should.have.key("workspaces").length_of(125)
full_page.shouldnt.have.key("nextToken")
all_workspaces = client.list_workspaces(maxResults=1000)["workspaces"]
length = len(all_workspaces)
# 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