Artillery.io-POST二进制数据

时间:2018-08-02 21:53:39

标签: binary load load-testing binary-data artillery

您如何通过炮兵发送带有二进制数据的POST请求?更具体地说,我正在尝试进行批处理请求,并从文件中读取炮兵的尸体

我确实在文档中看到我需要使用自定义JS函数,但似乎无法正确将值传递回火炮:

https://artillery.io/docs/http-reference/#advanced-writing-custom-logic-in-javascript

1 个答案:

答案 0 :(得分:1)

我阅读了有关可以自定义js的文章,

'use strict';
 module.exports = {
  generateRandomPayload
};
var contents = require('fs').readFileSync("/home/ec2-user/image_data/data6.json");

function generateRandomPayload(userContext, events, done) {
  var payload = {
    "data":"data"
  };
payload = JSON.parse(contents);
userContext.vars.payload = payload;
return done();
}

火炮的Yaml文件可以像这样:

config:
target: "https://0giahrna63.execute-api.us-east-1.amazonaws.com/Prod/"
processor: "./image-payload.js"
phases:
   - duration: 120
   - arrivalRate: 1
scenarios:
   - flow:
   - function: "generateRandomPayload"
   - post:
      url: "/resource"
      json: "{{payload}}"