1

I'm using Artillery with Node.js to load testing a free API.

My purpose would be to list the name of French department with a file of department numbers. To do that I need to do GET request to the following URL and change the department number which is the main parameter.

"https://geo.api.gouv.fr/departements/75?fields=region"

So far I can do it if I list myself the number in the scenario (which is not practical as I have a file listing the department numbers), as an example I only list "76" and "77":

config:
  target: "https://geo.api.gouv.fr/departements/01?fields=region"
  phases:
    - duration: 3
      arrivalRate: 1
      name: Warm up
  variables:
    dep:
    - "76"
    - "77"

scenarios:
  - name: "Discover department"
    flow:
      - get:
          url: "https://geo.api.gouv.fr/departements/{{ dep }}?fields=region"
          capture:
              - json: "$.nom"
                as: "result"   
      - log: "this is {{ result }}"
      - think: 1

I don't get error and I get my log "this is Seine-et-Marne | this is Seine-Maritime | this is Seine-et-Marne", which is enough for me.

Now I tried to use a CSV file with "76" and "77" from the path: "../source/departement.csv":

config:
  target: "https://geo.api.gouv.fr/departements/01?fields=region"
  phases:
    - duration: 3
      arrivalRate: 1
      name: Warm up
  payload:
    path: "../source/departement.csv"
    fields:
      - "departement"


scenarios:
  - name: "Discover department"
    flow:
      - get:
          url: "https://geo.api.gouv.fr/departements/{{ departement }}?fields=region"
          json:
            kw: "{{ departement }}" 
          capture:
              - json: "$.nom"
                as: "result"
      - log: "c'est bon {{ result }} "
      - think: 1

But this time I get errors:

errors.ERR_GOT_REQUEST_ERROR: .................................................. 3
vusers.created: ................................................................ 3
vusers.created_by_name.Discover department: .................................... 3
vusers.failed: ................................................................. 3

Any ideas what's wrong?

To run the test, I'm using the command line:

artillery run <script>

Edit: In the scenario, by changing:

json:
     kw: "{{ departement }}" 

to:

csv:
     kw: "{{ departement }}" 

I'm getting kind of good result:

http.responses: .................................................. 3
vusers.completed: ................................................ 1
vusers.created: .................................................. 3
vusers.created_by_name.Discover department: ...................... 3
vusers.failed: ................................................... 2

Sometimes, it's either 1 or 2 vusers.failed, this is strange. The first method I wrote always return 0 vusers.failed.

GrowyTobe
  • 115
  • 1
  • 8

0 Answers0