The Want for the Creation of the STS Plugin
From a Internet Utility in Tomcat
The concept of getting a server to handle the dataset was born throughout the efficiency assessments of the earnings tax declaration utility of the French Ministry of Public Finance in 2012. The dataset consisted of thousands and thousands of traces to simulate tens of hundreds of people that stuffed out their earnings tax return type per hour and there have been a dozen injectors to distribute the injection load of a efficiency shot. The dataset was consumed, that’s to say, as soon as the road with the particular person’s data was learn or consumed, we may not take the particular person’s data once more.
The administration of the dataset in a centralized method had been applied with a Java net utility (battle) operating in Tomcat. Injectors requesting a row of the dataset from the net utility.
To a Plugin for Apache JMeter
The necessity to have centralized administration of the dataset, particularly with an structure of a number of JMeter injectors, was on the origin of the creation in 2014 of the plugin for Apache JMeter named HTTP Easy Desk Server or STS. This plugin takes over the options of the devoted utility for Tomcat talked about above however with a lighter and less complicated technical answer based mostly on the NanoHTTPD library.
Handle the Dataset With HTTP Easy Desk Server (STS)
Including Centralized Administration of the Dataset
Efficiency assessments with JMeter will be finished with a number of JMeter injectors or load mills (with out interface, on a distant machine) and a JMeter controller (with person interface or command line interface on the native machine). JMeter script and properties are despatched by RMI protocol to injectors. The outcomes of the calls are returned periodically to the JMeter controller.
Nevertheless, the dataset and CSV information should not transferred from the controller to the injectors.
It’s natively not doable with JMeter to learn the dataset randomly or in reverse order. Nevertheless, there are a number of exterior plugins that can help you randomly learn a knowledge file, however not in a centralized method.
It’s natively not doable to save lots of information created throughout assessments akin to file numbers or new paperwork in a file. The potential for saving values will be finished with the Groovy script in JMeter, however not in a centralized method for those who use a number of injectors throughout the efficiency check.
The primary thought is to make use of a small HTTP server to handle the dataset information with easy instructions to retrieve or add information traces to the info information. This HTTP server will be launched alone in an exterior program or within the JMeter instrument.
The HTTP server is named the “Simple Table Server” or STS. The identify STS can be a reference to the Digital Desk Server (VTS) program of LoadRunner with totally different functionalities and a unique technical implementation, however shut within the use instances.
STS could be very helpful in a check with a number of JMeter injectors, nevertheless it additionally brings fascinating options with a single JMeter for efficiency testing.
Some Potentialities of Utilizing the HTTP Easy Desk Server
Studying Information in a Distributed and Collision-Free Manner
Some purposes don’t tolerate that 2 customers join with the identical login on the identical time. It’s typically advisable to not use the identical information for two customers related with the identical login on the identical time to keep away from conflicts on the info used.
The STS can simply handle the dataset in a distributed method to make sure that logins are totally different for every digital person at a given time T of the check. A dataset with logins/passwords with plenty of traces higher than the variety of lively threads at a given time is required.
We manually load in the beginning of the STS or by script the logins/password file, and the injectors ask the STS for a line with login/password by the command READ
, KEEP=TRUE
, and READ_MODE=FIRST
.
We are able to contemplate that the studying of the dataset is completed in a round method.
Studying Single-Use Information
The dataset will be single-use, that means that it’s used solely as soon as throughout the check. For instance, individuals who register on a web site can not register with the identical data as a result of the system detects a reproduction. Paperwork are awaiting validation by an administrator. When the paperwork are validated, they’re not in the identical state and might not be validated once more.
To do that, we’ll learn a knowledge file within the reminiscence of the HTTP STS and the digital customers will learn by deleting the worth on the prime of the record. When the check is stopped, we are able to save the values that stay in reminiscence in a file (with or with out a timestamp prefix) or let the HTTP STS run for one more check whereas maintaining the values nonetheless in reminiscence.
Producers and Shoppers of a Queue
With the STS, we are able to handle a queue with producers who deposit within the queue and customers who devour the info of the queue. In observe, we begin a script with producers who create information like new paperwork or new registered individuals. The identifiers of created paperwork or the data of newly registered persons are saved within the HTTP STS by the ADD
command in mode ADD_MODE=LAST
. The customers begin a bit of later so that there’s information within the queue.
It is usually needed that the customers don’t devour too rapidly in comparison with the producers or it’s essential to handle the case the place the record not incorporates a price by detecting that there is no such thing as a extra worth out there and ready a couple of seconds earlier than repeating in a loop.
The customers devour the values by the instructions READ
, FIRST
, KEEP=FALSE
. Here’s a schema to clarify how the producers ADD
and customers READ
in the identical queue.
Producer and Client With Search By FIND
It is a variation of the earlier answer.
Producer
A person with rights restricted to a geographical sector creates paperwork and provides a line together with his login + the doc quantity (ex: login23;D12223).
login1;D120000
login2;D120210
login23;D12223
login24;D12233
login2;D120214
login23;D12255
Client
A person will modify the traits of the doc, however to take action, he should select from the record in reminiscence solely the traces with the identical login because the one he presently makes use of for questions of rights and geographic sector.
Search within the record with the FIND
command and FIND_MODE=SUBSTRING
. The string looked for is the login of the related particular person (ex: login23) so LINE=login23;
(with the separator ;
). On this instance, the returned line would be the 1st line login23
and the file quantity can be utilized in looking for information within the examined utility.
Right here, the results of the FIND by substring (SUBSTRING)
is: login23;D12223. The road will be consumed with KEEP=FALSE
or saved and positioned on the finish of the record with KEEP=TRUE
.
Enrich the Dataset because the Shot Progresses
The concept is to start out with a diminished dataset that’s learn in the beginning of the shot and so as to add new traces to the preliminary dataset because the shot progresses as a way to improve or enrich the dataset. The dataset is subsequently bigger on the finish of the shot than firstly. On the finish of the shot, the enriched dataset will be saved with the SAVE
command and the brand new file will be the long run enter file for a brand new shot.
For instance, we add individuals by a situation. We add to the search dataset these individuals within the record so the search is completed on the primary individuals of the file learn firstly but additionally the individuals added because the efficiency check progresses.
Verification of the Dataset
The preliminary dataset can include values that can generate errors within the script as a result of the navigation falls into a specific case or the entered worth is refused as a result of it’s incorrect or already exists.
We learn the dataset by INITFILE
or in the beginning of the STS, we learn (READ)
and use the worth if the script goes to the top (the Thread Group is configured with “Start Next Thread Loop on Sampler Error”), we save the worth by ADD
in a file (valuesok.csv). On the finish of the check, the values of the valuesok.csv file are saved (for instance, with a “tearDown Thread Group”). The verified information of the valuesok.csv file will then be used.
Storing the Added Values in a File
Within the script, the values added to the appliance database are saved in a file by the ADD
command. On the finish of the check, the values in reminiscence are saved in a file (for instance, with a “tearDown Thread Group”). The file containing the created values can be utilized to confirm the additions to the database a posteriori or to delete the created values as a way to return to an preliminary state earlier than the check.
A script devoted to creating a knowledge set can create values and retailer them in a knowledge file. This file will then be used within the JMeter script throughout efficiency assessments. Alternatively, a devoted erase script can take the file of created values to erase them in a loop.
Communication Between Software program
The HTTP STS can be utilized as a method to speak values between JMeter and different software program. The software program is usually a heavy shopper, an online utility, a shell script, a Selenium check, one other JMeter, a LoadRunner, and many others. We are able to additionally launch 2 command line assessments with JMeter in a row through the use of an “external standalone” STS as a method to retailer values created by the primary check and used within the second JMeter check. The software program can add or learn values by calling the URL of the HTTP STS, and JMeter can learn these added values or add them itself. This risk facilitates efficiency assessments but additionally non-regression assessments.
Enrich the Dataset because the Shot Progresses
Gradual Exiting the Check on All JMeter Injectors
In JMeter, there is no such thing as a notion as in LoadRunner of “GradualExiting
,” that’s to say, to point to the vuser on the finish of the iteration if it ought to proceed or to not repeat and subsequently cease. We are able to simulate this “GradualExiting
” with the STS and a bit of code within the JMeter script. With the STS we are able to load a file “status.csv
,” which incorporates a line with a specific worth like the road “RUN
.” The vuser asks firstly of the iteration the worth of the road of the file “status.csv
.” If the worth is the same as “STOP
” then the vuser stops. If the worth is zero or totally different from STOP
like “RUN
” then the person continues.
Gradual Exiting After Mounted Date Time
We are able to additionally program the cease request after a fastened time with this technique. We point out as a parameter the date and time to alter the worth of the standing to STOP
; e.g., 2024-07-31_14h30m45s
by a JMeter script that runs along with the present load testing. The script is launched, and we calculate the variety of milliseconds earlier than the indicated date of the requested cease.
The vuser is placed on maintain for the calculated period.
Then the “status.csv” file within the STS is deleted to place the STOP worth, which can permit the second JMeter script that’s already operating to learn the standing worth if standing == "STOP"
worth and to cease correctly on all of the JMeter injectors or the JMeter alone.
Begin the HTTP Easy Desk Server
Declaration and Begin of the STS by the Graphical Interface
The Easy Desk Server is positioned within the “Non-Test Elements” menu:
Click on on the “Start” button to start out the HTTP STS.
By default, the listing containing the information is
Begin From the Command Line
It’s doable to start out the STS server from the command line.
binsimple-table-server.cmd (Home windows OS)
/bin/simple-table-server.sh (Linux OS)
Or mechanically when beginning JMeter from the command line (CLI) by declaring the file these 2 traces in jmeter.properties
:
jsr223.init.file=simple-table-server.groovy
jmeterPlugin.sts.loadAndRunOnStartup=true
If the worth is false
, then the STS is just not began when launching JMeter from command line with out GUI.
The default port is 9191. It may be modified by the property:
# jmeterPlugin.sts.port=9191
If jmeterPlugin.sts.port=0
, then the STS doesn’t begin when launching JMeter in CLI mode.
The property jmeterPlugin.sts.addTimestamp=true
signifies if the backup of the file (e.g., information.csv) can be prefixed by the date and time (e.g.: 20240112T13h00m50s.information.csv
); in any other case, jmeterPlugin.sts.addTimestamp=false
writes/overwrites the file information.csv# jmeterPlugin.sts.addTimestamp=true
.
The property jmeterPlugin.sts.daemon=true
is used when the STS is launched as an exterior utility with the Linux nohup
command (instance: nohup ./simple-table-server.sh &
).
On this case, the STS doesn’t hearken to the keyboard. Use the
The STS enters an infinite loop, so you will need to name the /sts/STOP
command to cease the STS or the killer.
When jmeterPlugin.sts.daemon=false
, the STS waits for the entry of
Loading Information at Easy Desk Server Startup
The STS has the flexibility to load information into reminiscence at STS startup. Loading information is completed when the STS is launched as an exterior utility (
or
) and likewise when JMeter is launched from the command line with out GUI or by way of the JMeter Maven Plugin.
Loading information is not finished with JMeter in GUI mode.
The information are learn within the listing indicated by the property jmeterPlugin.sts.datasetDirectory
, and if this property is null
, then within the listing
.
The declaration of the information to be loaded is completed by the next properties:
jmeterPlugin.sts.initFileAtStartup=article.csv,filename.csv
jmeterPlugin.sts.initFileAtStartupRegex=false
or
jmeterPlugin.sts.initFileAtStartup=.+?.csv
jmeterPlugin.sts.initFileAtStartupRegex=true
When jmeterPlugin.sts.initFileAtStartupRegex=false
then the property jmeterPlugin.sts.initFileAtStartup
incorporates the record of information to be loaded with the comma character “,
” because the file identify separator. (e.g., jmeterPlugin.sts.initFileAtStartup=article.csv,filename.csv
). The STS at startup will attempt to load (INITFILE
) the information articles.csv then filename.csv.
When jmeterPlugin.sts.initFileAtStartupRegex=true
then the property jmeterPlugin.sts.initFileAtStartup
incorporates a daily expression that can be used to match the information within the listing of the property jmeterPlugin.sts.datasetDirectory
(e.g.,jmeterPlugin.sts.initFileAtStartup=.+?.csv
hundreds into reminiscence (INITFILE
) all information with the extension “.csv
“.
The file identify should not include particular characters that might permit altering the studying listing akin to ....fichier.csv
, /and many others/passwd
, or ../../../tomcat/conf/server.xml
.
The utmost measurement of a file identify is 128 characters (with out bearing in mind the listing path).
Administration of the Encoding of Information to Learn/Write and the HTML Response
It’s doable to outline the encoding when studying information or writing information information. The properties are as follows:
- Learn (INITFILE) or write (SAVE) file with an accent from the textual content file within the charset like UTF-8 or ISO8859_15
- All CSV information should be in the identical charset encoding:
jmeterPlugin.sts.charsetEncodingReadFile=UTF-8
jmeterPlugin.sts.charsetEncodingWriteFile=UTF-8
- Information can be learn (
INITFILE
) with the charset declared by the worth ofjmeterPlugin.sts.charsetEncodingReadFile
. - Information can be written (
SAVE
) with the charset declared by the worth ofjmeterPlugin.sts.charsetEncodingWriteFile
. - The default worth
jmeterPlugin.sts.charsetEncodingReadFile
corresponds to the System property: file.encoding. - The default worth
jmeterPlugin.sts.charsetEncodingWriteFile
corresponds to the System property: file.encoding. - All information information have to be in the identical charset in the event that they include non-ASCII characters.
- To reply in HTML to totally different instructions, particularly
READ
, thecharset
discovered within the response header is indicated byjmeterPlugin.sts.charsetEncodingHttpResponse
. jmeterPlugin.sts.charsetEncodingHttpResponse=
: Within the HTTP header add “(Use UTF-8) Content-Type:text/html; charset=
“- The default worth is the JMeter property:
sampleresult.default.encoding
- The record of charsets is asserted within the HTML web page (take the java.io API column)
- For the identify of the charset look, see Oracle docs for Supported Encodings.
- Column Canonical Title for java.io API and java.lang API
Assist With Use
The URL of an STS command is of the shape:
.
The instructions and the names of the parameters are in uppercase (case delicate).
If no command is indicated then the assistance message is returned: http://localhost:9191/sts/
.
Instructions and Configuration
The next is a listing of instructions and configuration of the HTTP STS with extracts from the documentation of the JMeter-plugins.org web site.
The calls are atomic (with synchronized) => Studying or including goes to the top of the present processing earlier than processing the following request.
The instructions to the Easy Desk Server are carried out by HTTP GET and/or POST calls relying on the command.
Documentation is out there on the JMeter plugin web site.
Distributed Structure for JMeter
The Easy Desk Server runs on the JMeter controller (grasp) and cargo mills (slaves) or injectors make calls to the STS to get, discover, or add some information.
Initially of the check, the primary load generator will load information in reminiscence (preliminary name) and on the finish of the check, it asks for the STS saving values in a file.
All of the load mills ask for information from the identical STS which is began on the JMeter controller.
The INITFILE will also be finished at STS startup time (with out the primary load generator preliminary name).
Instance of a dataset file logins.csv:
login1;password1
login2;password2
login3;password3
login4;password4
login5;password5
INITFILE: Load File in Reminiscence
- http://hostname:port/sts/INITFILE?FILENAME=logins.csv
OK
5 => variety of traces learn
- Linked record after this command:
login1;password1
login2;password2
login3;password3
login4;password4
login5;password5
The information are learn within the listing indicated by the property: jmeterPlugin.sts.datasetDirectory
; if this property is null, then within the listing
.
READ: Get One Line From Record
http://hostname:port/sts/
Obtainable choices:
- READ_MODE=FIRST => login1;password1
- READ_MODE=LAST => login5;password5
- READ_MODE=RANDOM => login?;password?
- KEEP=TRUE => The info is saved and put to the top of the record
- KEEP=FALSE => The info is eliminated
READMULTI: Get Multi Traces From Record in One Request
- GET Protocol
http://hostname:port/sts/READMULTI?FILENAME=logins.csv&NB_LINES={Nb traces to learn}&READ_MODE={FIRST, LAST, RANDOM}&KEEP={TRUE, FALSE}
- Obtainable choices:
- NB_LINES=Variety of traces to learn : 1
- READ_MODE=FIRST => Begin to learn on the first line
- READ_MODE=LAST => Begin to learn on the final line (reverse)
- READ_MODE=RANDOM => learn n traces randomly
- KEEP=TRUE => The info is saved and put to the top of record
- KEEP=FALSE => The info is eliminated
ADD: Add a Line Right into a File (GET OR POST HTTP Protocol)
- FILENAME=file.csv, LINE=D0001123, ADD_MODE={FIRST, LAST}
- HTML format:
- Obtainable choices:
- ADD_MODE=FIRST => Add to the start of the record
- ADD_MODE=LAST => Add to the top of the record
- FILENAME=file.csv => If does not exist already it creates a LinkList in reminiscence
- LINE=1234;98763 =>Tthe line so as to add
- UNIQUE => Don’t add a line if the record already incorporates such a line (return KO)
- HTTP POST request:
- Technique GET:
- GET Protocol:
http://hostname:port/sts/ADD FILENAME=file.csv&LINE=D0001123&ADD_MODE={FIRST, LAST}
- GET Protocol:
FIND: Discover a Line within the File (GET OR POST HTTP Protocol)
- Command
FIND
- Discover a line (
LINE
) in a file (FILENAME
) (GET or POST HTTP protocol)
- Discover a line (
- The
LINE
to seek out is forFIND_MODE
:- A string:
SUBSTRING
(Default,ALineInTheFile
incorporates thestringToFind
) orEQUALS
(stringToFind == ALineInTheFile
) - A daily expression with
REGEX_FIND
(incorporates) andREGEX_MATCH
(whole area matches the sample) KEEP=TRUE
=> The info is saved and put to the top of the recordKEEP=FALSE
=> The info is eliminated
- A string:
- GET Protocol:
http://hostname:port/sts/FIND?FILENAME=colours.txt&LINE=(BLUE|RED)&[FIND_MODE=[SUBSTRING,EQUALS,REGEX_FIND,REGEX_MATCH]]&KEEP={TRUE, FALSE}
If discover
return the primary line discovered, begin studying on the first line within the file (linked record):
If NOT discovered, return title KO
and message Error: Not discovered!
within the physique.
LENGTH: Return the Variety of Remaining Traces of a Linked Record
http://hostname:port/sts/LENGTH?FILENAME=logins.csv
- HTML format:
STATUS: Show the Record of Loaded Information and the Variety of Remaining Traces
http://hostname:port/sts/STATUS
- HTML format:
OK
logins.csv = 5
file.csv = 1
SAVE: Save the Specified Linked record in a File to the datasetDirectory Location
http://hostname:port/sts/SAVE?FILENAME=logins.csv
- If
jmeterPlugin.sts.addTimestamp
is about to true, then a timestamp can be added to the filename. The file is saved in jmeterPlugin.sts.datasetDirectory or if null within the/bin listing: 20240520T16h33m27s.logins.csv. - You may drive the
addTimestamp
worth with parameterADD_TIMESTAMP
within the URL like :http://hostname:port/sts/SAVE?FILENAME=logins.csv&ADD_TIMESTAMP={true,false}
- HTML format:
OK
5 => variety of traces saved
RESET: Take away All Parts From the Specified Record:
- http://hostname:port/sts/RESET?FILENAME=logins.csv
- HTML format:
The Reset
command is commonly used within the “setUp Thread Group” to clear the values within the reminiscence Linked Record from a earlier check.
It at all times returns OK even when the file doesn’t exist.
STOP: Shutdown the Easy Desk Server
- http://hostname:port/sts/STOP
- The cease command is used often when the HTTP STS server is launched by a script shell and we need to cease the STS on the finish of the check.
- When the
jmeterPlugin.sts.daemon=true
, you could name http://hostname:port/sts/STOP or kill the method to cease the STS.
CONFIG: Show STS Configuration
- http://hostname:port/sts/CONFIG
- Show the STS configuration, e.g.:
jmeterPlugin.sts.loadAndRunOnStartup=false
startFromCli=true
jmeterPlugin.sts.port=9191
jmeterPlugin.sts.datasetDirectory=null
jmeterPlugin.sts.addTimestamp=true
jmeterPlugin.sts.demon=false
jmeterPlugin.sts.charsetEncodingHttpResponse=UTF-8
jmeterPlugin.sts.charsetEncodingReadFile=UTF-8
jmeterPlugin.sts.charsetEncodingWriteFile=UTF-8
jmeterPlugin.sts.initFileAtStartup=
jmeterPlugin.sts.initFileAtStartupRegex=false
databaseIsEmpty=false
Error Response KO
When the command and/or a parameter are fallacious, the result’s a web page html standing 200 however the title incorporates the label KO.
Examples:
- Ship an unknown command. Watch out because the command a case delicate (
READ != learn
).
KO
Error : unknown command !
- Attempt to learn the worth from a file not but loaded with
INITFILE
.
KO
Error : logins.csv not loaded but !
- Attempt to learn the worth from a file however no extra traces within the Linked Record.
KO
Error : No extra line !
- Attempt to save traces in a file that incorporates unlawful characters like “..”, “:”
KO
Error : Unlawful character discovered !
- Command
FIND
andFIND_MODE=REGEX_FIND
orREGEX_MATCH
:
KO
Error : Regex compile error !
Modifying STS Parameters From the Command Line
You may override STS settings utilizing command-line choices:
-DjmeterPlugin.sts.port=
-DjmeterPlugin.sts.loadAndRunOnStartup=
-DjmeterPlugin.sts.datasetDirectory=
-DjmeterPlugin.sts.addTimestamp=
-DjmeterPlugin.sts.daemon=
-DjmeterPlugin.sts.charsetEncodingHttpResponse=
-DjmeterPlugin.sts.charsetEncodingReadFile=
-DjmeterPlugin.sts.charsetEncodingWriteFile=
-DjmeterPlugin.sts.initFileAtStartup=
-DjmeterPlugin.sts.initFileAtStartupRegex=false=
jmeter.bat -DjmeterPlugin.sts.loadAndRunOnStartup=true -DjmeterPlugin.sts.port=9191 -DjmeterPlugin.sts.datasetDirectory=c:/information -DjmeterPlugin.sts.charsetEncodingReadFile=UTF-8 -n –t testdemo.jmx
STS within the POM of a Check With the jmeter-maven-plugin
It’s doable to make use of STS in a efficiency check launched with the jmeter-maven-plugin. To do that:
- Put your CSV information within the
listing (e.g.,/src/check/jmeter logins.csv
). - Put the
simple-table-server.groovy
(Groovy script) within the
listing./src/check/jmeter - Put your JMeter script in
listing (e.g.,/src/check/jmeter test_login.jmx
). - Declare within the Maven construct part, within the configuration
declare theartifact kg.apc:jmeter-plugins-table-server:
. - Declare person properties for STS configuration and computerized begin.
- If you happen to use a localhost and a proxy configuration, you could possibly add a proxy configuration with
.localhost - Extract pom.xml devoted to HTTP Easy Desk Server :
com.lazerycode.jmeter
jmeter-maven-plugin
3.8.0
...
kg.apc:jmeter-plugins-table-server:5.0
9191
true
${mission.construct.listing}/jmeter/testFiles
true
${mission.construct.listing}/jmeter/testFiles/simple-table-server.groovy