Question

I'm trying to load test my Rails (3.2.13) application with httperf. It worked very well for the pages which don't require cookies. But, I couldn't make it working for the pages which require cookies. I'm using Gregg Pollack's httperf (https://github.com/Gregg/httperf_big_cookies) because the official version does not support big cookies.

Here is the command I used:

httperf --session-cookie --wsesslog=1,5,path.txt --rate=1 --timeout=15 --server=localhost --port=3000

And, this is the path.txt file:

    /log_in
    /sessions method=POST contents='utf8=✓&remember_me=1&commit=Login&email=john@widgetsco.com&password=password'

The cookies method always returns nil inside controllers.

So, please suggest me how can I overcome the problem or a better tool (console based) for testing load of rails applications.

Was it helpful?

Solution

You are probably having troubles with the CSRF verification that comes with rails. Check your logs and if you see the following line, then that's the reason:

WARNING: Can't verify CSRF token authenticity

A workaround can be to create a "secret/master" token to use for your tests to by pass the CSRF verification, then tell your application to accept it as a valid, for example, add the following line in your ApplicationController right after the "protect_from_forgery" line:

skip_before_filter :verify_authenticity_token, :if =>lambda{ params[:authenticity_token].present? && params[:authenticity_token] == 'YOUR_SECRET_TOKEN' }

then on the httperf tests, you should send the your master token with the params: &authenticity_token=YOUR_SECRET_TOKEN

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top