This feature allows you to define set of simple rules, and test the traffic against them. Such validation may test response for specific JSON fields, headers, etc.
Example 1: HTTP request (REST API call) that didn't pass validation is highlighted in red
Example 2: Details pane shows the validation rule details and whether it passed or failed
To use this feature - create simple rules file (see details below) and pass this file as parameter to mizu tap
command. For example, if rules are stored in file named rules.yaml
— run the following command:
mizu tap --traffic-validation-file rules.yaml
The structure of the traffic-validation-file is:
name
: string, name of the ruletype
: string, type of the rule, must bejson
orheader
orslo
key
: string, jsonpath used only injson
orheader
typevalue
: string, regex used only injson
orheader
typeservice
: string, regex service name to filterpath
: string, regex URL path to filterresponse-time
: integer, time in ms of the expected latency.
rules:
- name: holy-in-name-property
type: json
key: "$.name"
value: "Holy"
service: "catalogue.*"
path: "catalogue.*"
- name: content-length-header
type: header
key: "Content-Le.*"
value: "(\\d+(?:\\.\\d+)?)"
- name: latency-test
type: slo
response-time: 1
service: "carts.*"
-
First rule
holy-in-name-property
:This rule will be applied to all request made to
catalogue.*
services withcatalogue.*
on the URL path with a json response containing a$.name
field. If the value of$.name
isHoly
than is marked as success, marked as failure otherwise. -
Second rule
content-length-header
:This rule will be applied to all request that has
Content-Le.*
on header. If the value ofContent-Le.*
is(\\d+(?:\\.\\d+)?)
(number), will be marked as success, marked as failure otherwise. -
Third rule
latency-test
:This rule will be applied to all request made to
carts.*
services. If the latency of the response is greater than1ms
will be marked as failure, marked as success otherwise.