apache / jmeter

Apache JMeter open-source load testing tool for analyzing and measuring the performance of a variety of services
https://jmeter.apache.org/
Apache License 2.0
8.37k stars 2.1k forks source link

CompoundVariable - ignore function call errors #1119

Closed asfimport closed 21 years ago

asfimport commented 21 years ago

tjsb (Bug 20590): Test Plan element allows multiple variables to be defined, and supports the use of functions. This can be very useful.

Unfortunately, at present, if there is an error in any of the function calls (e.g. wrong number of parameters) none of the functions are evaluated. If several functions are involved, it can be tricky to find the one that is at fault.

The patch (to follow) changes this behaviour to treat invalid function calls as if they were strings. It is then obvious which functions have not worked.

The patch also makes some logging changes.

Severity: normal OS: other

asfimport commented 21 years ago

tjsb (migrated from Bugzilla): Created attachment CompoundVariable.patch: CompoundVariable.patch - skip bad function calls

CompoundVariable.patch ````diff Index: CompoundVariable.java =================================================================== RCS file: /home/cvspublic/jakarta-jmeter/src/core/org/apache/jmeter/engine/util/CompoundVariable.java,v retrieving revision 1.12 diff -u -r1.12 CompoundVariable.java --- CompoundVariable.java 5 Jun 2003 00:13:40 -0000 1.12 +++ CompoundVariable.java 8 Jun 2003 19:19:19 -0000 @@ -71,10 +71,10 @@ import org.apache.jmeter.threads.JMeterContextService; import org.apache.jmeter.threads.JMeterVariables; import org.apache.jmeter.util.JMeterUtils; +import org.apache.jorphan.logging.LoggingManager; import org.apache.jorphan.reflect.ClassFinder; -import org.apache.log.Hierarchy; import org.apache.log.Logger; -import org.apache.oro.text.perl.Perl5Util; +//import org.apache.oro.text.perl.Perl5Util; import org.apache.oro.text.regex.MalformedPatternException; import org.apache.oro.text.regex.Perl5Compiler; import org.apache.oro.text.regex.Perl5Matcher; @@ -91,17 +91,17 @@ public class CompoundVariable implements Function { transient private static Logger log = - Hierarchy.getDefaultHierarchy().getLoggerFor(JMeterUtils.ENGINE); + LoggingManager.getLoggerForClass(); private String rawParameters; - private JMeterVariables threadVars; - private Map varMap = new HashMap(); + //private JMeterVariables threadVars; + //private Map varMap = new HashMap(); static Map functions = new HashMap(); private boolean hasFunction, isDynamic; private String staticSubstitution; - private Perl5Util util = new Perl5Util(); + //private Perl5Util util = new Perl5Util(); private Perl5Compiler compiler = new Perl5Compiler(); private static final String unescapePattern = "[\\\\]([${}\\,])"; private String permanentResults = ""; @@ -275,7 +275,12 @@ funcEndIndex = findMatching( "${", "}", current ); functionStr = current.substring( funcStartIndex+2, funcEndIndex ); - Function newFunction = buildFunction( functionStr ); + Function newFunction = null; + try { + newFunction = buildFunction( functionStr ); + } + catch (InvalidVariableException e){// Don't abandon processing if function fails + } if ( newFunction == null ) { components.addLast(new SimpleVariable(functionStr) ); @@ -299,7 +304,7 @@ throws InvalidVariableException { Function returnFunction = null; - LinkedList parameterList; + //LinkedList parameterList; String functionName, params; int paramsStart = functionStr.indexOf("("); @@ -422,7 +427,8 @@ private static int findMatching( String openStr, String closeStr, String searchString ) { - int count, openIndex, closeIndex, previousMatch; + //int count; + int openIndex, closeIndex, previousMatch; boolean found = false; openIndex = closeIndex = previousMatch = -1; @@ -505,7 +511,7 @@ return ""; } - private JMeterVariables getVariables() + private JMeterVariables getVariables()//TODO: not used { return JMeterContextService.getContext().getVariables(); } ````