Appengine 1.7.4, webapp2, sessions.
Sessions are configured as shown in documentation: http://webapp-improved.appspot.com/api/webapp2_extras/sessions.html#webapp2_extras.sessions.SessionStore
# Some object
def post(self):
logging.error(self.session.get('cart')) #A 1 item
if '_put' in self.request.params:
return self.put()
cart = self.session.get('cart')
# add one item to cart
self.session['cart'] = cart
logging.error(self.session.get('cart')) #B OK, 2 items
return self.redirect(URL)
def put(self):
logging.error(self.session.get('cart')) #C 1 item?!
# some code
return self.redirect(URL)
Two POST request send by AJAX.
First without _put
- #A - returns 1 item - OK.
- #B - returns 2 items - OK.
Second, POST with _put.
- #A - returns 1 item - why? session was changed?
- #C - as above
Requests are executed one by one (user clicks once, two requests). Any ideas why this might be happening?
If I run only the first request (without _put) and refresh page - session is saved correctly.
Problem started after the migration from the webapp (1.x) and Python 2.5.
Thanks for any suggestions.
How much time is between these two requests? Less then 1 or 2 seconds? Then you might have a race-condition here:
Req. 1 reads the session
Req. 2 reads the session
Req. 1 saves its session
Req. 2 saves its session
==> Changes from Req. 1 are lost. Please note that (due to the distributed architecture of the appengine) "saving" can occur even after the request itself has finished!
Related
May i know how to achieve this scenario in JMeter.
Requirement 1 : Request 1 should execute for 15 mins, once 15 mins crossed request 2 should execute and request 1 to be stopped.
Requirement 2 : In request 1, we need to capture all dynamic value and store it some place and same dynamic value we should use it as request body for request 2. We like to run large numbers of users. Not sure, how to store all the response in some files or other alternatives.
Ex : Request 1 - > Trigger -> Store response somewhere(15 min run & 100 iteration) - stopped
Request 2 - > Trigger after 15 min - Execute request with above 100 iteration response)
Either take a look at Runtime Controller, using this guy you can choose how long its child(ren) will be run or just put your requests 1 and 2 into separate Thread Groups
If you want to store full responses into a file take a look at:
Post-Processors to capture the required part of the response into a JMeter Variable
Sample Variables property to tell JMeter to save this variable into .jtl results file
Flexible File Writer if you want to write the values into a separate file
Goal:
I would like to visit 10 different URLs of the form http:localhost/path/item/${id} where id is a Random Variable. For each of these URLs, I want to request them until the response returns a specified string.
Current setup:
I have a While Controller with an Http Request under it. The condition looks like ${__javaScript('${response}'.indexOf("my string") == -1,)} (the response variable is saved via a JSON Extractor). I also have the Loop Count in the Thread Group set to 10.
Problem:
My test plan works fine, but only for one URL. It's as if it's ignoring the Loop Count setting. Assuming the While Controller makes two requests per URL, it's only making two requests total, rather than expected 20.
This is puzzling because if I use a Loop Controller with a Loop Count of 5, it makes 50 total requests.
How can I achieve the desired behavior?
Cannot be 100% sure without seeing the whole plan, but I suspect it's because you are not unsetting ${response} for next iteration, after it reaches true condition. I.e.
First iteration starts, and ${response} is empty/undefined ==> enters while
At some iteration within while it sets ${response} so, that ${__javaScript('${response}'.indexOf("my string") == -1,)} gives true ==> While exits
Next iteration starts. If at this point ${response} is still the same as in previous iteration, it will never enter while, since it's already true.
If this is the case, reset value at the beginning of iteration.
To reset the value, add a BeanShell Sampler nd either remove a variable:
vars.remove("response");
or set its value to empty / something else:
vars.put("response", "");
If this is not the problem, look for exceptions in the jmeter.log. Could be that your script is exiting due to error.
My test plan is as following
- Test Plan
- Thread Group (No of Threads: 4)
- HTTP Request Defaults
- HTTP Cookie Manager
- CSV Data Set Config(Login Information) [4 user login]
- Simple Controller
- HTTP Request(GET: Open Login Page)
- HTTP Request(POST: Login auth)
- Loop Controller
- CSV Data Set Config(Operation Information) [8 operation data]
- HTTP Request(GET: Open Operation page)
- HTTP Request(POST: Commit Operation)
- HTTP Request(POST: Logout)
In this plan suppose I provide 4 users and 8 operation data.
What it doing is running 8 operation for 4 users each in total of 8x4=32 operations.
How could I make this as following
1st user will do 2 operations
2nd user will do 2 operations
3rd user will do 2 operations
4th user will do 2 operations
I want to provide user session wise different operations that 4 users will do number of transactions but the transactions will not be same.
How can I achieve this?
If I'm getting your test scenario correctly you can just set the "Sharing Mode" of your CSV Data Set Config (Operation Information) to Current Thread Group.
Current thread group - each file is opened once for each thread group in which the element appears
If you want more precise control I believe Switch Controller is what you're looking for, using it you can select which user will go for which execution branch.
See Running JMeter Samplers with Defined Percentage Probability article for more information.
As requested, I am posting my solution. Below is the test plan story.
Test Plan
Thread Group
I used only 1 thread in my thread group and 4 in the loop count as shown below.
Loop Controller
CSV Config for the both the files
Output
I am trying to do the load testing of the pages which can be access after login only.
As I am using Once Only Controller for login request ,when I changed Number of thread- 5 or more,login executes 5 times.
as Once Only Controller works for loopcount so I used loopcount but it slowdown my process and it executes the whole testplan.
My test-plan is:
login thread A- one time execution - how to do it?
http request B- multiple times(by using Number of threads)
http request C- multiple times(by using Number of threads)
What should I use for one time login execution and other successor requests needs to be executed multiple times without using Once Only Controller?
Kindly follow these steps:-
In Thread Group put number of threads:5 , Ramp-up:0 , Loop count: 1
Put your Login part in Once only controller
Right click on Your thread group > add > logic controller > loop controller
Now put your http request part in loop controller and set loop count of loop controller how many times you want to run
Then run the test you will get whatever you want
The Loop count in "Thread Group" is your full script Loop count not for your Transactions, for your transactions you have to put separate loop count before transaction starts.
Please do below
Your thread group setting should be below:
A.Number of threads :1
B:Ramp up period : 0 or as per application response.
C:Loop Count :5
Put your login request under Only once controller.
Request B and Request C should be at thread group Level.ie one step above it.
Run the request.
please find Sample Jmxsample Jmx for your reference Plse try. Hope it resolves your issue.
I'm having a stale attribute with the http session within Websphere 6 and may be related to in memory session replication..
Steps:
Object A.0 - Placed into the session with ID "ABC"
Remove A.0 from the session..
Object A.1 (New instance) - placed into Session with ID "ABC"
retrieve object with ID "ABC" from the session - RESULT: A.1 (Correct)
carry out a Servlet forward or a redirect (issues seen on both functions)..
retrieve "ABC" from the session - RESULT: A.0, the object that was removed from the session..
Notes -
Same Session object (hashcode/session ID) used in steps 1-5 using in
memory replication across 2 JVMs (single cluster)
time duration between steps 2 & 5 is total of 4 seconds
No other external threads have accessed the session in the interim..
Only noticed for 1 specific use-case; haven't encountered this in
other use-cases..
Anyone seen anything like this before where a stale data is being returned from the websphere application server?
Thanks,
Ian.
Are you explicitly writing the changed object back to the session before you forward/redirect? In at least some versions of WebSphere, in some configurations, you must do this to ensure the change is "committed".
(If I find a clear reference for this, I'll update my answer.)