Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k6 kttp_req_duration not giving correct numbers #2439

Closed
YusuffOzt opened this issue Mar 13, 2022 · 2 comments
Closed

k6 kttp_req_duration not giving correct numbers #2439

YusuffOzt opened this issue Mar 13, 2022 · 2 comments
Labels
awaiting user waiting for user to respond question

Comments

@YusuffOzt
Copy link

YusuffOzt commented Mar 13, 2022

Brief summary

http_req_duration number is not correct.Because I have totally 43 request. But duration is 1,193 s .1s is too low for sending+waiting+receiving requests for total 43 request.

### My result is below;
scenarios: (100.00%) 1 scenario, 1 max VUs, 10m30s max duration (incl. graceful stop):
* CreatePicking: 1 iterations for each of 1 VUs (maxDuration: 10m0s, exec: CreatePicking, gracefulStop: 30s)

running (00m44.2s), 0/1 VUs, 1 complete and 0 interrupted iterations
CreatePicking ✓ [======================================] 1 VUs 00m23.3s/10m0s 1/1 iters, 1 per VU
INFO[0046] [k6-reporter v2.3.0] Generating HTML summary report source=console
█ setup

 █ Picking load test senaryosu çalıştırır

   ✓ 204 is 204

 total_count...: avg=23275      min=23275      med=23275      max=23275      p(90)=23275      p(95)=23275
 checks................................................: 100.00% ✓ 1        ✗ 0
 data_received.........................................: 41 kB   938 B/s
 data_sent.............................................: 175 kB  4.0 kB/s
 group_duration........................................: avg=23275.72ms min=23275.72ms med=23275.72ms max=23275.72ms p(90)=23275.72ms p(95)=23275.72ms
 http_req_blocked......................................: avg=19.86ms    min=0.00ms     med=0.00ms     max=382.91ms   p(90)=0.00ms     p(95)=197.05ms
 http_req_connecting...................................: avg=5.06ms     min=0.00ms     med=0.00ms     max=86.96ms    p(90)=0.00ms     p(95)=53.43ms
 http_req_duration.....................................: avg=1005.63ms  min=148.90ms   med=532.32ms   max=18206.84ms p(90)=1193.57ms  p(95)=1408.60ms
   { expected_response:true }..........................: avg=1005.63ms  min=148.90ms   med=532.32ms   max=18206.84ms p(90)=1193.57ms  p(95)=1408.60ms
 http_req_failed.......................................: 0.00%   ✓ 0        ✗ 43
 http_req_receiving....................................: avg=0.20ms     min=0.00ms     med=0.00ms     max=3.24ms     p(90)=0.59ms     p(95)=0.96ms
 http_req_sending......................................: avg=0.13ms     min=0.00ms     med=0.00ms     max=0.58ms     p(90)=0.51ms     p(95)=0.55ms
 http_req_tls_handshaking..............................: avg=8.56ms     min=0.00ms     med=0.00ms     max=165.03ms   p(90)=0.00ms     p(95)=67.28ms
 http_req_waiting......................................: avg=1005.31ms  min=148.40ms   med=532.17ms   max=18206.84ms p(90)=1193.54ms  p(95)=1408.58ms
 http_reqs.............................................: 43      0.973519/s
 iteration_duration....................................: avg=22078.97ms min=20882.21ms med=22078.97ms max=23275.72ms p(90)=23036.37ms p(95)=23156.05ms
 iterations............................................: 1       0.02264/s
 vus...................................................: 1       min=0      max=1
 vus_max...............................................: 1       min=1      max=1

### My code is below;

import http from 'k6/http'
import { describe } from 'https://jslib.k6.io/expect/0.0.4/index.js';
import exec from 'k6/execution';
import { Trend } from 'k6/metrics';
import { htmlReport } from "https://raw.githubusercontent.com/benc-uk/k6-reporter/main/dist/bundle.js";
import { textSummary } from 'https://jslib.k6.io/k6-summary/0.0.1/index.js';

let totalPickingTimeTrend = new Trend('total_count');

