org.apache.jmeter.visualizers.backend.BackendListenerContext Java Examples

The following examples show how to use org.apache.jmeter.visualizers.backend.BackendListenerContext. 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: JMeterInfluxDBImportFileClient.java    From JMeter-InfluxDB-Writer with Apache License 2.0 6 votes vote down vote up
@Override
public void teardownTest(BackendListenerContext context) throws Exception {
	LOGGER.info("Shutting down influxDB scheduler...");
	scheduler.shutdown();

	addVirtualUsersMetrics(0, 0, 0, 0, JMeterContextService.getThreadCounts().finishedThreads);
	Point endPoint = Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
			.tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.FINISHED).tag(TestStartEndMeasurement.Tags.TEST_NAME, testName).build();

	exportFileWriter.append(endPoint.lineProtocol());
	exportFileWriter.newLine();
	
	try {
		scheduler.awaitTermination(30, TimeUnit.SECONDS);
		LOGGER.info("influxDB scheduler terminated!");
	} catch (InterruptedException e) {
		LOGGER.error("Error waiting for end of scheduler");
	}

	samplersToFilter.clear();
	exportFileWriter.close();
	super.teardownTest(context);
}
 
Example #2
Source File: JMeterInfluxDBImportFileClient.java    From JMeter-InfluxDB-Writer with Apache License 2.0 6 votes vote down vote up
/**
 * Processes sampler results.
 */
