10

I'm trying to set Artillery config to be able to send nested JSON body. This is how my configuration looks like:

config:
  target: <URL>
  phases:
    - duration: 10
      arrivalRate: 20
  processor: "./input-parser.js"
scenarios:
  - flow:
    - function: "parseJsonFile"
    - post:
        url: /workflow-instance
        headers:
           Content-Type: "application/json"
        json:
          name: "{{ name }}"
          namespace: "{{ namespace }}"
          template_name: "{{ template_name }}"
          attributes: "{{ attributes }}"
    - get:
        url: "/workflow-instance/status?name={{ template_name }}&namespace={{ namespace }}"

I have a problem with "attributes" because the content of attributes is:

{ pod_name: 'POD_NAME', port: 'PORT_NUMBER' }

So basically, this will not work:

attributes: "{ pod_name: 'POD_NAME', port: 'PORT_NUMBER' }"

as well as this:

attributes:
  pod_name: 'POD_NAME'
  port: 'PORT_NUMBER'

I didn't found good examples for this particular case in Artillery docs.

Rob
  • 14,746
  • 28
  • 47
  • 65
Bakir Jusufbegovic
  • 2,806
  • 4
  • 32
  • 48

2 Answers2

1

The following workaround worked for me Embedding JSON Data into YAML file

Then you'd have to change your attributes for:

attributes: '{ pod_name: "POD_NAME", port: "PORT_NUMBER" }'

I'm using:

Artillery: 1.7.9
Artillery Pro: not installed (https://artillery.io/pro)
Node.js: v14.6.0
OS: darwin/x64
jmartori
  • 384
  • 1
  • 5
  • 14
0

For future readers looking for hardcoding nested JSON, this worked for me:

...
scenarios:
  -
    flow:
      -
        post:
          url: "/"
          json:
            text: {"filter": {"enabled": true}}
sP_
  • 1,738
  • 2
  • 15
  • 29