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

Retry until #751

Open
lvijnck opened this issue Jan 7, 2022 · 5 comments
Open

Retry until #751

lvijnck opened this issue Jan 7, 2022 · 5 comments

Comments

@lvijnck
Copy link
Contributor

lvijnck commented Jan 7, 2022

Hi,

I'm wondering whether there exists functionality to keep retrying the test under certain condition. This is especially relevant for APIs with long running 'asynchronous' tasks, i.e., consider the following endpoints:

  1. /create endpoint that accepts the task and immediately yields a 200 status
  2. /status endpoint that returns the status of the job, e.g., IN_PROGRESS, SUCCESS and FAILED

I'd like to express a test that keeps re-trying the /status endpoint until the status is either SUCCESS or FAILED. This could indeed be achieved with the retry functionality, but that would result in a rather flaky test as the duration of the task varies heavily.

P.S. Happy to contribute after discussion.

@michaelboulton
Copy link
Member

I'm not sure I get the utility of this suggestion - how would a 'retry until' be practically any different than just using the existing 'retry' key? They both involve running the same query until a certain condition is fulfilled, and with the existing retry key you can just add a delay before the stage which will let you set a time bound on how long to try (ie, setting a 1 second delay with 10 retries limits it to 10 seconds).

@lvijnck
Copy link
Contributor Author

lvijnck commented Feb 21, 2022

Hi @michaelboulton the difference here is that my long running task can possibly take an hour to complete, while failure along the way is very likely. So it would be relevant to specify additional stop (and failure) conditions.

@michaelboulton
Copy link
Member

I suppose this is related to #621 then , some way of specifying that you don't want something to happen?

@lvijnck
Copy link
Contributor Author

lvijnck commented Feb 27, 2022

Yeah, exactly!

@puneeter
Copy link

puneeter commented May 24, 2023

Hi @michaelboulton ! I have a similar problem. The app's status can only be (Succeeded, Failed, Running) one of these. I was using this stage in my test but it seems like I could do an early quit in case of status=="Failed". In the current implementation, I can only see it working for MQTT. Any chance we can get this functionality in the standard tests?

- name: <name>
    delay_before: 10
    max_retries: 60
    request:
      URL: <URL>
      method: GET
      headers:
        content-type: application/json
    response:
      status_code: 200
      json:
        status: Succeeded
      # unexpected: true -> Can we use this here? If yes then how do we define the unexpected value?
      headers:
        content-type: application/json

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

No branches or pull requests

3 participants