Highlighted
Respected Contributor.
Respected Contributor.
4254 views

lr_end_transaction("transaction name", LR_FAIL) not working?

All,

We have a lot of tests that do web_reg_find at the beginning, then check the count at the end and  lr_end_transaction("transaction name", LR_FAIL) at the end if the count is not what we expect.  However LR_FAIL doesn't seem to do anything.  Even when the script logically fails, the results and reports show it as passing.  What is LR_FAIL supposed to do?

BTW, I have noticed that not checking the result of web_reg_find at all causes an error message to get written to the log if the string was not found and the execution is counted as failing.

thanks

John

 
0 Likes
7 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: lr_end_transaction("transaction name", LR_FAIL) not working?

Hi

First a small advice, if your question is regarding scripting, vugen or analysis there are more users in the LoadRunner forum and you will get a detter chanse of getting help.

 

 lr_end_transaction("transaction name", LR_FAIL) 

This is a essential part of PC/LoadRunner and I think that if it was not working, someone else would have noticed. So I think that the problem is just that it is not working exactly as you think.

 

This line of code will mark the transaction "transaction name" as Failed, when analysing the results. But it seems like you think that something else should happen.Then you need to specify that, because LR_FAIL will not.

This maybe this is more what you are after:
lr_fail_trans_with_error.htm

If something else is supposed to happen you could give a code example.

br /ola


Please mark post as solved if your problems or questions is/are resolved.
If this post was valuable to you, please consider kudo it.

 

 

 

.
0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Re: lr_end_transaction("transaction name", LR_FAIL) not working?

My question is about how Performance Center interprets the LR_FAIL status.  I assumed that it would count that test as failed, but it doesn't seem to.  If I look at the results in Analysis, it shows them as passing regardless of the transaction end status.

The tests that it counts as failed seem to be the ones where the web_reg_find expression did not find a match, I did not explicitly check for the count, and exited with lr_end_transaction("txn name", LR_AUTO).

thanks

 

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: lr_end_transaction("transaction name", LR_FAIL) not working?

Hi again

I think that we have some mismatch in the namings here, which is a big part in the confusion.

In Performance Center, there is "Test", wich is the highest level and is the whole description of which scripts to be executed, how many and for how long. In LoadRunner the corresponding name is "Scenario".

So each Test is build up on "Groups", which consists of one script and a number of vusers and a scudule. Each group do also have it's own Runtime settings.

At last we have the "Vuser" or "Script" level, which is every simulated users during runtime.

In each script there is often multiple "Transactions", which will measure the time between lr_start_transaction and lr_end_transaction.

For lr_end_transaction you have 3 different choices:
LR_PASS - Mark the transaction as "Passed" always, despite what has happened.
LR_FAIL - Mark the transaction as "Failed" always, despite what has happened.
LR_AUTO - (default) If there have been any errors after the transaction started, then mark it as "Failed" otherwise "Passed".

So using LR_FAIL will not generate an Error, just set the transaction as "Failed"
When you have a web_reg_find with out a match, an Error will be triggered, and can be seen in the Analysis summary as "Error" and all ongoing transactions (with LR_AUTO) will also be set to "Fail".

So the when you say

If I look at the results in Analysis, it shows them as passing regardless of the transaction end status.

and

The tests that it counts as failed seem to be the ones where the web_reg_find expression did not find a match

you do not mean tests, but something else like "Scripts without errors". But LR_FAIL will never throw and error and do only mark the current transaction as "Failed".

If you mean something else I think you will need to post an image describing more the "tests" beening showed as passed.

br /ola


Please mark post as solved if your problems or questions is/are resolved.
If this post was valuable to you, please consider kudo it.

 

 

 

 

 

 

 

.
0 Likes
Highlighted
Respected Contributor.
Respected Contributor.

Re: lr_end_transaction("transaction name", LR_FAIL) not working?

Yes, I am being a little sloppy in my terminology.

What I really want is to be able to look at the results in Analysis (or one of the generated reports) and know which scripts/transactions failed.  FWIW, we tend to have one action and one transaction per script.  If that seems unusual,  it's because we're testing web services.  We don't have scenarios where a user logs in, clicks from screen to screen to screen, and logs out.

I thought using LR_FAIL would increment the failure count in the reports but it doesn't seem to do that.  It seems that what show up as failures in the reports are really what you're calling errors.

I think I can get what I want by omitting the web_reg_find check completely, but then what is the value of ending a transaction with LR_FAIL?  The fact that some transactions end with LR_FAIL doesn't seem to show up in the results, so why do it at all?

 

thanks

0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: lr_end_transaction("transaction name", LR_FAIL) not working?

Hi

Then I think we need to be even more stringent, also when coming to failed transactions and errors. 🙂

I created a small script just using the using the following code

Action()
{
	
	lr_start_transaction("total");
	
	lr_start_transaction("lr_pass");
	lr_start_transaction("lr_fail");
	lr_start_transaction("lr_auto");
	
	sleep(rand()%1000); 
	
	lr_end_transaction("lr_pass",LR_PASS);
	lr_end_transaction("lr_fail",LR_FAIL);
	lr_end_transaction("lr_auto",LR_AUTO);

	lr_end_transaction("total",LR_AUTO);
	
	return 0;
}

and then executed it in a scenario. Then you will get the following result were you can see that LR_PASS and LR_FAIL will give you pass and fail for the transactions.fail-pass.png

Works just as expected, LR_FAIL are marked "Failed" and LR_PASS are marked as "Passed" in the statistics. And nothing in the red box as we do not have any Errors (like web_reg_save_param will throw). Do we want to have them marked as an Errors, then we need to create an error, for example by

lr_fail_trans_with_error("Only %d occurenses", 2);



br /ola


Please mark post as solved if your problems or questions is/are resolved.
If this post was valuable to you, please consider kudo it.

.
Highlighted
Absent Member.
Absent Member.

can you tell me when LR_FAIL takes place while using LR_AUTO

 
0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

Re: can you tell me when LR_FAIL takes place while using LR_AUTO

Hi

 In short, it will take place if an error have occured since lr_start_transaction(), and if no error have happened, it will be a LR_PASS.

br /ola


Please mark post as solved if your problems or questions is/are resolved.
If this post was valuable to you, please consider kudo it.

.
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.