Skip to content

feat(http): add retry support #59

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat(http): add retry support #59

wants to merge 3 commits into from

Conversation

robmorgan
Copy link
Owner

HTTP Retry Functionality

InfraSpec now supports retrying HTTP requests until the response contains expected content. This is useful for handling eventual consistency, temporary failures, or waiting for services to become available.

Usage

Basic Retry with Default Values

Given I have a HTTP endpoint at "http://localhost:8000/status"
When I retry the HTTP request until the response contains "ready"
Then the HTTP response status should be 200

This uses default values:

  • Max retries: 5
  • Timeout: 30 seconds
  • Sleep between retries: 1 second

Custom Retry Configuration

Given I have a HTTP endpoint at "http://localhost:8000/api/data"
When I retry the HTTP request until the response contains "processed" with max 10 retries and a 60 second timeout
Then the HTTP response should contain "data_id"

With Authentication

Given I have a HTTP endpoint at "http://localhost:8000/health"
And I set basic auth credentials with username "admin" and password "secret"
When I retry the HTTP request until the response contains "healthy" with max 5 retries and a 30 second timeout
Then the HTTP response status should be 200

With Bearer Token

Given I have a HTTP endpoint at "http://localhost:8000/api/data"
And I am authenticated with a valid bearer token
When I retry the HTTP request until the response contains "processed"
Then the HTTP response should contain "data_id"

With POST Request and Body

Given I have a HTTP endpoint at "http://localhost:8000/jobs"
And I set the headers to
  | Name         | Value            |
  | Content-Type | application/json |
And I set the request body to "{\"job_type\": \"data_processing\"}"
When I retry the HTTP request until the response contains "completed" with max 20 retries and a 120 second timeout
Then the HTTP response should be valid JSON

Copy link

vercel bot commented Jul 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
infraspec ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 28, 2025 10:40pm

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

Successfully merging this pull request may close these issues.

1 participant