top of page
  • Writer's picturekyle Hailey

jmeter – getting started


jmeter

This blog post is just a start at documenting some of my experiences with jmeter. As far as load testing tools go, jmeter looks the most promising to me. It has an active community, supports many different databases and looks quite flexible as far as architecting different work loads goes.

The flexibility of jmeter also makes it hard to use. One can use jmeter for many other things besides databases so the initial set up is a bit oblique and there look to be many paths to similar results. As such, my understand and method for doing things will probably change considerably as I start to use jmeter more and more.

I’m installing it on a mac and using RDS instances.

installing jmeter

brew install jmeter

see

Database Driver download (I’m using the following)

  1. Mysql   mysql-connector-java-5.1.40-bin.jar http://ftp.iij.ad.jp/pub/db/mysql/Downloads/Connector-J/

  2. Oracle  ojdbc6.jar

  3. Postgres postgresql-9.4-jdbc4.jar

Created a test table

  1. CREATE TABLE authors (id INT, name VARCHAR(20), email VARCHAR(20));

  2. INSERT INTO authors (id,name,email) VALUES(2,’foo’,’foo@foo.com’);

Startup up jmeter

    $ which jmeter 
      /usr/local/bin/jmeter 
    $ jmeter 
      Writing log file to: /Users/kylelf/jmeter.log

brings up a graphic window


screen-shot-2017-01-03-at-2-40-06-pm

Add your path to the database drivers at the bottom of the screen by clicking “Browse …” and going to your driver file and selecting it.


screen-shot-2017-01-04-at-1-48-19-pm

We are going to create the following (minimum setup for an example)

  1. create test: Thread group named ‘Database Users’

  2. db connection: Config element of type JDBC Connection Configuration

  3. query to run: Sampler of type JDBC Request

  4. results output: Listener of type “View Results Tree”

1. First to do is add a “Thread Group”

(right click on “Test Plan”)

Define how many connections to make and how many loops to make of the workload


thread_group


screen-shot-2017-01-03-at-2-45-25-pm

interesting parts here are

  1. “Number of Threads (users)” : can set the number of database connections

  2. “Loop Count ” : can set the number of iterations of the test query

2. Add a Config Element of type JDBC Connection Configuration

Define what database to connect to


screen-shot-2017-01-03-at-2-46-28-pm

For Oracle make sure and change “Select 1″ to “Select 1 from dual” or you’ll get non-obvious error.

Name the pool. For example I call mine “orapool”

and fill out all the connection information

  1. Database machine, port and SID of form: jdbc:oracle:thin:@yourmachine:1521:ORCL

  2. JDBC Driver Class: oracle.jdbc.OracleDriver

  3. Username

  4. Password

screen-shot-2017-01-03-at-3-03-46-pm

3. Sampler of type JDBC Request

Define a SQL statement to run


screen-shot-2017-01-03-at-3-35-47-pm

screen-shot-2017-01-03-at-3-39-24-pm

Make sure and include the name of the thread pool created above. In my case it’s called “orapool”

add a SQL statement to run


screen-shot-2017-01-03-at-3-53-39-pm

4. Listener of type “View Results Tree”

create a widget to see the output


screen-shot-2017-01-03-at-3-55-36-pm

Final setup looks like

run your load and look at the output


Now you hit the run button, the green triangle.

Then click on “View Results Tree” to see the output.


screen-shot-2017-01-03-at-4-02-54-pm

I clicked on “View Results Tree” and then clicked on “JDBC Request” in red.

Then I’ll see some output. I choose “Response data” because it’s a bit more succinct and see the error. In this case there is an extra space ” ” at the end of “oracle.jdbc.OracleDriver “. Jmeter is sensitive to spaces. I’ve gotten a lot of errors because of spaces in fields such as variable names and such.

Correcting that it runs


screen-shot-2017-01-03-at-4-52-52-pm

All the setup might sound like a bit of a pain but once it’s set up, it’s easy to click through and make modifications.

All the setup is available in a text .jmx file and if you are brave you can edit directly there.

Look for “my” and replace

  1. myinstance.rds.amazonaws.com

  2. myuser

  3. mypassword

The above example is more or less pointless – sort of a “Hello World”.

From here though you can increase the number of threads, increase the number of loops, add more SQL statements.

Jmeter allows a lot of customization so you can add .cvs files for input values, capture output values into variables and use them in input values, have different types of loops with different users running concurrently etc.

More to come.

Christian Antognini gave a presentation at Oaktable World SF in Sept 2016. He was gracious enough to send along his functionally rich .jmx file and I’ll blog on that soon.

NOTE: PL/SQL has to be called with “call” and not “exec” and had to be a “callable  statement” type:

call minute_rollup(1000000)

4 views0 comments

Recent Posts

See All

Comments


bottom of page