public void handleSampleResults(List<SampleResult> sampleResults, BackendListenerContext context) {
	for (SampleResult sampleResult : sampleResults) {
		getUserMetrics().add(sampleResult);

		if ((null != regexForSamplerList && sampleResult.getSampleLabel().matches(regexForSamplerList)) || samplersToFilter.contains(sampleResult.getSampleLabel())) {
			Point point = Point.measurement(RequestMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
					.tag(RequestMeasurement.Tags.REQUEST_NAME, sampleResult.getSampleLabel()).addField(RequestMeasurement.Fields.ERROR_COUNT, sampleResult.getErrorCount())
					.addField(RequestMeasurement.Fields.RESPONSE_TIME, sampleResult.getTime()).build();
			try {
				exportFileWriter.append(point.lineProtocol());
				exportFileWriter.newLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
	}
}
 
Example #3
Source File: LoadosophiaClient.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Override
public void handleSampleResults(List<SampleResult> list, BackendListenerContext backendListenerContext) {
    if (list != null && isOnlineInitiated) {
        try {
            JSONArray array = getDataToSend(list);
            log.info(array.toString());
            apiClient.sendOnlineData(array);
        } catch (IOException ex) {
            log.warn("Failed to send active test data", ex);
        }
        try {
            Thread.sleep(delay);
        } catch (InterruptedException e) {
            log.warn("Backend listener client thread was interrupted");
        }
    }
}
 
Example #4
Source File: BlazemeterBackendListenerClientTest.java    From jmeter-bzm-plugins with Apache License 2.0 6 votes vote down vote up
@Test
public void testFlow() throws Exception {
    StatusNotifierCallbackTest.StatusNotifierCallbackImpl notifier = new StatusNotifierCallbackTest.StatusNotifierCallbackImpl();
    BlazeMeterBackendListenerClient client = new BLCEmul();
    final Arguments arguments = new Arguments();
    arguments.addArgument(BlazeMeterUploader.SHARE_TEST, Boolean.toString(false));
    arguments.addArgument(BlazeMeterUploader.PROJECT, "project");
    arguments.addArgument(BlazeMeterUploader.TITLE, "title");
    client.setupTest(new BackendListenerContext(arguments));
    client.setInformer(notifier);
    client.initiateOnline();
    assertNotNull(client.getApiClient());

    client.handleSampleResults(BlazemeterAPIClientTest.generateResults(), null);

    client.teardownTest(null);

    String output = notifier.getBuffer().toString();
    assertTrue(output.contains("No BlazeMeter API key provided, will upload anonymously"));
}
 
Example #5
Source File: ElasticSearchMetric.java    From jmeter-elasticsearch-backend-listener with MIT License 6 votes vote down vote up
/**
 * Methods that add all custom fields added by the user in the Backend Listener's GUI panel
 *
 * @param context BackendListenerContext
 */
private void addCustomFields(BackendListenerContext context) {
    Iterator<String> pluginParameters = context.getParameterNamesIterator();
    String parameter;
    while (pluginParameters.hasNext()) {
        String parameterName = pluginParameters.next();

        if (!parameterName.startsWith("es.") && context.containsParameter(parameterName)
                && !"".equals(parameter = context.getParameter(parameterName).trim())) {
            if (isCreatable(parameter)) {
                addFilteredJSON(parameterName, Long.parseLong(parameter));
            } else {
                addFilteredJSON(parameterName, parameter);
            }
        }
    }
}
 
Example #6
Source File: ElasticsearchBackendClient.java    From jmeter-elasticsearch-backend-listener with MIT License 6 votes vote down vote up
/**
 * 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 #7
Source File: BlazeMeterBackendListenerClient.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private void init(BackendListenerContext context) {
    report = new BlazeMeterReport();
    report.setShareTest(Boolean.valueOf(context.getParameter(BlazeMeterUploader.SHARE_TEST)));
    report.setProject(context.getParameter(BlazeMeterUploader.PROJECT));
    report.setTitle(context.getParameter(BlazeMeterUploader.TITLE));
    report.setToken(context.getParameter(BlazeMeterUploader.UPLOAD_TOKEN));
}
 
Example #8
Source File: JMeterInfluxDBImportFileClient.java    From JMeter-InfluxDB-Writer with Apache License 2.0 5 votes vote down vote up
/**
 * Parses list of samplers.
 * 
 * @param context
 *            {@link BackendListenerContext}.
 */
private void parseSamplers(BackendListenerContext context) {
	samplersList = context.getParameter(KEY_SAMPLERS_LIST, "");
	samplersToFilter = new HashSet<String>();
	if (context.getBooleanParameter(KEY_USE_REGEX_FOR_SAMPLER_LIST, false)) {
		regexForSamplerList = samplersList;
	} else {
		regexForSamplerList = null;
		String[] samplers = samplersList.split(SEPARATOR);
		samplersToFilter = new HashSet<String>();
		for (String samplerName : samplers) {
			samplersToFilter.add(samplerName);
		}
	}
}
 
Example #9
Source File: JMeterInfluxDBImportFileClient.java    From JMeter-InfluxDB-Writer with Apache License 2.0 5 votes vote down vote up
@Override
public void setupTest(BackendListenerContext context) throws Exception {
	testName = context.getParameter(KEY_TEST_NAME, "Test");

	File exportFile = new File(context.getParameter(KEY_FILE_PATH, "influxDBExport.txt"));

	if (exportFile.getParentFile() != null && !exportFile.getParentFile().exists()) {
		exportFile.getParentFile().mkdirs();
	}

	if (exportFile.exists()) {
		exportFile.delete();
		boolean created = exportFile.createNewFile();
		if (!created) {
			throw new RuntimeException("Export file could not be created!");
		}
	}

	exportFileWriter = new BufferedWriter(new FileWriter(exportFile));

	Point startPoint = Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
			.tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.STARTED).tag(TestStartEndMeasurement.Tags.TEST_NAME, testName).build();
	exportFileWriter.append(startPoint.lineProtocol());
	exportFileWriter.newLine();

	parseSamplers(context);
	scheduler = Executors.newScheduledThreadPool(1);

	scheduler.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS);
}
 
Example #10
Source File: InfluxDBConfig.java    From JMeter-InfluxDB-Writer with Apache License 2.0 5 votes vote down vote up
public InfluxDBConfig(BackendListenerContext context) {
	String influxDBHost = context.getParameter(KEY_INFLUX_DB_HOST);
	if (StringUtils.isEmpty(influxDBHost)) {
		throw new IllegalArgumentException(KEY_INFLUX_DB_HOST + "must not be empty!");
	}
	setInfluxDBHost(influxDBHost);

	int influxDBPort = context.getIntParameter(KEY_INFLUX_DB_PORT, InfluxDBConfig.DEFAULT_PORT);
	setInfluxDBPort(influxDBPort);

	String influxUser = context.getParameter(KEY_INFLUX_DB_USER);
	setInfluxUser(influxUser);

	String influxPassword = context.getParameter(KEY_INFLUX_DB_PASSWORD);
	setInfluxPassword(influxPassword);

	String influxDatabase = context.getParameter(KEY_INFLUX_DB_DATABASE);
	if (StringUtils.isEmpty(influxDatabase)) {
		throw new IllegalArgumentException(KEY_INFLUX_DB_DATABASE + "must not be empty!");
	}
	setInfluxDatabase(influxDatabase);

	String influxRetentionPolicy = context.getParameter(KEY_RETENTION_POLICY, DEFAULT_RETENTION_POLICY);
	if (StringUtils.isEmpty(influxRetentionPolicy)) {
		influxRetentionPolicy = DEFAULT_RETENTION_POLICY;
	}
	setInfluxRetentionPolicy(influxRetentionPolicy);
	
	String influxHTTPScheme = context.getParameter(KEY_HTTP_SCHEME, DEFAULT_HTTP_SCHEME);
	if (StringUtils.isEmpty(influxHTTPScheme)) {
		influxHTTPScheme = DEFAULT_HTTP_SCHEME;
	}
	// TODO: no checks but should be only "http" and "https"
	setInfluxHTTPScheme(influxHTTPScheme);
}
 
Example #11
Source File: JMeterInfluxDBBackendListenerClient.java    From JMeter-InfluxDB-Writer with Apache License 2.0 5 votes vote down vote up
/**
 * Parses list of samplers.
 * 
 * @param context
 *            {@link BackendListenerContext}.
 */
private void parseSamplers(BackendListenerContext context) {
	samplersList = context.getParameter(KEY_SAMPLERS_LIST, "");
	samplersToFilter = new HashSet<String>();
	if (context.getBooleanParameter(KEY_USE_REGEX_FOR_SAMPLER_LIST, false)) {
		regexForSamplerList = samplersList;
	} else {
		regexForSamplerList = null;
		String[] samplers = samplersList.split(SEPARATOR);
		samplersToFilter = new HashSet<String>();
		for (String samplerName : samplers) {
			samplersToFilter.add(samplerName);
		}
	}
}
 
Example #12
Source File: JMeterInfluxDBBackendListenerClient.java    From JMeter-InfluxDB-Writer with Apache License 2.0 5 votes vote down vote up
/**
 * Setup influxDB client.
 * 
 * @param context
 *            {@link BackendListenerContext}.
 */
private void setupInfluxClient(BackendListenerContext context) {
	influxDBConfig = new InfluxDBConfig(context);
	influxDB = InfluxDBFactory.connect(influxDBConfig.getInfluxDBURL(), influxDBConfig.getInfluxUser(), influxDBConfig.getInfluxPassword());
	influxDB.enableBatch(100, 5, TimeUnit.SECONDS);
	createDatabaseIfNotExistent();
}
 
Example #13
Source File: JMeterInfluxDBBackendListenerClient.java    From JMeter-InfluxDB-Writer with Apache License 2.0 5 votes vote down vote up
@Override
public void teardownTest(BackendListenerContext context) throws Exception {
	LOGGER.info("Shutting down influxDB scheduler...");
	scheduler.shutdown();

	addVirtualUsersMetrics(0,0,0,0,JMeterContextService.getThreadCounts().finishedThreads);
	influxDB.write(
			influxDBConfig.getInfluxDatabase(),
			influxDBConfig.getInfluxRetentionPolicy(),
			Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
					.tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.FINISHED)
					.tag(TestStartEndMeasurement.Tags.NODE_NAME, nodeName)
					.tag(TestStartEndMeasurement.Tags.RUN_ID, runId)
					.tag(TestStartEndMeasurement.Tags.TEST_NAME, testName)
					.addField(TestStartEndMeasurement.Fields.PLACEHOLDER,"1")
					.build());

	influxDB.disableBatch();
	try {
		scheduler.awaitTermination(30, TimeUnit.SECONDS);
		LOGGER.info("influxDB scheduler terminated!");
	} catch (InterruptedException e) {
		LOGGER.error("Error waiting for end of scheduler");
	}

	samplersToFilter.clear();
	super.teardownTest(context);
}
 
