4

我试图用httperf加载测试我的Rails(3.2.13)应用程序。它对于不需要cookie的页面非常有效。但是,我无法使它适用于需要cookie的页面。我正在使用Gregg Pollack的httperf(https://github.com/Gregg/httperf_big_cookies),因为官方版本不支持大饼干。Rails使用httperf加载测试

这里是我所使用的命令:

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

而且,这是在文件path.txt:

/log_in 
    /sessions method=POST contents='utf8=✓&remember_me=1&commit=Login&[email protected]&password=password' 

cookies该方法总是返回nil内部控制器。

所以,请建议我如何克服这个问题或更好的工具(基于控制台)来测试rails应用程序的负载。

回答

5

您可能在使用rails附带的CSRF验证时遇到麻烦。检查你的日志,如果你看到下面的行,那么这就是原因:

WARNING: Can't verify CSRF token authenticity 

一种解决方法可以是建立一个“秘密/主”令牌使用您的测试由通过CSRF验证,然后告诉您的应用程序接受它作为一个有效的,例如,“protect_from_forgery”行之后添加以下行你的ApplicationController:

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

再上的httperf测试,你应该用PARAMS发送您的主代币:& authenticity_token = YOUR_SECRET_TOKEN