drill icon indicating copy to clipboard operation
drill copied to clipboard

support for repeat-until and microsecond delays

Open ghost opened this issue 1 year ago • 0 comments

Hi, I like your tool! My infra not so much, but that's the whole idea isn't it 😄

I want to use it to loadtest a poc. I have an app exposing a HTTP API. It also has a async/background processor. When I create a 'payment' using the API it's stored in a db with status "pending" and the transaction id is pushed to a queue, which is consumed by the background processor. This processor will do 'something' and update the payment status to "complete" or "rejected".

Now I'd like to use drill to simulate a real scenario using this pseudo plan:

request /create-payment

for {
    request /get-payment-status
    break if body.status != "pending"
    sleep 50ms
}

I could not find a "repeat until assertion fails/succeeds" or "jump to step X if assertion fails". Is this maybe something you would be willing to implement?

So I tried next best thing: I tried to mock the loop by just doing the request 5 times, like:

  - name: get payment status
    request:
      url: /get-payment-status
      method: POST
      body: '{ "transaction_id": "{{ create_payment.body.transaction_id }}" }'
    delay:
      seconds: 0.05
    with_items:
    - 1
    - 2
    - 3
    - 4
    - 5

This did not work, because:

  • the combination of request and delay does not work
  • (later I noticed the 'delay' was actually ignored, because using seconds: 0.05 causes a panic, because the value is expected to be an i64. It would be awesome to have float or microsecond support)

Then I tried moving the request + separate delay into a snippet:

- name: get payment status
  request:
    url: /get-payment-status
    method: POST
    body: '{ "transaction_id": "{{ create_payment.body.transaction_id }}" }'

- name: sleep
  delay:
    seconds: 1

... and include it, like:

  - name: get payment status
    include: get-payment-status.yml
    with_items:
    - 1
    - 2
    - 3
    - 4
    - 5

But it seems the combination "include" and "with" is not supported.

So, for now I have to revert to:

  - name: get payment status
    include: get-payment-status.yml

  - name: get payment status
    include: get-payment-status.yml

  - name: get payment status
    include: get-payment-status.yml

  - name: get payment status
    include: get-payment-status.yml

  - name: get payment status
    include: get-payment-status.yml

Love to hear your suggestions. Maybe I am unaware of some relevant features?

Cheers!

ghost avatar Mar 14 '23 16:03 ghost