Test Rest APIs with Authentication Using JMeter – RedLine13

Add ‘regular expression extractor’ under login request.

We will use it to fetch dynamic access token from the response of Login Request. See the below screenshot-

You will have to set following parameters for ‘Regular Expression Extractor’:

a) Reference Name: Name of the variable in which the extracted text will be stored. In our example, it is ‘BEARER’.

b) Regular Expression: The pattern against which the extracted text will be matched. You can read more about JMeter regular expressions here.In this example I have used {“access_token”:”(. ?)” because I wanted to extract everything after {“access_token”:” string until next “ (inverted) comma.

c) Template: Grouping of strings within ( ) brackets. $1$ means 1st group, $2$ means 2nd group

d) Match Number: Tells which match should be picked. 0 is used for random.

e) Default Value: In case of no match which value should be picked.

Associating requests with responses

If you define the property proxy.number.requests=true
JMeter will add a number to each sampler and each response.
Note that there may be more responses than samplers if excludes or includes have been used.
Responses that have been excluded will have labels enclosed in [ and ], for example [23 /favicon.ico]

Capturing binary post data

JMeter is able to capture binary POST data.
To configure which content-types are treated as binary, update the JMeter property proxy.binary.types.
The default settings are as follows:

How to login into the web application using jmeter?

The instructions below are for login, logout will be similar.

Installing the certificate in firefox

Choose the following options:

Load testing on the cloud

After checking that your script worked well, you can run this script, as you would with any JMeter script, on AWS (Amazon Web Services) to perform load test.  Apache JMeter is one of the most popular tools for load testing and scaling out your JMeter test plan on the cloud in RedLine13 is easy.  This guide and video walks you through running your first JMeter test.

That’s it.

Open model thread group¶

This thread group is experimental, and it might change in the future releases. Please provide your feedback on what works and what could be improved.

Open Model Thread Group defines a pool of users that will execute a particular test case against the server.
The users are generated according to the schedule.

The load profile consists of a sequence of constant, increasing or decreasing load.
The following commands are available:

  • rate(<number>/sec) — configures target load rate.
    The following time units are supported: ms, sec, min, hour, day.
    You can omit time unit in case the rate is 0: rate(0)
  • random_arrivals(<number> sec) — configures random arrivals schedule with the given duration.
    The starting load rate is configured before random_arrivals, and the finish load rate is configured after random_arrivals.
    For example, 10 minute test from 5/sec at the beginning till 15/sec at the end could be configured as rate(5/sec) random_arrivals(10 min) rate(15/sec).

    The implicit rate at the beginning of the test is 0. If the finish rate is not provided (or if several random_arrivals steps go one after another),
    then the load is constant. For instance, rate(3/sec) random_arrivals(1 min) random_arrivals(2 min) rate(6/sec) configures
    constant rate of 3/sec for the first 1 minute, and then the load increases from 3/sec till 6/sec during the next 2 minutes.
    The time units are the same as in rate.
  • even_arrivals(<number> sec) — configures even arrivals (TODO: not implemented yet). For instance, if the desired load
    is 1/sec, then random_arrivals would lauch samples with exactly 1 second intervals.
  • pause(<number> sec) — configures a pause for the given duration.
    The rate is restored after the pause, so rate(2/sec) random_arrivals(5 sec) pause(5 sec) random_arrivals(5 sec)
    generates random arrivals with 2/sec rate, then a pause for 5 seconds (no new arrivals), then 5 more seconds with 2/sec rate.
    Note: pause duration is always honoured, even if all the scenarios are complete, and no new ones will be scheduled.
    For instance, if you use rate(1/sec) random_arrivals(1 min) pause(1 hour), the thread group would
    always last for 61 minutes no matter how much time do individual scenarios take.
  • /* Comments */ can be used to clarify the schedule or temporary disable some steps. Comments
    cannot be nested.
  • // line comments can be used to clarify the schedule or temporary disable some steps.
    Line comment lasts till the end of the line.
Похожее:  Как активировать Alexa на Amazfit Band 5 | Руководство тест - GizChina.it

The thread groups terminates threads as soon as the schedule ends. In other words, the threads are interrupted
after all arrivals and pause intervals.
If you want to let the threads complete safely, consider adding pause(5 min) at the end of the schedule.
That will add 5 minutes for the threads to continue.

There are no special functions for generating the load profile in a loop, however, the default JMeter templating functions
can be helpful for generating the schedule.

For example, the following pattern would generate a sequence of 10 steps where each step lasts 10 seconds: 10/sec, 20/sec, 30/sec, …
${__groovy((1..10).collect { “rate(” it*10 “/sec) random_arrivals(10 sec) pause(1 sec)” }.join(” “))}
You can get variables from properties as follows:
rate(${__P(beginRate,40)}) random_arrivals(${__P(testDuration, 10)} sec) rate(${__P(endRate,40)})

Currently, the load profile is evaluated at the beginning of the test only, so if you use dynamic functions, then only the first result will be used.

Ssl manager¶

The SSL Manager is a way to select a client certificate so that you can test
applications that use Public Key Infrastructure (PKI).
It is only needed if you have not set up the appropriate System properties.

Choosing a Client Certificate