let authUrl = 'test';
let requestUrlAPI = 'test';
let requestUrlSeed = 'test';
let tokenPayload = {
    client_id: "test",
   
};

export function setup() {
    let createPickingStartedSalesOrdersHeader = {
        headers: {
            "apikey": "test",
            "Content-Type": "application/json"
        },
    };
    let createPickingStartedSalesOrdersRes = http.post(requestUrlSeed + 'tester', JSON.stringify({
        salesOrderConfigurations: [
            {
                amount: 100
            }
        ],
        tenant: 'test',
        operation: 'test'
    }), createPickingStartedSalesOrdersHeader)
    let response = http.post(authUrl, tokenPayload);
    return [response.json(), createPickingStartedSalesOrdersRes.json()]

}

export function handleSummary(data) {
    return {
        "result.html": htmlReport(data),
        stdout: textSummary(data, { indent: " ", enableColors: true }),
    };
}

export const options = {
    summaryTimeUnit: 'ms',
    scenarios: {
        CreatePicking: {
            exec: 'CreatePicking',
            executor: 'per-vu-iterations',
            vus: 1,
            iterations: 1
        },
    }
}

export function CreatePicking(data) {

    let generateTokenHeader = {
        headers: {
            'Authorization': `Bearer ${data[0].access_token}`,
            'content-type': 'application/json',
        },
    };
    describe('Picking load test senaryosu çalıştırır', (t) => {
        let startTime = Date.now();

        //if exist
        let continueIfExistRes = http.post(requestUrlAPI + 'test1', JSON.stringify({
            label: `${data[1][exec.vu.idInTest - 1]}`
        }), generateTokenHeader
        )
        let pickingProcessReferenceNumber = continueIfExistRes.json().route.pickingProcessReferenceNumber;
        let createdIsCompleted = continueIfExistRes.json().route.isCompleted;
        while (createdIsCompleted == false) {

            //check
            http.post(requestUrlAPI + 'test2', JSON.stringify({
                pickingReferenceNumber: `${pickingProcessReferenceNumber}`,
            }), generateTokenHeader)

            //control
            http.post(requestUrlAPI + 'test3', JSON.stringify({
                pickingReferenceNumber: `${pickingProcessReferenceNumber}`,
            }), generateTokenHeader)

            //place
            let placeProductRes = http.post(requestUrlAPI + 'test4', JSON.stringify({
                pickingReferenceNumber: `${pickingProcessReferenceNumber}`,
            }), generateTokenHeader)
            pickingProcessReferenceNumber = placeProductRes.json().pickingProcessReferenceNumber;
            createdIsCompleted = placeProductRes.json().isCompleted;
        }

        //complete
        let completePickingCompleteProcessRes = http.post(requestUrlAPI + 'test5', JSON.stringify({
            pickingReferenceNumber: `${pickingProcessReferenceNumber}`,
            placeTrolleyAddressLabel: "PA",
        }), generateTokenHeader)
        t.expect(completePickingCompleteProcessRes.status).toEqual(204);
        let totalTime = Date.now() - startTime
        totalPickingTimeTrend.add(totalTime)
    });

}

k6 version

k6 v0.36.0 ((devel), go1.17.6, windows/amd64)

OS

Windows 11

Docker version and image (if applicable)

No response

Steps to reproduce the problem

Send request containf for or while loop

Expected behaviour

http_req_duration number should be high

Actual behaviour

http_req_duration number is not correct.Because I have totally 43 request. But duration is 1,193 s .1s is too low for sending+waiting+receiving requests for total 43 request.

@YusuffOzt YusuffOzt added the bug label Mar 13, 2022
@mstoykov
Copy link
Collaborator

Hi @YusufOzturk-Development, are you expecting that http_req_duration is showing the total time for all requests?
It is for each request but on their own. So the min value is the smallest for all requests and max is the highest for all requests. While the average ... is well the average :).

At which point 1s+ per requests is probably a bit on the high side.

@mstoykov
Copy link
Collaborator

I am closing this as from other communication it seems like this was a misunderstanding of how metrics work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting user waiting for user to respond question
Projects
None yet
Development

No branches or pull requests

3 participants