Comments (3)
This is really interesting, thank you for asking for this.
I have a question: are the SQLs part of setup/teardown logic or are they part of actual load/performance test?
If they are part of setup/teardown logic you might use existing test framework methods (like @BeforeEach
and @AfterEach
in Junit 5) and implement necessary logic with Java.
In the other case we might add directoryFilesDataSet
to JMeter DSL and you could use something like:
String sqlFileVar = "SQL_FILE";
String queryVar = "QUERY";
String poolName = "pool";
testPlan(
// using directory listing plugin (https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/directory-listing/DirectoryListing.md)
directoryFilesDataSet(new TestResource("sqls"), sqlFileVar),
jdbcConnectionPool(poolName, Driver.class, "jdbc:postgresql://localhost/my_db")
.user("user")
.password("pass"),
threadGroup(1, 1,
jdbcSampler(poolName, "${" + queryVar + "}")
.children(jsr223PreProcessor(s ->
s.vars.put(queryVar, new TestResource(s.vars.get(sqlFileVar)).rawContents())))
)
).run();
If you have different query types (not just selects), you could use s.sampler.setProperty("queryType", X)
inside the pre processor or we could extend jdbcSampler.queryType
method to allow any arbitrary string which would allow you to use queryType("${QUERY_TYPE}")
and set the query type in the pre processor the same way we are setting the query.
PS: as with csvDataSet
we could add a stopThreadOnEOF
method to stop test plan on directory listing exhaustion or to just re start from beginning of the list
from jmeter-java-dsl.
Thank you for your quick and fast responses.
The sql are not part of the setup/tear down.
Actually right now i have a JMX test plan where i store the queries in csv file and read then using the csv reader. This works for small files but when the number of enteries in the csv file (queries) or the query itself becomes large, then maintaining and reading from csv becomes a bit of challenge. I therefore wanted to see if I can place all the sql files in a directory and then the directory reader can read them one by one.
This could be further enhanced as per below logic when reading the sql from directory:
- If i run in functional mode then it should run only once and capture the responses and do response assertion.
- If i run it in Non functional mode, it can keep repeating the files in directory.
Attached Test Plan for reference:
Test_Plan_Scale_UP_down_UTG.jmx.zip
I run this as below using properties file as below:
jmeter -t Test_Plan_Scale_UP_down_UTG.jmx -q connection.properties -q test.properties
connection.properties:
#Change below properties to connect
HOSTNAME=localhost
PORT=80
USER=george
PASSWORD=
CATALOG=tpcds
DATABASE=sf100
#Change below for the JDBC connection
CONNECTION_STRING=jdbc:presto://localhost:8080/tpcds/sf10
DRIVER_CLASS=com.facebook.presto.jdbc.PrestoDriver
test.properties
JMETER_HOME=/Users/macbookpro/jmeter/apache-jmeter-5.6.2
#Change below for Queries
QUERY_PATH=/Users/macbookpro/Documents/Jmeter_Test_Plans/Data_Files/CSV_Files/Jmeter-TPCDS-50.csv
#Change below for Report dir path
REPORT_PATH=/Users/macbookpro/Documents/Jmeter-Results
#Change below for concurrancy and test control
CONCURRENT_QUERY_COUNT=10
HOLD_PERIOD=10
QUERY_TIMEOUT=10
LIMIT_RESULTSET=1000
MAX_CONCURRANCY=10
Note : The test plan i don't think fully converts to a valid DSL using the jmx converter
from jmeter-java-dsl.
Great, thank you for the detailed example and explanation!
If you would like to try to implement and contribute the directoryFilesDataSet
, I think it would be a really good contribution. Otherwise you might wait until we can dedicate to it (in a few weeks).
Another potential implementation might be something like:
String queryVar = "QUERY";
String poolName = "pool";
testPlan(
// using directory listing plugin (https://github.com/Blazemeter/jmeter-bzm-plugins/blob/master/directory-listing/DirectoryListing.md)
directoryFilesDataSet(new TestResource("sqls"), queryVar)
.fileContents(),
jdbcConnectionPool(poolName, Driver.class, "jdbc:postgresql://localhost/my_db")
.user("user")
.password("pass"),
threadGroup(1, 1,
jdbcSampler(poolName, "${" + queryVar + "}")
)
).run();
This would make resulting test plan simpler but more effort to implement since it requires implementation of new JMeter test element.
Regards
from jmeter-java-dsl.
Related Issues (20)
- jmdsl fails to convert a test plan with JDBC request where query is read via a csvdataset config using the variable of csvdataset HOT 1
- JMeter 5.6 upgrade HOT 5
- Add support to jmeter-influxdb2-listener-plugin HOT 4
- Add support for the User Parameters preprocessor HOT 3
- Header inheritance fails if encounters JSR223 sampler with SamplerScript class HOT 3
- Support both a number of iterations and Duration HOT 3
- Add graphite in BackendListener like InfluxDbBackendListener HOT 3
- Add support for saving variables between different threads HOT 3
- Add support for lambdas in azure HOT 4
- Add support to Stepping Thread Group HOT 3
- Flow control action HOT 8
- RpsThreadgroup - IllegalArgumentException (Host may not be blank) HOT 11
- Support for Prometheus Listener for generating Grafana dashboard HOT 12
- getting socket connection closed when using rpsThreadGroup HOT 2
- Add support HTTP2 & gRCP HOT 2
- InfluxDB listener HOT 3
- Want to use in python projects HOT 3
- Remote Testing java.lang.NoSuchMethodException: DistributedJmeterEngine$1.<init>() HOT 1
- IllegalArgumentException: URI is not hierarchical HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jmeter-java-dsl.