apache / apache/jmeter

org.apache.jmeter.services.FileServer not providing correct base dir path on JMeter server (load generator in distributed setup)

Open
#5,552 0 comments 0 reactions 0 assignees View on GitHub
os: Linux P2
Dominant language
Java
Stars
9.5k
Forks
2.3k
Avg merge
1d 22h
Merged PRs (30d)
5

Description

**Madhuri Jain** ([Bug 65417](https://bz.apache.org/bugzilla//show_bug.cgi?id=65417&redirect=false)):
We're running JMeter distributed setup and have created an alpine-based jre-headless docker image containing JMeter v5.4.1.

There's a groovy script in our JMeter test plan using JSR223PostProcessor which is simply logging the FileServer base dir path and it runs fine on testing both JMeter client and server running on same PC or in single docker container:

Groovy Script:

import org.apache.jmeter.services.FileServer
def inputPath = FileServer.getFileServer().getBaseDir()
log.info(inputPath);

Result:
2021-06-30 17:09:20,491 INFO o.a.j.e.J.JSR223 PostProcessor: /root/artifacts

While running the same test plan using same docker image with JMeter client and server running on separate docker containers (on same or different machines), it shows the following path on JMeter SERVER (taken from worker/JMeter server logs):

2021-06-30 17:09:20,488 INFO o.a.j.e.J.JSR223 PostProcessor: /root/artifacts/root/artifacts

This is incorrect (repeated path) and is critical as we have a logic to access a file to populate POST body in HTTP request which throws FileNotFoundException.

2021-06-30 17:09:20,489 WARN o.a.j.f.Groovy: Error running groovy script
javax.script.ScriptException: javax.script.ScriptException: java.io.FileNotFoundException: /root/artifacts/root/artifacts/message.json (No such file or directory)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:158) ~[groovy-jsr223-3.0.7.jar:3.0.7]
at javax.script.AbstractScriptEngine.eval(Unknown Source) ~[java.scripting:?]
at org.apache.jmeter.functions.Groovy.execute(Groovy.java:120) [ApacheJMeter_functions.jar:5.4.1]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:138) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:113) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:100) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:280) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.config.Argument.getValue(Argument.java:145) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.protocol.http.util.HTTPArgument.getEncodedValue(HTTPArgument.java:249) [ApacheJMeter_http.jar:5.4.1]
at org.apache.jmeter.protocol.http.util.HTTPArgument.getEncodedValue(HTTPArgument.java:230) [ApacheJMeter_http.jar:5.4.1]
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.setupHttpEntityEnclosingRequestData(HTTPHC4Impl.java:1643) [ApacheJMeter_http.jar:5.4.1]
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.handleMethod(HTTPHC4Impl.java:886) [ApacheJMeter_http.jar:5.4.1]
at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:641) [ApacheJMeter_http.jar:5.4.1]
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66) [ApacheJMeter_http.jar:5.4.1]
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296) [ApacheJMeter_http.jar:5.4.1]
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285) [ApacheJMeter_http.jar:5.4.1]
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.4.1]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.4.1]
at java.lang.Thread.run(Unknown Source) [?:?]
Caused by: javax.script.ScriptException: java.io.FileNotFoundException: /root/artifacts/root/artifacts/message.json (No such file or directory)
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320) ~[groovy-jsr223-3.0.7.jar:3.0.7]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155) ~[groovy-jsr223-3.0.7.jar:3.0.7]
... 20 more
Caused by: java.io.FileNotFoundException: /root/artifacts/root/artifacts/message.json (No such file or directory)
at java.io.FileInputStream.open0(Native Method) ~[?:?]
at java.io.FileInputStream.open(Unknown Source) ~[?:?]
at java.io.FileInputStream.<init>(Unknown Source) ~[?:?]
at groovy.util.CharsetToolkit.<init>(CharsetToolkit.java:78) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.ResourceGroovyMethods.newReader(ResourceGroovyMethods.java:1780) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.ResourceGroovyMethods.getText(ResourceGroovyMethods.java:591) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.dgm$1040.doMethodInvoke(Unknown Source) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.reflection.GeneratedMetaMethod$Proxy.doMethodInvoke(GeneratedMetaMethod.java:83) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.metaclass.MethodMetaProperty$GetBeanMethodMetaProperty.getProperty(MethodMetaProperty.java:76) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.GetEffectivePojoPropertySite.getProperty(GetEffectivePojoPropertySite.java:63) ~[groovy-3.0.7.jar:3.0.7]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:329) ~[groovy-3.0.7.jar:3.0.7]
at Script1.run(Script1.groovy:1) ~[?:?]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:317) ~[groovy-jsr223-3.0.7.jar:3.0.7]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:155) ~[groovy-jsr223-3.0.7.jar:3.0.7]
... 20 more

Also, please suggest any workaround if feasible by the time this is investigated.

Severity: major
OS: Linux

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.