JMeter groovy pre-processor throws exceptions when trying to configure "Custom SOAP Sampler" -
i'm trying create groovy-based pre-processor **custom soap sampler* plugin, intended cover following tasks:
- read list of file attachments csv input file;
- empty list of attachments registered custom soap sampler;
- register attachments read csv file custom soap sampler.
after quite extensive research on net--i'm new whole groovy, java, jmeter topic--, managed assemble groovy script shown below.
// read data csv input file arraylist reclst = new arraylist(); string fldsep = vars.get("fldsep"); string fldhd = vars.get("fldhd"); integer = 0; // todo: test/debugging new file(vars.get("indat")).eachline('utf-8') { if ((it != null) && (fldhd != null) && (!it.trim().equals(fldhd.trim())) && (i < 2)) { reclst.add(it.trim()); } // if i++; // todo: test/debugging } // file.eachline // todo: test/debugging (rec in reclst) { string[] flds = rec.split(fldsep); vars.put("dbgtmstmp", flds[0]); vars.put("dbgprodid", flds[1]); vars.put("dbgtenid", flds[2]); vars.put("dbgfnam", flds[3]); } arraylist oldatts = new arraylist(); oldatts = ctx.getcurrentsampler().getattachments(); vars.put("dbgoldatts", oldatts.size()); // todo: test/debugging // extract relevant parts , feed custom soap sampler (registered attachments) // csv format: tmstmp;prodid;tenid;fnam;mdat if (reclst.size() > 0) { // empty current attachment list // arraylist oldatts = ctx.getcurrentsampler().getattachments(); // vars.put("dbgoldatts", oldatts.size()); // todo: test/debugging if (oldatts.size() > 0) { (attdef in oldatts) { attdef.attachment = null; attdef.contentid = null; attdef.contenttype = null; attdef.type = null; } // } // if // create new attachment list arraylist newatts = new arraylist(); (rec in reclst) { string[] flds = rec.split(fldsep); def attdef = ctx.getcurrentsampler().getattachmentdefinition(); attdef.attachment = new file(flds[3]); attdef.contentid = "flds[0]"; attdef.contenttype = "application/pdf"; // 1 of selections dropdown (no pdf listed there) attdef.type = 1; // 1 = resource, 2 = variable newatts.add(attdef); } // if (newatts.size() > 0) { ctx.getcurrentsampler().setattachments(newatts); } // if } // if unfortunately appears failing, i've added debugging information, eg. setting variables ('dbg....'). 'dbgtmstmp', 'dbgprodid', 'dbgtenid', , 'dbgfnam' getting set expected, when trying retrieve defined attachments , set 'dbgoldatts' number of attachments found, exception thrown.
setting breakpoint @ groovy script (jsr223preprocessor) , starting debugger (blazemeter) yields
2017/04/06 14:50:28 info - jmeter.engine.standardjmeterengine: running test! 2017/04/06 14:50:28 info - jmeter.samplers.sampleevent: list of sample_variables: [] 2017/04/06 14:50:28 info - jmeter.engine.standardjmeterengine: starting threadgroup: 1 : number of users (single key) 2017/04/06 14:50:28 info - jmeter.engine.standardjmeterengine: starting 1 threads group number of users (single key). 2017/04/06 14:50:28 info - jmeter.engine.standardjmeterengine: thread continue on error 2017/04/06 14:50:28 info - jmeter.engine.standardjmeterengine: thread groups have been started 2017/04/06 14:50:28 info - jmeter.threads.jmeterthread: thread started: number of users (single key) 1-1 2017/04/06 14:50:28 info - jmeter.services.fileserver: stored: /media/sf_projects/tstprj/archive/tstdoc.csv continuing test plan execution (step over) produces
2017/04/06 14:54:45 error - jmeter.modifiers.jsr223preprocessor: problem in jsr223 script jsr223 preprocessor javax.script.scriptexception: javax.script.scriptexception: groovy.lang.missingmethodexception: no signature of method: com.blazemeter.jmeter.debugger.elements.samplerdebug.getattachments() applicable argument types: () values: [] @ org.codehaus.groovy.jsr223.groovyscriptengineimpl.eval(groovyscriptengineimpl.java:155) @ javax.script.abstractscriptengine.eval(abstractscriptengine.java:233) @ org.apache.jmeter.util.jsr223testelement.processfileorscript(jsr223testelement.java:220) @ org.apache.jmeter.modifiers.jsr223preprocessor.process(jsr223preprocessor.java:42) @ com.blazemeter.jmeter.debugger.elements.preprocessordebug.process(preprocessordebug.java:11) @ org.apache.jmeter.threads.jmeterthread.runpreprocessors(jmeterthread.java:798) @ org.apache.jmeter.threads.jmeterthread.executesamplepackage(jmeterthread.java:453) @ org.apache.jmeter.threads.jmeterthread.processsampler(jmeterthread.java:418) @ org.apache.jmeter.threads.jmeterthread.run(jmeterthread.java:249) @ com.blazemeter.jmeter.debugger.engine.debuggingthread.run(debuggingthread.java:23) @ java.lang.thread.run(thread.java:745) caused by: javax.script.scriptexception: groovy.lang.missingmethodexception: no signature of method: com.blazemeter.jmeter.debugger.elements.samplerdebug.getattachments() applicable argument types: () values: [] @ org.codehaus.groovy.jsr223.groovyscriptengineimpl.eval(groovyscriptengineimpl.java:346) @ org.codehaus.groovy.jsr223.groovyscriptengineimpl.eval(groovyscriptengineimpl.java:152) ... 10 more caused by: groovy.lang.missingmethodexception: no signature of method: com.blazemeter.jmeter.debugger.elements.samplerdebug.getattachments() applicable argument types: () values: [] @ org.codehaus.groovy.runtime.scriptbytecodeadapter.unwrap(scriptbytecodeadapter.java:58) @ org.codehaus.groovy.runtime.callsite.pojometaclasssite.call(pojometaclasssite.java:49) @ org.codehaus.groovy.runtime.callsite.callsitearray.defaultcall(callsitearray.java:48) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:113) @ org.codehaus.groovy.runtime.callsite.abstractcallsite.call(abstractcallsite.java:117) @ script6.run(script6.groovy:31) @ org.codehaus.groovy.jsr223.groovyscriptengineimpl.eval(groovyscriptengineimpl.java:343) ... 11 more and finishing execution results in
2017/04/06 15:00:06 error - com.jmeter.protocol.soap.sampler.customsoapsampler: caught exception while updating attachments javax.xml.soap.soapexception: inputstream not represent valid soap 1.2 message @ com.sun.xml.internal.messaging.saaj.soap.ver1_2.soappart1_2impl.createenvelopefromsource(soappart1_2impl.java:72) @ com.sun.xml.internal.messaging.saaj.soap.soappartimpl.getenvelope(soappartimpl.java:128) @ com.jmeter.protocol.soap.sampler.customsoapsampler.updateattachmentreferences(customsoapsampler.java:448) @ com.jmeter.protocol.soap.sampler.customsoapsampler.sample(customsoapsampler.java:256) @ com.blazemeter.jmeter.debugger.elements.samplerdebug.sample(samplerdebug.java:15) @ org.apache.jmeter.threads.jmeterthread.executesamplepackage(jmeterthread.java:475) @ org.apache.jmeter.threads.jmeterthread.processsampler(jmeterthread.java:418) @ org.apache.jmeter.threads.jmeterthread.run(jmeterthread.java:249) @ com.blazemeter.jmeter.debugger.engine.debuggingthread.run(debuggingthread.java:23) @ java.lang.thread.run(thread.java:745) 2017/04/06 15:00:09 info - jmeter.threads.jmeterthread: stopping thread: org.apache.jorphan.util.jmeterstopthreadexception: unable update attachment references 2017/04/06 15:00:09 info - jmeter.threads.jmeterthread: stop thread detected thread: number of users (single key) 1-1 2017/04/06 15:00:09 info - jmeter.threads.jmeterthread: thread finished: number of users (single key) 1-1 2017/04/06 15:00:09 info - jmeter.engine.standardjmeterengine: notifying test listeners of end of test 2017/04/06 15:00:09 info - jmeter.services.fileserver: close: /media/sf_projects/tstprj/archive/tstdoc.csv i have admit, i'm utterly @ loss, how tackle issue.
my setup comprises:
- ubuntu linux 17.04;
- apache jmeter 3.1 r1770033;
- blazemeter step-by-step debugger 0.3;
- custom soap sampler 1.3;
- groovy 2.4.7 (scripting engine 2.0).
sample input csv file
tmstmp;prodid;tenid;fnam;mdat '20170406112044044970077';'prod01';'tenant03';'/media/sf_projects/tstprj/archive/tstdoc/tstdoc-00000.pdf';'<?xml version=1.0 encoding=utf-8?><tstpfx:metainformation xmlns:tstpfx=http://my.host.local/tstprj/metainformation_v2.xsd id=000000069496>meta data #01</tstpfx:metainformation> ' '20170406112047030620037';'prod02';'tenant01';'/media/sf_projects/tstprj/archive/tstdoc/tstdoc-00001.pdf';'<?xml version=1.0 encoding=utf-8?><tstpfx:metainformation xmlns:tstpfx=http://my.host.local/tstprj/metainformation_v2.xsd id=000000069496>meta data #02</tstpfx:metainformation> ' this file getting read twice: (1) jsr223 pre-processor build attachment list; (2) custom soap sampler, subsequently iterates on each entry of file, , passes relevant bits & bobs soap envelop
<soapenv:envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tstprj="http://my.host.local/"> <soapenv:header/> <soapenv:body> <tstprj:archive> <product>${prodid}</product> <tenant>${tenid}</tenant> <filename>${fnam}</filename> <metadata>${mdat}</metadata> <content>cid:${tmstmp}</content> </tstprj:archive> </soapenv:body> </soapenv:envelope>
you should report issue @ :
the plugin wraps samplers custom samplerdebug.
so code :
ctx.getcurrentsampler() returns samplerdebug instead of class mentioned in doc:
- jmetersoapsampler
see:
Comments
Post a Comment