Continuous Testing and CircleCI Orb

Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

Overview

CircleCI Build Status CircleCI Orb Version Apache 2.0 License CircleCI Community

Run Synthetic tests in your CircleCI pipelines using the Datadog CircleCI orb.

The CircleCI command orb installs datadog-ci and uses the datadog-ci synthetics run-tests command to execute Datadog Synthetic tests.

Setup

To get started:

  1. Add your Datadog API and application keys as environment variables to your CircleCI project.
  2. Ensure the image running the orb is a Linux x64 base image with cURL installed.
  3. Customize your workflow by creating a run-tests.yml file and following the naming conventions to specify inputs for your workflow.

Your workflow can be simple or complex.

Simple usage

Example orb usage using public IDs

version: 2.1

orbs:
  synthetics-ci: datadog/synthetics-ci-orb@4.2.0

jobs:
  e2e-tests:
    docker:
      - image: cimg/base:stable
    steps:
      - synthetics-ci/run-tests:
          public_ids: |
            abc-d3f-ghi
            jkl-mn0-pqr            

workflows:
  run-tests:
    jobs:
      - e2e-tests

Example orb usage using a global configuration override

This orb overrides the path to the pattern for test files.

version: 2.1

orbs:
  synthetics-ci: datadog/synthetics-ci-orb@4.2.0

jobs:
  e2e-tests:
    docker:
      - image: cimg/base:stable
    steps:
      - synthetics-ci/run-tests:
          files: e2e-tests/*.synthetics.json

workflows:
  run-tests:
    jobs:
      - e2e-tests

For another example pipeline that triggers Synthetic tests, see the simple-example.yml file.

Complex usage

Example orb usage using the test_search_query

version: 2.1

orbs:
  synthetics-ci: datadog/synthetics-ci-orb@4.2.0

jobs:
  e2e-tests:
    docker:
      - image: cimg/base:stable
    steps:
      - synthetics-ci/run-tests:
          test_search_query: 'tag:e2e-tests'

workflows:
  run-tests:
    jobs:
      - e2e-tests

Example orb usage using the Continuous Testing Tunnel

version: 2.1

orbs:
  synthetics-ci: datadog/synthetics-ci-orb@4.2.0

jobs:
  e2e-tests:
    docker:
      - image: your-image
    steps:
      - checkout
      - run:
          name: Running server in background
          command: npm start
          background: true
      - synthetics-ci/run-tests:
          config_path: tests/tunnel-config.json
          files: tests/*.synthetics.json
          test_search_query: 'tag:e2e-tests'
          tunnel: true

workflows:
  test-server:
    jobs:
      - build-image
      - integration-tests:
          requires:
            - build-image

For additional options such as customizing the batchTimeout for your CircleCI pipelines, see CI/CD Integrations Configuration. For another example pipeline that starts a local server and triggers Synthetic tests using the Continuous Testing Tunnel, see the advanced-example.yml file.

Inputs

To customize your workflow, you can set the following parameters in a run-tests.yml file:

NameDescription
api_keyThe name of the environment variable containing the API key.
Default: DATADOG_API_KEY
app_keyThe name of the environment variable containing the APP key.
Default: DATADOG_APP_KEY
backgroundWhether or not this step should run in the background.
See official CircleCI documentation for the default value.
batch_timeoutThe duration (in milliseconds) after which the batch fails as timed out.
Default: 1800000 (30 minutes)
config_pathThe global JSON configuration used when launching tests.
Default: datadog-ci.json
fail_on_critical_errorsFail if tests were not triggered or results could not be fetched.
Default: false
fail_on_missing_testsFail if at least one specified test with a public ID (using public_ids or listed in a test file) is missing in a run (for example, if it has been deleted programmatically or on the Datadog site).
Default: false
fail_on_timeoutForce the CI to fail (or pass) if one of the results exceeds its test timeout.
Default: true
filesA list of glob patterns to detect Synthetic tests config files, separated by new lines.
Default: {,!(node_modules)/**/}*.synthetics.json
junit_reportThe filename for a JUnit report if you want to generate one.
Default: none
locationsString of locations separated by semicolons to override the locations where your tests run.
Default: none
no_output_timeoutElapsed time the command can run without output. The string is a decimal with unit suffix, such as “20m”, “1.25h”, “5s”.
See official CircleCI documentation for the default value.
public_idsPublic IDs of Synthetic tests to run, separated by new lines or commas. If no value is provided, tests are discovered in *.synthetics.json files.
Default: none
siteThe Datadog site to send data to. If the DD_SITE environment variable is set, it takes preference.
Default: datadoghq.com
subdomainThe name of the custom subdomain set to access your Datadog application.
Default: app
test_search_queryTrigger tests corresponding to a search query.
Default: none
tunnelUse the Continuous Testing Tunnel to trigger tests.
Default: false
variablesKey-value pairs for injecting variables into tests, separated by newlines or commas. For example: START_URL=https://example.org,MY_VARIABLE=My title.
Default: none

To learn about additional options for your CircleCI pipelines, see Continuous Testing & CI/CD Integrations Configuration.

Further reading

Additional helpful documentation, links, and articles:

PREVIEWING: yuqing.bian/fix-sources-searchterm