Resolving 500-Internal Server Error during Validate for Loadtest
Parasoft: 500 - Internal Server Error during Validate for Loadtest
Description:
During Web functional troubleshooting, it is important to pay close attention to the request/response headers. This is especially the case when we receive a 500 - internal server error when performing “Validate for Load Test”. Aside from incorrect or duplicate headers, a user should also be alert for any Custom Headers such as the following:
X-GWT X-GWT-Permutation or X-APPIAN-CSRF-TOKEN
Google Web Toolkit applications and CSRF-Protected Web sites append these custom HTTP headers to all HTTP requests to prevent a security problem known as cross-site request forgery (XSRF). In such situations, performing “Validate for Load Test” on GWT applications may cause a failure such as a 500 – Internal Server error.
This occurs because JavaScript does not get executed in a load test context-and without JavaScript execution, these particular headers do not get set as part of the requests.
Solution:
To remedy this, we can write a short script to add the missing headers so that they are sent along with all requests during a Loadtest. Prior to doing this, we will need to run the Web Functional Scenario in the SOAtest Perspective and analyze the traffic viewer to identify the missing headers and their appropriate values. Once we identify the missing values, we will need to add an extension tool before the first test in the scenario that fails. By doing this, the scripted headers will be passed in the subsequent tests.
1) Change to the Parasoft Load Test perspective and run your test for “Configure for Load Test”.
2) After the test has succeeded, we can begin making our changes. Add an extension tool before the first test in the scenario that fails so that the headers are sent along in the subsequent test. Please note that if the test is run for “Configure for Load Test” again, any changes made to the test may be reverted.
3) Add the following sample Jython script to set the required headers:
from com.parasoft.api import * def addHeader(x, context): BrowserTestUtil.addHttpHeader("HeaderName", "HeaderValue", context)
4) Perform “Validate for Load Test” and verify in the traffic viewer that the headers were passed successfully in the subsequent test. If you continue to have errors, it may be necessary to pass additional headers in the requests.
5) As a precaution, we recommend adding the request MIME type (Multipurpose Internet Mail Extension) to your Parasoft>Preferences in order to ensure that all request messages are identified according to their nature and format.
6) If you expect multiple scenarios to require the Extension Tool, we recommend defining the Extension Tool as a global tool so that you may quickly add it into any other scenarios.
More detailed information regarding Custom Headers and GWT applications can be found in your SOAtest Userguide located in your SOAtest installation directory.