Closed asfimport closed 17 years ago
Sebb (migrated from Bugzilla): Could you attach a simple test case that shows the problem, please?
rino (migrated from Bugzilla): Created attachment cookie.jmx: simple test plan
rino (migrated from Bugzilla): I'm having the same problem, although I'm using the "User Defined Variables" defined in the "Test Plan". In the file I attached, I set a "domain" variable, and I try to use it for the cookie domain. Won't work :(
Charles Eakins (migrated from Bugzilla): We are also seeing this bug, with user variables and built in variables like ${_StringFromFile(file-path)}. We need to change a value in the cookie to about a hundred different combonations. BTW keep up the good work, I really like what I have seen so far, in fact better than loadrunner.
Sebb (migrated from Bugzilla): [Thanks for the sample]
I've had a quick look at the code, and the Cookie Manager stores its values in a slightly different way from (most) other test elements - the result is that it treats them as fixed strings, and does not try to interpret them as functions/variables.
theshaman (migrated from Bugzilla): I just want to say I also face with this limitation (not possible to add personalized cookies to each user threads, using user variables or other means) of JMeter. I think it could be a very useful enhancement of JMeter. Nevertheless congratulations and thanks for your work.
Stephen Cooper (migrated from Bugzilla): This patch allows the expansion of UserParameters and Function calls in the Cookie Manager. It does so by no longer overriding the setRunningVersion and recoverRunningVersion methods. As a result of no longer overriding these, I had to create some way to accurately reset cookies for each iteration. So I introduced a variable "temporaryCookies" which gets populated with the cookie name of any cookie to remove - any cookie added while isRunningVersion is set to true.
Created attachment CookieManager.patch: Fix to allow expansion of functions and user parameters in the CookieManager
File: CookieManager.java Status: Locally Modified
Working revision: 1.40
Repository revision: 1.40
/home/cvspublic/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java,v
Sticky Tag: v2_1_1 (revision: 1.40)
Sticky Date: (none)
Sticky Options: (none)
Alf Hogemark (migrated from Bugzilla): I have been briefly looking at this.
The following short patch seems to make it possible to use functions and user parameters in the CookieManager.
--- C:/Documents and Settings/alf/workspace/Jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java (revision 519613) +++ C:/Documents and Settings/alf/workspace/Jmeter/src/protocol/http/org/apache/jmeter/protocol/http/control/CookieManager.java (working copy) @@ -290,7 +290,10 @@ int i=0; for (PropertyIterator iter = getCookies().iterator(); iter.hasNext();) { Cookie jmcookie = (Cookie) iter.next().getObjectValue();
However, I'm not sure this is the correct way of fixing this. I have not looked much at the CookieManager code. Are there threading issues involved ? I.e. can different threads be accessing the cookies at the same time ? In that case, the different threads can set and unset the running version. Or do each thread have it's own instance of the CookieManager and all other ConfigTestElement ? If each thread have their own CookieManager, I think the simple patch above is correct.
Do we want to only allow variable expansion in the static cookies, and not in the runtime cookies received during sampling ?
Perhaps Stephen Cooper's patch from 2005-10-10 looks better, but the code seems to have changed a bit since his suggestion.
Could we just call "setRunningVersion(false); setRunningVersion(false);" on each cookie as the first thing to do in "testIterationStart" ? Or will we get threading issues here as well ?
And also call "setRunningVersion(false);" on each cookie on "testEnded" ? Perhaps that is not needed, as it seems like the GUI recreates all the cookies "static cookies" when you go to the CookieManager GUI. I'm at least unable to figure out when all the dynamic cookies are deleted, but I never see them in the GUI.
Or should we add a flag to the Cookie class, so we know which ones are static and which ones are dynamic, and then loop over all the static ones in the following methods in CookieManager : public void recoverRunningVersion() public void setRunningVersion
I'm sorry for all the questions, but this bug seems like an "easy" one to fix, and quite important.
Any comments ?
Sebb (migrated from Bugzilla): Code has been added to Cookie Manager in SVN r571789.
Just in case it causes a problem, one can set the property:
CookieManager.allow_variable_cookies=false
to disable the fix.
jimmyxu (migrated from Bugzilla): hi I am not sure whether I have got correct configuration of Jmeter, but I do see user parameter is not work in cookie manager. I got this problem both Jmeter 2.4 and Jmeter 2.5.1 reproduce step:
result: $SessID is treated as a string not a variable (but this variable works in http sampler.)
expected: $SessID is treated as a variable
Sebb (migrated from Bugzilla): (In reply to comment 11)
hi I am not sure whether I have got correct configuration of Jmeter, but I do see user parameter is not work in cookie manager. I got this problem both Jmeter 2.4 and Jmeter 2.5.1 reproduce step:
- Create http request to access a website
- Create a regular expression extractor to get a SessionID value as SessID variable
- Create a HTTP Cookie Manager to reference SessID(${SessID})
result: $SessID is treated as a string not a variable (but this variable works in http sampler.)
expected: $SessID is treated as a variable
WOrks fine for me; note that the Cookie Manager is a configuration element so only resolves variables at the start of a loop.
jimmyxu (migrated from Bugzilla): (In reply to comment 12)
(In reply to comment 11) > hi > I am not sure whether I have got correct configuration of Jmeter, but I do see > user parameter is not work in cookie manager. I got this problem both Jmeter > 2.4 and Jmeter 2.5.1 > reproduce step: > 1. Create http request to access a website > 2. Create a regular expression extractor to get a SessionID value as SessID > variable > 3. Create a HTTP Cookie Manager to reference SessID(${SessID}) > > result: $SessID is treated as a string not a variable > (but this variable works in http sampler.) > > expected: $SessID is treated as a variable
WOrks fine for me; note that the Cookie Manager is a configuration element so only resolves variables at the start of a loop.
Thanks. I misunderstand user parameter, user parameter works well. What I want to do is reset cookie value for a http smapler, is there any method can do that in Jmeter?
Jimmy
Sebb (migrated from Bugzilla): Bugzilla is not a support forum.
Please subscribe to the JMeter user list and ask there.
Vibhav Garg (Bug 28715): In our app we need to assign cookie values using User Parameters. However, right now, variable expansion does not work in HTTP Cookie Manager.
Votes in Bugzilla: 1 Severity: normal OS: All