Jmeter邮件通知配置

问题描述 投票:0回答:2

对于jmeter中的通知邮件,我按照https://www.blazemeter.com/blog/load-testing-your-email-server-how-send-and-receive-e-mails-jmeter中的步骤进行操作。

但是执行测试后我无法得到结果。请查看我所附的屏幕截图,了解我在 SMTP 采样器中所做的所有配置。enter image description here

请让我知道我需要在此处添加什么才能使其成功运行。

jmeter
2个回答
0
投票

假设这是您的 SMTP 请求采样器配置:

根据 Google SMTP 配置说明,如果您使用端口

587
,您需要勾选
Use StartTLS
单选按钮。

或者,您可以将端口更改为

465
并勾选
Use SSL
按钮。

我认为 Gmail 不会接受非加密邮件。请再次阅读负载测试您的电子邮件服务器:如何使用 JMeter 发送和接收电子邮件,并更加注意其中提到的正确配置:


0
投票

String jsonData = "{" +
    "\"Blacklist Add User\": {" +
    "\"transaction\": \"Blacklist Add User\"," +
    "\"sampleCount\": 1," +
    "\"errorCount\": 0," +
    "\"errorPct\": 0.0," +
    "\"meanResTime\": 337.0," +
    "\"medianResTime\": 337.0," +
    "\"minResTime\": 337.0," +
    "\"maxResTime\": 337.0," +
    "\"pct1ResTime\": 337.0," +
    "\"pct2ResTime\": 337.0," +
    "\"pct3ResTime\": 337.0," +
    "\"throughput\": 2.967359050445104," +
    "\"receivedKBytesPerSec\": 1.6662416543026706," +
    "\"sentKBytesPerSec\": 1.4778839020771513" +
    "}," +
    "\"Total\": {" +
    "\"transaction\": \"Total\"," +
    "\"sampleCount\": 4," +
    "\"errorCount\": 0," +
    "\"errorPct\": 0.0," +
    "\"meanResTime\": 187.75," +
    "\"medianResTime\": 188.5," +
    "\"minResTime\": 37.0," +
    "\"maxResTime\": 337.0," +
    "\"pct1ResTime\": 337.0," +
    "\"pct2ResTime\": 337.0," +
    "\"pct3ResTime\": 337.0," +
    "\"throughput\": 5.141388174807197," +
    "\"receivedKBytesPerSec\": 2.214211118251928," +
    "\"sentKBytesPerSec\": 2.4539584672236505" +
    "}" +
    "}";

// Parse JSON
Object json = new groovy.json.JsonSlurper().parseText(jsonData);

// Find the maximum length of keys and values
int maxKeyLength = 0;
int maxValueLength = 0;

for (Object key : ((Map) json).keySet()) {
    maxKeyLength = Math.max(maxKeyLength, ((String) key).length());
    Map<String, Object> transactionData = (Map<String, Object>) ((Map) json).get(key);
    for (Object value : transactionData.keySet()) {
        if (value instanceof String) {
            maxValueLength = Math.max(maxValueLength, ((String) value).length());
        } else {
            maxValueLength = Math.max(maxValueLength, String.valueOf(value).length());
        }
    }
}

// Construct text table
StringBuilder textTable = new StringBuilder();
textTable.append("-".repeat(maxKeyLength + maxValueLength + 5)).append("\n");
textTable.append(String.format("| %-" + maxKeyLength + "s | %-" + maxValueLength + "s |\n", "Key", "Value"));
textTable.append("-".repeat(maxKeyLength + maxValueLength + 5)).append("\n");

for (Object key : ((Map) json).keySet()) {
    if (key instanceof String) {
        textTable.append(String.format("| %-" + maxKeyLength + "s | ", key));
        Map<String, Object> transactionData = (Map<String, Object>) ((Map) json).get(key);
        for (Object value : transactionData.values()) {
            if (value instanceof String) {
                textTable.append(String.format("%-" + maxValueLength + "s |", value));
            } else {
                textTable.append(String.format("%-" + maxValueLength + "s |", String.valueOf(value)));
            }
        }
        textTable.append("\n");
    }
}

textTable.append("-".repeat(maxKeyLength + maxValueLength + 5)).append("\n");

// Construct HTML table
StringBuilder htmlTable = new StringBuilder();
htmlTable.append("<table border='1'>");

// Table header
htmlTable.append("<tr>");
for (Object key : ((Map) json).keySet()) {
    htmlTable.append("<th>").append(key).append("</th>");
}
htmlTable.append("</tr>");

// Table rows
for (Object value : ((Map) json).values()) {
    htmlTable.append("<tr>");
    for (Object nestedValue : ((Map) value).values()) {
        htmlTable.append("<td>").append(nestedValue).append("</td>");
    }
    htmlTable.append("</tr>");
    }

    htmlTable.append("</table>");

    // Store text table and HTML table in JMeter variables
    vars.put("textTable", textTable.toString());
    vars.put("htmlTable", htmlTable.toString());

© www.soinside.com 2019 - 2024. All rights reserved.