dotnet / crank

Benchmarking infrastructure for applications
MIT License
970 stars 103 forks source link

Passing a body in .yml for POST scenarios #747

Closed vabic closed 1 month ago

vabic commented 1 month ago

I want to pass a body to benchmark.yml for POST verb. The Body should be a json object with a property Id and value. like this

{
  "Id" : "49E950A4-CB18-4A92-9CE7-08DC8FCD9A06"
}

1.

  post_scenario:
    load:
      job: bombardier
      variables:
        path: "{{BaseUrl}}/v2/entity/SetRefId"
        customHeaders: ["Authorization: Bearer {{token}}", "content-type: application/json"]
        connections: 1
        requests: 1
        warmup: 0
        timeout: 600
        body: '{"refId" : "49E950A4-CB18-4A92-9CE7-08DC8FCD9A06"}'
        verb: POST

Never work -- the parsed body is always in wrong format. Could you please give an example how to pass this variable correctly?

  post_scenario:
    load:
      job: bombardier
      variables:
        path: "{{BaseUrl}}/v2/entity/SetRefId"
        customHeaders: ["Authorization: Bearer {{token}}", "content-type: application/json"]
        connections: 1
        requests: 1
        warmup: 0
        timeout: 600
        bodyFile: path/to/file.json
        verb: POST

Works well, but the file is removed after the run !! So, why crank removed my file?

sebastienros commented 1 month ago

I confirm these are two bugs

the -b argument that is passed is not read by the C# code. We need to fix it.

The deleted fiel is also a bug. It's working fine when downloading urls locally, but otherwise it should know to not delete it.

https://github.com/dotnet/crank/blob/main/src/Microsoft.Crank.Jobs.Bombardier/Program.cs#L140