Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add checkbox to enable/disable params in HTTP Sampler #6291

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

pochopsp
Copy link
Contributor

Description

This pull request adds a new column in the HTTP Sampler parameters table which allows the user to enable or disable the http parameter.

To implement this feature, a new "isEnabledFromGui" property has been added in HTTPArgument and it has been used in several places (HTTPHC4Impl, HTTPSamplerBase, PutWriter etc.) to determine whether to include the argument in the request or not.
To enable the property setting by the user a new column has been added in HTTPArgumentsPanel.
The HTTPArgumentSchema has been adjusted to include this new field too.
Tests file and localization files has been adjusted to be compliant with this new attribute.

Motivation and Context

I think this feature could be really useful, because sometimes I and other people I know wished JMeter had it while doing some tests.
Fixes #5466

How Has This Been Tested?

I have successfully built the project by using ./gradlew build and all tests ran without issues.
My testing environment is Windows 10, Intel I5 6th gen, 16GB Ram DD4, Oracle JDK 17.

Screenshots (if appropriate):

image
image

Types of changes

  • New feature (non-breaking change which adds functionality)

Checklist:

  • [x ] My code follows the code style of this project.
  • I have updated the documentation accordingly.

pochopsp added 2 commits June 11, 2024 23:55
Added a new "isEnabledFromGui" property in HTTPArgument used
to determine whether to include the argument in the request
or not.
This property is set by the user for each HTTP parameter by
clicking on the "Enable" column put on the very left of each
parameter row.

Fixes apache#5466
@pochopsp
Copy link
Contributor Author

Hi @vlsi could you please help me on that?
I don't really have a clue on why these tests are failing...

@pochopsp
Copy link
Contributor Author

@vlsi I've also ran on my machine the task :src:dist-check:batchResponseDecompression which is failing in 17, microsoft, windows, America/New_York, tr_TR and it ran successfully
image

@@ -30,6 +30,9 @@ import org.apiguardian.api.API
public abstract class HTTPArgumentSchema : ArgumentSchema() {
public companion object INSTANCE : HTTPArgumentSchema()

public val enabledFromGui: BooleanPropertyDescriptor<HTTPArgumentSchema>
by boolean("HTTPArgument.enabled_from_gui")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is hard, however, I am not sure we want stressing "from gui" part.
This is more like a generic enable/disable feature rather than "enabled in gui".

@vlsi
Copy link
Collaborator

vlsi commented Nov 1, 2024

@pochopsp, have you tried using the default org.apache.jmeter.testelement.TestElementSchema#getEnabled for the attributes?
Is there a need for a separate property?

@pochopsp
Copy link
Contributor Author

pochopsp commented Nov 8, 2024

@vlsi you were right, there is no need for a new property in the HTTArgumentSchema. I updated my pull request with commits including the use of org.apache.jmeter.testelement.TestElementSchema.enabled as you suggested.
Furthermore, by doing so the number of edited files decreased to just six.

@vlsi vlsi force-pushed the #5466-HTTP-disable-params branch 4 times, most recently from facce27 to 3a066b8 Compare January 14, 2025 13:43
*
* @param name the name of the parameter
* @param value the value of the parameter
* @param alreadyEncoded true if the name and value is already encoded, in which case they are decoded before storage.
* @param contentEncoding the encoding used for the parameter value
*/
public HTTPArgument(String name, String value, boolean alreadyEncoded, String contentEncoding) {
setEnabled(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed? enabled is the default state, so I am not sure what is the reason of adding it here

@@ -299,7 +296,7 @@ public void setHeaders(URLConnection connection, HTTPSamplerBase sampler) throws

// Just append all the parameter values, and use that as the post body
StringBuilder postBodyBuffer = new StringBuilder();
for (JMeterProperty jMeterProperty : sampler.getArguments()) {
for (JMeterProperty jMeterProperty : sampler.getArguments().getEnabledArguments()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we should not filter "empty" arguments from here.

Frankly, I do not understand the reason why "empty named" (.isSkippable(...)) arguments are included only in certain cases.

@vlsi vlsi force-pushed the #5466-HTTP-disable-params branch 3 times, most recently from c8b378f to 8b183d0 Compare January 14, 2025 16:29
@vlsi vlsi force-pushed the #5466-HTTP-disable-params branch from 8b183d0 to bbce13d Compare January 14, 2025 16:53
@vlsi
Copy link
Collaborator

vlsi commented Jan 14, 2025

Looks like the regression tests pass, however, we should add new tests for the disabled arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTTP Sampler and HTTP Request Defaults - add checkbox to enable/disable parameters
2 participants