1 | ---
|
2 | - test: Test help output
|
3 | steps:
|
4 | - in: bn --help
|
5 | out: |-
|
6 | Binaris command line interface
|
7 |
|
8 | Usage: bn <command> [options]
|
9 |
|
10 | Commands:
|
11 | bn create <runtime> <function> [options] Create a function from template
|
12 | bn deploy <function> [options] Deploys a function to the cloud
|
13 | bn remove <function> [options] Remove a previously deployed function
|
14 | bn invoke <function> [options] Invoke a Binaris function
|
15 | bn list [options] List all deployed functions
|
16 | bn perf <function> [options] Measure invocation latency (experimental)
|
17 | bn logs <function> [options] Print the logs of a function
|
18 | bn login Login to your Binaris account using an API key
|
19 |
|
20 | Options:
|
21 | --version Show version number [boolean]
|
22 | --path, -p Use directory dir. "create" will create this directory if needed. [string]
|
23 | --help, -h Show help [boolean]*
|
24 | - test: Test list help output
|
25 | steps:
|
26 | - in: bn list --help
|
27 | out: |-
|
28 | Usage: bn list [options]
|
29 |
|
30 | Options:
|
31 | --version Show version number [boolean]
|
32 | --path, -p Use directory dir. "create" will create this directory if needed. [string]
|
33 | --help, -h Show help [boolean]
|
34 | --json Output as JSON*
|
35 | - test: Test logs help output (good-path)
|
36 | steps:
|
37 | - in: bn logs --help
|
38 | out: |-
|
39 | Usage: bn logs <function> [options]
|
40 |
|
41 | Positionals:
|
42 | function Function name [string] [required]
|
43 |
|
44 | Options:
|
45 | --version Show version number [boolean]
|
46 | --path, -p Use directory dir. "create" will create this directory if needed. [string]
|
47 | --help, -h Show help [boolean]
|
48 | --tail, -t Outputs logs in "tail -f" fashion [boolean]
|
49 | --since, -s Outputs logs after the given ISO timestamp [string]
|
50 |
|
51 | Examples:
|
52 | // retrieve all logs
|
53 | bn logs foo
|
54 |
|
55 | // tail all logs
|
56 | bn logs foo --tail
|
57 |
|
58 | // ISO
|
59 | bn logs foo --since 2018-03-09T22:12:21.861Z
|
60 |
|
61 | // unix
|
62 | bn logs foo --since 1520816105798
|
63 |
|
64 | // offset format
|
65 | bn logs foo --since 3d
|
66 | bn logs foo --since 13hours
|
67 | bn logs foo --since 9s*
|
68 |
|
69 | - test: Test login (good-path)
|
70 | cleanup:
|
71 | - bn remove momentousgiants
|
72 | steps:
|
73 | - in: bn create node8 momentousgiants
|
74 | out: |-
|
75 | Created function * in /home/dockeruser/test
|
76 | (use "bn deploy momentousgiants" to deploy the function)
|
77 | - in: echo "$BINARIS_API_KEY" | bn login
|
78 | out: |-
|
79 | Please enter your Binaris API key to deploy and invoke functions.
|
80 | If you don't have a key, head over to https://binaris.com to request one
|
81 | *? API Key: *
|
82 | *Authentication Succeeded*
|
83 | (use "bn create node8 hello" to create a Node.js template function in your CWD)
|
84 | - in: bn deploy momentousgiants
|
85 | out: |-
|
86 | Deployed function to *
|
87 | (use "bn invoke momentousgiants" to invoke the function)
|
88 |
|
89 | - test: Test create (good-path)
|
90 | steps:
|
91 | - in: bn create node8 snowmanolympics
|
92 | out: |-
|
93 | Created function * in /home/dockeruser/test
|
94 | (use "bn deploy *" to deploy the function)
|
95 | - in: bn create node8 purplecannon -p /home/dockeruser/test/purplecannon
|
96 | out: |-
|
97 | Created function purplecannon in /home/dockeruser/test/purplecannon
|
98 | (use "bn deploy -p /home/dockeruser/test/purplecannon purplecannon" to deploy the function)
|
99 |
|
100 | - test: Test deploy (good-path)
|
101 | cleanup:
|
102 | - bn remove drybeef
|
103 | steps:
|
104 | - in: bn create node8 drybeef
|
105 | out: |-
|
106 | Created function * in /home/dockeruser/test
|
107 | (use "bn deploy drybeef" to deploy the function)
|
108 | - in: bn deploy drybeef
|
109 | out: |-
|
110 | Deployed function to *
|
111 | (use "bn invoke drybeef" to invoke the function)
|
112 | - in: bn deploy drybeef
|
113 | out: |-
|
114 | Deployed function to *
|
115 | (use "bn invoke drybeef" to invoke the function)
|
116 |
|
117 | - test: Test list
|
118 | serial: true
|
119 | setup:
|
120 | - >
|
121 | for i in {1..2};
|
122 | do out="$(bn remove listtest$i 2>&1)";
|
123 | echo "$out";
|
124 | if ! echo "$out" | grep -e "No such function" -e "Removed function"; then false; fi
|
125 | done;
|
126 | cleanup:
|
127 | - >
|
128 | for i in {1..2};
|
129 | do out="$(bn remove listtest$i 2>&1)";
|
130 | echo "$out";
|
131 | if ! echo "$out" | grep -e "No such function" -e "Removed function"; then false; fi
|
132 | done;
|
133 | steps:
|
134 | - in: bn create node8 listtest1
|
135 | - in: bn deploy listtest1
|
136 | - in: bn create node8 listtest2
|
137 | - in: bn deploy listtest2
|
138 | - in: bn list
|
139 | out: |-
|
140 | FUNCTION *LAST DEPLOYED*
|
141 | listtest1 *201*-*-*T*:*:*Z*
|
142 | listtest2 *201*-*-*T*:*:*Z*
|
143 | - in: bn list --json
|
144 | out: |-
|
145 | *[*{"name":"listtest1","lastDeployed":"[20*-*-*T*:*:*Z]"}*,*{"name":"listtest2","lastDeployed":"[20*-*-*T*:*:*Z]"}*]*
|
146 |
|
147 | - test: Test invoke (good-path)
|
148 | setup:
|
149 | - |-
|
150 | echo '{"name": "unguessable"}' > invoke.json
|
151 | cleanup:
|
152 | - bn remove extrasmallaunt
|
153 | steps:
|
154 | - in: bn create node8 extrasmallaunt
|
155 | out: |-
|
156 | Created function * in /home/dockeruser/test
|
157 | (use "bn deploy extrasmallaunt" to deploy the function)
|
158 | - in: bn deploy extrasmallaunt
|
159 | out: |-
|
160 | Deployed function to *
|
161 | (use "bn invoke extrasmallaunt" to invoke the function)
|
162 | - in: cd /home/
|
163 | - in: bn invoke extrasmallaunt
|
164 | out: |-
|
165 | "Hello World!"
|
166 | - in: |-
|
167 | bn invoke extrasmallaunt -d '{"name": "unguessable"}'
|
168 | out: |-
|
169 | "Hello unguessable!"
|
170 | - in: bn invoke extrasmallaunt -j ./dockeruser/test/invoke.json
|
171 | out: |-
|
172 | "Hello unguessable!"
|
173 |
|
174 | - test: Test logs (good-path)
|
175 | setup:
|
176 | - export FUNC_NAME=rand$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1)
|
177 | - bn create node8 $FUNC_NAME
|
178 | - sed -i '2 a \ console.log(`Hello ${name}!`);' function.js
|
179 | cleanup:
|
180 | - bn remove $FUNC_NAME
|
181 | steps:
|
182 | - in: bn deploy $FUNC_NAME
|
183 | out: |-
|
184 | Deployed function to *
|
185 | (use "bn invoke *" to invoke the function)
|
186 | - in: bn invoke $FUNC_NAME
|
187 | out: |-
|
188 | "Hello World!"
|
189 | - in: sleep 5
|
190 | - in: bn logs $FUNC_NAME
|
191 | out: |-
|
192 | [201*-*-*T*:*:*Z] Hello World!
|
193 | [201*-*-*T*:*:*Z] Function invocation took * us
|
194 | - in: |-
|
195 | bn invoke $FUNC_NAME -d '{"name": "again"}'
|
196 | out: |-
|
197 | "Hello again!"
|
198 | - in: sleep 8
|
199 | - in: bn logs $FUNC_NAME
|
200 | out: |-
|
201 | [201*-*-*T*:*:*Z] Hello World!
|
202 | [201*-*-*T*:*:*Z] Function invocation took * us
|
203 | [201*-*-*T*:*:*Z] Hello again!
|
204 | [201*-*-*T*:*:*Z] Function invocation took * us
|
205 | - in: sleep 15
|
206 | - in: |-
|
207 | bn invoke $FUNC_NAME -d '{"name": "for the last time"}'
|
208 | out: |-
|
209 | "Hello for the last time!"
|
210 | - in: sleep 8
|
211 | - in: bn logs $FUNC_NAME --since 10s
|
212 | out: |-
|
213 | [201*-*-*T*:*:*Z] Hello for the last time!
|
214 | [201*-*-*T*:*:*Z] Function invocation took * us
|
215 | - in: cd /home/
|
216 | - in: bn logs $FUNC_NAME --since 40sec
|
217 | out: |-
|
218 | [201*-*-*T*:*:*Z] Hello again!
|
219 | [201*-*-*T*:*:*Z] Function invocation took * us
|
220 | [201*-*-*T*:*:*Z] Hello for the last time!
|
221 | [201*-*-*T*:*:*Z] Function invocation took * us
|
222 |
|
223 | - test: 'Test {PY_VERSION} E2E (good-path)'
|
224 | foreach:
|
225 | - PY_VERSION: python2
|
226 | - PY_VERSION: pypy2
|
227 | setup:
|
228 | - export FUNC_NAME={PY_VERSION}$(cat /dev/urandom | tr -dc 'a-z0-9' | fold -w 32 | head -n 1)
|
229 | - 'bn create {PY_VERSION} $FUNC_NAME'
|
230 | - |-
|
231 | cat > function.py <<EOF
|
232 | def handler(body, req):
|
233 | name = req.query.get('name') or body.get('name') or 'World'
|
234 | out = 'Hello {}!'.format(name)
|
235 | print out
|
236 | return out
|
237 | EOF
|
238 | cleanup:
|
239 | - bn remove $FUNC_NAME
|
240 | steps:
|
241 | - in: bn deploy $FUNC_NAME
|
242 | out: |-
|
243 | Deployed function to *
|
244 | (use "bn invoke *" to invoke the function)
|
245 | - in: |-
|
246 | bn invoke $FUNC_NAME -d '{"name": "Binaris"}'
|
247 | out: |-
|
248 | "Hello Binaris!"
|
249 | - in: sleep 5
|
250 | - in: bn logs $FUNC_NAME
|
251 | out: |-
|
252 | [201*-*-*T*:*:*Z] Hello Binaris!
|
253 | [201*-*-*T*:*:*Z] Function invocation took * us
|
254 |
|
255 | - test: Test deploy invoke remove cycle commands (good-path)
|
256 | steps:
|
257 | - in: bn create node8 gulliblezebra
|
258 | out: |-
|
259 | Created function * in /home/dockeruser/test
|
260 | (use "bn deploy gulliblezebra" to deploy the function)
|
261 | - in: bn deploy gulliblezebra
|
262 | out: |-
|
263 | Deployed function to *
|
264 | (use "bn invoke gulliblezebra" to invoke the function)
|
265 | - in: bn invoke gulliblezebra
|
266 | out: |-
|
267 | "Hello World!"
|
268 | - in: bn remove gulliblezebra
|
269 | out: |-
|
270 | Removed function *
|
271 |
|
272 | - test: "envs: deploy invoke remove with secrets"
|
273 | steps:
|
274 | - in: bn create node8 secretsanta
|
275 | - in: |-
|
276 | cat <<EOF >/home/dockeruser/test/binaris.yml
|
277 | functions:
|
278 | secretsanta:
|
279 | file: function.js
|
280 | entrypoint: handler
|
281 | runtime: node8
|
282 | env:
|
283 | FORWARD_ME:
|
284 | DEFINED_HERE: value
|
285 | BN_FUNCTION: "dont-override"
|
286 | EOF
|
287 | - in: |-
|
288 | cat <<EOF >/home/dockeruser/test/function.js
|
289 | exports.handler = () => [process.env.FORWARD_ME, process.env.DEFINED_HERE, process.env.BN_FUNCTION];
|
290 | EOF
|
291 | - in: FORWARD_ME=please bn deploy secretsanta
|
292 | out: |-
|
293 | Deployed function to *
|
294 | (use "bn invoke secretsanta" to invoke the function)
|
295 | - in: bn invoke secretsanta
|
296 | out: |-
|
297 | *["please","value","*secretsanta"]*
|
298 | - in: bn remove secretsanta
|
299 | out: |-
|
300 | Removed function *
|
301 | - test: "envs: fail to deploy if non-string in env"
|
302 | steps:
|
303 | - in: bn create node8 invalidenv
|
304 | - in: |-
|
305 | cat <<EOF >/home/dockeruser/test/binaris.yml
|
306 | functions:
|
307 | invalidenv:
|
308 | file: function.js
|
309 | entrypoint: handler
|
310 | runtime: node8
|
311 | env:
|
312 | A_NUMBER: 6.66
|
313 | EOF
|
314 | - in: bn deploy invalidenv
|
315 | exit: 1
|
316 | err: |-
|
317 | *A_NUMBER's value is not a string*
|
318 | - test: "envs: fail to deploy if empty string in env"
|
319 | steps:
|
320 | - in: bn create node8 emptiness
|
321 | - in: |-
|
322 | cat <<EOF >/home/dockeruser/test/binaris.yml
|
323 | functions:
|
324 | emptiness:
|
325 | file: function.js
|
326 | entrypoint: handler
|
327 | runtime: node8
|
328 | env:
|
329 | EMPTY: ""
|
330 | EOF
|
331 | - in: bn deploy emptiness
|
332 | exit: 1
|
333 | err: |-
|
334 | *Empty string *EMPTY not supported.*
|
335 | - test: Test login (bad-path)
|
336 | steps:
|
337 | - in: bn create node8 stormysummer
|
338 | - in: echo "9239239" | bn login
|
339 | err: Invalid API key
|
340 | exit: 1
|
341 |
|
342 | - test: Test create (bad-path)
|
343 | steps:
|
344 | - in: bn create node8 a*b*c*
|
345 | err: Invalid characters in function name a*b*c*. Use only letters and digits
|
346 | exit: 1
|
347 | - in: bn create node8 a_b%c#d@e+
|
348 | err: Invalid characters in function name a_b%c#d@e+. Use only letters and digits
|
349 | exit: 1
|
350 | - in: bn create node8 a=b~c,d.
|
351 | err: Invalid characters in function name a=b~c,d.. Use only letters and digits
|
352 | exit: 1
|
353 | - in: bn create node8 a:b?c!d-
|
354 | err: Invalid characters in function name a:b?c!d-. Use only letters and digits
|
355 | exit: 1
|
356 | - in: bn create node8 tooooooooooooooooooooooooooooooooooooooooooooooolongggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
|
357 | err: Function names cannot be longer than 58 characters.
|
358 | exit: 1
|
359 | - in: bn create
|
360 | err: "*Not enough non-option arguments: got 0, need at least 2"
|
361 | exit: 1
|
362 | - in: bn create node8
|
363 | err: "*Not enough non-option arguments: got 1, need at least 2"
|
364 | exit: 1
|
365 | - in: bn create abcd
|
366 | err: "*Not enough non-option arguments: got 1, need at least 2"
|
367 | exit: 1
|
368 | - in: bn create cpp4096 abcd
|
369 | err: '*Invalid values:*Argument: runtime, Given: "cpp4096", Choices:*'
|
370 | exit: 1
|
371 |
|
372 | - test: Test invoke (bad-path)
|
373 | steps:
|
374 | - in: bn create node8 quarrelsometest -p /home/dockeruser/test/alloftheoptions
|
375 | - in: bn invoke quarrelsometest -j myFile.json -d data
|
376 | err: Invoke flags --json(-j) and --data(-d) are mutually exclusive
|
377 | exit: 1
|
378 | - in: bn invoke quarrelsometest -j myFile.json
|
379 | err: "ENOENT: no such file or directory, open 'myFile.json'"
|
380 | exit: 1
|
381 |
|
382 | - test: Test remove (bad-path)
|
383 | steps:
|
384 | - in: bn create node8 dispensabledrop
|
385 | - in: bn remove dispensabledrop
|
386 | err: No such function
|
387 | exit: 1
|
388 | - in: bn deploy dispensabledrop
|
389 | - in: bn remove dispensabledrop
|
390 | - in: bn remove dispensabledrop
|
391 | err: No such function
|
392 | exit: 1
|
393 | - in: bn remove
|
394 | err: "*Not enough non-option arguments: got 0, need at least 1"
|
395 | exit: 1
|
396 |
|
397 | - test: Test logs (bad-path)
|
398 | steps:
|
399 | - in: bn create node8 endlessclue
|
400 | - in: bn logs endlessclue --since h23sdh2
|
401 | err: |-
|
402 | Invalid time format "h23sdh2"
|
403 | exit: 1
|
404 | - in: bn logs endlessclue --since 231213daysf
|
405 | err: |-
|
406 | Invalid offset format, unknown unit "daysf"
|
407 | exit: 1
|
408 |
|
409 | - test: Invalid name in binaris.yml (bad-path)
|
410 | setup:
|
411 | - bn create node8 pickypumpkin
|
412 |
|
413 | - sed -i '2 c \ inv@a-d:' binaris.yml
|
414 | steps:
|
415 | - in: bn deploy "inv@a-d"
|
416 | err: Invalid characters in function name inv@a-d. Use only letters and digits
|
417 | exit: 1
|
418 |
|
419 | - test: Unknown command (bad-path)
|
420 | steps:
|
421 | - in: bn alwaysbad
|
422 | err: "*Unknown command: 'alwaysbad'"
|
423 | exit: 1
|
424 |
|
425 | - test: No permission
|
426 | setup:
|
427 | - mkdir /home/dockeruser/test/securedir
|
428 | - echo binaris | sudo -S chown root:root /home/dockeruser/test/securedir
|
429 | - echo binaris | sudo -S chmod 700 /home/dockeruser/test/securedir
|
430 | steps:
|
431 | - in: bn create node8 orangehero -p /home/dockeruser/test/securedir
|
432 | err: "EACCES: permission denied, unlink '/home/dockeruser/test/securedir/function.js'"
|
433 | exit: 1
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 | - test: No such path (bad-path)
|
453 | steps:
|
454 | - in: bn deploy livelyhall -p /home/dockeruser/test/bogus/comeon/really/hello.js
|
455 | err: "ENOENT: no such file or directory, open '/home/dockeruser/test/bogus/comeon/really/hello.js/binaris.yml'"
|
456 | exit: 1
|
457 |
|
458 | - test: No API key or conf file (bad-path)
|
459 | setup:
|
460 | - unset BINARIS_API_KEY
|
461 | steps:
|
462 | - in: bn create node8 handsomelycalendar
|
463 | - in: bn deploy handsomelycalendar
|
464 | err: Binaris conf file could not be read and BINARIS_API_KEY is undefined, please use "bn login"
|
465 | exit: 1
|
466 |
|
467 | - test: Deploy of 200MB function succeeds
|
468 | setup:
|
469 | - bn create python2 largeData200MB
|
470 | - dd if=/dev/urandom bs=1048576 count=200 of=large.data
|
471 | cleanup:
|
472 | - bn remove largeData200MB
|
473 | steps:
|
474 | - in: bn deploy largeData200MB
|
475 | out: |-
|
476 | Deployed function to *
|
477 | (use "bn invoke *" to invoke the function)
|
478 | - in: bn invoke largeData200MB
|
479 | out: |-
|
480 | "Hello World!"
|
481 |
|
482 | - test: Deploy of 300MB function fails with significant error message
|
483 | setup:
|
484 | - bn create python2 largeData300MB
|
485 | - dd if=/dev/urandom bs=1048576 count=300 of=very.large.data
|
486 | steps:
|
487 | - in: bn deploy largeData300MB
|
488 | err: Payload too large
|
489 | exit: 1
|