Example #14
Source File: JMeterInfluxDBBackendListenerClient.java    From JMeter-InfluxDB-Writer with Apache License 2.0 5 votes vote down vote up
@Override
public void setupTest(BackendListenerContext context) throws Exception {
	testName = context.getParameter(KEY_TEST_NAME, "Test");
               runId = context.getParameter(KEY_RUN_ID,"R001"); //Will be used to compare performance of R001, R002, etc of 'Test'
	randomNumberGenerator = new Random();
	nodeName = context.getParameter(KEY_NODE_NAME, "Test-Node");


	setupInfluxClient(context);
	influxDB.write(
			influxDBConfig.getInfluxDatabase(),
			influxDBConfig.getInfluxRetentionPolicy(),
			Point.measurement(TestStartEndMeasurement.MEASUREMENT_NAME).time(System.currentTimeMillis(), TimeUnit.MILLISECONDS)
					.tag(TestStartEndMeasurement.Tags.TYPE, TestStartEndMeasurement.Values.STARTED)
					.tag(TestStartEndMeasurement.Tags.NODE_NAME, nodeName)
					.tag(TestStartEndMeasurement.Tags.TEST_NAME, testName)
					.addField(TestStartEndMeasurement.Fields.PLACEHOLDER, "1")
					.build());

	parseSamplers(context);
	scheduler = Executors.newScheduledThreadPool(1);

	scheduler.scheduleAtFixedRate(this, 1, 1, TimeUnit.SECONDS);

	// Indicates whether to write sub sample records to the database
	recordSubSamples = Boolean.parseBoolean(context.getParameter(KEY_RECORD_SUB_SAMPLES, "false"));
}
 
