-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { AWSConfig, LambdaClient } from '../build/lambda.js' | ||
import { check } from 'k6'; | ||
|
||
const awsConfig = new AWSConfig({ | ||
region: __ENV.AWS_REGION, | ||
accessKeyId: __ENV.AWS_ACCESS_KEY_ID, | ||
secretAccessKey: __ENV.AWS_SECRET_ACCESS_KEY, | ||
sessionToken: __ENV.AWS_SESSION_TOKEN, | ||
}) | ||
|
||
const lambdaClient = new LambdaClient(awsConfig) | ||
|
||
export default async function () { | ||
const response = await lambdaClient.invoke('add-numbers', JSON.stringify({x: 1, y: 2})) | ||
|
||
check(response, { | ||
'status is 200': (r) => r.statusCode === 200, | ||
'payload is 3': (r) => r.payload === 3, | ||
}) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
#!/bin/bash | ||
|
||
FUNCTION_NAME="test-jslib-aws-lambda" | ||
testdata_folder="/etc/localstack/init/testdata/lambda" | ||
zip_dir=/tmp/lambda | ||
mkdir -p "$zip_dir" | ||
|
||
# Create a dummy lambda function responding with a static string "Hello World!" | ||
cat >index.js <<EOF | ||
exports.handler = async function(event, context) { | ||
return "Hello World!"; | ||
} | ||
EOF | ||
for file in "$testdata_folder"/*; do | ||
function_name=$(basename "$file") | ||
function_zip="$zip_dir/$function_name.zip" | ||
(cd "$file" || exit; zip "$function_zip" ./*) | ||
|
||
# Create a zip file containing the lambda function | ||
zip lambda.zip index.js | ||
|
||
# Create a dummy lambda function responding with a static string "Hello World!" | ||
awslocal lambda create-function \ | ||
--function-name "$FUNCTION_NAME" \ | ||
--runtime nodejs18.x \ | ||
--handler index.handler \ | ||
--zip-file fileb://lambda.zip \ | ||
--role arn:aws:iam::123456789012:role/irrelevant | ||
awslocal lambda create-function \ | ||
--function-name "$function_name" \ | ||
--runtime nodejs18.x \ | ||
--zip-file "fileb://$function_zip" \ | ||
--handler index.handler \ | ||
--role arn:aws:iam::000000000000:role/lambda-role | ||
done |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exports.handler = async (event) => { | ||
throw new Error(event) | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exports.handler = async (event) => { | ||
console.log('received event:', JSON.stringify(event)); | ||
return event.a * event.b | ||
}; |