1

For my JMeter test, I would like to login once and then navigate the reports in my application concurrently with multi-threads. I created two thread groups that run consecutively, the first thread group contains the login HTTP requests that is set to run with one thread. The second thread group contains the HTTP requests for each report in my application, and it is set to run with 50 threads.

The application is deployed on a weblogic server, and the application sessions are stateful.

I want to share the JsessionID generated by the first thread group through weblogic after a successful login, with the second thread group HTTP Requests.

the problem is that the JsessionID for each of the HTTP requests in the second thread group are unique and all different than the JsessionID of the login HTTP requests in the first thread group. As a result, the application is failing to call the authenticate the call.

The JsessionID is embedded in the cookies inside the header. I tried extracting it from the HTTP request in the first thread Group using Regular Expression Extractor(see the attached picture) and define it in HTTP Cookie Manager, but the problem persisted. Regular Expression Extractor config

Ali Mahdi
  • 15
  • 5

2 Answers2

2
  1. There is an easier way to fetch JSESSIONID cookie value using HTTP Cookie Manager

    • add the next line to user.properties file

      CookieManager.save.cookies=true
      
    • restart JMeter to pick the property up
    • once done you will be able to access the cookie value as ${COOKIE_JSESSIONID} where required
  2. In order to make it available in 2nd thread group you need to convert it into a JMeter Property using __setProperty() function like:

    ${__setProperty(JSESSIONID,${COOKIE_JSESSIONID},)}
    

    and once done you will be able to access the value in 2nd thread group using __P() function as ${__P(JSESSIONID,)}

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
  • I was able to successfully extract the cookie value as ${COOKIE_JSESSIONID}. Also successfully converted it into JMeter Property (validated using debug sampler). Yet failed to access the value in the 2nd thread group. I did it by adding the __P() function to the Cookie Manager – Ali Mahdi Sep 04 '18 at 11:17
  • Check if the property is **really** available in 2nd Thread Group using Debug Sampler. If you launch thread groups at the same moment you might need to "wait" until the cookie is generated prior to using in in 2nd thread group, this can be done using [Inter-Thread Communication Plugin](https://jmeter-plugins.org/wiki/InterThreadCommunication/) (can be installed using [JMeter Plugins Manager](https://www.blazemeter.com/blog/how-install-jmeter-plugins-manager)). Otherwise you might also need to pass not only the cookie name and value, but other attributes: domain, path and secure flag as well. – Dmitri T Sep 04 '18 at 11:23
  • The 2nd Thread Group runs once the first is completed. the property is available in the second group using the Debug Sampler and it is the one I seek. I am convinced that i am not passing the value correctly to the 2nd thread group. I did it through the Cookie Manager at the Thread group level, by adding a new line where the value is ${__P(JSESSIONID,)} – Ali Mahdi Sep 04 '18 at 11:31
  • You will need to pass at least the **Name** along with the value. Also if you don't want to pass other parameters make sure that you switch ["Cookie Policy"](https://hc.apache.org/httpcomponents-client-4.2.x/tutorial/html/statemgmt.html)to **netscape** so your [HTTP Cookie Manager](https://www.blazemeter.com/blog/using-http-cookie-manager-jmeter-not-cookie-jar) configuration would look like https://i.stack.imgur.com/aR48c.png – Dmitri T Sep 04 '18 at 11:41
  • It worked, I was able to apply the JSessionID in the second Thread Group, however, cookies are showing 2 JSessionID's. The one I applied and the one generated by the call. I only need the JSessionID that I applied(Extracted from the first Thread Group). is there any way around it? – Ali Mahdi Sep 04 '18 at 13:19
  • I have added a screenshot at the bottom of the body above. – Ali Mahdi Sep 04 '18 at 13:39
0

For Reference. IT WORKS:

I found a different way to complete my test and successfully suppress the cookies generated in the second thread group by the ones generated in the first thread group in order to bypass login authentication.

I wrote a small bsh in the first thread group that extracts the cookie and store it in different variables. Extract cookies from the first thread group

I then wrote another bsh in the second thread group to suppress the cookies by applying the generated variables

Applying cookies in the second thread group

Now I can log in once and navigate the reports with multi-threads all sharing the same SessionID.

Ali Mahdi
  • 15
  • 5