From 83d76676f2d34c3cd091143ec0f4c5ebc8d9f510 Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Tue, 7 Feb 2023 09:34:02 -0600 Subject: [PATCH 1/5] Update Kinesis Mock to 0.3.5 See https://github.com/etspaceman/kinesis-mock/releases/tag/0.3.5 In particular, fixes a couple of fields in response types so that they are nullable, rather than empty lists (or 0'd integers). --- localstack/services/kinesis/packages.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/localstack/services/kinesis/packages.py b/localstack/services/kinesis/packages.py index 07320dff39dfd..b3e3528b05e3e 100644 --- a/localstack/services/kinesis/packages.py +++ b/localstack/services/kinesis/packages.py @@ -6,7 +6,7 @@ from localstack.packages import GitHubReleaseInstaller, Package, PackageInstaller from localstack.utils.platform import get_arch, get_os -_KINESIS_MOCK_VERSION = os.environ.get("KINESIS_MOCK_VERSION") or "0.3.4" +_KINESIS_MOCK_VERSION = os.environ.get("KINESIS_MOCK_VERSION") or "0.3.5" class KinesisMockPackage(Package): From 5d429d09d0b9e00281b474d7af06c13e391e6924 Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Tue, 7 Feb 2023 10:23:50 -0600 Subject: [PATCH 2/5] Remove assertion for FailedRecordCount FailedRecordCount is now null, not 0, for these types of responses --- tests/integration/test_apigateway.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/test_apigateway.py b/tests/integration/test_apigateway.py index 08786bb2a55c8..f4b8dbd953ea5 100644 --- a/tests/integration/test_apigateway.py +++ b/tests/integration/test_apigateway.py @@ -275,7 +275,6 @@ def test_api_gateway_kinesis_integration(self): # post test data to Kinesis via API Gateway result = requests.post(url, data=json.dumps(test_data)) result = json.loads(to_str(result.content)) - assert 0 == result["FailedRecordCount"] assert len(test_data["records"]) == len(result["Records"]) # clean up From 22f2eedf5a4c2789faebd223c586de5f23f69364 Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Tue, 7 Feb 2023 10:36:49 -0600 Subject: [PATCH 3/5] More test fixes --- .../cloudformation/resources/test_kinesis.snapshot.json | 7 +------ .../cloudformation/resources/test_lambda.snapshot.json | 5 ----- tests/integration/test_apigateway.py | 1 + tests/integration/test_error_injection.py | 2 +- 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/tests/integration/cloudformation/resources/test_kinesis.snapshot.json b/tests/integration/cloudformation/resources/test_kinesis.snapshot.json index 25aab03f987b3..eee6e67dc661f 100644 --- a/tests/integration/cloudformation/resources/test_kinesis.snapshot.json +++ b/tests/integration/cloudformation/resources/test_kinesis.snapshot.json @@ -29,11 +29,6 @@ "stream_description": { "StreamDescription": { "EncryptionType": "NONE", - "EnhancedMonitoring": [ - { - "ShardLevelMetrics": [] - } - ], "HasMoreShards": false, "RetentionPeriodHours": 24, "Shards": [ @@ -63,4 +58,4 @@ } } } -} \ No newline at end of file +} diff --git a/tests/integration/cloudformation/resources/test_lambda.snapshot.json b/tests/integration/cloudformation/resources/test_lambda.snapshot.json index 11299cb9db39d..d306b3c8aef11 100644 --- a/tests/integration/cloudformation/resources/test_lambda.snapshot.json +++ b/tests/integration/cloudformation/resources/test_lambda.snapshot.json @@ -1228,11 +1228,6 @@ "describe_stream_result": { "StreamDescription": { "EncryptionType": "NONE", - "EnhancedMonitoring": [ - { - "ShardLevelMetrics": [] - } - ], "HasMoreShards": false, "RetentionPeriodHours": 24, "Shards": [ diff --git a/tests/integration/test_apigateway.py b/tests/integration/test_apigateway.py index f4b8dbd953ea5..8616eed2e230d 100644 --- a/tests/integration/test_apigateway.py +++ b/tests/integration/test_apigateway.py @@ -275,6 +275,7 @@ def test_api_gateway_kinesis_integration(self): # post test data to Kinesis via API Gateway result = requests.post(url, data=json.dumps(test_data)) result = json.loads(to_str(result.content)) + assert None == result.get["FailedRecordCount"] assert len(test_data["records"]) == len(result["Records"]) # clean up diff --git a/tests/integration/test_error_injection.py b/tests/integration/test_error_injection.py index 6ef0de9a007a0..888e4309de774 100644 --- a/tests/integration/test_error_injection.py +++ b/tests/integration/test_error_injection.py @@ -22,7 +22,7 @@ def test_kinesis_error_injection(self, monkeypatch, kinesis_client, wait_for_str # by default, no errors test_no_errors = kinesis.put_records(StreamName=stream_name, Records=records) - assert test_no_errors["FailedRecordCount"] == 0 + assert test_no_errors.get["FailedRecordCount"] == None # with a probability of 1, always throw errors monkeypatch.setattr(config, "KINESIS_ERROR_PROBABILITY", 1.0) From abbeb892af3a1b9d5bfd74a65284a0ea60670a29 Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Tue, 7 Feb 2023 10:44:40 -0600 Subject: [PATCH 4/5] Linting --- tests/integration/test_apigateway.py | 2 +- tests/integration/test_error_injection.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_apigateway.py b/tests/integration/test_apigateway.py index 8616eed2e230d..7f8a997aaa669 100644 --- a/tests/integration/test_apigateway.py +++ b/tests/integration/test_apigateway.py @@ -275,7 +275,7 @@ def test_api_gateway_kinesis_integration(self): # post test data to Kinesis via API Gateway result = requests.post(url, data=json.dumps(test_data)) result = json.loads(to_str(result.content)) - assert None == result.get["FailedRecordCount"] + assert result.get["FailedRecordCount"] is None assert len(test_data["records"]) == len(result["Records"]) # clean up diff --git a/tests/integration/test_error_injection.py b/tests/integration/test_error_injection.py index 888e4309de774..3a6143f8a8864 100644 --- a/tests/integration/test_error_injection.py +++ b/tests/integration/test_error_injection.py @@ -22,7 +22,7 @@ def test_kinesis_error_injection(self, monkeypatch, kinesis_client, wait_for_str # by default, no errors test_no_errors = kinesis.put_records(StreamName=stream_name, Records=records) - assert test_no_errors.get["FailedRecordCount"] == None + assert test_no_errors.get["FailedRecordCount"] is None # with a probability of 1, always throw errors monkeypatch.setattr(config, "KINESIS_ERROR_PROBABILITY", 1.0) From 22b089d2361b8a5b1791144303f42b59d80b80ea Mon Sep 17 00:00:00 2001 From: Eric Meisel Date: Tue, 7 Feb 2023 11:36:48 -0600 Subject: [PATCH 5/5] Fix --- tests/integration/test_apigateway.py | 2 +- tests/integration/test_error_injection.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/test_apigateway.py b/tests/integration/test_apigateway.py index 7f8a997aaa669..7703779d81682 100644 --- a/tests/integration/test_apigateway.py +++ b/tests/integration/test_apigateway.py @@ -275,7 +275,7 @@ def test_api_gateway_kinesis_integration(self): # post test data to Kinesis via API Gateway result = requests.post(url, data=json.dumps(test_data)) result = json.loads(to_str(result.content)) - assert result.get["FailedRecordCount"] is None + assert result.get("FailedRecordCount") is None assert len(test_data["records"]) == len(result["Records"]) # clean up diff --git a/tests/integration/test_error_injection.py b/tests/integration/test_error_injection.py index 3a6143f8a8864..a5902cb3677eb 100644 --- a/tests/integration/test_error_injection.py +++ b/tests/integration/test_error_injection.py @@ -22,7 +22,7 @@ def test_kinesis_error_injection(self, monkeypatch, kinesis_client, wait_for_str # by default, no errors test_no_errors = kinesis.put_records(StreamName=stream_name, Records=records) - assert test_no_errors.get["FailedRecordCount"] is None + assert test_no_errors.get("FailedRecordCount") is None # with a probability of 1, always throw errors monkeypatch.setattr(config, "KINESIS_ERROR_PROBABILITY", 1.0)