Example #15
Source File: ElasticsearchBackendClient.java    From jmeter-elasticsearch-backend-listener with MIT License 5 votes vote down vote up
@Override
public void teardownTest(BackendListenerContext context) throws Exception {
    if (this.sender.getListSize() > 0) {
        this.sender.sendRequest(this.esVersion);
    }
    this.sender.closeConnection();
    super.teardownTest(context);
}
 
Example #16
Source File: ElasticsearchBackendClient.java    From jmeter-elasticsearch-backend-listener with MIT License 5 votes vote down vote up
/**
 * Method that sets the SSL configuration to be able to send requests to a secured endpoint
 * @param context
 */
private void setSSLConfiguration(BackendListenerContext context) {
    String keyStorePath = context.getParameter(ES_SSL_KEYSTORE_PATH);
    if (!keyStorePath.equalsIgnoreCase("")) {
        logger.warn("KeyStore system properties overwritten by ES SSL configuration.");
        System.setProperty("javax.net.ssl.keyStore", keyStorePath);
        System.setProperty("javax.net.ssl.keyStorePassword", context.getParameter(ES_SSL_KEYSTORE_PW));
        switch (FilenameUtils.getExtension(keyStorePath)) {
            case "jks":
                System.setProperty("javax.net.ssl.keyStoreType", "jks");
                break;
            case "p12":
                System.setProperty("javax.net.ssl.keyStoreType", "pkcs12");
                break;
            default:
                System.setProperty("javax.net.ssl.keyStoreType", "");
                break;
        }
    }

    String trustStorePath = context.getParameter(ES_SSL_TRUSTSTORE_PATH);
    if (!trustStorePath.equalsIgnoreCase("")) {
        logger.warn("TrustStore system properties overwritten by ES SSL configuration.");
        System.setProperty("javax.net.ssl.trustStore", trustStorePath);
        System.setProperty("javax.net.ssl.trustStorePassword", context.getParameter(ES_SSL_TRUSTSTORE_PW));
        switch (FilenameUtils.getExtension(trustStorePath)) {
            case "jks":
                System.setProperty("javax.net.ssl.trustStoreType", "jks");
                break;
            case "p12":
                System.setProperty("javax.net.ssl.trustStoreType", "pkcs12");
                break;
            default:
                System.setProperty("javax.net.ssl.trustStoreType", "");
                break;
        }
    }

}
 
Example #17
Source File: ElasticsearchBackendClient.java    From jmeter-elasticsearch-backend-listener with MIT License 5 votes vote down vote up
/**
 * Method that converts a semicolon separated list contained in a parameter into a string set
 * @param context
 * @param parameter
 * @param set
 */
private void convertParameterToSet(BackendListenerContext context, String parameter, Set<String> set) {
    String[] array = (context.getParameter(parameter).contains(";")) ? context.getParameter(parameter).split(";")
            : new String[] { context.getParameter(parameter) };
    if (array.length > 0 && !array[0].trim().equals("")) {
        for (String entry : array) {
            set.add(entry.toLowerCase().trim());
            if(logger.isDebugEnabled())
                logger.debug("Parsed from " + parameter + ": " + entry.toLowerCase().trim());
        }
    }
}
 
