-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
DABURON Vincent
committed
Mar 11, 2024
1 parent
1d43b9a
commit 86dc45c
Showing
14 changed files
with
835 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,131 @@ | ||
# har-convertor-jmeter-plugin | ||
Apache JMeter Plugin to convert a HAR file to a JMeter script and Record XML file | ||
<p align="center"> | ||
<img src="https://github.com/vdaburon/har-convertor-jmeter-plugin/blob/main/doc/har_convertor_logo.png" alt="har convertor jmeter plugin logo"/> | ||
|
||
<p align="center">Convert a HAR file to a JMeter script and a Record XML file.</p> | ||
<p align="center"><a href="https://github.com/vdaburon/har-convertor-jmeter-plugin">Link to github project har-convertor-jmeter-plugin</a></p> | ||
</p> | ||
|
||
# Convert a HAR file to a JMeter script and a Record XML file. | ||
|
||
## GUI interface in the JMeter Tools Menu | ||
This tool is present in the Menu Tools > vdn@github - HAR Convertor Tool | ||
|
||
![Menu Tools](doc/images/jmeter_menu_tools_with_har_convertor.png) | ||
|
||
When you click and the menu line "vdn@github - HAR Convertor Tool", the tool GUI is display | ||
|
||
![Menu Tools](doc/images/har_convertor_tool_gui.png) | ||
|
||
### Parameters | ||
Parameters are : | ||
* har_in the HAR file to read (exported HAR from Web Browser : Chrome, Firefox, Edge ...) | ||
* jmx_out the file JMeter script generated, if the text field is empty then the jmx_out is the file name of har_in without the extension with suffix ".jmx" <br/> | ||
e.g. har_in = myhar1.har, jmx_out is empty then file_out will be myhar1.jmx | ||
* record_out create the record xml file from the har file (could be open with the Listener View Results Tree) <br/> | ||
e.g. record_out = record.xml | ||
* new_tc_pause time between 2 urls to create a new page (Transaction Controller) (default 5000 = jmeter property value : proxy.pause=5000) <br/> | ||
* e.g. 5000 for 5 sec between 2 urls | ||
* filter_include, the regular expression matches the URL to Include <br/> | ||
* default all = empty (no filter) | ||
* e.g. filter_include = https://mysite.com/.* | ||
* filter_exclude, the regular expression matches the URL to Exclude <br/> | ||
* default all = empty (no filter) | ||
* e.g. filter_include = https://notmysite.com/.* | ||
* add_pause checkbox, add Flow Control Action Pause, parameter new_tc_pause must be > 0 (default true) <br/> | ||
* remove_cookie checkbox , remove header with cookie because add a Cookie Manager in the script (default true) <br/> | ||
* remove_cache_request checkbox, remove cache request header because add a Cache Manager in the script (default true) <br/> | ||
|
||
Status, the status line contains the tool status or the tool result. | ||
|
||
e.g. : Status Results **OK** | ||
* Tool HAR Convertor Finished OK, fileJmxOut=C:\Temp\script1.jmx | ||
* Tool HAR Convertor Finished OK, fileJmxOut=C:\Temp\script1.jmx AND recordXmlOut=C:\Temp\record.xml | ||
|
||
e.g. : Status Results **KO** | ||
* Tool HAR Convertor Finished KO, CAN'T READ HAR fileHarIn = C:\Temp\harzzzz.har | ||
* Tool HAR Convertor Finished KO, exception = java.util.regex.PatternSyntaxException: Unmatched closing ')' near index 2 (.)) | ||
* Tool HAR Convertor Finished KO, exception = net.sf.saxon.trans.XPathException: Failed to create output file file:/c:/toto.jmx | ||
|
||
|
||
## Creating a har file and run the tool har-to-jmx-convertor to simulate recording from the JMeter recording template | ||
This tool har-to-jmx-convertor try to **simulate** a script JMeter and a record xml file recording from the **JMeter Recording Template**. | ||
|
||
### JMeter Recording Template and HTTP(S) Test Script Recorder - The standard way to record | ||
The JMeter Recording Template : <br/> | ||
![JMeter recording template start](doc/images/jmeter_record_template_begin.png) | ||
|
||
The result of recording with JMeter "HTTP(S) Test Script Recorder" : <br/> | ||
![JMeter script and record](doc/images/jmeter_record_template_tree_view.png) | ||
|
||
### HAR created on a Browser (e.g. Firefox) - The new way with the convertor tool | ||
Record the navigation in the web application with Developer tool : **Network** and **save** exchanges in **HAR** file format : <br/> | ||
![Browser save HAR file](doc/images/browser_create_har.png) | ||
|
||
Launch the "Convertor tool" : <br/> | ||
![Step to create script and record from HAR file](doc/images/browsers_har_convertor_script_record.png) | ||
|
||
Tool results : Open the script created and the record.xml in a View Results Tree <br/> | ||
![Open the script created](doc/images/jmeter_script_record_created.png) | ||
|
||
## More documentation from har-to-jmeter-convertor | ||
For more documentation look at README from [har-to-jmeter-convertor](https://github.com/vdaburon/har-to-jmeter-convertor) | ||
|
||
## Command line tool (CLI) | ||
This tool could be use with script shell Windows or Linux. | ||
|
||
Scripts shell are in <JMETER_HOME>\bin | ||
* har-convertor-to-jmeter.cmd for Windows OS | ||
* har-convertor-to-jmeter.sh for Linux/Mac OS | ||
|
||
Help to see all parameters : | ||
|
||
<pre> | ||
C:\apache-jmeter\bin>har-convertor-to-jmeter.cmd -help | ||
usage: io.github.vdaburon.jmeter.har.HarForJMeter [-add_pause <add_pause>] [-filter_exclude <filter_exclude>] | ||
[-filter_include <filter_include>] -har_in <har_in> [-help] -jmx_out <jmx_out> [-new_tc_pause <new_tc_pause>] | ||
[-record_out <record_out>] [-remove_cache_request <remove_cache_request>] [-remove_cookie <remove_cookie>] | ||
io.github.vdaburon.jmeter.har.HarForJMeter | ||
-add_pause <add_pause> Optional boolean, add Flow Control Action Pause after Transaction | ||
Controller (default true) | ||
-filter_exclude <filter_exclude> Optional, regular expression to exclude url | ||
-filter_include <filter_include> Optional, regular expression to include url | ||
-har_in <har_in> Har file to read (e.g : my_file.har) | ||
-help Help and show parameters | ||
-jmx_out <jmx_out> JMeter file created to write (e.g : script.jmx) | ||
-new_tc_pause <new_tc_pause> Optional, create new Transaction Controller after request ms, same as | ||
jmeter property : proxy.pause, need to be > 0 if set. Usefully for Har | ||
created by Firefox or Single Page Application (Angular, ReactJS, VuesJS | ||
...) | ||
-record_out <record_out> Optional, file xml contains exchanges likes recorded by JMeter | ||
-remove_cache_request <remove_cache_request> Optional boolean, remove cache header in the http request (default true | ||
because add a Cache Manager) | ||
-remove_cookie <remove_cookie> Optional boolean, remove cookie in http header (default true because add | ||
a Cookie Manager) | ||
E.g : java -jar har-for-jmeter-<version>-jar-with-dependencies.jar -har_in myhar.har -jmx_out scriptout.jmx | ||
-new_tc_pause 5000 -add_pause true -filter_include "https://mysite/.*" -filter_exclude "https://notmysite/*" | ||
</pre> | ||
|
||
|
||
<pre> | ||
C:\apache-jmeter\bin>har-convertor-to-jmeter.cmd -har_in "myhar.har" -jmx_out "script_out.jmx" -filter_include "https://mysite.com/.*" -filter_exclude "https://notmysite.com/.*" -add_pause true -new_tc_pause 5000 | ||
</pre> | ||
|
||
<pre> | ||
/var/opt/apache-jmeter/bin>./har-convertor-to-jmeter.sh -har_in "myhar.har" -jmx_out "script_out.jmx" -record_out "record.xml" -add_pause true -new_tc_pause 5000 | ||
</pre> | ||
|
||
## Tool installed with jmeter-plugins-manager | ||
This tool could be installed with the jmeter-plugins-manager from jmeter.plugins.org.<br> | ||
The tool name is : "vdn@github - har-convertor-jmeter-tool" | ||
|
||
## Usage Maven | ||
The maven groupId, artifactId and version, this plugin is in the **Maven Central Repository** [![Maven Central har-convertor-jmeter-plugin](https://maven-badges.herokuapp.com/maven-central/io.github.vdaburon/har-convertor-jmeter-plugin/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.github.vdaburon/har-convertor-jmeter-plugin) | ||
|
||
```xml | ||
<groupId>io.github.vdaburon</groupId> | ||
<artifactId>har-convertor-jmeter-plugin</artifactId> | ||
<version>1.0</version> | ||
``` | ||
## Versions | ||
Version 1.0 date 2024-0311, First Release | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>io.github.vdaburon</groupId> | ||
<artifactId>har-convertor-jmeter-plugin</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>Apache JMeter Plugin to convert a HAR file to a JMeter script and Record XML</name> | ||
<description>Apache JMeter Plugin to convert a HAR file to a JMeter script and Record XML</description> | ||
<url>https://github.com/vdaburon/har-convertor-jmeter-plugin</url> | ||
<inceptionYear>2024</inceptionYear> | ||
<licenses> | ||
<license> | ||
<name>Apache License, Version 2.0</name> | ||
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url> | ||
<comments>A business-friendly OSS license</comments> | ||
</license> | ||
</licenses> | ||
|
||
<developers> | ||
<developer> | ||
<id>vdaburon</id> | ||
<name>Vincent DABURON</name> | ||
<email>vdaburon at gmail dot com</email> | ||
<roles> | ||
<role>architect</role> | ||
<role>developer</role> | ||
</roles> | ||
</developer> | ||
</developers> | ||
|
||
<issueManagement> | ||
<system>jmeter-plugins-google-group</system> | ||
<url>https://groups.google.com/g/jmeter-plugins</url> | ||
</issueManagement> | ||
|
||
<scm> | ||
<connection>https://github.com/vdaburon/har-convertor-jmeter-plugin.git</connection> | ||
<developerConnection>https://github.com/vdaburon/har-convertor-jmeter-plugin.git</developerConnection> | ||
<url>https://github.com/vdaburon/har-convertor-jmeter-plugin</url> | ||
<tag>HEAD</tag> | ||
</scm> | ||
<distributionManagement> | ||
<snapshotRepository> | ||
<id>ossrh</id> | ||
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url> | ||
</snapshotRepository> | ||
<repository> | ||
<id>ossrh</id> | ||
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url> | ||
</repository> | ||
</distributionManagement> | ||
|
||
<properties> | ||
<maven.compiler.source>8</maven.compiler.source> | ||
<maven.compiler.target>8</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<mavenCentralAutoReleaseAfterClose>false</mavenCentralAutoReleaseAfterClose> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.jmeter</groupId> | ||
<artifactId>ApacheJMeter_core</artifactId> | ||
<version>5.5</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<!-- This JMeter Plugin use mainly this tool --> | ||
<dependency> | ||
<groupId>io.github.vdaburon</groupId> | ||
<artifactId>har-to-jmeter-convertor</artifactId> | ||
<version>1.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.12.1</version> | ||
<configuration> | ||
<source>${maven.compiler.source}</source> | ||
<target>${maven.compiler.target}</target> | ||
<encoding>${project.build.sourceEncoding}</encoding> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<version>2.9.1</version> | ||
<executions> | ||
<execution> | ||
<id>attach-javadocs</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>3.3.0</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<!-- create the uber jar : mvn clean package --> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>3.6.0</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
<configuration> | ||
<archive> | ||
<manifest> | ||
<mainClass> | ||
io.github.vdaburon.jmeterplugins.har.HarConvertorIntegrateGui | ||
</mainClass> | ||
</manifest> | ||
</archive> | ||
<descriptorRefs> | ||
<descriptorRef>jar-with-dependencies</descriptorRef> | ||
</descriptorRefs> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-gpg-plugin</artifactId> | ||
<version>3.1.0</version> | ||
<executions> | ||
<execution> | ||
<id>sign-artifacts</id> | ||
<phase>verify</phase> | ||
<goals> | ||
<goal>sign</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<!-- deploy jar in maven central or stagging only : mvn clean deploy | ||
if autoReleaseAfterClose == true then release in maven central; | ||
if autoReleaseAfterClose == false then release in stagging only not maven central | ||
--> | ||
<groupId>org.sonatype.plugins</groupId> | ||
<artifactId>nexus-staging-maven-plugin</artifactId> | ||
<version>1.6.13</version> | ||
<extensions>true</extensions> | ||
<configuration> | ||
<serverId>ossrh</serverId> | ||
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl> | ||
<autoReleaseAfterClose>${mavenCentralAutoReleaseAfterClose}</autoReleaseAfterClose> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
|
||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<!-- add version for the generated library in the script shell .cmd and .sh --> | ||
<filtering>true</filtering> | ||
</resource> | ||
</resources> | ||
</build> | ||
|
||
</project> |
43 changes: 43 additions & 0 deletions
43
src/main/java/io/github/vdaburon/jmeterplugins/har/HarConvertorInstaller.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2024 Vincent DABURON | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
|
||
package io.github.vdaburon.jmeterplugins.har; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.StandardCopyOption; | ||
|
||
public class HarConvertorInstaller { | ||
public static void main(String[] argv) throws IOException { | ||
writeOut("har-convertor-to-jmeter.cmd", false); | ||
writeOut("har-convertor-to-jmeter.sh", true); | ||
} | ||
|
||
private static void writeOut(String resName, boolean executable) throws IOException { | ||
resName = "/io/github/vdaburon/jmeterplugins/har/" + resName; | ||
File self = new File(HarConvertorInstaller.class.getProtectionDomain().getCodeSource().getLocation().getFile()); | ||
File src = new File(resName); | ||
String home = self.getParentFile().getParentFile().getParent(); | ||
File dest = new File(home + File.separator + "bin" + File.separator + src.getName()); | ||
|
||
InputStream is = HarConvertorInstaller.class.getResourceAsStream(resName); | ||
Files.copy(is, dest.toPath(), StandardCopyOption.REPLACE_EXISTING); | ||
dest.setExecutable(executable); | ||
} | ||
} |
Oops, something went wrong.