How to clear the consul in jmeter - using groovy - groovy

I have a question about the printing that I perform in Jmeter, I use
System.out.println and the consul is full with data.
the problem is that if I want in each iteration to clear the consul how can I do it?
the consul is full with data from last run, or Prev thread and I just want to clear it.
regards (it is the black consul that opened in a new window.)

You should log messages using log.info("Hello World"); (log is a script global variable) instead of using OUT in your scripts. Therefore, the logs will be sent to jmeter.log file.
See the documentation about JSR223 Sampler for more information.

For Windows you can use something like:
new ProcessBuilder('cmd', '/c', 'cls').inheritIO().start().waitFor()
For other operating system it will depend on SHELL implementation, you will need to amend the command line according to your requirements, most likely using clear command.
References:
ProcessBuilder documentation
Groovy is the New Black

Related

Jmeter passes steps and not print to consul

I am facing an issue that I could not understand how to resolve.
I created a test plan that need to connect DB and count the results.
The problem is that Jmeter not perform any validation afterwards, I created a JSSR223 in the JDBC request and just want to print the results and Jmeter not print.
I created another sampler to print the DB results and still Jmeter not printing.
Jmeter just passes this steps,
In the results tree I saw that it connects to DB and failed in the assertion, but why it passes the other steps? and just moving to debug sampler?
I can not print the results, I can not perform any debug since it is just black box.
can someone please advise?
you can see in yellow all the steps that Jmeter not performed and just not exists in the results tree.
enter image description here
Get used to check jmeter.log file, it normally contains information regarding what went wrong, you should be able to figure out the root cause by looking into the log file. If you are not - update your question with jmeter.log file contents (at least essential parts)
My expectation is that your ${Conv_sense} variable is not defined (or cannot be cast to Integer). Double check whether it is defined or not using Debug Sampler and View Results Tree listener combination.
Also don't refer JMeter Variables like ${Conv_sense} in Groovy scripts body, use vars.get('Conv_sense}') instead, otherwise it might conflict with Groovy GStringTemplate resulting in undefined behavior.

Read Jenkins build console output and set email content

I have certain errors which I set in my code, which should add corresponding error messages to the email content of the final build email.
I was thinking of printing something such as ("EMAIL CONTENT ERROR: _______") to the console, reading through it (in a pre-send groovy script?), and adding corresponding error messages for each error found.
I was thinking of using a pre-send groovy script, setting the mimeMessage object(was reading jenkins email-ext documentation). Would this be viable?
Also, I have never used groovy before, so pointers to how to approach this would be extremely helpful(or a link to where i can find an implementation of something with a similar idea of reading console). Any advice would be greatly appreciated. Thanks in advance!
Can you check attaching "Build Log" This would highlight all the process of build process.
This is a very similar concept to the question here. The technique there was to use the log parser plugin to scan the console output for you, and then use groovy to add all the errors into an email.
This is generally a pretty good idea because it also means that you can view the same set of highlighted errors from jenkins itself, rather than just the email.
There are a couple of ways this is different from your setup, the main points are:
Yes, write errors directly to the console in a known format
Set the log parser up with regular expressions that find your error format
Instead of a pre-send script, in this case you would use a groovy template for your email generation
The template reads the error list from the console parser and adds them to your email. Each one is a link that links back to the jenkins console output.

Jenkins/Hudson Groovy Script Console: Flexibility

I really like being able to run Groovy scripts in Hudson (or Jenkins, but I use Hudson).
For example, see my question In Groovy, how do I get the list of parameter names for a given job? Hudson parameter names question][1]
The thing is, now I'd like use these Groovy scripts like a keyboard macro or utility. I want to be visiting one of my jobs, hit the special keystroke, and voila, the Groovy script is run. I leave it as an exercise for myself to pick up parameters from environment of current job.
Does anybody out there do this sort of thing, and if so, what strategy has been useful. So far, all I know how to do is bring up the script console, pasted in my code, edit the variable containing the name of the Hudson job, and hit "run". Kinda klunky. Suggestions appreciated.
You can use jenkins Remote access method to do this. The Jenkins wiki describes how to use Remote access:
User can execute groovy scripts remotely sending post request to
/script/ url or /scriptText/ to have response returned without the
html wrapping.
$ curl -d "script=<your_script_here>" http://jenkins/script
$ # or
$ curl -d "script=<your_script_here>" http://jenkins/scriptText
Also, Jenkins CLI offers the possibility to execute groovy
scripts remotely using groovy command or execute groovy interactivelly
via groovysh.

JMeter howto: same thread group - same variable - different value

I'm doing a performance test on different versions of my application.
The results end up in a csv summary-report.
Is there a way to change the variable correctly for each thread group?
Manual Script:
Script with variable: (not working, help needed).
I don't want to change the version manually when a version changes, but only one parameter. Thanks!
Try using _P or _property function in your Thread Group and Sampler names.
Like Application-${__P(version1,)}, Login-${__P(version1,)}, etc.
Provide property value via 'user.properties' file or via -J command-line argument as
jmeter -Jversion1=1.0 -Jversion2=2.0 -n -t path_to_your_script.jmx -l path_to_results.jtl
All generated reports will contain these properties.
References:
How do I run JMeter in non-gui mode
Apache JMeter Properties Customization Guide

GGTS can't run Groovy Shell

I'm using the Groovy Grails Tool Suite to practice Groovy. I want to run a Groovy Shell, but when I create a new shell and try to run it, I get this error:
Could not find $jarName on the class path. Please add it manually
What does this mean, and how do I resolve this?
I believe this is happening because JLine can't be found on your classpath. I submitted a PR to make the error message in this case actually useful.
I had a similar problem with this exact same message, but the reason was that I was attempting to run the script without specifying which script to run. Ensure you have the script open in the editing window and trying running it again - that got rid of the message for me.

Resources