Load test AWS Lambda with Artillery.io
npm install artillery-engine-lambda
Load test AWS Lambda with Artillery.io
Based on the Kinesis Engine by Shoreditch.
Important: The plugin requires Artillery 1.5.8-3 or higher.
```If Artillery is installed globally:
npm install -g artillery-engine-lambda
1. Set config.target to the name of the Lambda functionconfig.lambda
2. Specify additional options in :region
- - AWS region (default: us-east-1)engine
3. Set the property of the scenario to lambda.invoke
4. Use in your scenario to invoke the Lambda functionpayload
5. Specify additional invocation parameters:
- - String or object with the payload to send to the Lambda functioninvocationType
- - Lambda invocation type. One of Event, RequestResponse, DryRunlogType
- - One of None, Tailqualifier
- - Lambda qualifierclientContext
- - client context to pass to the Lambda function as contexttarget
- - invocation specific target overriding global default in config.target.
#### Payload substitution
The Lambda payload can include variable and function placeholders in the form of {{ [VAR_NAME_OR_FUNC_CALL] }}.
For example the payload might include a call to the built-in Artillery functions $randomNumber(min max) or $randomString(length).
Use $contextUid() to get the scenario unique ID in your payload.
#### Example Script
`yaml
config:
target: "lambda_function_name"
lambda:
region: "us-east-1"
phases:
arrivalCount: 10
duration: 1
engines:
lambda: {}
scenarios:
- name: "Invoke function"
engine: "lambda"
flow:
- loop:
- invoke:
# data may be a string or an object. Objects
# will be JSON.stringified.
clientContext: '{"app": "MyApp"}'
invocationType: "Event"
logType: "Tail"
payload: "Some payload"
qualifier: "1"
- think: 1
count: 100
`
(See example.yml for a complete example.)
```
AWS_PROFILE=dev artillery run my_script.yml