This page describes how to replay incoming request traffic to another route for testing purposes.

Routing to production and testing servers.

The original and the replayed requests are independent. The replayed request is sent in background, and its response is not handled by the original route.

Some use cases:

  • Enable sandboxed testing at scale without significantly impacting production traffic or customer experience.
  • Sending real traffic that contains complex input combinations and edge cases.
  • Providing a way for load testing.
  • A good read on the availability and latency ranges under different production conditions.
  • Ensuring relevant operational insights, metrics and logging before migrating to production.

You can activate the feature configuring the target in the route metadata structured property replay.to. The property accepts a path or a URI as a value.

Note The property must be structured as an object, not a plain property.

Not valid configuration:

metadata:
  replay.to: /this-doesnt-work

Valid configuration:

metadata:
  replay:
    to: /this-works

Using the replay.to and the upstream request URI generated by Spring Cloud Gateway, the final URI to replay traffic is calculated following the next rules:

  • Any host, port and schema detected in replay.to overrides the upstream request URI.
  • Any path extracted from replay.to is added as a prefix to the path of the upstream request URI.
  • Any query parameter extracted from replay.to is concatenated to the current query parameters of the upstream request URI.
apiVersion: "tanzu.vmware.com/v1"
kind: SpringCloudGatewayRouteConfig
metadata:
  name: my-gateway-routes
spec:
  service:
    uri: https://production:443
  routes:
  - title: Case 1
    metadata:
      replay:
        to: http://development:8080
    predicates:
      - Path=/case-1/animals/**
  - title: Case 2
    metadata:
      replay:
        to: http://development:80/testing
    predicates:
      - Path=/case-2/animals/**
  - title: Case 3
    metadata:
      replay:
        to: /
    predicates:
      - Path=/case-3/animals/**
  - title: Case 4
    metadata:
      replay:
        to: /testing
    predicates:
      - Path=/case-4/animals/**

For the above routes, when the URI resolved by Spring Cloud Gateway is "https://production:443/animals/1" the traffic will be replayed to:

  • Case 1: "http://development:8080/animals/1"
  • Case 2: "http://development:80/testing/animals/1"
  • Case 3: "https://production:443/animals/1"
  • Case 4: "https://production:443/testing/animals/1"
check-circle-line exclamation-circle-line close-line
Scroll to top icon