---
teardown:
  - do:
      ingest.delete_pipeline:
        id: "my_pipeline"
        ignore: 404

---
"Test foreach Processor":
  - do:
      ingest.put_pipeline:
        id: "my_pipeline"
        body:  >
          {
            "description": "_description",
            "processors": [
              {
                "foreach" : {
                  "field" : "values",
                  "processor" : {
                      "uppercase" : {
                        "field" : "_ingest._value"
                      }
                  }
                }
              }
            ]
          }
  - match: { acknowledged: true }

  - do:
      index:
        index: test
        id: "1"
        pipeline: "my_pipeline"
        body: >
          {
            "values": ["foo", "bar", "baz"]
          }

  - do:
      get:
        index: test
        id: "1"
  - match: { _source.values: ["FOO", "BAR", "BAZ"] }

 #exceeds the recurse max per thread and will runs some of these on a different thread
  - do:
      index:
        index: test
        id: "1"
        pipeline: "my_pipeline"
        body: >
          {
            "values": ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
                       "v", "w", "x", "y", "z"]
          }

  - do:
      get:
        index: test
        id: "1"
  - match: { _source.values: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U",
                              "V", "W", "X", "Y", "Z"] }
