Skip to content

Commit

Permalink
added new tests for failing delay calculation, partly covers grouping…
Browse files Browse the repository at this point in the history
… as well
  • Loading branch information
besessener committed May 15, 2024
1 parent 9c2a88b commit 72248b8
Show file tree
Hide file tree
Showing 5 changed files with 57,001 additions and 10 deletions.
2 changes: 1 addition & 1 deletion plugin.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Plugin metadata
name=JMeter HAR Importer Plugin
version=0.2.1
version=0.2.2
author=Matthias Eggert
description=This plugin allows importing HTTP Archive (HAR) files into JMeter.

Expand Down
6 changes: 3 additions & 3 deletions release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Release Notes

Product Name: JMeter HAR Importer
Release Number: Version 0.2.1
Release Number: Version 0.2.2
Release Date: [2024-05-14]

Overview:
The JMeter HAR Importer plugin is designed to facilitate the import of HTTP Archive (HAR) files into JMeter. This release fixes the an issue with timers after adding the grouping functionality.

Purpose:
This release note provides an overview of the purpose and features included in Version 0.2.1 of the JMeter HAR Importer plugin. It outlines the changes, bug fixes, and new features introduced in this release.
This release note provides an overview of the purpose and features included in Version 0.2.2 of the JMeter HAR Importer plugin. It outlines the changes, bug fixes, and new features introduced in this release.

Issue Summary:
- Fix bug with ConstantTimers: now with grouping HTTP samplers into one transaction, a constant timer is not solving the "think time" problem. Instead a Flow Control Action was added.
- Fix bug with ConstantTimers: now with grouping HTTP samplers into one transaction, a constant timer is not solving the "think time" problem. Instead a Flow Control Action was added. The Flow Time delay was wrongly calculated though.

Notes:
- For detailed instructions on installation and usage, refer to the plugin documentation.
Expand Down
14 changes: 9 additions & 5 deletions src/main/java/de/qytera/jmeterharimporter/HARImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,24 +139,28 @@ public JMeterTreeNode addNewThreadGroupWithSamplers(Boolean shouldAddThinkTime,
long currentEntryStartTime = harEntry.getStartedDateTime().getTime();
long timeDifference = currentEntryStartTime - lastTimestamp;

if (transactionControllerHasTimer.get(currentEntryStartTime) == null) {
lastTimestamp = currentEntryStartTime;
}

HarRequest harRequest = harEntry.getRequest();
URI uri = URI.create(harRequest.getUrl());
if (this.hostsIgnored.contains(uri.getHost())) {
continue;
}
// add a transaction controller for each entry to group the samplers
if (transactionControllers.get(timeDifference) == null) {
if (transactionControllers.get(currentEntryStartTime) == null) {
TransactionController transactionController = createTransactionController("TC.%03d - %s".formatted(i++, uri.getHost()));
JMeterTreeNode transactionControllerNodeSub = addComponent(transactionController, threadGroupNode);
transactionControllers.put(timeDifference, transactionControllerNodeSub);
transactionControllers.put(currentEntryStartTime, transactionControllerNodeSub);
}

JMeterTreeNode transactionControllerNodeSub = transactionControllers.get(timeDifference);
JMeterTreeNode transactionControllerNodeSub = transactionControllers.get(currentEntryStartTime);

// add a constant timer to simulate the think time
if (shouldAddThinkTime) {
if (transactionControllerHasTimer.get(timeDifference) == null) {
transactionControllerHasTimer.put(timeDifference, true);
if (transactionControllerHasTimer.get(currentEntryStartTime) == null) {
transactionControllerHasTimer.put(currentEntryStartTime, true);
addComponent(createFlowControlAction(timeDifference), transactionControllerNodeSub);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.util.List;
import java.util.Map;

import org.apache.jmeter.timers.ConstantTimer;
import org.apache.jmeter.config.Argument;
import org.apache.jmeter.gui.tree.JMeterTreeNode;
import org.apache.jmeter.protocol.http.control.HeaderManager;
Expand Down Expand Up @@ -56,6 +55,23 @@ public void testHARImporter_timer() {
}
}

@Test
public void testHARImporter_timer_grouping() {
HARImporter harImporter = new HARImporter("src/test/resources/www.qytera.de.har");
threadGroupNode = harImporter.addNewThreadGroupWithSamplers(true, false, false);


String[] timerDelays = { "0", "1", "78", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "20" };

for (int i = 0; i < timerDelays.length; i++) {
JMeterTreeNode controller = (JMeterTreeNode) threadGroupNode.getChildAt(i);
JMeterTreeNode timer = (JMeterTreeNode) controller.getChildAt(0);
assertEquals("Think Time", timer.getName());
TestAction timerObject = (TestAction) timer.getUserObject();
assertEquals(timerDelays[i], timerObject.getDurationAsString());
}
}

@Test
public void testHARImporter_no_timer() {
HARImporter harImporter = new HARImporter("src/test/resources/get-www.randomnumberapi.com.har");
Expand Down
Loading

0 comments on commit 72248b8

Please sign in to comment.