How to Use Orb's Test Mode for CI/CD Integration Testing

Last updated: November 7, 2024

Orb provides a test mode environment that allows you to integrate automated testing into your CI/CD pipeline. This article explains how to effectively use Orb's test mode for integration testing without affecting your production data or hitting rate limits.

Using the Dry-Run Header

The key to testing Orb integrations in your CI pipeline is the `Dry-run` request header. This header allows you to simulate API actions without saving any changes, making it ideal for automated testing.

To use the dry-run feature:

  1. Add the `Dry-run: true` header to your API requests in your test scripts.

  2. Send requests to Orb's API as you normally would.

  3. The API will return responses as if the action occurred, but no changes will be saved.

For more information on the dry-run feature, see the Dry Run documentation.

Setting Up E2E Tests

To set up end-to-end (E2E) tests that validate the entire workflow, follow these steps:

  1. Create test resources: Set up a fixed group of resources in Orb specifically for testing purposes.

  2. Simulate actions: Use the dry-run header to simulate actions on these resources without committing changes.

  3. Validate responses: Check the API responses to ensure they match expected outcomes.

Example E2E Test Workflow

Here's an example of how you might structure your E2E tests:

  1. Create a Customer: Use a dry run to simulate customer creation and validate the response.

  2. Subscribe a Customer to a Plan: Pre-create a customer in Orb, then use a dry run to simulate subscription creation.

  3. Change a Plan: Use the pre-created customer to test plan changes (upgrades/downgrades) with dry runs.

  4. Cancel a Subscription: Simulate subscription cancellation using the same pre-created customer.

By following this approach, you can validate each step of your integration with Orb without making permanent changes to your test environment.

Best Practices

  • Be sure to only setup CI/CD tests in test mode

  • Create a set of test resources that remain constant between test runs.

  • Always use the dry-run header in your CI/CD pipeline to prevent unintended changes.

  • Validate both successful operations and error scenarios in your tests.

By following these guidelines, you can effectively test your Orb integration in your CI/CD pipeline without concerns about rate limits or unintended data changes.