Would Match.percent be useful?

Yesterday I wanted to test something that required multiple fault injections for my route. Basically I wanted to return a mix of 2xx, 3xx, 4xx and 5xx response codes. I found that this was not easily configured as a route allows for only one fault.

After playing with it (for way-too-long), I found a “hack” way to do what I wanted. I configured multiple routes under match expressions that used regex against the x-request-id http header (yaml below) to sort-of randomly distribute the matching.

Assuming routes will continue to be limited to a single fault, this sort of testing could be easier with something like match.percent, that simply matched on some percentage of requests. Would something like this be useful to others? Or maybe I completely missed an easier way to accomplish what I wanted to do.

Here is the VS I came up with:

---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: details-abort-vs
spec:
  hosts:
  - details
  http:
  - match:
    - headers:
        x-request-id:
          regex: "^[1234].*"
    route:
      - destination:
          host: details
          subset: details-abort-dr-subset-v1
    fault:
      abort:
        httpStatus: 333
        percent: 100
  - match:
    - headers:
        x-request-id:
          regex: "^[5678].*"
    route:
      - destination:
          host: details
          subset: details-abort-dr-subset-v1
    fault:
      abort:
        httpStatus: 444
        percent: 100
  - match:
    - headers:
        x-request-id:
          regex: "^[90ab].*"
    route:
      - destination:
          host: details
          subset: details-abort-dr-subset-v1
    fault:
      abort:
        httpStatus: 555
        percent: 100
  - route:
    - destination:
        host: details
        subset: details-abort-dr-subset-v1
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: details-abort-dr
spec:
  host: details
  subsets:
  - name: details-abort-dr-subset-v1
    labels:
      version: v1