UNPKG

6.1 kBMarkdownView Raw
1# *** UNDER ACTIVE DEVELOPMENT - EXPECT LOTS OF CHURN THRU Friday October 21, 2016 ***
2
3# serverless-artillery [![Build Status](https://travis-ci.org/Nordstrom/serverless-artillery.svg)](https://travis-ci.org/Nordstrom/serverless-artillery)
4Combine [`serverless`](https://serverless.com) with [`artillery`](https://artillery.io) and you get `serverless-artillery` (a.k.a. `serverless-artillery`) for instant, cheap, and easy performance testing at scale
5
6## Installation
7We assume you have node.js (v4 or better) installed. Likewise you should have the serverless framework (v1.0+) either installed globally or available in the local `node_modules`.
8
9```
10npm install -g serverless-artillery
11```
12
13## Quick Start & Finish
14
15```
16$ slsart deploy // and then
17$ slsart invoke // repeat as desired, before...
18$ slsart remove
19```
20
21### Deeper Dive
22
23```
24$ slsart deploy // If not already deployed.
25
26// create a custom test against your service with a 10 second duration and 3 RPS:
27$ slsart script -e https://your.endpoint.com -d 10 -r 3
28$ slsart invoke // iterate on editing `./script.yml` and invoking as desired, before...
29
30$ slsart remove
31```
32
33### More advanced use cases
34
35Use arbitrary script files
36
37`$ slsart -s /my/path/to/my.other.script.yml`
38
39Generate a customizable script on the CLI (hit `https://your.endpoint.com` with `10` requests per second, scaling up to `25` requests per second over `60` seconds)
40
41`$ slsart script -e https://your.endpoint.com -d 60 -r 10 -t 25`
42
43Generate a local copy of the function that can be edited and redeployed with your changed settings. This enables more advanced configurations of the function to send [load against VPC hosted services](https://serverless.com/framework/docs/providers/aws/vpc/), [use CSV files to specify variables in your URLs](https://artillery.io/docs/script-reference.html#Payloads) (hint: put your `csv` in the same directory as your `serverless.yml` and redeploy), or other non-default use cases. Similarly, you'll want to do this if you need to alter hard-coded limits. See https://docs.serverless.com for function configuration related documentation. See https://artillery.io/docs for script configuration related documentation.
44
45```
46$ slsart configure
47$ nano serverless.yml
48$ nano handler.js
49```
50
51## Detailed Usage
52
53```
54$ slsart --help
55Commands:
56 deploy Deploy a default version of the function that will execute your
57 Artillery scripts.
58 invoke Invoke your function with your Artillery script. Will prefer a
59 script given by `-s` over a `script.[yml|json]` in the current
60 directory over the default script.
61 remove Remove the function and the associated resources created for or by
62 it.
63 script Create a local Artillery script so that you can customize it for
64 your specific load requirements. See https://artillery.io for
65 documentation.
66 configure Create a local copy of the deployment assets for modification and
67 deployment. See https://docs.serverless.com for documentation.
68
69Options:
70 --help Show help [boolean]
71 --version Show version number [boolean]
72 -D, --debug Execute the command in debug mode. It will be chatty about
73 what it is happening in the code.
74 -V, --verbose Execute the command in verbose mode. It will be chatty about
75 what it is attempting to accomplish.
76```
77
78### Commands
79
80#### deploy
81```
82$ slsart deploy --help
83
84slsart deploy
85```
86
87#### invoke
88```
89$ slsart invoke --help
90
91slsart invoke
92
93Options:
94 -s, --script The Artillery script to execute. [string]
95```
96
97#### remove
98```
99$ slsart remove --help
100
101slsart remove
102
103```
104
105#### script
106```
107$ slsart script --help
108
109slsart script
110
111Options:
112 -e, --endpoint The endpoint to load with traffic. [string]
113 -d, --duration The duration, in seconds, to load the given endpoint. [number]
114 -r, --rate The rate, in requests per second, at which to load the given
115 endpoint. [number]
116 -t, --rampTo The rate to adjust towards away from the given rate, in
117 requests per second at which to load the given endpoint.
118 [number]
119 -o, --out The file to output the generated script in to. [string]
120```
121
122#### configure
123```
124$ slsart configure
125
126slsart configure
127```
128
129## Script Customization
130
131```
132$ mkdir myCustomLoadTest // Make your own test directory
133$ cd myCustomLoadTest
134$ slsart script // Use slsart to get basic files
135$ nano script.yml // Edit event.json to change test endpoint
136```
137
138Modify the script.yml file to point at your own endpoint with the load profile that you want to test your application with. See https://artillery.io for documentation on scripts.
139
140For example, change the script to target your service:
141
142```
143config:
144 target: "https://your.endpoint.com"
145scenarios:
146 -
147 flow:
148 -
149 get:
150 url: "/your/path"
151
152```
153
154and up the duration of the test to one minute and provide more load:
155
156```
157 config:
158 phases:
159 -
160 duration: 60 # Duration of test in seconds
161 arrivalRate: 100 # Starting rate (requests per second)
162 rampTo: 200 # Ending rate (RPS at end of test duration)
163```
164
165Then invoke the function with your script again using:
166
167```
168$ slsart invoke
169```
170
171Now you can create a copy of the test, edit that copy, and invoke the function with it.
172
173```
174$ cp script.yml trafficSpike.yml
175$ nano trafficSpike.yml
176```
177
178Update the load spec... Then invoke it!
179
180```
181$ slsart invoke -s trafficSpike.yml
182```
183
184## Function Customization
185
186TODO
187
188## References
1891. [artillery.io](https://artillery.io) for documentation about how to define your load shape, volume, targets, inputs, et cetera
1902. [serverless.com](https://docs.serverless.com) for documentation about how to create a custom function configuration