Example #18
Source File: LoadosophiaClient.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
private void init(BackendListenerContext context) {
    token = context.getParameter(LoadosophiaUploader.UPLOAD_TOKEN);
    project = context.getParameter(LoadosophiaUploader.PROJECT);
    color = context.getParameter(LoadosophiaUploader.COLOR);
    title = context.getParameter(LoadosophiaUploader.TITLE);
    fileName = context.getParameter(LoadosophiaUploader.FILE_NAME);
    isOnlineInitiated = Boolean.parseBoolean(context.getParameter(LoadosophiaUploader.USE_ONLINE));
}
 
Example #19
Source File: BlazeMeterBackendListenerClient.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void teardownTest(BackendListenerContext backendListenerContext) throws Exception {
    if (!isInterruptedThroughUI) {
        apiClient.endOnline();
        informer.notifyAbout("Upload finished successfully");
    }
    accumulator.clear();
}
 
Example #20
Source File: BlazeMeterBackendListenerClient.java    From jmeter-bzm-plugins with Apache License 2.0 5 votes vote down vote up
@Override
public void handleSampleResults(List<SampleResult> list, BackendListenerContext backendListenerContext) {
    if (isInterruptedThroughUI) {
        return;
    }

    accumulator.addAll(list);
    JSONObject data = JSONConverter.convertToJSON(accumulator, list);

    int counter = 0;
    while (!apiClient.isTestStarted() && counter < 3) {
        log.debug("Waiting for test starting");
        makeDelay();
        counter++;
    }

    try {
        apiClient.sendOnlineData(data);
    } catch (JMeterStopTestException ex) {
        isInterruptedThroughUI = true;
        StandardJMeterEngine.stopEngineNow();
    } catch (IOException e) {
        log.warn("Failed to send data: " + data, e);
    }

    makeDelay();
}
 
Example #21
Source File: ElasticsearchBackendClient.java    From jmeter-elasticsearch-backend-listener with MIT License 4 votes vote down vote up
@Override
public void setupTest(BackendListenerContext context) throws Exception {
    try {
        this.filters = new HashSet<>();
        this.fields = new HashSet<>();
        this.modes = new HashSet<>(Arrays.asList("info", "debug", "error", "quiet"));
        this.bulkSize = Integer.parseInt(context.getParameter(ES_BULK_SIZE));
        this.timeoutMs = Integer.parseInt((context.getParameter(ES_TIMEOUT_MS)));
        this.buildNumber = (JMeterUtils.getProperty(ElasticsearchBackendClient.BUILD_NUMBER) != null
                && !JMeterUtils.getProperty(ElasticsearchBackendClient.BUILD_NUMBER).trim().equals(""))
                        ? Integer.parseInt(JMeterUtils.getProperty(ElasticsearchBackendClient.BUILD_NUMBER)) : 0;

        setSSLConfiguration(context);

        if (context.getParameter(ES_AWS_ENDPOINT).equalsIgnoreCase("")) {
            client = RestClient
                    .builder(new HttpHost(context.getParameter(ES_HOST),
                            Integer.parseInt(context.getParameter(ES_PORT)), context.getParameter(ES_SCHEME)))
                    .setRequestConfigCallback(requestConfigBuilder -> requestConfigBuilder.setConnectTimeout(5000)
                            .setSocketTimeout((int) timeoutMs))
                    .setFailureListener(new RestClient.FailureListener() {
                        @Override
                        public void onFailure(Node node) {
                            logger.error("Error with node: " + node.toString());
                        }
                    }).build();
        } else {
            AWS4Signer signer = new AWS4Signer();
            signer.setServiceName(SERVICE_NAME);
            signer.setRegionName(context.getParameter(ES_AWS_REGION));
            HttpRequestInterceptor interceptor = new AWSRequestSigningApacheInterceptor(SERVICE_NAME, signer,
                    credentialsProvider);
            client = RestClient.builder(HttpHost.create(context.getParameter(ES_AWS_ENDPOINT)))
                    .setHttpClientConfigCallback(hacb -> hacb.addInterceptorLast(interceptor)).build();
        }

        convertParameterToSet(context, ES_SAMPLE_FILTER, this.filters);
        convertParameterToSet(context, ES_FIELDS, this.fields);

        this.sender = new ElasticSearchMetricSender(client, context.getParameter(ES_INDEX).toLowerCase(),
                context.getParameter(ES_AUTH_USER), context.getParameter(ES_AUTH_PWD),
                context.getParameter(ES_AWS_ENDPOINT));
        this.sender.createIndex();
        this.esVersion = sender.getElasticSearchVersion();

        checkTestMode(context.getParameter(ES_TEST_MODE));
        super.setupTest(context);
    } catch (Exception e) {
        throw new IllegalStateException("Unable to connect to the ElasticSearch engine", e);
    }
}
 
