File tree Expand file tree Collapse file tree 7 files changed +458
-131
lines changed
instrumentation/opentelemetry-instrumentation-aws-lambda/tests Expand file tree Collapse file tree 7 files changed +458
-131
lines changed Original file line number Diff line number Diff line change 1+ MOCK_LAMBDA_ALB_EVENT = {
2+ "requestContext" : {
3+ "elb" : {
4+ "targetGroupArn" : "arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-target-group/6d0ecf831eec9f09"
5+ }
6+ },
7+ "httpMethod" : "GET" ,
8+ "path" : "/" ,
9+ "queryStringParameters" : {"foo" : "bar" },
10+ "headers" : {
11+ "accept" : "text/html,application/xhtml+xml" ,
12+ "accept-language" : "en-US,en;q=0.8" ,
13+ "content-type" : "text/plain" ,
14+ "cookie" : "cookies" ,
15+ "host" : "lambda-846800462-us-east-2.elb.amazonaws.com" ,
16+ "user-agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)" ,
17+ "x-amzn-trace-id" : "Root=1-5bdb40ca-556d8b0c50dc66f0511bf520" ,
18+ "x-forwarded-for" : "72.21.198.66" ,
19+ "x-forwarded-port" : "443" ,
20+ "x-forwarded-proto" : "https" ,
21+ },
22+ "isBase64Encoded" : False ,
23+ "body" : "request_body" ,
24+ }
Original file line number Diff line number Diff line change 1+ """
2+ https://docs.aws.amazon.com/elasticloadbalancing/latest/application/lambda-functions.html#multi-value-headers
3+
4+ When an ALB is configured to send multi-value headers, the headers are sent as a list of values under the key in the multiValueHeaders object.
5+ """
6+
7+ MOCK_LAMBDA_ALB_MULTI_VALUE_HEADER_EVENT = {
8+ "requestContext" : {
9+ "elb" : {
10+ "targetGroupArn" : "arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-target-group/6d0ecf831eec9f09"
11+ }
12+ },
13+ "httpMethod" : "GET" ,
14+ "path" : "/" ,
15+ "queryStringParameters" : {"foo" : "bar" },
16+ "multiValueHeaders" : {
17+ "accept" : ["text/html,application/xhtml+xml" ],
18+ "accept-language" : ["en-US,en;q=0.8" ],
19+ "content-type" : ["text/plain" ],
20+ "cookie" : ["cookies" ],
21+ "host" : ["lambda-846800462-us-east-2.elb.amazonaws.com" ],
22+ "user-agent" : ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6)" ],
23+ "x-amzn-trace-id" : ["Root=1-5bdb40ca-556d8b0c50dc66f0511bf520" ],
24+ "x-forwarded-for" : ["72.21.198.66" ],
25+ "x-forwarded-port" : ["443" ],
26+ "x-forwarded-proto" : ["https" ],
27+ },
28+ "isBase64Encoded" : False ,
29+ "body" : "request_body" ,
30+ }
Original file line number Diff line number Diff line change 1+ """
2+ https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html
3+ """
4+
5+ MOCK_LAMBDA_DYNAMO_DB_EVENT = {
6+ "Records" : [
7+ {
8+ "eventID" : "1" ,
9+ "eventVersion" : "1.0" ,
10+ "dynamodb" : {
11+ "Keys" : {"Id" : {"N" : "101" }},
12+ "NewImage" : {
13+ "Message" : {"S" : "New item!" },
14+ "Id" : {"N" : "101" },
15+ },
16+ "StreamViewType" : "NEW_AND_OLD_IMAGES" ,
17+ "SequenceNumber" : "111" ,
18+ "SizeBytes" : 26 ,
19+ },
20+ "awsRegion" : "us-west-2" ,
21+ "eventName" : "INSERT" ,
22+ "eventSourceARN" : "arn:aws:dynamodb:us-east-2:123456789012:table/my-table/stream/2023-06-10T19:26:16.525" ,
23+ "eventSource" : "aws:dynamodb" ,
24+ },
25+ {
26+ "eventID" : "2" ,
27+ "eventVersion" : "1.0" ,
28+ "dynamodb" : {
29+ "OldImage" : {
30+ "Message" : {"S" : "New item!" },
31+ "Id" : {"N" : "101" },
32+ },
33+ "SequenceNumber" : "222" ,
34+ "Keys" : {"Id" : {"N" : "101" }},
35+ "SizeBytes" : 59 ,
36+ "NewImage" : {
37+ "Message" : {"S" : "This item has changed" },
38+ "Id" : {"N" : "101" },
39+ },
40+ "StreamViewType" : "NEW_AND_OLD_IMAGES" ,
41+ },
42+ "awsRegion" : "us-west-2" ,
43+ "eventName" : "MODIFY" ,
44+ "eventSourceARN" : "arn:aws:dynamodb:us-east-2:123456789012:table/my-table/stream/2023-06-10T19:26:16.525" ,
45+ "eventSource" : "aws:dynamodb" ,
46+ },
47+ ]
48+ }
Original file line number Diff line number Diff line change 1+ """
2+ https://docs.aws.amazon.com/lambda/latest/dg/with-s3.html
3+ """
4+
5+ MOCK_LAMBDA_S3_EVENT = {
6+ "Records" : [
7+ {
8+ "eventVersion" : "2.1" ,
9+ "eventSource" : "aws:s3" ,
10+ "awsRegion" : "us-east-2" ,
11+ "eventTime" : "2019-09-03T19:37:27.192Z" ,
12+ "eventName" : "ObjectCreated:Put" ,
13+ "userIdentity" : {"principalId" : "AWS:AIDAINPONIXQXHT3IKHL2" },
14+ "requestParameters" : {"sourceIPAddress" : "205.255.255.255" },
15+ "responseElements" : {
16+ "x-amz-request-id" : "D82B88E5F771F645" ,
17+ "x-amz-id-2" : "vlR7PnpV2Ce81l0PRw6jlUpck7Jo5ZsQjryTjKlc5aLWGVHPZLj5NeC6qMa0emYBDXOo6QBU0Wo=" ,
18+ },
19+ "s3" : {
20+ "s3SchemaVersion" : "1.0" ,
21+ "configurationId" : "828aa6fc-f7b5-4305-8584-487c791949c1" ,
22+ "bucket" : {
23+ "name" : "DOC-EXAMPLE-BUCKET" ,
24+ "ownerIdentity" : {"principalId" : "A3I5XTEXAMAI3E" },
25+ "arn" : "arn:aws:s3:::lambda-artifacts-deafc19498e3f2df" ,
26+ },
27+ "object" : {
28+ "key" : "b21b84d653bb07b05b1e6b33684dc11b" ,
29+ "size" : 1305107 ,
30+ "eTag" : "b21b84d653bb07b05b1e6b33684dc11b" ,
31+ "sequencer" : "0C0F6F405D6ED209E1" ,
32+ },
33+ },
34+ }
35+ ]
36+ }
Original file line number Diff line number Diff line change 1+ """
2+ https://docs.aws.amazon.com/lambda/latest/dg/with-sns.html
3+ """
4+
5+ MOCK_LAMBDA_SNS_EVENT = {
6+ "Records" : [
7+ {
8+ "EventVersion" : "1.0" ,
9+ "EventSubscriptionArn" : "arn:aws:sns:us-east-1:123456789012:sns-lambda:21be56ed-a058-49f5-8c98-aedd2564c486" ,
10+ "EventSource" : "aws:sns" ,
11+ "Sns" : {
12+ "SignatureVersion" : "1" ,
13+ "Timestamp" : "2019-01-02T12:45:07.000Z" ,
14+ "Signature" : "mock-signature" ,
15+ "SigningCertURL" : "https://sns.us-east-1.amazonaws.com/SimpleNotificationService-ac565b8b1a6c5d002d285f9598aa1d9b.pem" ,
16+ "MessageId" : "95df01b4-ee98-5cb9-9903-4c221d41eb5e" ,
17+ "Message" : "Hello from SNS!" ,
18+ "MessageAttributes" : {
19+ "Test" : {"Type" : "String" , "Value" : "TestString" },
20+ "TestBinary" : {"Type" : "Binary" , "Value" : "TestBinary" },
21+ },
22+ "Type" : "Notification" ,
23+ "UnsubscribeURL" : "https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789012:test-lambda:21be56ed-a058-49f5-8c98-aedd2564c486" ,
24+ "TopicArn" : "arn:aws:sns:us-east-1:123456789012:sns-lambda" ,
25+ "Subject" : "TestInvoke" ,
26+ },
27+ }
28+ ]
29+ }
Original file line number Diff line number Diff line change 1+ """
2+ https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html
3+ """
4+
5+ MOCK_LAMBDA_SQS_EVENT = {
6+ "Records" : [
7+ {
8+ "messageId" : "059f36b4-87a3-44ab-83d2-661975830a7d" ,
9+ "receiptHandle" : "AQEBwJnKyrHigUMZj6rYigCgxlaS3SLy0a..." ,
10+ "body" : "Test message." ,
11+ "attributes" : {
12+ "ApproximateReceiveCount" : "1" ,
13+ "SentTimestamp" : "1545082649183" ,
14+ "SenderId" : "AIDAIENQZJOLO23YVJ4VO" ,
15+ "ApproximateFirstReceiveTimestamp" : "1545082649185" ,
16+ },
17+ "messageAttributes" : {},
18+ "md5OfBody" : "e4e68fb7bd0e697a0ae8f1bb342846b3" ,
19+ "eventSource" : "aws:sqs" ,
20+ "eventSourceARN" : "arn:aws:sqs:us-east-2:123456789012:my-queue" ,
21+ "awsRegion" : "us-east-2" ,
22+ }
23+ ]
24+ }
You can’t perform that action at this time.
0 commit comments