HTTP Simple Table ServerPerformance testing with JMeter can be done with several JMeter injectors (on a remote host) and one JMeter controller (with GUI or CLI, on your local host). Scripts are sent to JMeter injectors using RMI protocol. Results are brought back periodically to the JMeter controller. Unfortunately the dataset and csv files aren't transferred from the controller to injectors. The main idea is to use a tiny http server in JMeter Plugins to manage the dataset files with simple commands to get / find / add rows of data in files. ConfigurationIn jmeter.properties file, STS properties are :
Do not use '\' in the path directory, it doesn't work well, use '/' or '\\' instead. It is also recommended to use UTF-8 as the encoding:
If you want automatically start a Simple Table Server on JMeter STARTUP simply add jsr223.init.file=simple-table-server.groovy in jmeter.properties Be sure that simple-table-server.groovy file is in your JMETER_HOME/bin directory. The Simple Table Server is a tiny http server which can send http GET/POST requests on port 9191 (by default). You can set a custom port through the graphical user interface or by overriding the jmeterplugin.sts.port property. Distributed architecture for JMeterThe Simple Table Server runs on the JMeter controller (master) and load generators/injectors (slaves) make calls to the STS to get or add some data.
Getting Started
There are different ways to start the STS:
When the STS is running go to Usually Calls are synchronized, all commands are executed ONE BY ONE. Example of a dataset file logins.csv:
INITFILELoad file in memory. Lines are stored in a linked list, 1 line = 1 element The filename is limited to 128 characters maxi and must not contains characters \ / : or .. This limits are for security reasons (E.g: NOT read "/etc/passwd" or ../../../tomcat/conf/server.xml).
HTML format:
Linked list after this command:
The charset to read the file is jmeterPlugin.sts.charsetEncodingReadFile=\ File could be load when STS startup with
OR
jmeterPlugin.sts.initFileAtStartupRegex=false and jmeterPlugin.sts.initFileAtStartup=file1.csv,file2.csv,otherfile.csv read csv files with comma separator (not a regular expression), e.g : read file1.csv and file2.csv and otherfile.csv OR jmeterPlugin.sts.initFileAtStartupRegex=true and jmeterPlugin.sts.initFileAtStartup=.+.csv read all csv files in the dataset directory the jmeterPlugin.sts.initFileAtStartup value is a regular expression READGet one line from list The charset use in the response is jmeterPlugin.sts.charsetEncodingHttpResponse=
HTML format:
Available options: - READ_MODE=FIRST => login1;password1 - READ_MODE=LAST => login5;password5 - READ_MODE=RANDOM => login?;password? - KEEP=TRUE => the data is kept and put to the end of list - KEEP=FALSE => the data is removed KEEP=TRUE, READ_MODE=FIRST => login1;password1 Linked list after this command:
KEEP=TRUE, READ_MODE=LAST => login5;password5 Linked list after this command:
KEEP=TRUE, READ_MODE=RANDOM => login2;password2 Linked list after this command:
KEEP=FALSE (delete mode), READ_MODE=FIRST => login1;password1 Linked list after this command:
KEEP=FALSE, READ_MODE=LAST => login5;password5 Linked list after this command:
KEEP=FALSE, READ_MODE=RANDOM => login2;password2 Linked list after this command:
READMULTIGet multi lines from list in one request Available options: - NB_LINES=Number of lines to read : 1 \<= Nb lines (Integer) and Nb lines \<= list size - READ_MODE=FIRST =>start to read at the first line - READ_MODE=LAST => start to read at the last line (reverse) - READ_MODE=RANDOM => read n lines randomly - KEEP=TRUE => the data is kept and put to the end of list - KEEP=FALSE => the data is removed GET Protocol
GET parameters : FILENAME=logins.csv, NB_LINES=Nb lines to read (Integer), READ_MODE=FIRST (Default) or LAST or RANDOM, KEEP=TRUE (Default) or FALSE E.g : Read first 3 lines, http://hostname:port/sts/READMULTI?FILENAME=logins.csv&NB1_LINES=3&READ_MODE=FIRST&KEEP=true NB_LINES=3, KEEP=TRUE, READ_MODE=FIRST, KEEP=TRUE => result
Linked list after this command:
If NB_LINES greater than list size
ADDAdd a line into a file: (GET OR POST HTTP protocol) GET Protocol
GET Parameters : FILENAME=dossier.csv&LINE=D0001123&ADD_MODE={FIRST, LAST}&UNIQUE={FALSE, TRUE} POST Protocol
POST Parameters : FILENAME=dossier.csv, LINE=D0001123, ADD_MODE={FIRST, LAST}, UNIQUE={FALSE, TRUE} HTML format:
Available options: - ADD_MODE=FIRST => add to the top - ADD_MODE=LAST => add to the end - FILENAME=dossier.csv => if doesn't already exist it creates a LinkedList in memory - LINE=1234;98763 => the line to add - UNIQUE=TRUE => do not add line if the list already contains such line (if already exits then return title KO and don't add the same line) POST Protocol with parameters
FINDFind a line in a file (GET OR POST HTTP protocol) The LINE to find is for FIND_MODE : - A string this SUBSTRING (Default, ALineInTheFile contains the stringToFind ) or EQUALS (stringToFind == ALineInTheFile) - A regular expression with REGEX_FIND (contains) and REGEX_MATCH (entire region the pattern) - KEEP=TRUE => the data is kept and put to the end of list - KEEP=FALSE => the data is removed GET Protocol
GET parameters : FILENAME=colors.txt, LINE=LineToFind, FIND_MODE=SUBSTRING,EQUALS,REGEX_FIND or REGEX_MATCH (SUBSTRING Default), KEEP=TRUE (Default) or FALSE POST Protocol
POST Parameters : FILENAME=colors.txt, LINE=BLUE|RED or LINE=BLUE or LINE=B.* or LINE=.*E.* ,FIND_MODE=SUBSTRING (Default),EQUALS,REGEX_FIND or REGEX_MATCH, KEEP=TRUE (Default) or FALSE If find return the first line finded, start reading at first line in the file (linked list)
If NOT find return title KO and "Error : Not find !"
LENGTHReturn the number of remaining lines of a linked list
HTML format:
STATUSDisplay the list of loaded files and the number of remaining lines for each linked list
HTML format:
SAVESave the specified linked list in a file to the specified location The charset use to write the file is set with jmeterPlugin.sts.charsetEncodingWriteFile=\
If jmeterPlugin.sts.addTimestamp is set to true then a timestamp will be add to the filename, the file is stored in the custom directory specified by editing the jmeterPlugin.sts.datasetDirectory property or in JMETER_HOME/bin directory by default:
HTML format:
You can force the addTimestamp value with parameter ADD_TIMESTAMP in the url like :
RESETRemove all of the elements from the specified list
HTML format:
Always returns title OK even if the file did not exist STOPShutdown the Simple Table Server
When the jmeterPlugin.sts.daemon=true, you need to call http://hostname:port/sts/STOP or kill the process to stop the STS CONFIGDisplay the current configuration for the Simple Table Server
Using STS in a Test PlanInitialize file using a "setUp Thread Group" by calling URL with one or more HTTP Request Sampler or with jmeterPlugin.sts.initFileAtStartup property to read file at JMeter startup. Reading a row of data is done by calling READ method at each iteration by a HTTP Request Sampler. Then you can use a Regular Expression Extractor to parse the response data. Reading login:
Reading password:
At the end of your Test Plan you can save remaining/adding data with a HTTP Request Sampler in a "tearDown Thread Group". If you need to parse more than 2 columns, you could use a Post-Processeur groovy JSR223 like :
Examples
In a loop, read random values from a file containing a login and a password at each row: Download Example Test Plan 1 Read random values example Read value from a file containing a login and a password at each row, each value is unique and cannot be read anymore: Download Example Test Plan 2 Consume login lines example Add rows in a new linked list and save it in a file when the test is done: Download Example Test Plan 3 Save list example Read in a random mode a dataset located on the controller machine with severals slaves. The first injector loads the dataset in memory while the other injectors are waiting few seconds (you could also use jmeterPlugin.sts.initFileAtStartup=file1.csv,file2.csv and jmeterPlugin.sts.initFileAtStartupRegex=false to read files when STS startup) The different injectors read randomly the data containing logins and passwords. When the test is done the first injector save the values in a file with a timestamp as prefix: Download Example Test Plan 4 Multi JMeter injectors and save list examples You can override STS settings using command-line options:
- -DjmeterPlugin.sts.port=\
When it's done see results in the Listener Tree View. JMETER MAVEN PLUGINIf you want to use the Http Simple Server with the JMeter Maven plugin, you could :
- Put your csv files in Extract pom.xml dedicated to Http Simple Table Server :
VERSIONSVersion 5.0 november 2023, add READMULTI command Version 4.0 june 2023, add FIND command Version 3.1 may 2022, add CONFIG command, add Charset configuration, init files at startup and daemon |