我正在将blazemeter/taurus:1.13.2
Docker映像与blazemeter报告模块一起使用以执行测试。
在taurus命令行中是否可以通过某种方式为BlazeMeter上的“ Notes”字段传递值?我已经成功传递了其他值,例如:
-o modules.blazemeter.report-name="${report_name}"
我希望传递“注释”所需要的全部类似。我尝试过:
-o modules.blazemeter.notes="${notes}"
但没有运气。
这是我运行完整命令行的脚本:
#!/bin/bash
api_token=$1
timestamp=`date +%s`
report_name="`hostname`_`git log --format='%h' -n 1`_taurus-jmeter_${timestamp}"
notes="testing use of notes through taurus command line args"
artifacts_dir="artifacts/${timestamp}"
docker run -t --rm -v `pwd`:/bzt-configs -v `pwd`/artifacts:/tmp/artifacts blazemeter/taurus:1.13.2 taurus.yml -o settings.artifacts-dir="${artifacts_dir}" -o modules.blazemeter.report-name="${report_name}" -o modules.blazemeter.notes="${notes}" -o modules.blazemeter.token="${api_token}"
答案 0 :(得分:1)
使用JMeter,您可以使用此代码,并将其放在JSR223 Sampler内的setup Thread Group中 或者,您可以使用Shell Exec。
Java中的代码: URL url =新URL(“ https://a.blazemeter.com:443/api/v4/masters/” + masterId); HttpURLConnection conn = null; 尝试{ conn =(HttpURLConnection)url.openConnection(); conn.setRequestMethod(“ POST”); conn.setRequestProperty(“ Content-Type”,“ application / json”); conn.setDoInput(true); conn.setDoOutput(true);
/* We use the API Key and API Secret as Basic Authentication */
String usernameColonPassword = "" + X_GlobalVariables.BZM_API_KEY + ":" + X_GlobalVariables.BZM_API_SECRET + "";
String basicAuthPayload = "Basic " + Base64.getEncoder().encodeToString(usernameColonPassword.getBytes());
// Include the HTTP Basic Authentication payload
conn.addRequestProperty("Authorization", basicAuthPayload);
//Create JSONObject here
JSONObject jsonParam = new JSONObject();
jsonParam.put("note", "Service Version: " + serviceVersion + "\nGateway Version: " + gatewayVersion + "");
try (OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream())) {
out.write(jsonParam.toString());
}
/* Check here for a OK (200) response */
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
/* Release the connection */
} finally {
if (conn != null) {
conn.disconnect();
}
}
来源: