Skip to content

Commit 6bf4927

Browse files
author
DABURON Vincent
committed
Version 7.0, Use new library har-to-jmeter-convertor 7.0 add manage the websocket connection and messages with 'WebSocket Samplers by Peter Doornbosch', add checkbox for boolean parameter 'ws_with_pdoornbosch' (default unchecked == false).
1 parent 9974b7f commit 6bf4927

File tree

6 files changed

+82
-10
lines changed

6 files changed

+82
-10
lines changed

README.md

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
An article about motivations to create this tool: https://dzone.com/articles/convert-a-har-file-to-jmeter-script
1010

11+
Since version 7.0, **Websocket** is manage with samplers from the plugin "WebSocket Samplers by Peter Doornbosch".
12+
1113
## GUI interface in the JMeter Tools Menu
1214
This tool is present in the Menu Tools > vdn@github - HAR Convertor Tool
1315

@@ -25,6 +27,7 @@ Parameters are :
2527
* record_out create the record xml file from the har file (could be open with the Listener View Results Tree) <br/>
2628
e.g. record_out = record.xml
2729
* add_result_tree_record, add a View Result Tree to view the Recording XML File Generated (default true), the record_out must be not empty
30+
* ws_with_pdoornbosch, create WebSocket Sampler if HAR contains WebSocket Connection (ws or wss) and WebSocket Exchange message (default false). Need this JMeter plugin "WebSocket Samplers by Peter Doornbosch" to open generated JMeter script.
2831
* external_file_infos, external csv file contains information about Timestamp, Transaction Name, date start or end. <br/>
2932
e.g. external_file_infos = myappli_transactions.csv
3033
* new_tc_pause time between 2 urls to create a new page (Transaction Controller) (default 5000 = jmeter property value : proxy.pause=5000) <br/>
@@ -130,6 +133,32 @@ The BrowserUp Proxy **active** project is available at this url : <br/>
130133

131134
Note : The BrowserMod Proxy tool is no more active (since september 2017) and it's recommended to migrate to BrowerUp proxy https://github.com/valfirst/browserup-proxy the "valfirst" GitHub username is important.
132135

136+
The BrowserUp Proxy **active** project is available at this url : <br/>
137+
[Goto the BrowserUp Proxy active project](https://github.com/valfirst/browserup-proxy)
138+
139+
Note : The BrowserMod Proxy tool is no more active (since september 2017) and it's recommended to migrate to BrowerUp proxy https://github.com/valfirst/browserup-proxy the "valfirst" GitHub username/project is important.
140+
141+
## Websocket use the plugin "WebSocket Samplers by Peter Doornbosch"
142+
If your Har file contains WebSocket Connection and Messages, check the checkbox <code>ws_with_pdoornbosch</code> (set true), this tool will try to create Websocket Samplers in the JMeter script generated and the exchanges in the Recording XML file if you set the record xml file name.
143+
144+
Documentation at : https://bitbucket.org/pjtr/jmeter-websocket-samplers/src/master/
145+
146+
The HAR is record from **Chrome** Browser not Firefox Browser and not Egde Browser (research in har file the attribute : '_webSocketMessages').
147+
148+
Currently limitation to only one websocket connection and multi text messages (send or receive) in this websocket connection (binary message is not tested).
149+
150+
Text message could be on "STOMP" format (https://en.wikipedia.org/wiki/Streaming_Text_Oriented_Messaging_Protocol) or no "STOMP" (simple text).
151+
152+
Need the plugin "WebSocket Samplers by Peter Doornbosch" to open the generated script that contain Websocket Samplers.
153+
154+
This demonstration use the web site : https://websocket.org/tools/websocket-echo-server/
155+
156+
![Script generated with Websocket samplers and xml record messages](doc/images/jmeter_websocket_script_and_xml_record.png)
157+
158+
If you click on the checkbox "Create WebSocket Sampler if HAR contains WebScoket Connection" but the JMeter **have not the plugin** "WebSocket Samplers by Peter Doornbosch" a warning message is display and the button "CONVERT AND LOAD GENERATED SCRIPT" is disable.
159+
160+
![Warning if the plugin "WebSocket Samplers by Peter Doornbosch" is not present](doc/images/har_convertor_tool_gui_check_ws_plugin.png)
161+
133162

134163
## More documentation from har-to-jmeter-convertor CLI Tool
135164
This plugin use a **library** from the Command Line Interface tool (har-to-jmeter-convertor)<br/>
@@ -152,7 +181,7 @@ usage: io.github.vdaburon.jmeter.har.HarForJMeter [-add_pause &lt;add_pause&gt;]
152181
[-filter_include &lt;filter_include&gt;] -har_in &lt;har_in&gt; [-help] -jmx_out &lt;jmx_out&gt; [-new_tc_pause &lt;new_tc_pause&gt;]
153182
[-page_start_number &lt;page_start_number&gt;] [-record_out &lt;record_out&gt;] [-remove_cache_request
154183
&lt;remove_cache_request&gt;] [-remove_cookie &lt;remove_cookie&gt;] [-sampler_start_number &lt;sampler_start_number&gt;]
155-
[-use_lrwr_infos &lt;use_lrwr_infos&gt;]
184+
[-use_lrwr_infos &lt;use_lrwr_infos&gt;] [-ws_with_pdoornbosch &lt;ws_with_pdoornbosch&gt;]
156185
io.github.vdaburon.jmeter.har.HarForJMeter
157186
-add_pause &lt;add_pause&gt; Optional boolean, add Flow Control Action Pause after Transaction
158187
Controller (default true)
@@ -179,9 +208,13 @@ io.github.vdaburon.jmeter.har.HarForJMeter
179208
-use_lrwr_infos &lt;use_lrwr_infos&gt; Optional, the har file has been generated with LoadRunner Web
180209
Recorder and contains Transaction Name, expected value :
181210
'transaction_name' or don't add this parameter
211+
-ws_with_pdoornbosch &lt;ws_with_pdoornbosch&gt; Optional boolean, Manage websocket messages with the JMeter plugin
212+
from Peter DOORNBOSH (default false), if true need the plugin from
213+
Peter DOORNBOSH to open the generated script
182214
E.g : java -jar har-for-jmeter-&lt;version&gt;-jar-with-dependencies.jar -har_in myhar.har -jmx_out scriptout.jmx -record_out
183215
recording.xml -add_result_tree_record true -new_tc_pause 5000 -add_pause true -filter_include "https://mysite/.*"
184-
-filter_exclude "https://notmysite/*" -page_start_number 50 -sampler_start_number 250
216+
-filter_exclude "https://notmysite/*" -page_start_number 50 -sampler_start_number 250 -ws_with_pdoornbosch false
217+
185218
</pre>
186219

187220
<pre>
@@ -202,13 +235,15 @@ The maven groupId, artifactId and version, this plugin is in the **Maven Central
202235
```xml
203236
<groupId>io.github.vdaburon</groupId>
204237
<artifactId>har-convertor-jmeter-plugin</artifactId>
205-
<version>6.1</version>
238+
<version>7.0</version>
206239
```
207240

208241
## License
209242
Licensed under the Apache License, Version 2.0
210243

211244
## Versions
245+
Version 7.0 date 2025-02-27, Use new library har-to-jmeter-convertor 7.0 add manage the websocket messages with 'WebSocket Samplers by Peter Doornbosch', add checkbox for boolean parameter 'ws_with_pdoornbosch' (default unchecked == false).
246+
212247
Version 6.1 date 2025-01-28, Use new library har-to-jmeter-convertor 6.1 to correct a NullPointerException when creating the Recording XML file.
213248

214249
Version 6.0 date 2024-09-19, Use new library har-to-jmeter-convertor 6.0 for adding 'HTTP(S) Test Script Recorder' and 'View Results Tree' to view the Record.xml file created. Correct save file no url encoded name.
4.35 KB
Loading
45.6 KB
Loading
82.4 KB
Loading

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.vdaburon</groupId>
88
<artifactId>har-convertor-jmeter-plugin</artifactId>
9-
<version>6.1</version>
9+
<version>7.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>Apache JMeter Plugin to convert a HAR file to a JMeter script and Record XML</name>
@@ -82,7 +82,7 @@
8282
<dependency>
8383
<groupId>io.github.vdaburon</groupId>
8484
<artifactId>har-to-jmeter-convertor</artifactId>
85-
<version>6.1</version>
85+
<version>7.0</version>
8686
</dependency>
8787
</dependencies>
8888

src/main/java/io/github/vdaburon/jmeterplugins/har/gui/HarConvertorGui.java

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package io.github.vdaburon.jmeterplugins.har.gui;
1919

2020
import io.github.vdaburon.jmeter.har.HarForJMeter;
21+
2122
import org.apache.jmeter.exceptions.IllegalUserActionException;
2223
import org.apache.jmeter.gui.GuiPackage;
2324
import org.apache.jmeter.gui.JMeterFileFilter;
@@ -29,19 +30,23 @@
2930
import org.apache.jmeter.save.SaveService;
3031
import org.apache.jorphan.collections.HashTree;
3132
import org.apache.jorphan.gui.ComponentUtil;
33+
3234
import org.slf4j.Logger;
3335
import org.slf4j.LoggerFactory;
3436

3537
import javax.swing.*;
38+
3639
import java.awt.*;
3740
import java.awt.event.ActionEvent;
3841
import java.awt.event.ActionListener;
3942
import java.io.File;
43+
import java.io.Serializable;
4044
import java.util.HashSet;
4145
import java.util.Set;
4246

4347
public class HarConvertorGui extends AbstractAction implements
44-
ActionListener, UnsharedComponent, MenuCreator {
48+
ActionListener, UnsharedComponent, MenuCreator, Serializable {
49+
4550
private static Set<String> commands = new HashSet<>();
4651

4752
@SuppressWarnings("unused")
@@ -54,7 +59,8 @@ public class HarConvertorGui extends AbstractAction implements
5459
private static final String BROWSE_EXTERNAL_FILE_IN = "BROWSE_EXTERNAL_FILE_IN";
5560
private static final String ACTION_CONVERT = "ACTION_CONVERT";
5661
private static final String ACTION_CONVERT_AND_LOAD_SCRIPT = "ACTION_CONVERT_LOAD";
57-
private static final String ACTION_MENU_TOOL = "ACTION_MENU_TOOL";
62+
private static final String ACTION_MENU_TOOL = "ACTION_MENU_TOOL";
63+
private static final String ACTION_CHECKBOX_WEBSOCKET = "ACTION_CHECKBOX_WEBSOCKET";
5864

5965
private EscapeDialog messageDialog;
6066

@@ -76,6 +82,7 @@ public class HarConvertorGui extends AbstractAction implements
7682
private JCheckBox isRemoveCacheRequestHeaderCheckbox;
7783
private JCheckBox isUseLrwrTransactionNameCheckbox;
7884
private JCheckBox isAddResultTreeRecordCheckbox;
85+
private JCheckBox isWebSocketPDoornboschCheckbox;
7986

8087
private JButton btConvert;
8188
private JButton btConvertAndLoad;
@@ -101,8 +108,6 @@ public void doAction(ActionEvent e) throws IllegalUserActionException {
101108
harConvertorGui.showInputDialog(jfMainFrame);
102109
}
103110

104-
105-
106111
public void showInputDialog(JFrame parent) {
107112
setupInputDialog(parent);
108113
launchInputDialog();
@@ -237,6 +242,7 @@ public void actionPerformed(ActionEvent action) {
237242
boolean isRemoveCacheRequestHeader = isRemoveCacheRequestHeaderCheckbox.isSelected();
238243
boolean isAddResultTreeRecord = isAddResultTreeRecordCheckbox.isSelected();
239244
boolean isUseLrwrTransactionName = isUseLrwrTransactionNameCheckbox.isSelected();
245+
boolean isWebSocketPDoornbosch = isWebSocketPDoornboschCheckbox.isSelected();
240246

241247

242248
String lrwr_info = "";
@@ -253,6 +259,7 @@ public void actionPerformed(ActionEvent action) {
253259
log.info("fileJmxOut=<" + fileJmxOut + ">");
254260
log.info("recordXmlOut=<" + recordXmlOut + ">");
255261
log.info("isAddResultTreeRecord=<" + isAddResultTreeRecord + ">");
262+
log.info("isWebSocketPDoornbosch=<" + isWebSocketPDoornbosch + ">");
256263
log.info("createNewTransactionAfterRequestMs=<" + createNewTransactionAfterRequestMs + ">");
257264
log.info("isAddPause=<" + isAddPause + ">");
258265
log.info("regexFilterInclude=<" + regexFilterInclude + ">");
@@ -264,7 +271,9 @@ public void actionPerformed(ActionEvent action) {
264271
log.info("externalFileInfoIn=<" + externalFileInfoIn + ">");
265272
log.info("****************************************");
266273

267-
HarForJMeter.generateJmxAndRecord(fileHarIn, fileJmxOut,createNewTransactionAfterRequestMs,isAddPause, isRemoveCookieHeader, isRemoveCacheRequestHeader, regexFilterInclude, regexFilterExclude, recordXmlOut, pageStartNumber, samplerStartNumber, lrwr_info, externalFileInfoIn, isAddResultTreeRecord);
274+
HarForJMeter.generateJmxAndRecord(fileHarIn, fileJmxOut,createNewTransactionAfterRequestMs,isAddPause, isRemoveCookieHeader, isRemoveCacheRequestHeader,
275+
regexFilterInclude, regexFilterExclude, recordXmlOut, pageStartNumber, samplerStartNumber, lrwr_info, externalFileInfoIn,
276+
isAddResultTreeRecord, isWebSocketPDoornbosch);
268277

269278
log.info("After HarForJMeter.generateJmxAndRecord");
270279
btConvert.setEnabled(true);
@@ -321,6 +330,25 @@ public void actionPerformed(ActionEvent action) {
321330
labelStatus.setText("Waiting configuration ... ");
322331
labelStatus.setForeground(java.awt.Color.BLACK);
323332
}
333+
334+
if (command.equals(ACTION_CHECKBOX_WEBSOCKET)) {
335+
boolean isWSChecked = isWebSocketPDoornboschCheckbox.isSelected();
336+
if (isWSChecked) {
337+
try {
338+
// check if plugin "WebSocket Samplers by Peter Doornbosch" is present
339+
Class.forName("eu.luminis.jmeter.wssampler.WebsocketGeneralSampler");
340+
log.info("plugin \"WebSocket Samplers by Peter Doornbosch\" is present");
341+
} catch (ClassNotFoundException ex) {
342+
labelStatus.setText("You must install the plugin 'WebSocket Samplers by Peter Doornbosch' to open the JMeter generated script file");
343+
labelStatus.setForeground(java.awt.Color.RED);
344+
btConvertAndLoad.setEnabled(false);
345+
}
346+
} else {
347+
labelStatus.setText("Waiting configuration ... ");
348+
labelStatus.setForeground(java.awt.Color.BLACK);
349+
btConvertAndLoad.setEnabled(true);
350+
}
351+
}
324352
}
325353

326354
private JPanel createControls() {
@@ -378,6 +406,12 @@ private JPanel createFilterAndPausePanel() {
378406
private JPanel createCheckbox() {
379407
JPanel panel = new JPanel(new GridLayout(0, 2));
380408

409+
JLabel isWebSocketPDoornboschLabel = new JLabel("(Optional) Create WebSocket Sampler if HAR contains WebSocket Connection (default false)");
410+
isWebSocketPDoornboschCheckbox= new JCheckBox("",false);
411+
isWebSocketPDoornboschCheckbox.addActionListener(this);
412+
isWebSocketPDoornboschCheckbox.setActionCommand(ACTION_CHECKBOX_WEBSOCKET);
413+
isWebSocketPDoornboschCheckbox.setEnabled(true);
414+
381415
JLabel isAddPauseLabel = new JLabel("(Optional) Add a pause between Transaction Controller (default true), time between 2 URLs must be > 0");
382416
isAddPauseCheckbox= new JCheckBox("",true);
383417

@@ -393,6 +427,9 @@ private JPanel createCheckbox() {
393427
JLabel isUseLrwrTransactionNameLabel = new JLabel("(Optional) HAR was generated with LoadRunner Web Recorder and Transaction Names (default false)");
394428
isUseLrwrTransactionNameCheckbox= new JCheckBox("",false);
395429

430+
panel.add(isWebSocketPDoornboschLabel);
431+
panel.add(isWebSocketPDoornboschCheckbox);
432+
396433
panel.add(isAddPauseLabel);
397434
panel.add(isAddPauseCheckbox);
398435

0 commit comments

Comments
 (0)