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). 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. A dzone.com article about this tool : https://dzone.com/articles/jmeter-plugin-http-simple-table-server "Take an in-depth look to discover some of the possibilities of using the HTTP Simple Table Server a JMeter Plugin in this short manual." ConfigurationIn jmeter.properties file, STS properties are :
Do not use '\' in the path directory, it doesn't work well, use '/' or '\\' instead.
If you want automatically start a Simple Table Server on JMeter STARTUP simply add The Simple Table Server is a tiny http server which can send http GET/POST requests on port 9191 (by default). 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:
Calls are synchronized, all commands are executed ONE BY ONE (no concurrent access to datas) HELPShow a html page to explain parameters and examples.
When the STS is running go to Usually Help at http://localhost:9191/sts/ 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 contain characters \ / : or .. This limits are for security reasons (E.g: NOT read "/etc/passwd" or ../../../tomcat/conf/server.xml). Example of a dataset file logins.csv:
Load the file "logins.csv" in memory (linked list)
Result in 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 OR jmeterPlugin.sts.initFileAtStartupRegex=true and jmeterPlugin.sts.initFileAtStartup=.+\.csv READGet one line from list The charset use in the response is jmeterPlugin.sts.charsetEncodingHttpResponse=<charset>, default value = JMeter property : sampleresult.default.encoding
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, 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=<charset>, default value = System property : file.encoding
If jmeterPlugin.sts.addTimestamp is set to true then a timestamp will be added to the filename,
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 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. 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. Download Example Test Plan 4 Multi JMeter injectors and save list examples You can override STS settings using command-line options: - -DjmeterPlugin.sts.port=<port number> - -DjmeterPlugin.sts.loadAndRunOnStartup=<true/false> - -DjmeterPlugin.sts.datasetDirectory=<path/to/your/directory> - -DjmeterPlugin.sts.addTimestamp=<true/false> - -DjmeterPlugin.sts.daemon=<true/false> - -DjmeterPlugin.sts.charsetEncodingHttpResponse=<charset like UTF-8> - -DjmeterPlugin.sts.charsetEncodingReadFile=<charset like UTF-8> - -DjmeterPlugin.sts.charsetEncodingWriteFile=<charset like UTF-8> - -DjmeterPlugin.sts.initFileAtStartup=<files to read when STS startup, e.g : article.csv,users.csv> - -DjmeterPlugin.sts.initFileAtStartupRegex=<true/false> false : no regular expression, files with comma separator, true : read files matching the regular expression.
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 :
Link to JMeter Maven plugin : https://github.com/jmeter-maven-plugin/jmeter-maven-plugin STS ALONEThe Http Simple Table Server (STS) exist in external tool (.jar) without the need of JMeter. 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 |