Thursday 8 February 2024

Ignore HTTP errors in LoadRunner - Ignore errors in vugen script

When a Virtual User (Vuser) encounters an HTTP error during script execution, it typically results in the termination of the script and is reported as a failure. This behavior can be problematic, especially in scenarios where encountering certain HTTP errors is expected behavior or where the primary focus is on other aspects of the test.

LoadRunner provides a straightforward mechanism to configure HTTP errors as warnings, thereby allowing scripts to continue execution even when encountering such errors. This is achieved using the web_set_rts_key function to set the HttpErrorsAsWarnings runtime setting key to a value of 1. By enabling this setting, HTTP errors will be marked as warnings instead of causing the script to fail.


Here is the Syntax:

web_set_rts_key("key=HttpErrorsAsWarnings", "Value=1", LAST);
  • The web_set_rts_key function is used to set a runtime setting key. "key=HttpErrorsAsWarnings" indicates the setting being configured is for marking HTTP errors as warnings.
  •  "Value=1" sets the value to 1, which means HTTP errors will be marked as warnings instead of causing the script to fail.
  •  LAST indicates that this is the last parameter being set for this function call.
Consider a scenario where a LoadRunner script needs to access a URL that occasionally returns a 404 HTTP status code. Instead of failing the script when encountering this error, we can configure it to treat it as a warning.

Example:

web_set_rts_key("key=HttpErrorsAsWarnings", "Value=1", LAST);

web_url("jquery.unobRE-ajax.js", 
        "URL=https://easyloadrunner.blogspot.com/", 
        "Resource=1", 
        "RecContentType=application/javascript", 
        "Referer=http://easyloadrunner.com/", 
        "Snapshot=t2.inf", 
        LAST);
web_set_rts_key("key=HttpErrorsAsWarnings", "Value=0", LAST); 

In addition to treating all HTTP errors as warnings, LoadRunner allows for more granular control by specifying block lists or allow lists for specific HTTP error codes. This enables testers to customize the behavior based on project requirements. For instance, you may want to treat certain error codes as warnings while still failing the script on others.

Example:

// Block List Example
web_set_rts_key("key=HttpErrorsAsWarnings", "Value=1", LAST);
web_set_rts_key("key=BlockList", "Value=404,400,501", LAST);


// Allow List Example
web_set_rts_key("key=HttpErrorsAsWarnings", "Value=1", LAST);
web_set_rts_key("key=AllowList", "Value=1**,3**,401", LAST);

Pacing Calculator | Pacing Calculator Loadrunner

Pacing Calculator

Pacing Calculator

Additional Information:

Since the residual time (R) is negative, it indicates that the test window is insufficient to complete all iterations within the provided duration. This suggests that the iterations cannot be paced evenly within the given time frame. Therefore, in this scenario, the pacing calculation may not yield a meaningful result.

However, if you want to interpret the result, it would imply that each iteration should be executed with a pacing interval of approximately -122.928 seconds, which is not practically feasible. It's important to adjust the test duration or the number of iterations to ensure that the test can be completed within a reasonable time frame.