注意:邮递员请求工作正常
我已完成以下操作:
运行 postman-to-k6 命令:
postman-to-k6 loadTest.postman_collection.json -o k6-script.js
使用http-debug标志运行k6命令来运行命令
k6 run --out csv=test_results.csv k6-script.js --http-debug="full"
// Auto-generated by the postman-to-k6 converter
export let options = { maxRedirects: 4 };
const Request = Symbol.for("request");
postman[Symbol.for("initial")]({
options
});
export default function() {
postman[Request]({
name: "Campaigns",
id: "189fa369-87c7-4dcb-bf9d-e812d4efd6e8",
method: "POST",
address: "https://api.beta.detail-page.journeys.a2z.com/graphql",
data:
'{"query":"\\n query campaigns($projectId: ID!) {\\n campaigns(projectId: $projectId) {\\n id\\n createdAt\\n createdBy\\n typeId\\n originalPodData\\n useReactAppUrl\\n }\\n }\\n ","variables":{"projectId":"ghost:PublishTest 2:US"}}',
headers: {
"Content-Type": "application/json",
identitytoken: <Backend-JWT-Token>
},
auth(config, Var) {
const address = new URI(config.address);
const options = {
method: "POST",
protocol: address.protocol(),
hostname: address.hostname(),
port: address.port(),
path: address.path() + address.search(),
body: config.data,
region: "us-west-2",
service: <Service-Name>
};
const credential = {
accessKeyId: <accessKey-ID>,
secretAccessKey: <Secret-key>,
sessionToken: <Session-token>
};
const signed = aws4.sign(options, credential);
const [path, query = ""] = signed.path.split("?");
config.address = new URI()
.protocol(address.protocol())
.hostname(signed.hostname)
.path(path)
.query(query)
.toString();
Object.assign(config.headers, signed.headers);
}
});
});
}
信息[0004]请求:
POST /graphql HTTP/1.1
Host: api.beta.detail-page.journeys.a2z.com
User-Agent: k6/0.40.0 (https://k6.io/)
Content-Length: 354
Authorization: AWS4-HMAC-SHA256 Credential=ASIAVGC47R5TZOZXHHNM/20221025/us-west-2/execute-api/aws4_request, SignedHeaders=content-length;content-type;host;x-amz-date;x-amz-security-token, Signature=9dceffc3e3376fd6f9b860025ce9a82454f740bd189ffa8da3c0a6d8d83e230f
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Identitytoken: <Identity-token>
X-Amz-Date: 20221025T200827Z
X-Amz-Security-Token: <Security-token>
Accept-Encoding: gzip
INFO[0004] Response:
HTTP/2.0 500 Internal Server Error
Content-Length: 61
Access-Control-Allow-Origin: *
Content-Type: text/html; charset=utf-8
Date: Tue, 25 Oct 2022 20:08:27 GMT
Etag: W/"3d-hTSca7jJI4XwK3C0Li5aF8JIkvc"
X-Amz-Apigw-Id: ak9JUEu-PHcFefQ=
X-Amzn-Remapped-Connection: close
X-Amzn-Remapped-Content-Length: 61
X-Amzn-Remapped-Date: Tue, 25 Oct 2022 20:08:27 GMT
X-Amzn-Requestid: bee58104-704c-4cb0-9ec4-399e6f69450d
X-Amzn-Trace-Id: Root=1-6358423b-5dc39ed81536364944f6bd11
X-Powered-By: Express
POST 正文丢失。您忘记使用 body-parser 中间件了吗?组= iter=0 request_id=ad10989c-1023-46c9-5f34-e381a7d5795b 场景=默认源=http-debug vu=1
有人可以发布针对此问题的修复吗