I created a simple groovy script in shared library to update the build details
def call(body) {
currentBuild.displayName = body.displayName
currentBuild.description = body.description
}
I call UpdateBuildDetails from pipeline step
UpdateBuildDetails ([displayName: params.SERVICE_NAME,
description: 'Test'])
Here is the error. Can someone advise what I am missing:
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: UpdateBuildDetails.call() is applicable for argument types: (java.util.LinkedHashMap) values: [[displayName:update-service, description:Test]]
Possible solutions: call(java.lang.Object, java.lang.Object), wait(), any(), wait(long), main([Ljava.lang.String;), each(groovy.lang.Closure)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
Related
I am using JMeter to run query load tests against an Elasticsearch cluster. I have a csv file of 100 names that I am iterating through to populate the ES query with a different search term on each call.
The column in the csv file is called name, so in the JMeter HTTP request, the query in the Body Data looks like this:
{
"query": {
"match": {
"search_name": "${name}"
}
}
}
And to iterate through the csv file to get the names, I have a JSR223 PreProcessor as a child of the HTTP request as such:
upto(1, {
if (vars.get('param' + "$it") != null) {
sampler.addArgument(vars.get('param' + "$it"),'name')
}
})
then a JSR223 PostProcessor as such:
upto(1, {
vars.remove("param" + "$it")
})
I came up with this approach by reading the accepted answer at this thread: How to make the search parameters in http request as dynamic in jmeter and adjusting as I saw fit.
The processing code is doing what it's supposed to be doing as far as correctly populating the queries, and all HTTP Requests are successful. However, every call is also throwing an error in the Jmeter log at both the PreProcessor and PostProcessor step:
ERROR o.a.j.m.JSR223PreProcessor: Problem in JSR223 script, JSR223 PreProcessor
javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.upto() is applicable for argument types: (Integer, Script1$_run_closure1) values: [1, Script1$_run_closure1#7c7ff704]
Possible solutions: put(java.lang.String, java.lang.Object), wait(), grep(), any(), dump(), find()
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320) ~[groovy-jsr223-3.0.11.jar:3.0.11]
at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:71) ~[groovy-jsr223-3.0.11.jar:3.0.11]
at javax.script.CompiledScript.eval(CompiledScript.java:93) ~[java.scripting:?]
at org.apache.jmeter.util.JSR223TestElement.processFileOrScript(JSR223TestElement.java:217) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.modifiers.JSR223PreProcessor.process(JSR223PreProcessor.java:45) ~[ApacheJMeter_components.jar:5.5]
at org.apache.jmeter.threads.JMeterThread.runPreProcessors(JMeterThread.java:978) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:561) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:501) ~[ApacheJMeter_core.jar:5.5]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:268) ~[ApacheJMeter_core.jar:5.5]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.upto() is applicable for argument types: (Integer, Script1$_run_closure1) values: [1, Script1$_run_closure1#7c7ff704]
Possible solutions: put(java.lang.String, java.lang.Object), wait(), grep(), any(), dump(), find()
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.callGlobal(GroovyScriptEngineImpl.java:404) ~[groovy-jsr223-3.0.11.jar:3.0.11]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.access$100(GroovyScriptEngineImpl.java:90) ~[groovy-jsr223-3.0.11.jar:3.0.11]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl$3.invokeMethod(GroovyScriptEngineImpl.java:303) ~[groovy-jsr223-3.0.11.jar:3.0.11]
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:73) ~[groovy-3.0.11.jar:3.0.11]
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:51) ~[groovy-3.0.11.jar:3.0.11]
at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:83) ~[groovy-3.0.11.jar:3.0.11]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:194) ~[groovy-3.0.11.jar:3.0.11]
at Script1.run(Script1.groovy:1) ~[?:?]
at org.codehaus.groovy.jsr223.GroovyScrip
tEngineImpl.eval(GroovyScriptEngineImpl.java:317) ~[groovy-jsr223-3.0.11.jar:3.0.11]
In the interest of saving space, I won't paste the PostProcessor code, which is virtually identical.
I am not well-versed in groovy at all, and again, I did my best to adapt the pre and post processor code from the other thread. Even though everything appears to be working, I'd like to resolve this error b/c I can't imagine I have a clean test going with all these errors thrown.
The error you're getting means syntax error, you cannot call upto() function per se, according to its JavaDoc:
Iterates from this number up to the given number, inclusive, incrementing by one each time.
So I think you need to amend it to look like:
0.upto(1, {
if (vars.get('param' + "$it") != null) {
sampler.addArgument(vars.get('param' + "$it"),'name')
}
})
the Post-Processor can be just removed.
More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?
Groovy has its own very comprehensive documentation: https://groovy-lang.org/documentation.html#gettingstarted
Caught: groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.reset() is applicable for argument types: () values: []
Possible solutions: keySet(), keySet(), keySet(), get(java.lang.Object), get(java.lang.Object), get(java.lang.Object)
groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.reset() is applicable for argument types: () values: []
Possible solutions: keySet(), keySet(), keySet(), get(java.lang.Object), get(java.lang.Object), get(java.lang.Object)
at main.run(main.groovy:394)
There is code at line 394 of main.groovy that is calling reset() (directly or indirectly) on an instance of LinkedHashMap. That isn't valid.
My test code below:
trait Behavior {
}
class Dog {
def greet() {
println 'Hi, I am a dog.'
}
}
def foo(Dog dog) {
dog.greet()
}
def dog = new Dog() as Behavior
dog.greet()
foo(dog)
It gives errors as below:
Hi, I am a dog.
Caught: groovy.lang.MissingMethodException: No signature of method: test2.foo() is applicable for argument types: (Dog1_groovyProxy) values: [Dog1_groovyProxy#48f278eb]
Possible solutions: foo(Dog), run(), run(), any(), find(), use([Ljava.lang.Object;)
groovy.lang.MissingMethodException: No signature of method: test2.foo() is applicable for argument types: (Dog1_groovyProxy) values: [Dog1_groovyProxy#48f278eb]
Possible solutions: foo(Dog), run(), run(), any(), find(), use([Ljava.lang.Object;)
at test2.run(test2.groovy:18)
Why does the trait change the class type of 'dog'? When it implements the trait 'Behavior', it won't be an instance of class Dog? Calling 'foo' method gives errors.
Trait changes class type compatibility unlike 'implement'?
as here changes the instance type to a Behavior, as explained in the documentation
When coercing an object to a trait, the result of the operation is not the same instance. It is guaranteed that the coerced object will implement both the trait and the interfaces that the original object implements, but the result will not be an instance of the original class.
After this code I have error:
gebLocator(wait: true) { $("a#fCoverage") }
browser.js.exec(gebLocator+ ".addEventListener('click', function(){alert('GTM')});")
Error message:
groovy.lang.MissingMethodException: No signature of method:
geb.navigator.NonEmptyNavigator.plus() is applicable for argument
types: (java.lang.String) values: [.addEventListener('click',
function(){alert('GTM')});] Possible solutions:
plus(geb.navigator.Navigator), has(java.lang.String),
is(java.lang.String), last(), value(), add(java.lang.String)
The error message means that you have tried to execute method plus(String) on NonEmptyNavigator what is impossible because NonEmptyNavigator doesn't have such a method.
If you want to execute js code using geb driver:
browser.js.exec("document.getElementById('fCoverage').addEventListener('click', function(){alert('GTM')});")
How to use getStartupArgs()
Since 0.9.1 it seems you can read the command line arguments issue #245 with the getStartupArgs() method (documentation)
But I do know how to use it, I've put it in in all the Griffon lifecycle, Controller, Service, and I get the exception
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: [LifeCycle|Controller|Service].getStartupArgs() is applicable for argument types: () values: []
Caused by: groovy.lang.MissingMethodException: No signature of method: [LifeCycle|Controller|Service].getStartupArgs() is applicable for argument types: () values: [
]
app.getStartupArgs()
That's the way you can read the arguments