Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/group same time #10

Merged
merged 2 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Qytera GmbH and contributors
Copyright (c) 2024 Qytera GmbH and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ This HAR file now contains a detailed record of all network requests and respons

To install the JMeter HAR Importer plugin, follow these steps:

1. Download the latest release of the plugin JAR file from the [GitHub releases page](https://github.com/Qytera-Gmbh/JMeterHARImporterPlugin/releases).
2. Copy the downloaded JAR file to the "lib/ext" directory within your JMeter installation directory.
3. Restart JMeter to load the plugin.
1. In JMeter install the Plugins Manager
2. Choose the "HAR (HTTP Archive) Import" plugin

# Usage

Expand Down
4 changes: 2 additions & 2 deletions plugin.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Plugin metadata
name=JMeter HAR Importer Plugin
version=0.1.0
author=Matthias
version=0.2.0
author=Matthias Eggert
description=This plugin allows importing HTTP Archive (HAR) files into JMeter.

# Plugin components
Expand Down
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
<configuration>
<target>
<!-- Copy the built JAR to JMeter's lib/ext directory -->
<copy file="${project.build.directory}/${project.artifactId}-${project.version}.jar"
<copy
file="${project.build.directory}/${project.artifactId}-${project.version}.jar"
todir="${jmeter.path}/lib/ext" />
</target>
</configuration>
Expand All @@ -100,6 +101,6 @@
</execution>
</executions>
</plugin>
</plugins>
</plugins>
</build>
</project>
15 changes: 7 additions & 8 deletions release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
Release Notes

Product Name: JMeter HAR Importer
Release Number: Version 0.1.0
Release Date: [2024-02-15]
Release Number: Version 0.2.0
Release Date: [2024-05-14]

Overview:
The JMeter HAR Importer plugin v0.1.0 is the initial release of the plugin, designed to facilitate the import of HTTP Archive (HAR) files into JMeter. This release introduces essential features for importing HAR files and generating JMeter sampler elements based on the captured requests.
The JMeter HAR Importer plugin is designed to facilitate the import of HTTP Archive (HAR) files into JMeter. This release introduces option for en/disabling some options which were always active before.

Purpose:
This release note provides an overview of the purpose and features included in Version 0.1.0 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.0 of the JMeter HAR Importer plugin. It outlines the changes, bug fixes, and new features introduced in this release.

Issue Summary:
- Added support for importing HAR files into JMeter.
- Automatically generates JMeter sampler elements for each HTTP request found in the HAR file.
- Supports parsing request headers, cookies, query parameters, and request body from the HAR file.
- Basic support for GET, POST, PUT, PATCH, DELETE added.
- The importer has a host exclude list now
- Added multiple options for elements to be added or excluded.
- Groups http samplers into the same transaction controller, if they were recorded at the same time.

Notes:
- For detailed instructions on installation and usage, refer to the plugin documentation.
Expand Down
Binary file modified screenshot-usage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 22 additions & 10 deletions src/main/java/de/qytera/jmeterharimporter/HARImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
import java.net.URI;
import java.net.URL;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class HARImporter {
Expand Down Expand Up @@ -121,30 +123,40 @@ public JMeterTreeNode addNewThreadGroupWithSamplers(Boolean shouldAddThinkTime,
// Create a Thread Group to hold the requests
JMeterTreeNode threadGroupNode = addComponent(createThreadGroup(), root);

Map<Long, JMeterTreeNode> transactionControllers = new HashMap<>();
Map<Long, Boolean> transactionControllerHasTimer = new HashMap<>();

int i = 1;
long lastTimestamp = -1;
for (HarEntry harEntry : this.har.getLog().getEntries()) {
// calculate think time
if (lastTimestamp == -1) {
lastTimestamp = harEntry.getStartedDateTime().getTime(); // first entry should become 0
}

long currentEntryStartTime = harEntry.getStartedDateTime().getTime();
long timeDifference = currentEntryStartTime - lastTimestamp;

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
JMeterTreeNode transactionControllerNodeSub = addComponent(createTransactionController(
"TC.%03d - %s".formatted(i++, uri.getHost())),
threadGroupNode);

// calculate think time
if (lastTimestamp == -1) {
lastTimestamp = harEntry.getStartedDateTime().getTime(); // first entry should become 0
if (transactionControllers.get(timeDifference) == null) {
TransactionController transactionController = createTransactionController("TC.%03d - %s".formatted(i++, uri.getHost()));
JMeterTreeNode transactionControllerNodeSub = addComponent(transactionController, threadGroupNode);
transactionControllers.put(timeDifference, transactionControllerNodeSub);
}

long currentEntryStartTime = harEntry.getStartedDateTime().getTime();
long timeDifference = currentEntryStartTime - lastTimestamp;
JMeterTreeNode transactionControllerNodeSub = transactionControllers.get(timeDifference);

// add a constant timer to simulate the think time
if (shouldAddThinkTime) {
addComponent(createConstantTimer(timeDifference), transactionControllerNodeSub);
if (transactionControllerHasTimer.get(timeDifference) == null) {
transactionControllerHasTimer.put(timeDifference, true);
addComponent(createConstantTimer(timeDifference), transactionControllerNodeSub);
}
}

// add the http sampler
Expand Down
Loading