Java Code Examples for org.apache.jmeter.samplers.SampleResult#isSuccessful()
The following examples show how to use
org.apache.jmeter.samplers.SampleResult#isSuccessful() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ElasticsearchBackendClient.java From jmeter-elasticsearch-backend-listener with MIT License | 6 votes |
/** * This method will validate the current sample to see if it is part of the filters or not. * * @param context * The Backend Listener's context * @param sr * The current SampleResult * @return true or false depending on whether or not the sample is valid */ private boolean validateSample(BackendListenerContext context, SampleResult sr) { boolean valid = true; String sampleLabel = sr.getSampleLabel().toLowerCase().trim(); if (this.filters.size() > 0) { for (String filter : filters) { Pattern pattern = Pattern.compile(filter); Matcher matcher = pattern.matcher(sampleLabel); if (!sampleLabel.startsWith("!!") && (sampleLabel.contains(filter) || matcher.find())) { valid = true; break; } else { valid = false; } } } // if sample is successful but test mode is "error" only if (sr.isSuccessful() && context.getParameter(ES_TEST_MODE).trim().equalsIgnoreCase("error") && valid) { valid = false; } return valid; }
Example 2
Source File: ConsoleStatusLogger.java From jmeter-plugins with Apache License 2.0 | 6 votes |
@Override public synchronized void sampleOccurred(SampleEvent se) { // TODO: make the interval configurable long sec = System.currentTimeMillis() / 1000; if (sec != cur && count > 0) { if (cur == 0) { begin = sec; } log.debug(cur + " " + begin); flush(sec - begin); cur = sec; } SampleResult res = se.getResult(); count++; sumRTime += res.getTime(); sumLatency += res.getLatency(); errors += res.isSuccessful() ? 0 : 1; threads = res.getAllThreads(); }
Example 3
Source File: LoadosophiaClient.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
private JSONObject getAggregateSecond(Long sec, List<SampleResult> raw) { /* "rc": item.http_codes, "net": item.net_codes */ JSONObject result = new JSONObject(); Date ts = new Date(sec * 1000); log.debug("Aggregating " + sec); result.put("ts", format.format(ts)); int avg_rt = 0; Long[] rtimes = new Long[raw.size()]; String[] rcodes = new String[raw.size()]; int cnt = 0; int failedCount = 0; long maxThreadCount = 0; for (SampleResult res : raw) { if (maxThreadCount < res.getAllThreads()) { maxThreadCount = res.getAllThreads(); } avg_rt += res.getTime(); rtimes[cnt] = res.getTime(); rcodes[cnt] = res.getResponseCode(); if (!res.isSuccessful()) { failedCount++; } cnt++; } result.put("rps", cnt); result.put("threads", maxThreadCount); result.put("avg_rt", avg_rt / cnt); result.put("quantiles", getQuantilesJSON(rtimes)); result.put("net", getNetJSON(failedCount, cnt - failedCount)); result.put("rc", getRCJSON(rcodes)); result.put("planned_rps", 0); // JMeter has no such feature like Yandex.Tank return result; }
Example 4
Source File: JSONConverter.java From jmeter-bzm-plugins with Apache License 2.0 | 5 votes |
private static int getFails(List<SampleResult> list) { int res = 0; for (SampleResult result : list) { if (!result.isSuccessful()) { res++; } } return res; }
Example 5
Source File: AbstractMonitoringVisualizer.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void add(SampleResult res) { if (res.isSuccessful()) { if(isSampleIncluded(res)) { super.add(res); addMonitoringRecord(res.getSampleLabel(), normalizeTime(res.getStartTime()), MonitoringSampleResult.getValue(res)); updateGui(null); } } else { addErrorMessage(res.getResponseMessage(), res.getStartTime()); } }
Example 6
Source File: TransactionsPerSecondGui.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void add(SampleResult res) { if (!isSampleIncluded(res)) { return; } super.add(res); if (res.isSuccessful()) { addTransaction(true, res.getSampleLabel(), normalizeTime(res.getEndTime()), 1); } else { addTransaction(false, res.getSampleLabel(), normalizeTime(res.getEndTime()), 1); } updateGui(null); }
Example 7
Source File: PerfMonGui.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void add(SampleResult res) { if (res.isSuccessful()) { if (isSampleIncluded(res)) { super.add(res); addPerfMonRecord(res.getSampleLabel(), normalizeTime(res.getStartTime()), PerfMonSampleResult.getValue(res)); updateGui(null); } } else { addErrorMessage(res.getResponseMessage(), res.getStartTime()); } }
Example 8
Source File: JMXMonGui.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void add(SampleResult res) { if (res.isSuccessful()) { if (isSampleIncluded(res)) { super.add(res); addJmxMonRecord(res.getSampleLabel(), normalizeTime(res.getStartTime()), JMXMonSampleResult.getValue(res)); updateGui(null); } } else { addErrorMessage(res.getResponseMessage(), res.getStartTime()); } }
Example 9
Source File: DbMonGui.java From jmeter-plugins with Apache License 2.0 | 5 votes |
@Override public void add(SampleResult res) { if (res.isSuccessful()) { if(isSampleIncluded(res)) { super.add(res); addDbMonRecord(res.getSampleLabel(), normalizeTime(res.getStartTime()), DbMonSampleResult.getValue(res)); updateGui(null); } } else { addErrorMessage(res.getResponseMessage(), res.getStartTime()); } }
Example 10
Source File: JSONConverter.java From jmeter-bzm-plugins with Apache License 2.0 | 4 votes |
private static Map<String, Object> getMainMetrics(List<SampleResult> list) { long first = Long.MAX_VALUE; long last = 0; long failed = 0; long bytesCount = 0; long sumTime = 0; long sumLatency = 0; Long[] rtimes = new Long[list.size()]; int counter = 0; for (SampleResult sample : list) { long endTime = sample.getEndTime(); if (endTime < first) { first = endTime; } if (endTime > last) { last = endTime; } if (!sample.isSuccessful()) { failed++; } bytesCount += sample.getBytes(); sumTime += sample.getTime(); sumLatency += sample.getLatency(); rtimes[counter] = sample.getTime(); counter++; } final Map<String, Object> results = new HashMap<>(); results.put("first", first); results.put("last", last); results.put("failed", failed); results.put("bytesCount", bytesCount); results.put("sumTime", sumTime); results.put("sumLatency", sumLatency); results.put("rtimes", rtimes); return results; }
Example 11
Source File: HonoSender.java From hono with Eclipse Public License 2.0 | 4 votes |
/** * Publishes multiple messages to Hono. * * @param sampleResult The result object representing the combined outcome of the samples. * @param messageCount The number of messages to send * @param deviceId The identifier if the device to send a message for. * @param waitForDeliveryResult A flag indicating whether to wait for the result of the send operation. */ public void send(final SampleResult sampleResult, final int messageCount, final String deviceId, final boolean waitForDeliveryResult) { final long sampleStart = System.currentTimeMillis(); long addedSendDurations = 0; boolean isSuccessful = true; String firstResponseErrorMessage = ""; String firstResponseErrorCode = ""; long sentBytes = 0; int errorCount = 0; for (int i = 0; i < messageCount; i++) { final SampleResult subResult = new SampleResult(); subResult.setDataType(SampleResult.TEXT); subResult.setResponseOK(); subResult.setResponseCodeOK(); subResult.setSampleLabel(sampleResult.getSampleLabel()); // send the message send(subResult, deviceId, waitForDeliveryResult); // can't call sampleResult.addSubResult(subResult) here - this would prevent a later invocation of sampleResult.setStampAndTime() sampleResult.addRawSubResult(subResult); if (!subResult.isSuccessful()) { isSuccessful = false; errorCount++; if (firstResponseErrorMessage.isEmpty()) { firstResponseErrorMessage = subResult.getResponseMessage(); firstResponseErrorCode = subResult.getResponseCode(); } } sentBytes += subResult.getSentBytes(); addedSendDurations += subResult.getTime(); } sampleResult.setSuccessful(isSuccessful); final String responseMessage = MessageFormat.format("BatchResult {0}/{1}/{2}", sampler.getEndpoint(), sampler.getTenant(), deviceId); if (isSuccessful) { sampleResult.setResponseMessage(responseMessage); } else { sampleResult.setResponseMessage(responseMessage + ": " + errorCount + " errors - first: " + firstResponseErrorMessage); sampleResult.setResponseCode(firstResponseErrorCode); } sampleResult.setSentBytes(sentBytes); sampleResult.setSampleCount(messageCount); sampleResult.setErrorCount(errorCount); // NOTE: This method does nothing in JMeter 3.3/4.0 final long averageElapsedTimePerMessage = addedSendDurations / messageCount; sampleResult.setStampAndTime(sampleStart, averageElapsedTimePerMessage); }