Skip to content

JMeter

JMeter Beanshell Server

The Beanshell Interpreter in JMeter can act as a server which as stated in the JMeter documentation is accessible by telnet or http.

So what, I hear you say, well this can be useful and we will explore some of these uses in this Blog Post.

Before we move on the definition of a Beanshell can be found on the official Web Site.

But at a high level:

You can use BeanShell interactively for Java experimentation and debugging as well as to extend your applications in new ways. Scripting Java lends itself to a wide variety of applications including rapid prototyping, user scripting extension, rules engines, configuration, testing, dynamic deployment, embedded systems, and even Java education.

In short, BeanShell is dynamically interpreted Java, plus a scripting language and flexible environment all rolled into one clean package.

So effectively the Beanshell can dynamically change properties or variables while the test is running.

Managing data during performance testing

We are going to talk about data in this blog post, predominately test data required for performance testing.

This is something that makes the life of a performance tester extremely difficult and awkward as because of the huge quantities required, in the right state, that match the criteria required for your test to run.

We often have to approach the use of large quantities data for the purpose of performance testing in a number of ways:

  • Use a small subset,
  • Ask business users or functional test teams for a set of data, that may become redundant after an execution of your testing because you may alter the state during testing making this data short lived and therefore requests to the business become frequent,
  • Restore your database after each test iteration, this may not be possible if the database is shared and is certainly not agile,
  • Create your own data before the tests start, this can be long-winded and may require multiple legacy system interaction or overnight batch processes to get the data in the right state.

Fear not, help is at hand from your friends at OctoPerf.

As we have seen above there are a number of valid ways to get data but the one we are going to explore and the one that make our tests reusable and agile is to query the database of the application under test, or any supporting application databases, to retrieve usable data using SQL this way we avoid our defined pitfalls above by:

  • Taking as much data as we need from our databases,
  • Not needing to ask the business because we have the relevant SQL at our disposal,
  • Not needing to restore the database as we just take more of the data we need from our data-sources
  • Avoid creating your own data using the user interface.

Ok, we need to caveat this if you have a performance test environment that does not contain a copy of production data, or artificially constructed representative data volumes then this approach will not work but you could argue that performance testing on a system that does not have production quantities of data is not representative so lets assume you do, because I think most will.

Before moving on there is obviously the ability, in JMeter, to create random data that conform to any number of rules (Dates, Random Strings or Integers, Values from Arrays, a value from any number of the JMeter native, or 3rd party, function libraries.

But if you need data that exists in your application under test to either use, update or delete then you need to know the values before testing starts and this is what we are looking at in this post.

Is JMeter a good alternative to LoadRunner

The subject of this post is ‘Is JMeter, a good alternative to LoadRunner’.

The short answer is yes absolutely, the longer answer is of course a lot more complex and interesting and worthy of discussion.

We will not discuss the more technical aspects of the tools as there are many, many posts talk about this already and it’s not worth repeating the same thing again.

Let’s look at it from a usability in the real world perspective.

JMeter If Controller

You may ask yourself:

  • How can I script Thread groups with dynamic behavior?
  • How to use the JMeter If Controller to leverage conditional behavior?

Good News! We're going to show you the JMeter If Controller by introducing you to conditional statements, advanced conditions and performance considerations.

Use-Cases

The If Controller works great when you need to execute some elements of the Thread Group based on a given state. Let me give you meaningful examples:

  • If the shopping cart is empty, then execute Add a New Product to Cart,
  • If Account balance is below Zero, then Issue a wire transfer to rebalance the Account.

Depending on a given condition, then a given action is taken. That's it!

Performance Test Strategy

A long time ago, Quality Assurance was executed after development. Performance testing was an activity executed when software was ready for production.

If a performance issue was found, most companies:

  • Fix the issue which means a complete new cycle including QA Tests and performance tests are required,
  • Or put the software live and decided to fix it as part of ongoing development,
  • Or borrow from the future. That's technical debt.

Let’s be fair: this approach isn't optimal.

The root cause is performance testing is not considered viable until the software reached a certain level of maturity.

The DevOps approach is exactly the opposite: performance test early.

It is known as shift left performance testing and it works it just needs Quality Assurance teams to think a little differently when it comes to performance testing and to have a performance test strategy in place to support shift left performance testing.

Let’s explore how to integrate load testing as part of your software development strategy.