★ wanayoo — archive 1999 https://github.com/scanapi/scanapi/issues/298Nouvelle recherche | Portail wanayoo
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

New feature: retry request calls #298

Closed
camilamaia opened this issue Oct 6, 2020 · 1 comment · Fixed by #314
Closed

New feature: retry request calls #298

camilamaia opened this issue Oct 6, 2020 · 1 comment · Fixed by #314
Assignees
Labels
Feature Hacktoberfest

Comments

@camilamaia
Copy link
Member

@camilamaia camilamaia commented Oct 6, 2020

Retry request calls

The possibility to retry certain call if a connection error happened.

@camilamaia camilamaia added the Feature label Oct 6, 2020
@camilamaia camilamaia added Hacktoberfest Needs Investigation and removed Needs Investigation labels Oct 8, 2020
@camilamaia camilamaia added this to Done in Hacktoberfest 2020 Oct 8, 2020
@camilamaia camilamaia moved this from Done to To do in Hacktoberfest 2020 Oct 8, 2020
@flaviotruzzi
Copy link
Contributor

@flaviotruzzi flaviotruzzi commented Oct 10, 2020

Can I work on this?

I was thinking on adding a retry block under the endpoints like this:

endpoints:
  - name: pokeapi
    path: https://pokeapi.co/api/v2/
    endpoints:
      - name: pokemon
        path: pokemon
        requests:
          - name: list_all
            method: get
            retry:
              max_retries: 2
            vars:
              pokemon_name: ${{ response.json()["results"][0]["name"] }}
            tests:
              - name: status_code_is_200
                assert: ${{ response.status_code == 200 }}            
              - name: response_time_is_under_half_second
                assert: ${{ response.elapsed.total_seconds() < 0.5 }}
              - name: results_length_is_20
                assert: ${{ len(response.json()["results"]) == 20 }}
              - name: count_is_gte_1050
                assert: ${{ response.json()["count"] >= 1050 }}
          - name: details
            method: get
            path: ${pokemon_name}

assertion would be the condition for retry, using exponential backoff, adding maximum number of retries.

I think it would be fairly easy to add such a feature by using Retry for time control one could set parameters from retry that we could expose to tune the exponential back off. I think it would be possible to retry based on assertions, I am not sure I can think on use cases to retry on a valid response content that would not interfere with the testing itself.

What do you think @camilamaia ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Hacktoberfest
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants