Back to Vector

Vector Config Unit Testing Improvements

website/content/en/highlights/2022-01-12-vector-unit-test-improvements.md

0.55.01.3 KB
Original Source

We've added support for unit testing transforms with multiple outputs as well as full support for testing task-style transforms (previously there may have been issues when using multiple inputs with task transforms). For example, you can now test remap transform's dropped output like so,

yaml
transforms:
  foo:
    type: "remap"
    inputs: []
    drop_on_abort: true
    reroute_dropped: true
    source: "abort"

tests:
  - name: "remap_dropped_output"
    no_outputs_from: ["foo"]
    inputs:
      - insert_at: "foo"
        type: "log"
        log_fields:
          message: "I will be dropped"
    outputs:
      - extract_from: "foo.dropped"
        conditions:
          - type: "vrl"
            source: 'assert_eq!(.message, "I will be dropped", "incorrect message")'

Under-the-hood, we've reworked the unit testing implementation to more closely align with how a configuration actually runs, making it easier to support testing new features. However, as a result, some unit testing debug UX has also changed: previously, on a test condition error, debug output included input event information representing the event(s) prior to being transformed. input event information is no longer available. The original input event(s) for a test can be determined from your configuration.