Compare commits

...

4 Commits

Author SHA1 Message Date
Milamber b09e12e2ae
Merge 177a53073c into 77675e0b8e 2025-06-17 15:48:03 +00:00
Milamber 177a53073c
See #6219 - fix unnecessary yield usage in the switch expression 2025-06-17 18:46:10 +03:00
Milamber 9578941ad4
See #6219 - refactor CompOper to an enum 2025-06-17 18:43:29 +03:00
Milamber 21440e9778
Remove not standard options for Java 17 2025-06-17 18:38:50 +03:00
6 changed files with 113 additions and 90 deletions

View File

@ -183,13 +183,11 @@ esac
# Modern container memory detection is automatic in Java 17+ # Modern container memory detection is automatic in Java 17+
# RUN_IN_DOCKER="-XX:+UseContainerSupport" # RUN_IN_DOCKER="-XX:+UseContainerSupport"
# Java 17 specific performance optimizations
# Modern JVM performance flags for better throughput and reduced latency
JAVA17_PERFORMANCE="-XX:+AlwaysPreTouch -XX:+UseLargePages -XX:+OptimizeStringConcat"
# Enhanced G1GC tuning for Java 17 # Finally, some tracing to help in case things go astray:
# Improved G1 performance with better defaults and new features # You may want to add those settings:
: "${GC_ALGO:="-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -XX:+ParallelRefProcEnabled -XX:+UseStringDeduplication -XX:G1HeapRegionSize=16m"}" # -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem
: "${GC_ALGO:="-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20"}"
# Always dump on OOM (does not cost anything unless triggered) # Always dump on OOM (does not cost anything unless triggered)
@ -198,7 +196,7 @@ SYSTEM_PROPS="-Djava.security.egd=file:/dev/urandom"
SERVER="-server" SERVER="-server"
if [ -z "${JMETER_COMPLETE_ARGS}" ]; then if [ -z "${JMETER_COMPLETE_ARGS}" ]; then
ARGS="$JAVA_OPTS $SERVER $DUMP $HEAP $VERBOSE_GC $GC_ALGO $JAVA17_PERFORMANCE $SYSTEM_PROPS $JMETER_LANGUAGE $RUN_IN_DOCKER" ARGS="$JAVA_OPTS $SERVER $DUMP $HEAP $VERBOSE_GC $GC_ALGO $SYSTEM_PROPS $JMETER_LANGUAGE $RUN_IN_DOCKER"
else else
ARGS="" ARGS=""
fi fi

View File

