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 : jmeterPlugin.sts.port=9191 jmeterPlugin.sts.addTimestamp=true jmeterPlugin.sts.datasetDirectory=D:/jmeter/dataset jmeterPlugin.sts.loadAndRunOnStartup=false jmeterPlugin.sts.daemon=false jmeterPlugin.sts.charsetEncodingHttpResponse=UTF-8 jmeterPlugin.sts.charsetEncodingReadFile=UTF-8 jmeterPlugin.sts.charsetEncodingWriteFile=UTF-8 jmeterPlugin.sts.initFileAtStartup=article.csv,users.csv jmeterPlugin.sts.initFileAtStartupRegex=false jmeterPlugin.sts.initFileAtStartup=file\d+\.csv jmeterPlugin.sts.initFileAtStartupRegex=true 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: sampleresult.default.encoding=UTF-8 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. At the beginning of the test, the first load injector will load data in memory (initial call) and at the end of the test it asks the STS saving values in a file. All the load injectors ask data from the same STS which is started on the JMeter controller. Getting StartedThere are different ways to start the STS:
jmeterPlugin.sts.loadAndRunOnStartup=true jmeterPlugin.sts.port=9191 jmeterPlugin.sts.daemon=false jsr223.init.file=simple-table-server.groovy When the STS is running go to http://<HOST>:<PORT>/sts/ to see all available commands and a short help. Usually http://localhost:9191/sts/ Calls are synchronized, all commands are executed ONE BY ONE.Example of a dataset file logins.csv: login1;password1 login2;password2 login3;password3 login4;password4 login5;password5 INITFILELoad file in memory. Lines are stored in a linked list, 1 line = 1 elementThe 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). http://hostname:port/sts/INITFILE?FILENAME=logins.csv HTML format:
Linked list after this command: login1;password1 login2;password2 login3;password3 login4;password4 login5;password5 The charset to read the file is jmeterPlugin.sts.charsetEncodingReadFile=<charset>, default value = System property : file.encoding File could be load when STS startup with jmeterPlugin.sts.initFileAtStartupRegex=false jmeterPlugin.sts.initFileAtStartup=article.csv,users.csv OR jmeterPlugin.sts.initFileAtStartupRegex=true jmeterPlugin.sts.initFileAtStartup=file\d+\.csv 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 listThe charset use in the response is jmeterPlugin.sts.charsetEncodingHttpResponse=<charset>, default value = JMeter property : sampleresult.default.encoding http://hostname:port/sts/READ?READ_MODE={FIRST, LAST, RANDOM}&KEEP={TRUE, FALSE}&FILENAME=logins.csv HTML format:
Available options:
KEEP=TRUE, READ_MODE=FIRST => login1;password1 Linked list after this command: login2;password2 login3;password3 login4;password4 login5;password5 login1;password1 KEEP=TRUE, READ_MODE=LAST => login5;password5 Linked list after this command: login1;password1 login2;password2 login3;password3 login4;password4 login5;password5 KEEP=TRUE, READ_MODE=RANDOM => login2;password2 Linked list after this command: login1;password1 login3;password3 login4;password4 login5;password5 login2;password2 KEEP=FALSE (delete mode), READ_MODE=FIRST => login1;password1 Linked list after this command: login2;password2 login3;password3 login4;password4 login5;password5 KEEP=FALSE, READ_MODE=LAST => login5;password5 Linked list after this command: login1;password1 login2;password2 login3;password3 login4;password4 KEEP=FALSE, READ_MODE=RANDOM => login2;password2 Linked list after this command: login1;password1 login3;password3 login4;password4 login5;password5 READMULTIGet multi lines from list in one requestAvailable options:
GET Protocol http://hostname:port/sts/READMULTI?FILENAME=logins.csv&NB_LINES={Nb lines to read}&READ_MODE={FIRST, LAST, RANDOM}&KEEP={TRUE, FALSE} 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: login4;password4 login5;password5 login1;password1 login2;password2 login3;password3 If *NB_LINES* greater than list size
ADDAdd a line into a file: (GET OR POST HTTP protocol)GET Protocol http://hostname:port/sts/ADD?FILENAME=dossier.csv&LINE=D0001123&ADD_MODE={FIRST, LAST}&UNIQUE={FALSE, TRUE} GET Parameters : FILENAME=dossier.csv&LINE=D0001123&ADD_MODE={FIRST, LAST}&UNIQUE={FALSE, TRUE} POST Protocol http://hostname:port/sts/ADD POST Parameters : FILENAME=dossier.csv, LINE=D0001123, ADD_MODE={FIRST, LAST}, UNIQUE={FALSE, TRUE} HTML format:
Available options:
POST Protocol with parameters FINDFind a line in a file (GET OR POST HTTP protocol)The LINE to find is for FIND_MODE :
GET Protocol http://hostname:port/sts/FIND?FILENAME=colors.txt&LINE=BLUE|RED&[FIND_MODE=[SUBSTRING,EQUALS,REGEX_FIND,REGEX_MATCH]]&KEEP=[TRUE, FALSE] 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 http://hostname:port/sts/FIND 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 listhttp://hostname:port/sts/LENGTH?FILENAME=logins.csv HTML format:
STATUSDisplay the list of loaded files and the number of remaining lines for each linked listhttp://hostname:port/sts/STATUS HTML format:
SAVESave the specified linked list in a file to the specified locationThe charset use to write the file is set with jmeterPlugin.sts.charsetEncodingWriteFile=<charset>, default value = System property : file.encoding http://hostname:port/sts/SAVE?FILENAME=logins.csv 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: 20140520T16h33m27s.logins.csv HTML format:
You can force the addTimestamp value with parameter ADD_TIMESTAMP in the url like : http://hostname:port/sts/SAVE?FILENAME=logins.csv&ADD_TIMESTAMP=[true,false] RESET*Remove all of the elements from the specified list* http://hostname:port/sts/RESET?FILENAME=logins.csv HTML format:
Always returns title OK even if the file did not exist STOPShutdown the Simple Table Serverhttp://hostname:port/sts/STOP 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 Serverhttp://hostname:port/sts/CONFIG 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:
jmeter.bat -DjmeterPlugin.sts.loadAndRunOnStartup=true -DjmeterPlugin.sts.port=9191 -DjmeterPlugin.sts.datasetDirectory=d:/data -DjmeterPlugin.sts.charsetEncodingReadFile=UTF-8 -n –t testdemo.jmx 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 :
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 |
On this page:
|