UNPKG

6.36 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 run // 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, save to myScript.yml:
27$ slsart script -e http://your.endpoint.com -d 10 -r 3 > myScript.yml
28
29$ slsart run -s myScript.yml // iterate on editting and running as desired, before...
30
31$ slsart remove
32```
33
34### More advanced use cases
35
36Use arbitrary script files
37
38`$ slsart -s my.other.script.yml`
39
40Configure a generated script on the CLI (hit your.endpoint.com with 10 requests per second, scaling up to 25 requests per second over 60 seconds)
41
42`$ slsart script -e http://your.endpoint.com -d 60 -r 10 -t 25`
43
44Create a local copy of the function that can be editted and redeployed with the new settings. This enables more advanced configurations of the function to load VPC hosted services 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 configuration related documentation.
45
46```
47$ slsart configure
48$ nano serverless.yml
49$ nano handler.js
50```
51
52## Detailed Usage
53
54```
55$ slsart --help
56Commands:
57 deploy Deploy a default version of the function that will execute your
58 Artillery scripts.
59 run Run your Artillery script. Will prefer a script given by `-s` over
60 a `script.[yml|json]` in the current directory over the default
61 script.
62 remove Remove the function and the associated resources created for or by
63 it.
64 script Create a local Artillery script so that you can customize it for
65 your specific load requirements. See https://artillery.io for
66 documentation.
67 configure Create a local copy of the deployment assets for modification and
68 deployment. See https://docs.serverless.com for documentation.
69
70Options:
71 --help Show help [boolean]
72 --version Show version number [boolean]
73 --debug, -D Run the command in debug mode.
74 --verbose, -v Run the command in verbose mode.
75```
76
77### Commands
78
79#### deploy
80```
81$ slsart deploy --help
82
83slsart deploy
84
85Options:
86 --help Show help [boolean]
87 --version Show version number [boolean]
88 --debug, -D Run the command in debug mode.
89 --func, -f Lambda function name to execute. [string] [default: "loadGenerator"]
90
91```
92
93#### run
94```
95$ slsart run --help
96
97slsart run
98
99Options:
100 --help Show help [boolean]
101 --version Show version number [boolean]
102 --debug, -D Run the command in debug mode.
103 --script, -s The Artillery script to execute. [string] [default: "script.yml"]
104 --func, -f Lambda function name to execute. [string] [default: "loadGenerator"]
105
106
107```
108
109#### remove
110```
111$ slsart remove --help
112
113slsart remove
114
115Options:
116 --help Show help [boolean]
117 --version Show version number [boolean]
118 --debug, -D Run the command in debug mode.
119 --func, -f Lambda function name to execute. [string] [default: "loadGenerator"]
120
121```
122
123#### script
124```
125$ slsart script --help
126
127Commands:
128 deploy Deploy a default version of the function that will execute your Artillery scripts.
129 run Run your Artillery script. Will prefer a script given by `-s` over a `script.[yml|json]`
130 in the current directory over the default script.
131 remove Remove the function and the associated resources created for or by it.
132 script Create a local Artillery script so that you can customize it for your specific load requirements.
133 See https://artillery.io for documentation.
134 configure Create a local copy of the deployment assets for modification and deployment.
135 See https://docs.serverless.com for documentation.
136
137Options:
138 --help Show help [boolean]
139 --version Show version number [boolean]
140 --debug, -D Run the command in debug mode.
141 --verbose, -v Run the command in verbose mode.
142
143
144```
145
146#### configure
147```
148$ slsart configure
149```
150
151## Script Customization
152
153```
154$ mkdir myCustomLoadTest // Make your own test directory
155$ cd myCustomLoadTest
156$ slsart script // Use slsart to get basic files
157$ nano script.yml // Edit event.json to change test endpoint
158```
159
160Modify 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.
161
162For example, change the "flow" to hit your application:
163
164```
165 scenarios:
166 -
167 flow:
168 -
169 get:
170 url: "http://your.endpoint.com" # URL of service to test
171
172```
173
174and up the duration of the test to one minute and provide more load:
175
176```
177 phases:
178 -
179 duration: 60 # Duration of test in seconds
180 arrivalRate: 100 # Starting rate (requests per second)
181 rampTo: 200 # Ending rate (RPS at end of test duration)
182```
183
184Then run the test again using:
185
186```
187$ slsart run
188```
189
190Now you can create a copy of the test and run a different test.
191
192```
193$ cp script.yml trafficSpike.yml
194$ nano trafficSpike.yml
195```
196
197Update the test spec... Then run it!
198
199```
200$ slsart run -f trafficSpike.yml
201```
202
203## Function Customization
204
205TODO
206
207## References
2081. [artillery.io](https://artillery.io) for documentation about how to define your load shape, volume, targets, inputs, et cetera
2092. [serverless.com](https://docs.serverless.com) for documentation about how to create a custom function configuration