@ -80,9 +80,6 @@ if not defined JMETER_LANGUAGE (
rem Minimal version to run JMeter rem Minimal version to run JMeter
set MINIMAL_VERSION=17.0.0 set MINIMAL_VERSION=17.0.0
rem Java 17 specific performance optimizations
rem Modern JVM performance flags for better throughput and reduced latency
set JAVA17_PERFORMANCE=-XX:+AlwaysPreTouch -XX:+UseLargePages -XX:+OptimizeStringConcat
rem Optimized GC logging for Java 17 with structured output and performance analysis rem Optimized GC logging for Java 17 with structured output and performance analysis
rem Uncomment to enable comprehensive GC logging with rotation and detailed metrics rem Uncomment to enable comprehensive GC logging with rotation and detailed metrics
@ -150,10 +147,8 @@ if not defined HEAP (
) )
rem Legacy GC verbose options removed (Java 8/9 support discontinued) rem Legacy GC verbose options removed (Java 8/9 support discontinued)
rem Enhanced G1GC tuning for Java 17
rem Improved G1 performance with better defaults and new features
if not defined GC_ALGO ( if not defined GC_ALGO (
set GC_ALGO=-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -XX:+ParallelRefProcEnabled -XX:+UseStringDeduplication -XX:G1HeapRegionSize=16m set GC_ALGO=-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20
) )
set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom set SYSTEM_PROPS=-Djava.security.egd=file:/dev/urandom
@ -182,7 +177,7 @@ if not defined DDRAW (
rem Collect the settings defined above rem Collect the settings defined above
if not defined JMETER_COMPLETE_ARGS ( if not defined JMETER_COMPLETE_ARGS (
set ARGS=%JAVA_OPTS% %DUMP% %HEAP% %VERBOSE_GC% %GC_ALGO% %JAVA17_PERFORMANCE% %DDRAW% %SYSTEM_PROPS% %JMETER_LANGUAGE% %RUN_IN_DOCKER% set ARGS=%JAVA_OPTS% %DUMP% %HEAP% %VERBOSE_GC% %GC_ALGO% %DDRAW% %SYSTEM_PROPS% %JMETER_LANGUAGE% %RUN_IN_DOCKER%
) else ( ) else (
set ARGS= set ARGS=
) )

View File

@ -35,17 +35,77 @@ public class SizeAssertion extends AbstractScopedAssertion implements Serializab
private static final long serialVersionUID = 241L; private static final long serialVersionUID = 241L;
// Static int to signify the type of logical comparator to assert /**
* Comparison operators for size assertions
*/
public enum ComparisonOperator {
EQUAL(1, "size_assertion_comparator_error_equal"),
NOTEQUAL(2, "size_assertion_comparator_error_notequal"),
GREATERTHAN(3, "size_assertion_comparator_error_greater"),
LESSTHAN(4, "size_assertion_comparator_error_less"),
GREATERTHANEQUAL(5, "size_assertion_comparator_error_greaterequal"),
LESSTHANEQUAL(6, "size_assertion_comparator_error_lessequal");
private final int value;
private final String errorMessageKey;
ComparisonOperator(int value, String errorMessageKey) {
this.value = value;
this.errorMessageKey = errorMessageKey;
}
public int getValue() {
return value;
}
public String getErrorMessageKey() {
return errorMessageKey;
}
public static ComparisonOperator fromValue(int value) {
for (ComparisonOperator op : values()) {
if (op.value == value) {
return op;
}
}
throw new IllegalArgumentException("Invalid comparison operator value: " + value);
}
public boolean evaluate(long actual, long expected) {
return switch (this) {
case EQUAL -> actual == expected;
case NOTEQUAL -> actual != expected;
case GREATERTHAN -> actual > expected;
case LESSTHAN -> actual < expected;
case GREATERTHANEQUAL -> actual >= expected;
case LESSTHANEQUAL -> actual <= expected;
};
}
}
// Backward compatibility constants - deprecated
/** @deprecated Use {@link ComparisonOperator#EQUAL} instead */
@Deprecated
public static final int EQUAL = 1; public static final int EQUAL = 1;
/** @deprecated Use {@link ComparisonOperator#NOTEQUAL} instead */
@Deprecated
public static final int NOTEQUAL = 2; public static final int NOTEQUAL = 2;
/** @deprecated Use {@link ComparisonOperator#GREATERTHAN} instead */
@Deprecated
public static final int GREATERTHAN = 3; public static final int GREATERTHAN = 3;
/** @deprecated Use {@link ComparisonOperator#LESSTHAN} instead */
@Deprecated
public static final int LESSTHAN = 4; public static final int LESSTHAN = 4;
/** @deprecated Use {@link ComparisonOperator#GREATERTHANEQUAL} instead */
@Deprecated
public static final int GREATERTHANEQUAL = 5; public static final int GREATERTHANEQUAL = 5;
/** @deprecated Use {@link ComparisonOperator#LESSTHANEQUAL} instead */
@Deprecated
public static final int LESSTHANEQUAL = 6; public static final int LESSTHANEQUAL = 6;
/** Key for storing assertion-information in the jmx-file. */ /** Key for storing assertion-information in the jmx-file. */
@ -174,41 +234,20 @@ public class SizeAssertion extends AbstractScopedAssertion implements Serializab
* than equal, less than equal. * than equal, less than equal.
* *
*/ */
private record ComparisonResult(boolean result, String errorMessage) {}
private String compareSize(long resultSize) { private String compareSize(long resultSize) {
long allowedSize = Long.parseLong(getAllowedSize()); long allowedSize = Long.parseLong(getAllowedSize());
int comp = getCompOper(); ComparisonOperator operator;
try {
operator = ComparisonOperator.fromValue(getCompOper());
} catch (IllegalArgumentException e) {
return "ERROR - invalid condition";
}
ComparisonResult comparison = switch (comp) { if (operator.evaluate(resultSize, allowedSize)) {
case EQUAL -> new ComparisonResult( return "";
resultSize == allowedSize, } else {
JMeterUtils.getResString("size_assertion_comparator_error_equal") //$NON-NLS-1$ return JMeterUtils.getResString(operator.getErrorMessageKey());
); }
case NOTEQUAL -> new ComparisonResult(
resultSize != allowedSize,
JMeterUtils.getResString("size_assertion_comparator_error_notequal") //$NON-NLS-1$
);
case GREATERTHAN -> new ComparisonResult(
resultSize > allowedSize,
JMeterUtils.getResString("size_assertion_comparator_error_greater") //$NON-NLS-1$
);
case LESSTHAN -> new ComparisonResult(
resultSize < allowedSize,
JMeterUtils.getResString("size_assertion_comparator_error_less") //$NON-NLS-1$
);
case GREATERTHANEQUAL -> new ComparisonResult(
resultSize >= allowedSize,
JMeterUtils.getResString("size_assertion_comparator_error_greaterequal") //$NON-NLS-1$
);
case LESSTHANEQUAL -> new ComparisonResult(
resultSize <= allowedSize,
JMeterUtils.getResString("size_assertion_comparator_error_lessequal") //$NON-NLS-1$
);
default -> new ComparisonResult(false, "ERROR - invalid condition");
};
return comparison.result() ? "" : comparison.errorMessage();
} }
private void setTestField(String testField) { private void setTestField(String testField) {

View File

@ -135,7 +135,7 @@ public class SizeAssertionGui extends AbstractAssertionGui implements ActionList
lessthanButton.setSelected(false); lessthanButton.setSelected(false);
greaterthanequalButton.setSelected(false); greaterthanequalButton.setSelected(false);
lessthanequalButton.setSelected(false); lessthanequalButton.setSelected(false);
execState = SizeAssertion.EQUAL; execState = SizeAssertion.ComparisonOperator.EQUAL.getValue();
} }
@Override @Override
@ -164,32 +164,32 @@ public class SizeAssertionGui extends AbstractAssertionGui implements ActionList
* <p> * <p>
* Allowed states are * Allowed states are
* <ul> * <ul>
* <li>{@link SizeAssertion#EQUAL}</li> * <li>{@link SizeAssertion.ComparisonOperator#EQUAL}</li>
* <li>{@link SizeAssertion#NOTEQUAL}</li> * <li>{@link SizeAssertion.ComparisonOperator#NOTEQUAL}</li>
* <li>{@link SizeAssertion#GREATERTHAN}</li> * <li>{@link SizeAssertion.ComparisonOperator#GREATERTHAN}</li>
* <li>{@link SizeAssertion#LESSTHAN}</li> * <li>{@link SizeAssertion.ComparisonOperator#LESSTHAN}</li>
* <li>{@link SizeAssertion#GREATERTHANEQUAL}</li> * <li>{@link SizeAssertion.ComparisonOperator#GREATERTHANEQUAL}</li>
* <li>{@link SizeAssertion#LESSTHANEQUAL}</li> * <li>{@link SizeAssertion.ComparisonOperator#LESSTHANEQUAL}</li>
* </ul> * </ul>
* @param state One of the allowed states * @param state One of the allowed states
*/ */
public void setState(int state) { public void setState(int state) {
if (state == SizeAssertion.EQUAL) { if (state == SizeAssertion.ComparisonOperator.EQUAL.getValue()) {
equalButton.setSelected(true); equalButton.setSelected(true);
execState = state; execState = state;
} else if (state == SizeAssertion.NOTEQUAL) { } else if (state == SizeAssertion.ComparisonOperator.NOTEQUAL.getValue()) {
notequalButton.setSelected(true); notequalButton.setSelected(true);
execState = state; execState = state;
} else if (state == SizeAssertion.GREATERTHAN) { } else if (state == SizeAssertion.ComparisonOperator.GREATERTHAN.getValue()) {
greaterthanButton.setSelected(true); greaterthanButton.setSelected(true);
execState = state; execState = state;
} else if (state == SizeAssertion.LESSTHAN) { } else if (state == SizeAssertion.ComparisonOperator.LESSTHAN.getValue()) {
lessthanButton.setSelected(true); lessthanButton.setSelected(true);
execState = state; execState = state;
} else if (state == SizeAssertion.GREATERTHANEQUAL) { } else if (state == SizeAssertion.ComparisonOperator.GREATERTHANEQUAL.getValue()) {
greaterthanequalButton.setSelected(true); greaterthanequalButton.setSelected(true);
execState = state; execState = state;
} else if (state == SizeAssertion.LESSTHANEQUAL) { } else if (state == SizeAssertion.ComparisonOperator.LESSTHANEQUAL.getValue()) {
lessthanequalButton.setSelected(true); lessthanequalButton.setSelected(true);
execState = state; execState = state;
} }
@ -200,12 +200,12 @@ public class SizeAssertionGui extends AbstractAssertionGui implements ActionList
* <p> * <p>
* Possible states are * Possible states are
* <ul> * <ul>
* <li>{@link SizeAssertion#EQUAL}</li> * <li>{@link SizeAssertion.ComparisonOperator#EQUAL}</li>
* <li>{@link SizeAssertion#NOTEQUAL}</li> * <li>{@link SizeAssertion.ComparisonOperator#NOTEQUAL}</li>
* <li>{@link SizeAssertion#GREATERTHAN}</li> * <li>{@link SizeAssertion.ComparisonOperator#GREATERTHAN}</li>
* <li>{@link SizeAssertion#LESSTHAN}</li> * <li>{@link SizeAssertion.ComparisonOperator#LESSTHAN}</li>
* <li>{@link SizeAssertion#GREATERTHANEQUAL}</li> * <li>{@link SizeAssertion.ComparisonOperator#GREATERTHANEQUAL}</li>
* <li>{@link SizeAssertion#LESSTHANEQUAL}</li> * <li>{@link SizeAssertion.ComparisonOperator#LESSTHANEQUAL}</li>
* </ul> * </ul>
* @return The current state of the radio Button * @return The current state of the radio Button
*/ */
@ -273,12 +273,12 @@ public class SizeAssertionGui extends AbstractAssertionGui implements ActionList
private Box createComparatorButtonPanel() { private Box createComparatorButtonPanel() {
ButtonGroup group = new ButtonGroup(); ButtonGroup group = new ButtonGroup();
equalButton = createComparatorButton("=", SizeAssertion.EQUAL, group); //$NON-NLS-1$ equalButton = createComparatorButton("=", SizeAssertion.ComparisonOperator.EQUAL.getValue(), group); //$NON-NLS-1$
notequalButton = createComparatorButton("!=", SizeAssertion.NOTEQUAL, group); //$NON-NLS-1$ notequalButton = createComparatorButton("!=", SizeAssertion.ComparisonOperator.NOTEQUAL.getValue(), group); //$NON-NLS-1$
greaterthanButton = createComparatorButton(">", SizeAssertion.GREATERTHAN, group); //$NON-NLS-1$ greaterthanButton = createComparatorButton(">", SizeAssertion.ComparisonOperator.GREATERTHAN.getValue(), group); //$NON-NLS-1$
lessthanButton = createComparatorButton("<", SizeAssertion.LESSTHAN, group); //$NON-NLS-1$ lessthanButton = createComparatorButton("<", SizeAssertion.ComparisonOperator.LESSTHAN.getValue(), group); //$NON-NLS-1$
greaterthanequalButton = createComparatorButton(">=", SizeAssertion.GREATERTHANEQUAL, group); //$NON-NLS-1$ greaterthanequalButton = createComparatorButton(">=", SizeAssertion.ComparisonOperator.GREATERTHANEQUAL.getValue(), group); //$NON-NLS-1$
lessthanequalButton = createComparatorButton("<=", SizeAssertion.LESSTHANEQUAL, group); //$NON-NLS-1$ lessthanequalButton = createComparatorButton("<=", SizeAssertion.ComparisonOperator.LESSTHANEQUAL.getValue(), group); //$NON-NLS-1$
equalButton.setSelected(true); equalButton.setSelected(true);
execState = Integer.parseInt(equalButton.getActionCommand()); execState = Integer.parseInt(equalButton.getActionCommand());

View File

@ -224,18 +224,9 @@ public class CSVDataSet extends ConfigTestElement
int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode); int modeInt = CSVDataSetBeanInfo.getShareModeAsInt(mode);
this.alias = switch(modeInt){ this.alias = switch(modeInt){
case CSVDataSetBeanInfo.SHARE_ALL -> alias; case CSVDataSetBeanInfo.SHARE_ALL -> alias;
case CSVDataSetBeanInfo.SHARE_GROUP -> { case CSVDataSetBeanInfo.SHARE_GROUP -> alias + "@" + System.identityHashCode(context.getThreadGroup());
// Complex logic for thread group sharing case CSVDataSetBeanInfo.SHARE_THREAD -> alias + "@" + System.identityHashCode(context.getThread());
yield alias + "@" + System.identityHashCode(context.getThreadGroup()); default -> alias + "@" + mode; // user-specified key
}
case CSVDataSetBeanInfo.SHARE_THREAD -> {
// Complex logic for thread-specific sharing
yield alias + "@" + System.identityHashCode(context.getThread());
}
default -> {
// User-specified key with validation
yield alias + "@" + mode; // user-specified key
}
}; };
} }

View File

@ -55,7 +55,7 @@ public class SizeAssertionTest extends JMeterTestCase {
@Test @Test
public void testSizeAssertionEquals() throws Exception { public void testSizeAssertionEquals() throws Exception {
assertion.setCompOper(SizeAssertion.EQUAL); assertion.setCompOper(SizeAssertion.ComparisonOperator.EQUAL.getValue());
assertion.setAllowedSize(0); assertion.setAllowedSize(0);
result = assertion.getResult(sample1); result = assertion.getResult(sample1);
assertFailed(); assertFailed();
@ -73,7 +73,7 @@ public class SizeAssertionTest extends JMeterTestCase {
@Test @Test
public void testSizeAssertionNotEquals() throws Exception { public void testSizeAssertionNotEquals() throws Exception {
assertion.setCompOper(SizeAssertion.NOTEQUAL); assertion.setCompOper(SizeAssertion.ComparisonOperator.NOTEQUAL.getValue());
assertion.setAllowedSize(0); assertion.setAllowedSize(0);
result = assertion.getResult(sample1); result = assertion.getResult(sample1);
assertPassed(); assertPassed();
@ -91,7 +91,7 @@ public class SizeAssertionTest extends JMeterTestCase {
@Test @Test
public void testSizeAssertionGreaterThan() throws Exception { public void testSizeAssertionGreaterThan() throws Exception {
assertion.setCompOper(SizeAssertion.GREATERTHAN); assertion.setCompOper(SizeAssertion.ComparisonOperator.GREATERTHAN.getValue());
assertion.setAllowedSize(0); assertion.setAllowedSize(0);
result = assertion.getResult(sample1); result = assertion.getResult(sample1);
assertPassed(); assertPassed();
@ -109,7 +109,7 @@ public class SizeAssertionTest extends JMeterTestCase {
@Test @Test
public void testSizeAssertionGreaterThanEqual() throws Exception { public void testSizeAssertionGreaterThanEqual() throws Exception {
assertion.setCompOper(SizeAssertion.GREATERTHANEQUAL); assertion.setCompOper(SizeAssertion.ComparisonOperator.GREATERTHANEQUAL.getValue());
assertion.setAllowedSize(0); assertion.setAllowedSize(0);
result = assertion.getResult(sample1); result = assertion.getResult(sample1);
assertPassed(); assertPassed();
@ -127,7 +127,7 @@ public class SizeAssertionTest extends JMeterTestCase {
@Test @Test
public void testSizeAssertionLessThan() throws Exception { public void testSizeAssertionLessThan() throws Exception {
assertion.setCompOper(SizeAssertion.LESSTHAN); assertion.setCompOper(SizeAssertion.ComparisonOperator.LESSTHAN.getValue());
assertion.setAllowedSize(0); assertion.setAllowedSize(0);
result = assertion.getResult(sample1); result = assertion.getResult(sample1);
assertFailed(); assertFailed();
@ -145,7 +145,7 @@ public class SizeAssertionTest extends JMeterTestCase {
@Test @Test
public void testSizeAssertionLessThanEqual() throws Exception { public void testSizeAssertionLessThanEqual() throws Exception {
assertion.setCompOper(SizeAssertion.LESSTHANEQUAL); assertion.setCompOper(SizeAssertion.ComparisonOperator.LESSTHANEQUAL.getValue());
assertion.setAllowedSize(0); assertion.setAllowedSize(0);
result = assertion.getResult(sample1); result = assertion.getResult(sample1);
assertFailed(); assertFailed();