Example #22
Source File: ElasticSearchMetric.java    From jmeter-elasticsearch-backend-listener with MIT License 4 votes vote down vote up
/**
 * This method returns the current metric as a Map(String, Object) for the provided sampleResult
 *
 * @param context BackendListenerContext
 * @return a JSON Object as Map(String, Object)
 */
public Map<String, Object> getMetric(BackendListenerContext context) throws Exception {
    SimpleDateFormat sdf = new SimpleDateFormat(this.esTimestamp);

    //add all the default SampleResult parameters
    addFilteredJSON("AllThreads", this.sampleResult.getAllThreads());
    addFilteredJSON("BodySize", this.sampleResult.getBodySizeAsLong());
    addFilteredJSON("Bytes", this.sampleResult.getBytesAsLong());
    addFilteredJSON("SentBytes", this.sampleResult.getSentBytes());
    addFilteredJSON("ConnectTime", this.sampleResult.getConnectTime());
    addFilteredJSON("ContentType", this.sampleResult.getContentType());
    addFilteredJSON("DataType", this.sampleResult.getDataType());
    addFilteredJSON("ErrorCount", this.sampleResult.getErrorCount());
    addFilteredJSON("GrpThreads", this.sampleResult.getGroupThreads());
    addFilteredJSON("IdleTime", this.sampleResult.getIdleTime());
    addFilteredJSON("Latency", this.sampleResult.getLatency());
    addFilteredJSON("ResponseTime", this.sampleResult.getTime());
    addFilteredJSON("SampleCount", this.sampleResult.getSampleCount());
    addFilteredJSON("SampleLabel", this.sampleResult.getSampleLabel());
    addFilteredJSON("ThreadName", this.sampleResult.getThreadName());
    addFilteredJSON("URL", this.sampleResult.getURL());
    addFilteredJSON("ResponseCode", this.sampleResult.getResponseCode());
    addFilteredJSON("TestStartTime", JMeterContextService.getTestStartTime());
    addFilteredJSON("SampleStartTime", sdf.format(new Date(this.sampleResult.getStartTime())));
    addFilteredJSON("SampleEndTime", sdf.format(new Date(this.sampleResult.getEndTime())));
    addFilteredJSON("Timestamp", this.sampleResult.getTimeStamp());
    addFilteredJSON("InjectorHostname", InetAddress.getLocalHost().getHostName());

    // Add the details according to the mode that is set
    switch (this.esTestMode) {
        case "debug":
            addDetails();
            break;
        case "error":
            addDetails();
            break;
        case "info":
            if (!this.sampleResult.isSuccessful())
                addDetails();
            break;
        default:
            break;
    }

    addAssertions();
    addElapsedTime();
    addCustomFields(context);
    parseHeadersAsJsonProps(this.allReqHeaders, this.allResHeaders);

    return this.json;
}
 
Example #23
Source File: LoadosophiaClient.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public SampleResult createSampleResult(BackendListenerContext backendListenerContext, SampleResult sampleResult) {
    return sampleResult;
}
 
Example #24
Source File: LoadosophiaClient.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public void teardownTest(BackendListenerContext context) throws Exception {
    stop();
}
 
Example #25
Source File: LoadosophiaClient.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public void setupTest(BackendListenerContext context) throws Exception {
    init(context);
}
 
Example #26
Source File: BlazeMeterBackendListenerClient.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public SampleResult createSampleResult(BackendListenerContext backendListenerContext, SampleResult sampleResult) {
    return sampleResult;
}
 
Example #27
Source File: BlazeMeterBackendListenerClient.java    From jmeter-bzm-plugins with Apache License 2.0 4 votes vote down vote up
@Override
public void setupTest(BackendListenerContext context) throws Exception {
    init(context);
    accumulator.clear();
    isInterruptedThroughUI = false;
}