github.com/kubeshop/testkube@v1.17.23/contrib/executor/k6/examples/k6-test-scenarios.js (about)

     1  import http from 'k6/http';
     2  import { sleep, check } from 'k6';
     3  
     4  export let options = {
     5    insecureSkipTLSVerify: true,
     6    thresholds: {
     7        'http_req_duration{kind:html}': ['avg<=250', 'p(95)<500'],
     8        'checks{type:testkube}': ['rate>0.95'],
     9        'checks{type:monokle}': ['rate>0.4'],
    10        // checks: ['rate>0.5'],
    11    },
    12    scenarios: {
    13      testkube: {
    14        executor: 'constant-vus',
    15        exec: 'testkube',
    16        vus: 5,
    17        duration: '10s',
    18        tags: { type: 'testkube' },
    19      },
    20      monokle: {
    21        executor: 'per-vu-iterations',
    22        exec: 'monokle',
    23        vus: 5,
    24        iterations: 10,
    25        startTime: '5s',
    26        maxDuration: '1m',
    27        tags: { type: 'monokle' },
    28      },
    29    },
    30  };
    31  
    32  export function testkube() {
    33    check(http.get('https://docs.testkube.io', {
    34        tags: {'kind': 'html'},
    35    }), {
    36        "Testkube is OK": (res) => res.status === 200,
    37    });
    38    sleep(1);
    39  }
    40  
    41  export function monokle() {
    42    check(http.get('https://kubeshop.github.io/monokle/', {
    43        tags: {'kind': 'html'},
    44    }), {
    45        "Monokle is OK": (res) => res.status === 200,
    46    });
    47    sleep(1);
    48  }
    49