Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
How to wait first post issue and use while loop in k6 load test scripts?

I have two post request. This post request should run until the response is "createdIsCompleted" == false .I m taking createdIsCompleted response from second post isssue. So how can I run two requests in while loop. By the way, I have to wait first post issue before the second post issue should be run...I know there is no await operator in k6. But I want to learn alternative ways. This while loop not working as I want. The response still returns "createdIsCompleted" == true

let createdISCompleted;
 describe('place products', (t) => {
            while (createdIsCompleted == false) {
              

               http.post(requestUrlAPI + 'PickingProcess.checkCell', JSON.stringify({
                    cellLabel: `${createdCellLabel}`,
                    pickingReferenceNumber: `${createdpickingProcessReferenceNumber}`,
                    allocatedItemId: `${createdAllocatedItemId}`,
                }), generateTokenHeader)

                let placeProductRes = http.post(requestUrlAPI + 'PickingProcess.placeProduct', JSON.stringify({
                    cellLabel: `${createdCellLabel}`,
                    pickingReferenceNumber: `${createdpickingProcessReferenceNumber}`,
                    pickingToteLabel: `${createdPickingToteLabel}`,
                    productLabel: `${createdProductLabel}`,
                    allocatedItemId: `${createdAllocatedItemId}`,
                }), generateTokenHeader) 
                createdIsCompleted = placeProductRes.json().isCompleted;
               
                break;
            }
        });

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

By the way, I have to wait first post issue before the second post issue should be run...I know there is no await operator in k6

K6 currently has only blocking calls so each post will finish fully before the next one starts.

On the loop question you have two(three) problems:

  • createdISCompleted is unitialized, so the while loop will never be run as it's not false.
  • you have big S in the declaration but then you have small s in the while loop.
  • you have break at the end of the loop which means it will always exit after the first iteration.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!