Skip to content

Commit 9af2464

Browse files
authored
SNS: Fix multi-region test (#13240)
1 parent 495604d commit 9af2464

File tree

3 files changed

+34
-26
lines changed

3 files changed

+34
-26
lines changed

tests/aws/services/sns/test_sns.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from cryptography import x509
1818
from cryptography.hazmat.primitives import hashes
1919
from cryptography.hazmat.primitives.asymmetric import padding
20+
from localstack_snapshot.snapshots.transformer import RegexTransformer
2021
from pytest_httpserver import HTTPServer
2122
from werkzeug import Response
2223

@@ -398,24 +399,31 @@ def test_create_topic_name_constraints(self, snapshot, sns_create_topic):
398399
"$..Attributes.DeliveryPolicy",
399400
],
400401
)
401-
def test_create_topic_in_multiple_regions(self, aws_client, aws_client_factory, snapshot):
402+
def test_create_topic_in_multiple_regions(
403+
self, aws_client, aws_client_factory, snapshot, region_name, secondary_region_name
404+
):
402405
topic_name = f"multiregion-{short_uid()}"
406+
snapshot.add_transformer(RegexTransformer(region_name, "<region-primary>"))
407+
snapshot.add_transformer(RegexTransformer(secondary_region_name, "<region-secondary>"))
403408

404-
# us-east-1
405-
sns_east = aws_client_factory(region_name="us-east-1").sns
406-
arn_east = sns_east.create_topic(Name=topic_name)["TopicArn"]
409+
sns_primary_region = aws_client_factory(region_name=region_name).sns
410+
topic_arn_primary_region = sns_primary_region.create_topic(Name=topic_name)["TopicArn"]
407411

408-
# us-west-2
409-
sns_west = aws_client_factory(region_name="us-west-1").sns
410-
arn_west = sns_west.create_topic(Name=topic_name)["TopicArn"]
412+
sns_secondary_region = aws_client_factory(region_name=secondary_region_name).sns
413+
topic_arn_secondary_region = sns_secondary_region.create_topic(Name=topic_name)["TopicArn"]
411414

412-
list_east_response = sns_east.list_topics()
413-
snapshot.match("list-east", list_east_response)
414-
list_west_response = sns_west.list_topics()
415-
snapshot.match("list-west", list_west_response)
415+
list_topics_primary = sns_primary_region.list_topics()
416+
snapshot.match("list-primary", list_topics_primary)
417+
list_topics_secondary = sns_secondary_region.list_topics()
418+
snapshot.match("list-secondary", list_topics_secondary)
416419

417-
snapshot.match("topic-east", sns_east.get_topic_attributes(TopicArn=arn_east))
418-
snapshot.match("topic-west", sns_west.get_topic_attributes(TopicArn=arn_west))
420+
snapshot.match(
421+
"topic-east", sns_primary_region.get_topic_attributes(TopicArn=topic_arn_primary_region)
422+
)
423+
snapshot.match(
424+
"topic-west",
425+
sns_secondary_region.get_topic_attributes(TopicArn=topic_arn_secondary_region),
426+
)
419427

420428
@markers.aws.validated
421429
def test_list_topic_paging(self, aws_client, sns_create_topic):

tests/aws/services/sns/test_sns.snapshot.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5601,23 +5601,23 @@
56015601
}
56025602
},
56035603
"tests/aws/services/sns/test_sns.py::TestSNSTopicCrudV2::test_create_topic_in_multiple_regions": {
5604-
"recorded-date": "29-09-2025, 11:34:38",
5604+
"recorded-date": "08-10-2025, 08:54:10",
56055605
"recorded-content": {
5606-
"list-east": {
5606+
"list-primary": {
56075607
"Topics": [
56085608
{
5609-
"TopicArn": "arn:<partition>:sns:<region>:111111111111:<resource:1>"
5609+
"TopicArn": "arn:<partition>:sns:<region-primary>:111111111111:<resource:1>"
56105610
}
56115611
],
56125612
"ResponseMetadata": {
56135613
"HTTPHeaders": {},
56145614
"HTTPStatusCode": 200
56155615
}
56165616
},
5617-
"list-west": {
5617+
"list-secondary": {
56185618
"Topics": [
56195619
{
5620-
"TopicArn": "arn:<partition>:sns:us-west-1:111111111111:<resource:1>"
5620+
"TopicArn": "arn:<partition>:sns:<region-secondary>:111111111111:<resource:1>"
56215621
}
56225622
],
56235623
"ResponseMetadata": {
@@ -5666,7 +5666,7 @@
56665666
"SNS:ListSubscriptionsByTopic",
56675667
"SNS:Publish"
56685668
],
5669-
"Resource": "arn:<partition>:sns:<region>:111111111111:<resource:1>",
5669+
"Resource": "arn:<partition>:sns:<region-primary>:111111111111:<resource:1>",
56705670
"Condition": {
56715671
"StringEquals": {
56725672
"AWS:SourceOwner": "111111111111"
@@ -5678,7 +5678,7 @@
56785678
"SubscriptionsConfirmed": "0",
56795679
"SubscriptionsDeleted": "0",
56805680
"SubscriptionsPending": "0",
5681-
"TopicArn": "arn:<partition>:sns:<region>:111111111111:<resource:1>"
5681+
"TopicArn": "arn:<partition>:sns:<region-primary>:111111111111:<resource:1>"
56825682
},
56835683
"ResponseMetadata": {
56845684
"HTTPHeaders": {},
@@ -5726,7 +5726,7 @@
57265726
"SNS:ListSubscriptionsByTopic",
57275727
"SNS:Publish"
57285728
],
5729-
"Resource": "arn:<partition>:sns:us-west-1:111111111111:<resource:1>",
5729+
"Resource": "arn:<partition>:sns:<region-secondary>:111111111111:<resource:1>",
57305730
"Condition": {
57315731
"StringEquals": {
57325732
"AWS:SourceOwner": "111111111111"
@@ -5738,7 +5738,7 @@
57385738
"SubscriptionsConfirmed": "0",
57395739
"SubscriptionsDeleted": "0",
57405740
"SubscriptionsPending": "0",
5741-
"TopicArn": "arn:<partition>:sns:us-west-1:111111111111:<resource:1>"
5741+
"TopicArn": "arn:<partition>:sns:<region-secondary>:111111111111:<resource:1>"
57425742
},
57435743
"ResponseMetadata": {
57445744
"HTTPHeaders": {},

tests/aws/services/sns/test_sns.validation.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,12 @@
306306
"last_validated_date": "2024-10-03T21:46:17+00:00"
307307
},
308308
"tests/aws/services/sns/test_sns.py::TestSNSTopicCrudV2::test_create_topic_in_multiple_regions": {
309-
"last_validated_date": "2025-09-29T11:34:38+00:00",
309+
"last_validated_date": "2025-10-08T08:54:10+00:00",
310310
"durations_in_seconds": {
311-
"setup": 1.06,
312-
"call": 3.66,
311+
"setup": 1.29,
312+
"call": 5.7,
313313
"teardown": 0.01,
314-
"total": 4.73
314+
"total": 7.0
315315
}
316316
},
317317
"tests/aws/services/sns/test_sns.py::TestSNSTopicCrudV2::test_create_topic_name_constraints": {

0 commit comments

Comments
 (0)