Jmeter series--Controllers: [Samplers, Logic Controllers], Listeners...all the introductions [links for details]

Execution priority/order of different components under the thread group

  1. configuration element, listener
  2. Preprocessor
  3. timer
  4. logic controller
  5. sampler
  6. post processor
  7. Affirmation

Sampler Execution Order

In the absence of a logic controller, the samplers are executed in order from top to bottom

Controllers

        Jmeter has two types of controllers: Samplers (samplers) and Logical Controllers (logic controllers);

  • The controller is to control the execution conditions of the sampler

Samplers

  • Sampler: Let Jmeter send requests to the server
  • The sampler instructs Jmeter to send a request to the server and wait for a response
  • Multiple samplers are run in the order they appear in the tree
  • Sampler + controller can modify the number of sampler executions

The sampler that comes with Jmeter

  • FTP Request
  • HTTP Request (can be used for SOAP or REST Webservice also)
  • JDBC Request
  • Java object request
  • JMS request
  • JUnit Test request
  • LDAP Request
  • Mail request
  • OS Process request
  • TCP request

============================================================================================================================================================================================================================================================================================================================================================================================================================

Features of Samplers

  • Each sampler has several properties that can be set
  • You can also add multiple Config Elements to a test plan or thread group to further customize the sampler
  • Finally, add a Listener to the test plan to view the request results, or store the results to disk
  • Remarks: The configuration components and listeners mentioned above will be explained in detail in later articles! just mention it here

Chestnut 1: Add HTTP request default value configuration element [HTTP header management, cookie management, cache management, request default value]

        If you want to send multiple requests of the same type (such as HTTP requests) to the same server, you can consider extracting public HTTP information

 

 Chestnut 2: Add assertion

When stress testing a web application, the server may return a successful response code or a failed response code; add an assertion to check that the response of the request is as expected

 All samplers will be explained in the future [Jump link: ]

============================================================================================================================================================================================================================================================================================================================================================================================================================

Logic Controllers

  • Logic controller: You can customize the logic that determines the timing of sending requests

Introduction to Logic Controllers

  • The logic controller can customize the logic that determines the timing of sending the request
  • You can also change the order of requests for its child elements
  • Logic controllers can be combined to obtain different results

The chestnut of the logic controller [Only one-time controller]

In normal times, whether it is stress testing or interface automation testing, our login request generally only needs to be executed once to obtain the token;

And only one controller can just meet this requirement [in fact, it is the same as obtaining token in conftest.py in pytest in interface automation]

what logic controller

 All logic controllers will be explained in the future [Jump link: ]

============================================================================================================================================================================================================================================================================================================================================================================================================================

Listeners

The listener provides the right to collect running information when Jmeter is running

Common Listeners

  • Graph Results:   Plot response times on a graph
  • View Result Tree: The most commonly used viewing result tree, showing the detailed information of Samplers request and response, which can be displayed in various formats (such as: HTML, XML)
  • Other listeners provide summary or aggregated information

save data locally

  • Each listener can save the collected data to a specified file
  • You can specify the fields to keep, and the format of the file (CSV or XML file)

focus on

  • The result data obtained by all listeners is consistent . The only difference is the display method of the data . Different listeners have different display methods .
  • Listeners can be added anywhere including test plans, thread groups, samplers, etc. They will collect data at the same level and all subcomponents

 what listener

jmeter has relatively few listeners by default, but if you want to do a good job in performance testing, it is essential to install some listener plug-ins.

 All listeners will be explained in the future [Jump link: ]

============================================================================================================================================================================================================================================================================================================================================================================================================================

Preprocessor

  • Perform some action before making a sampler request
  • The more commonly used are: setting some parameters, modifying the settings of the sampler, script preprocessing

what preprocessor

post processor

  • Do something after the sampler request
  • The more commonly used is: processing response data, extracting a certain value

what post processor

 All the pre- and post-positions will be explained in the future [Jump link: ]

============================================================================================================================================================================================================================================================================================================================================================================================================================

Affirmation

  • You can assert the content of the server's response
  • Use assertions in performance test scripts, generally for debugging scripts
  • The use of assertions in interface automation testing is generally to rigorously verify whether the interface response content meets expectations

Assertion success or failure

  • Whether the assertion is successful or not, you can view it through the listener-assertion result
  • If the assertion fails, the request will be marked as failed, and it will also be displayed in the viewing result tree , and the error rate will be displayed in the aggregation report

add assertion

  • Assertions can be added to any sampler, only the current one
  • If the assertion is under the thread group, it will be applied to all samplers under the thread group

Should assertions be used in performance testing?

In most cases, assertions cannot be used, because assertions will not only increase the response time, lower the final result value, but also occupy system resources

what assertion

 All assertions will be explained in the future [Jump link: ]

============================================================================================================================================================================================================================================================================================================================================================================================================================

Timer Timers

When not using the timer

  • The Jmeter thread will execute each sampler sequentially without pausing
  • Jmeter may make too many requests in a short period of time, overwhelming the server

When using the timer

  • You can add a timer under the sampler , so that the timer will only act on the current sampler
  • You can also add multiple timers under the thread group , count the sum of the timers, and then act on all samplers under the thread group

what timer

 All timers will be explained in the future [Jump link: ]

============================================================================================================================================================================================================================================================================================================================================================================================================================

Introduction to Configuration Components

  • Configuration elements and samplers are closely related
  • For example, commonly used: HTTP default value, setting database connection, FTP connection, etc.

what configuration element

 All configuration components will be explained in the future [Jump link: ] 

Guess you like

Origin blog.csdn.net/qq_41663420/article/details/129868078