jmeter-java-dsl icon indicating copy to clipboard operation
jmeter-java-dsl copied to clipboard

Default elements in test plan

Open 0xkkha opened this issue 3 years ago • 6 comments

JMeterDSL adds HTTP Cookie Manager and HTTP Cache Manager by default. In the same time when we create a test plan in JMeter natively there is no elements by default. I propose to remove default elements from jmeter-java-dsl test plan. Moreover, JMeterDSL and JMeter are multiprotocol load testing tools (http, jdbc, …), so http requests may not be in a test

Workaround according to docs:

testPlan(
    httpCookies().disable(),
    httpCache().disable(),

0xkkha avatar Feb 01 '22 14:02 0xkkha

Thank you for the proposal, and opening this for discussion.

Currently, httpCookies and httpCache manager are only added when an httpSampler is in the test plan.

This was added to simplify most of use cases: since is most common the requirement of using them than not using. Additionally, it avoids beginners and new comers to have to worry about such subtleties which are usually hidden and already included in browsers and similar apps.

In general terms: this eases most of test plans (not requiring to remember adding such elements), using sane defaults, encouraging good practices, already documented in user guide and java docs and only requiring simple lines to disabling.

Additionally, in general, in JMeter is usually adviceable to use provided templates, which already include best practices and most common settings (among which, cookie manager and cache manager are added by default in web test plan, advanced web test plan, recording and recording with think times templates).

The main scenario I see this could be a problem is for JMeter users which are already used to create test plan without such elements (which I have seen in many cases is something they unnoticeably miss), and some particular API corner cases that might require disabling them.

What are your main reasons for removing this logic?

Thank you again for asking for this, so we can think about this decision and understand/discuss about the reasoning behind it.

rabelenda avatar Feb 01 '22 15:02 rabelenda

This is another problem with this elem. You can invoke disable of it only from root of test plan. If I want to clear cache or cookie for only one sampler it doesn't work. If I add another cache/cookie managers into tree (not root) - there will be unclear logic of script.

kirillyu avatar Feb 02 '22 07:02 kirillyu

Hello,

Latest version of the library follows allows disabling and enabling httpCookies and httpCache at different levels of the test plan.

eg:

testPlan(
  httpCookies().disable(),
  httpCache().disable(),
  threadGroup(1, 1,
    // these requests will not use cache or cookies
    httpSampler("https://myservice.com"),
    httpSampler("https://myservice.com/products")
  ),
  threadGroup(1, 1,
    httpCookies(),
    httpCache(),
    // these requests will use cache and cookies
    httpSampler("https://myservice.com"),
    httpSampler("https://myservice.com/products")
  ),
)

In previous versions, above code would only disable cookies and cache for every item in test plan.

Is this the feature that your were you expecting @kirillyu ?

Or do you actually need a way of clearing cache and cookies (which can't currently explicitly be done don on JMeter, unless you use a jsr223 element)? If you actually need to clear cache and cookies at certain point in the test plan, maybe we can create a different issue and design a solution for it that doesn't require using custom jsr223 code.

Regards

rabelenda avatar Feb 02 '22 12:02 rabelenda

It's little bit different from what I want to say. If you have empty test plan with only one Thread Group and two httpSampler. You start it and see that there is cache or cookie that you not need. I don't know about that the cache or cookie are in test plan by default and try to disable. Go to the thread group level and write httpCache.disable() and nothing changed, go to the requests child's and again. And then go to the docs and then understand)

Probably we need the flag for this method like .global()?

kirillyu avatar Feb 02 '22 15:02 kirillyu

Have you tried what you mention with the latest version (released yesterday)?

What you describe sounds like the behavior previous versions of the DSL had.

rabelenda avatar Feb 02 '22 19:02 rabelenda

Hello, do you have any news testing with latest version?

We internally talked about some http cache issues with jmeter cache manager. We will further explore this and analyze if we should fix them.

rabelenda avatar Mar 14 '22 13:03 rabelenda