Skip to content

Commit 6e3a156

Browse files
authored
Fix approval tests and linter (#895)
* Fix approval tests * black * black?
1 parent 1f00133 commit 6e3a156

18 files changed

+185
-107
lines changed

aws/logs_monitoring/lambda_function.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
DD_RETRY_KEYWORD,
2828
)
2929

30-
3130
logger = logging.getLogger()
3231
logger.setLevel(logging.getLevelName(os.environ.get("DD_LOG_LEVEL", "INFO").upper()))
3332

aws/logs_monitoring/tests/approved_files/TestAWSLogsHandler.test_awslogs_handler_lambda_log.approved.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"ddsource": "lambda",
1313
"ddsourcecategory": "aws",
14-
"ddtags": "forwardername:function_name,forwarder_memorysize:10,forwarder_version:4.0.1,env:none",
14+
"ddtags": "forwardername:function_name,forwarder_memorysize:10,forwarder_version:4.0.2,env:none",
1515
"host": "/aws/lambda/test-lambda-default-log-group",
1616
"id": "37199773595581154154810589279545129148442535997644275712",
1717
"lambda": {

aws/logs_monitoring/tests/approved_files/TestAWSLogsHandler.test_awslogs_handler_rds_postgresql.approved.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"ddsource": "cloudwatch",
1313
"ddsourcecategory": "aws",
14-
"ddtags": "forwardername:function_name,forwarder_memorysize:10,forwarder_version:4.0.1,test_tag_key:test_tag_value",
14+
"ddtags": "forwardername:function_name,forwarder_memorysize:10,forwarder_version:4.0.2,test_tag_key:test_tag_value",
1515
"host": "/aws/rds/instance/datadog/postgresql",
1616
"id": "31953106606966983378809025079804211143289615424298221568",
1717
"message": "2021-01-02 03:04:05 UTC::@:[5306]:LOG: database system is ready to accept connections",

aws/logs_monitoring/tests/approved_files/TestAWSLogsHandler.test_awslogs_handler_step_functions_customized_log_group.approved.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"ddsource": "stepfunction",
1313
"ddsourcecategory": "aws",
14-
"ddtags": "forwardername:function_name,forwarder_memorysize:10,forwarder_version:4.0.1,test_tag_key:test_tag_value,dd_step_functions_trace_enabled:true",
14+
"ddtags": "forwardername:function_name,forwarder_memorysize:10,forwarder_version:4.0.2,test_tag_key:test_tag_value,dd_step_functions_trace_enabled:true",
1515
"host": "arn:aws:states:us-east-1:12345678910:stateMachine:StepFunction2",
1616
"id": "37199773595581154154810589279545129148442535997644275712",
1717
"message": "{\"id\": \"1\",\"type\": \"ExecutionStarted\",\"details\": {\"input\": \"{}\",\"inputDetails\": {\"truncated\": \"false\"},\"roleArn\": \"arn:aws:iam::12345678910:role/service-role/StepFunctions-test-role-a0iurr4pt\"},\"previous_event_id\": \"0\",\"event_timestamp\": \"1716992192441\",\"execution_arn\": \"arn:aws:states:us-east-1:12345678910:execution:StepFunction2:ccccccc-d1da-4c38-b32c-2b6b07d713fa\",\"redrive_count\": \"0\"}",

aws/logs_monitoring/tests/approved_files/TestAWSLogsHandler.test_awslogs_handler_step_functions_tags_added_properly.approved.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"ddsource": "stepfunction",
1313
"ddsourcecategory": "aws",
14-
"ddtags": "forwardername:function_name,forwarder_memorysize:10,forwarder_version:4.0.1,test_tag_key:test_tag_value,dd_step_functions_trace_enabled:true",
14+
"ddtags": "forwardername:function_name,forwarder_memorysize:10,forwarder_version:4.0.2,test_tag_key:test_tag_value,dd_step_functions_trace_enabled:true",
1515
"host": "arn:aws:states:us-east-1:12345678910:stateMachine:StepFunction1",
1616
"id": "37199773595581154154810589279545129148442535997644275712",
1717
"message": "{\"id\": \"1\",\"type\": \"ExecutionStarted\",\"details\": {\"input\": \"{}\",\"inputDetails\": {\"truncated\": \"false\"},\"roleArn\": \"arn:aws:iam::12345678910:role/service-role/StepFunctions-test-role-a0iurr4pt\"},\"previous_event_id\": \"0\",\"event_timestamp\": \"1716992192441\",\"execution_arn\": \"arn:aws:states:us-east-1:12345678910:execution:StepFunction1:ccccccc-d1da-4c38-b32c-2b6b07d713fa\",\"redrive_count\": \"0\"}",

aws/logs_monitoring/tests/approved_files/TestLambdaFunctionEndToEnd.test_kinesis_awslogs_handler.received.json

Lines changed: 0 additions & 43 deletions
This file was deleted.

aws/logs_monitoring/tests/test_awslogs_handler.py

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,13 @@ def test_awslogs_handler_rds_postgresql(self, mock_cache_init):
5050
"logStream": "datadog.0",
5151
"logEvents": [
5252
{
53-
"id": "31953106606966983378809025079804211143289615424298221568",
53+
"id": (
54+
"31953106606966983378809025079804211143289615424298221568"
55+
),
5456
"timestamp": 1609556645000,
55-
"message": "2021-01-02 03:04:05 UTC::@:[5306]:LOG: database system is ready to accept connections",
57+
"message": (
58+
"2021-01-02 03:04:05 UTC::@:[5306]:LOG: database system is ready to accept connections"
59+
),
5660
}
5761
],
5862
}
@@ -90,14 +94,22 @@ def test_awslogs_handler_step_functions_tags_added_properly(
9094
{
9195
"messageType": "DATA_MESSAGE",
9296
"owner": "425362996713",
93-
"logGroup": "/aws/vendedlogs/states/logs-to-traces-sequential-Logs",
94-
"logStream": "states/logs-to-traces-sequential/2022-11-10-15-50/7851b2d9",
97+
"logGroup": (
98+
"/aws/vendedlogs/states/logs-to-traces-sequential-Logs"
99+
),
100+
"logStream": (
101+
"states/logs-to-traces-sequential/2022-11-10-15-50/7851b2d9"
102+
),
95103
"subscriptionFilters": ["testFilter"],
96104
"logEvents": [
97105
{
98-
"id": "37199773595581154154810589279545129148442535997644275712",
106+
"id": (
107+
"37199773595581154154810589279545129148442535997644275712"
108+
),
99109
"timestamp": 1668095539607,
100-
"message": '{"id": "1","type": "ExecutionStarted","details": {"input": "{}","inputDetails": {"truncated": "false"},"roleArn": "arn:aws:iam::12345678910:role/service-role/StepFunctions-test-role-a0iurr4pt"},"previous_event_id": "0","event_timestamp": "1716992192441","execution_arn": "arn:aws:states:us-east-1:12345678910:execution:StepFunction1:ccccccc-d1da-4c38-b32c-2b6b07d713fa","redrive_count": "0"}',
110+
"message": (
111+
'{"id": "1","type": "ExecutionStarted","details": {"input": "{}","inputDetails": {"truncated": "false"},"roleArn": "arn:aws:iam::12345678910:role/service-role/StepFunctions-test-role-a0iurr4pt"},"previous_event_id": "0","event_timestamp": "1716992192441","execution_arn": "arn:aws:states:us-east-1:12345678910:execution:StepFunction1:ccccccc-d1da-4c38-b32c-2b6b07d713fa","redrive_count": "0"}'
112+
),
101113
}
102114
],
103115
}
@@ -139,13 +151,19 @@ def test_awslogs_handler_step_functions_customized_log_group(
139151
"messageType": "DATA_MESSAGE",
140152
"owner": "425362996713",
141153
"logGroup": "test/logs",
142-
"logStream": "states/logs-to-traces-sequential/2022-11-10-15-50/7851b2d9",
154+
"logStream": (
155+
"states/logs-to-traces-sequential/2022-11-10-15-50/7851b2d9"
156+
),
143157
"subscriptionFilters": ["testFilter"],
144158
"logEvents": [
145159
{
146-
"id": "37199773595581154154810589279545129148442535997644275712",
160+
"id": (
161+
"37199773595581154154810589279545129148442535997644275712"
162+
),
147163
"timestamp": 1668095539607,
148-
"message": '{"id": "1","type": "ExecutionStarted","details": {"input": "{}","inputDetails": {"truncated": "false"},"roleArn": "arn:aws:iam::12345678910:role/service-role/StepFunctions-test-role-a0iurr4pt"},"previous_event_id": "0","event_timestamp": "1716992192441","execution_arn": "arn:aws:states:us-east-1:12345678910:execution:StepFunction2:ccccccc-d1da-4c38-b32c-2b6b07d713fa","redrive_count": "0"}',
164+
"message": (
165+
'{"id": "1","type": "ExecutionStarted","details": {"input": "{}","inputDetails": {"truncated": "false"},"roleArn": "arn:aws:iam::12345678910:role/service-role/StepFunctions-test-role-a0iurr4pt"},"previous_event_id": "0","event_timestamp": "1716992192441","execution_arn": "arn:aws:states:us-east-1:12345678910:execution:StepFunction2:ccccccc-d1da-4c38-b32c-2b6b07d713fa","redrive_count": "0"}'
166+
),
149167
}
150168
],
151169
}
@@ -179,14 +197,22 @@ def test_awslogs_handler_lambda_log(self):
179197
{
180198
"messageType": "DATA_MESSAGE",
181199
"owner": "123456789012",
182-
"logGroup": "/aws/lambda/test-lambda-default-log-group",
183-
"logStream": "2023/11/06/[$LATEST]b25b1f977b3e416faa45a00f427e7acb",
200+
"logGroup": (
201+
"/aws/lambda/test-lambda-default-log-group"
202+
),
203+
"logStream": (
204+
"2023/11/06/[$LATEST]b25b1f977b3e416faa45a00f427e7acb"
205+
),
184206
"subscriptionFilters": ["testFilter"],
185207
"logEvents": [
186208
{
187-
"id": "37199773595581154154810589279545129148442535997644275712",
209+
"id": (
210+
"37199773595581154154810589279545129148442535997644275712"
211+
),
188212
"timestamp": 1668095539607,
189-
"message": "2021-01-02 03:04:05 UTC::@:[5306]:LOG: database system is ready to accept connections",
213+
"message": (
214+
"2021-01-02 03:04:05 UTC::@:[5306]:LOG: database system is ready to accept connections"
215+
),
190216
}
191217
],
192218
}
@@ -326,7 +352,9 @@ def test_get_state_machine_arn(self):
326352
{
327353
"message": json.dumps(
328354
{
329-
"execution_arn": "arn:aws:states:sa-east-1:425362996713:express:my-Various-States:7f653fda-c79a-430b-91e2-3f97eb87cabb:862e5d40-a457-4ca2-a3c1-78485bd94d3f"
355+
"execution_arn": (
356+
"arn:aws:states:sa-east-1:425362996713:express:my-Various-States:7f653fda-c79a-430b-91e2-3f97eb87cabb:862e5d40-a457-4ca2-a3c1-78485bd94d3f"
357+
)
330358
}
331359
),
332360
}
@@ -342,7 +370,9 @@ def test_get_state_machine_arn(self):
342370
{
343371
"message": json.dumps(
344372
{
345-
"execution_arn": "arn:aws:states:sa-east-1:425362996713:express:my-Various-States/7f653fda-c79a-430b-91e2-3f97eb87cabb:862e5d40-a457-4ca2-a3c1-78485bd94d3f"
373+
"execution_arn": (
374+
"arn:aws:states:sa-east-1:425362996713:express:my-Various-States/7f653fda-c79a-430b-91e2-3f97eb87cabb:862e5d40-a457-4ca2-a3c1-78485bd94d3f"
375+
)
346376
}
347377
)
348378
}
@@ -359,7 +389,9 @@ def test_get_state_machine_arn(self):
359389
{
360390
"message": json.dumps(
361391
{
362-
"execution_arn": "arn:aws:states:sa-east-1:425362996713:express:my-Various-States\\7f653fda-c79a-430b-91e2-3f97eb87cabb:862e5d40-a457-4ca2-a3c1-78485bd94d3f"
392+
"execution_arn": (
393+
"arn:aws:states:sa-east-1:425362996713:express:my-Various-States\\7f653fda-c79a-430b-91e2-3f97eb87cabb:862e5d40-a457-4ca2-a3c1-78485bd94d3f"
394+
)
363395
}
364396
)
365397
}

aws/logs_monitoring/tests/test_caching.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,19 @@ def test_generate_custom_tags_cache(self):
5656
{
5757
"ResourceTagMappingList": [
5858
{
59-
"ResourceARN": "arn:aws:lambda:us-east-1:123497598159:function:my-test-lambda-dev",
59+
"ResourceARN": (
60+
"arn:aws:lambda:us-east-1:123497598159:function:my-test-lambda-dev"
61+
),
6062
"Tags": [
6163
{"Key": "stage", "Value": "dev"},
6264
{"Key": "team", "Value": "serverless"},
6365
{"Key": "empty", "Value": ""},
6466
],
6567
},
6668
{
67-
"ResourceARN": "arn:aws:lambda:us-east-1:123497598159:function:my-test-lambda-prod",
69+
"ResourceARN": (
70+
"arn:aws:lambda:us-east-1:123497598159:function:my-test-lambda-prod"
71+
),
6872
"Tags": [
6973
{"Key": "stage", "Value": "prod"},
7074
{"Key": "team", "Value": "serverless"},

aws/logs_monitoring/tests/test_cloudtrail_s3.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,18 @@ class Context:
4343
"userIdentity": {
4444
"type": "AssumedRole",
4545
"principalId": "AROAYYB64AB3HGPQO2EPR:DatadogAWSIntegration",
46-
"arn": "arn:aws:sts::601427279990:assumed-role/Siti_DatadogAWSIntegrationRole/i-08014e4f62ccf762d",
46+
"arn": (
47+
"arn:aws:sts::601427279990:assumed-role/Siti_DatadogAWSIntegrationRole/i-08014e4f62ccf762d"
48+
),
4749
"accountId": "601427279990",
4850
"accessKeyId": "ASIAYYB64AB3DWOY7JNT",
4951
"sessionContext": {
5052
"sessionIssuer": {
5153
"type": "Role",
5254
"principalId": "AROAYYB64AB3HGPQO2EPR",
53-
"arn": "arn:aws:iam::601427279990:role/Siti_DatadogAWSIntegrationRole",
55+
"arn": (
56+
"arn:aws:iam::601427279990:role/Siti_DatadogAWSIntegrationRole"
57+
),
5458
"accountId": "601427279990",
5559
"userName": "Siti_DatadogAWSIntegrationRole",
5660
},
@@ -75,7 +79,9 @@ class Context:
7579
{
7680
"accountId": "601427279990",
7781
"type": "AWS::DynamoDB::Table",
78-
"ARN": "arn:aws:dynamodb:us-east-1:601427279990:table/KinesisClientLibraryLocal",
82+
"ARN": (
83+
"arn:aws:dynamodb:us-east-1:601427279990:table/KinesisClientLibraryLocal"
84+
),
7985
}
8086
],
8187
"eventType": "AwsApiCall",
@@ -114,7 +120,9 @@ def test_s3_cloudtrail_pasing_and_enrichment(
114120
"name": "test-bucket",
115121
},
116122
"object": {
117-
"key": "601427279990_CloudTrail_us-east-1_20210503T0000Z_QrttGEk4ZcBTLwj5.json.gz"
123+
"key": (
124+
"601427279990_CloudTrail_us-east-1_20210503T0000Z_QrttGEk4ZcBTLwj5.json.gz"
125+
)
118126
},
119127
}
120128
}

0 commit comments

Comments
 (0)