Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

151
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda