Artillery.io - POST 二进制数据

Artillery.io - POST binary data

你如何通过 artillery 发送带有二进制数据的 POST 请求?更具体地说,我正在尝试执行批处理请求并从 body

文件中读取 artillery

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

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

我看了post自定义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}}"