adoptium / aqa-systemtest

Java load testing and other full system application tests
Apache License 2.0
19 stars 65 forks source link

Question : How to add arbitrary Java Assert in StfCoreExtension Tests? #472

Closed joeyleeeeeee97 closed 2 years ago

joeyleeeeeee97 commented 2 years ago

I am trying to run an application twice when some function enabled/ disabled, but I found it's hard to add an 'assert step' in STF tests instead of adding new interfaces in StfCoreExtension.

Maybe I am being stupid and missing the point, let me demonstrate through this piece of code

test.run1() // output result to stdout1.log
test.run2() // // output result to stdout2.log

test.run( () -> {
// compare result in stdout1.log with stdout2.log 
});

What is the best practice now to do something like this? If we don't have the flexibility to do this now, could we add a new interface for this?

Mesbah-Alam commented 2 years ago

It depends on what you are trying to do in the "compare result" step in test.run() in the pseudo code above.

STF already has some APIs to obtain std out and std error files of a sub-process's run.

Here's an example: https://github.com/eclipse-openj9/openj9-systemtest/blob/bd49a2e6d3849b995b0ced7ca50040d3db453631/openj9.test.sharedClasses/src/test.sharedClasses/net/openj9/stf/SharedClassesWorkloadTest_Softmx_Increase.java#L140

Here you can see that the StfProcess instance 'p' runs a test process; then a call to p.getStderrFileRef() is used to reference the standard err file of the process; then another STF API, test.doCountFileMatches(..)- is used to search the std err file for occurrence of a specific string.

Please have a look at these APIs to see if it serves your purpose. Please let us know if you have more questions.

joeyleeeeeee97 commented 2 years ago

@Mesbah-Alam, Thanks for the information.

Actually I am trying to do something like this

res1=`cat result1 |awk -F ':' ' { print $2 } '`
res2=`cat result2 |awk -F ':' ' { print $2 } '`
if [ $res1 -lt $res2 ]; then echo "pass"; fi

It seems I need some more interfaces to do this. We could discuss what kind of interfaces are better? :)