1+ import http from "k6/http" ;
2+ import { sleep } from 'k6' ;
3+ import exec from 'k6/execution' ;
4+
5+ export const options = {
6+ scenarios : {
7+ warmup : {
8+ executor : 'constant-vus' ,
9+ vus : 5 ,
10+ duration : '1m' ,
11+ gracefulStop : '0s' ,
12+ exec : 'call_function_then_sleep' ,
13+ } ,
14+ constant_load : {
15+ executor : 'constant-vus' ,
16+ vus : 50 ,
17+ startTime : '1m' ,
18+ duration : "2m" ,
19+ gracefulStop : '0s' ,
20+ exec : 'call_function_then_sleep' ,
21+ } ,
22+ max_load : {
23+ executor : 'constant-vus' ,
24+ vus : 100 ,
25+ startTime : '3m' ,
26+ duration : "2m" ,
27+ gracefulStop : '0s' ,
28+ exec : 'call_function' ,
29+ } ,
30+ ramping_max_load : {
31+ executor : 'ramping-vus' ,
32+ startVUs : 0 ,
33+ stages : [
34+ { duration : '30s' , target : 175 } ,
35+ { duration : '30s' , target : 350 } ,
36+ { duration : '30s' , target : 525 } ,
37+ { duration : '30s' , target : 700 } ,
38+ { duration : '30s' , target : 875 } ,
39+ { duration : '30s' , target : 1050 } ,
40+ ] ,
41+ gracefulRampDown : '0s' ,
42+ startTime : '5m' ,
43+ gracefulStop : '0s' ,
44+ exec : 'call_function' ,
45+ } ,
46+ } ,
47+ } ;
48+
49+ export function call_function ( ) {
50+ get ( ) ;
51+ } ;
52+
53+ export function call_function_then_sleep ( ) {
54+ get ( ) ;
55+ sleep ( 1 ) ;
56+ } ;
57+
58+ function get ( ) {
59+ http . get ( `http://${ __ENV . FUNC_HOSTNAME } :80/` , {
60+ headers : {
61+ 'Content-Type' : 'application/json' ,
62+ 'width' : 800 ,
63+ 'height' : 640 ,
64+ 'iterations' : exec . instance . vusActive ,
65+ 'zoom' : 1 ,
66+ } ,
67+ } ) ;
68+ } ;
0 commit comments