You may either use a Java Key Store (JKS) format key store, or a Public Key
Certificate Standard #12 (PKCS12) file for your client certificates. There
is a feature of the JSSE libraries that require you to have at least a six character
password on your key (at least for the keytool utility that comes with your

To select the client certificate, choose from the menu bar.
You will be presented with a file finder that looks for PKCS12 files by default.
Your PKCS12 file must have the extension ‘.p12’ for SSL Manager to recognize it
as a PKCS12 file.

Any other file will be treated like an average JKS key store.
If JSSE is correctly installed, you will be prompted for the password. The text
box does not hide the characters you type at this point — so make sure no one is
looking over your shoulder.

Похожее:  Твинго (tvingo ru) личный кабинет Владикавказ - вход, проверить баланс Твинго телеком

Or you can set the appropriate System properties – see the system.properties file.

The next time you run your test, the SSL Manager will examine your key store to
see if it has at least one key available to it. If there is only one key, SSL
Manager will select it for you. If there is more than one key, it currently selects the first key.
There is currently no way to select other entries in the keystore, so the desired key must be the first.

Things to Look Out For

You must have your Certificate Authority (CA) certificate installed properly
if it is not signed by one of the five CA certificates that ships with your
JDK. One method to install it is to import your CA certificate into a JKS
file, and name the JKS file “jssecacerts”.

Place the file in your JRE’s
lib/security folder. This file will be read before the “cacerts” file in
the same directory. Keep in mind that as long as the “jssecacerts” file
exists, the certificates installed in “cacerts” will not be used.

Step 1 – add thread group 1 : thread group – authorization token generation

1) Add Thread Group – We should provide the name of the Thread Group. In this case, this thread group is used to generate the token, so named as Token Generation. We want to generate only 1 token, so Number of Threads, Ramp-up period and Loop Count are 1 only.

Step 3 – adding listeners to test plan

Listeners – They show the results of the test execution. They can show results in a different format such as a tree, table, graph, or log file

We have added  listeners – View Result Tree 

Step 4 – save the test plan

To Save: Click File Select -> Save Test Plan as ->Give the name of the Test Plan. It will be saved as .jmx format.

Step 5  – run the test plan

Click on Green Triangle as shown at the top to run the test.

Step 6 – view the execution status

Click on View Result Tree to see the status of Run. A successful request will be of a Green color in the Text Section

Here, we can see that the Token Generation request is successfully processed.

The below image shows that the Main Request is successfully executed too.

Congratulation!! We are able to add an authorization token generated by a request and add it to another request and processed the request using JMeter. 

Test plan¶

The Test Plan is where the overall settings for a test are specified.

Static variables can be defined for values that are repeated throughout a test, such as server names.
For example the variable SERVER could be defined as www.example.com, and the rest of the test plan
could refer to it as ${SERVER}. This simplifies changing the name later.

If the same variable name is reused on one of more
User Defined Variables Configuration elements,
the value is set to the last definition in the test plan (reading from top to bottom).
Such variables should be used for items that may change between test runs,
but which remain the same during a test run.

Похожее:  Сбербанк Онлайн Код Авторизации Номер Документа • Для чего предназначена | Вход в банк онлайн ☎

Note that the Test Plan cannot refer to variables it defines.

If you need to construct other variables from the Test Plan variables,
use a

User Defined Variables

test element.

Selecting Functional Testing instructs JMeter to save the additional sample information
– Response Data and Sampler Data – to all result files.
This increases the resources needed to run a test, and may adversely impact JMeter performance.
If more data is required for a particular sampler only, then add a Listener to it, and configure the fields as required.

The option does not affect CSV result files, which cannot currently store such information.

Also, an option exists here to instruct JMeter to run the Thread Group serially rather than in parallel.

Run tearDown Thread Groups after shutdown of main threads:
if selected, the tearDown groups (if any) will be run after graceful shutdown of the main threads.
The tearDown threads won’t be run if the test is forcibly stopped.

Test plan now provides an easy way to add classpath setting to a specific test plan.
The feature is additive, meaning that you can add jar files or directories,
but removing an entry requires restarting JMeter.

Note that this cannot be used to add JMeter GUI plugins, because they are processed earlier.

However it can be useful for utility jars such as JDBC drivers. The jars are only added to
the search path for the JMeter loader, not for the system class loader.

JMeter properties also provides an entry for loading additional classpaths.
In jmeter.properties, edit “user.classpath” or “plugin_dependency_paths” to include additional libraries.
See JMeter’s Classpath and
Configuring JMeter for details.

Thread group¶

Since JMeter 3.0, you can run a selection of Thread Group by selecting them and right clicking. A popup menu will appear:

Popup menu to start a selection of Thread Groups
Popup menu to start a selection of Thread Groups

Notice you have three options to run the selection of Thread Groups:

Start the selected thread groups only
Start no pauses
Start the selected thread groups only but without running the timers
Start the selected thread groups only using validation mode. Per default this runs the Thread Group in validation mode (see below)

Validation Mode:

This mode enables rapid validation of a Thread Group by running it with one thread, one iteration, no timers and no

Startup delay

set to

Behaviour can be modified with some properties by setting in

Uploading files

Some browsers (e.g. Firefox and Opera) don’t include the full name of a file when uploading files.
This can cause the JMeter proxy server to fail.
One solution is to ensure that any files to be uploaded are in the JMeter working directory,
either by copying the files there or by starting JMeter in the directory containing the files.

Where do samples get recorded?

JMeter places the recorded samples in the Target Controller you choose. If you choose the default option
“Use Recording Controller”, they will be stored in the first Recording Controller found in the test object tree (so be
sure to add a Recording Controller before you start recording).

1 Звезда2 Звезды3 Звезды4 Звезды5 Звезд (1 оценок, среднее: 4,00 из 5)

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *