How do you make SoapUI assert against log output? - groovy

I have a process that doesn't respond with output, it creates a log line in a file. I want soapui to generate a request, then look in a log file for the expected output.

If I understand your goal, you can use a Script assertion in your testStep to check for the content in your log file after the request is executed.
So then you can use something like the follow simple Groovy code as Script assertion:
// get your log content
def logFile = new File('pathTo/file.log')
// and assert if the log file
// contains the expected string
assert logFile.getText('UTF-8').contains('expectedText')
NOTE: If you want to check that your server writes a log instead of creates a response then you've to execute your SOAPUI tests from the server machine itself or alternatively have a shared access to this log file from the machine where you will run the tests.
Hope it helps,

Related

Blazemeter: How to read error JTL file of Blazemeter?

I want to read the error.jtl file which we get from Blazemeter Logs (File name- Artifacts).
I am currently using Excel to read the file. Is there any other way, I can view this JTL file, in the same manner, we see the JMeter results jtl file(to HTML Report)?
error.jtl is a JMeter-specific file which is generated by Taurus framework, it contains request and response data for the samplers which have failed during the test execution.
I don't know what do you mean by "read", the file is normal XML file so you can use any text or XML viewer/editor to inspect it.
Also as per How to Capture Response Data from a JMeter JTL File (NTC) article:
Unzip artifacts.zip and open the trace.jtl / error.jtl in JMeter's View Results Tree Listener. The samplers are listed. When selected, the response data can be examined.
so you can open it in View Results Tree or any other Listener of your choice.
You cannot generate HTML Reporting Dashboard from the .jtl file in XML format, however you can use i.e. Filter Results Tool to extract only failing sample results from the kpi.jtl file and generate the dashboard out of it.

Pass value from operator to dag

I have a BashOperator in my dag which runs a python script. At the end of its run, the python script creates a json as a report. In case of failure, I want to report this json to Slack. I have an on_failure_callback function which can push a message to Slack. However, I have no elegant way to pass the json value to the dag. Currently, I am saving the json to a file and then reading it from the file in the dag and reporting it. I also tried storing it in an environment variable and getting it in the dag. But is there a more direct way to pass this value to the dag? Preferably, without saving it to a file or an environment variable.
Rather than using on_failure_callback you should use another task to send your slack message.
And for that you should simply use XComs to push/pull the file. https://airflow.apache.org/docs/apache-airflow/stable/concepts/xcoms.html#
Then you can pull the xcom in the task that sends it further to slack.

Transfer attachment to another testStep

I have a REST test request that returns a MIME multipart/related message. One of the parts has type 'application/zip'.
In soapUi UI, I can see the zip file in the attachments tab.
1- I would like to have this file attached to the request of another REST testStep without manual intervention.
Is this possible with Groovy script ?
I guess it would start with :
def response = testRunner.testCase.getTestStepByName( "firstStep" ).testRequest.getResponse()
def firstStepAttachment = response1.attachments[0]
2- to make it a bit harder, the transfered file is a .zip and I'd like a specific file in it (I know its name and path), is there any way to do that during the file transfer?
Kudos

Groovy script to call Python and batch file

I wish to send email containing build status of all child job.
Therefore, I have used batch and python script to prepare the html file, which I will be importing in Editable Email Notification plugin.
However, in Pre Send script tab, we can only write groovy script.
So I would like to call my python file, that contains my logic from groovy
You would have to call your python script as part of the job (possibly via a shell action) and save the HTML in the workspace and the add that file to the email. Alternatively you could create a custom email template that does the same

Adding output from a batch file called by internal program to the project build logs

I have a project in CCNet and the executable needs to run a batch file. Is there a way of extracting the output from the batch file so it can be picked up by the build log? As all I've been able to get back so far has been a return code.
You could try piping the output of the batch file to a log file and then then use a file merge task to merge the contents into the build log.

Resources