This page describes how to replay incoming request traffic to another route for testing purposes.
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:
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:
replay.to
overrides the upstream request URI.replay.to
is added as a prefix to the path of the upstream request URI.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: