Apache JMeter 中的会话/cookie 管理 [英] Session/cookie management in Apache JMeter

查看:29
本文介绍了Apache JMeter 中的会话/cookie 管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在应用程序中有一个简单的性能测试流程.

We have a simple performance test flow in an application.

  1. 我们登录
  2. 根据某些条件搜索
  3. 重复搜索不同的参数.

我们正在使用 Jmeter 进行性能测试.我们需要运行多个线程来以可扩展的方式进行测试.

We are using Jmeter to do a performance testing. We need to have multiple threads running to test this in a scalable manner.

我们目前的安排方式是:

The way we currently have this arranged is:

-Test Plan
  - Thread Group
      - Cookie Manager
      - Login To application
      - Search on param 1
      - Search on param 2
  - results summary table
  - Summary report

所以基本上我们有计划级别的汇总返回表和报告,而 cookie 管理器存在于线程组级别.

So basically we have summary return table and report present on plan level while cookie manager is present on thread group level.

当我为一个线程运行时,它运行良好并且完成得很好.当我将它扩展到多个线程时,只要下一个线程开始,最后一个线程的会话就会失效.由于新产生的线程,这会导致所有已经运行的线程失败.

When I run for one thread it runs fine and completes well. When I scale it to multiple threads, as soon as the next thread kicks off, the session for the last thread is invalidated. This causes failures for all the already running threads due to newly spawned thread.

我通过观察得出了这个结果:
1.如果我运行多个线程,则只有最后一个线程在结果摘要树中得到有效响应
2.如果我用 2 个线程运行,启动周期为 10 秒,这意味着每个线程都有时间完成自己,然后它们都成功运行.

I reached this result with observation:
1. If I run multiple threads, only last thread has got valid responses in result summary tree
2. If I run with 2 threads with ramp up period as 10 seconds, which means each thread gets time to finish itself, then both of them run successfully.

根据我的理解,每个线程都登录到应用程序中,并且由于 cookie 管理器处于线程级别,因此将为每个线程分别维护会话 ID 的值?但是是什么导致了线程之间会话 id 值的覆盖?

As per my understanding each thread login's into application and since cookie manager is at thread level, the values will be maintained for session id for each thread respectively? But what is causing the override of the session id value between threads?

任何帮助将不胜感激.

推荐答案

复制自 jmeter 文档:

Copied from jmeter documentation:

最后一个元素是一个 HTTP Cookie经理 .Cookie 管理器应该是添加到所有网络测试 - 否则JMeter 将忽略 cookie.通过添加它在线程组级别,我们确保所有 HTTP 请求都将共享相同的 cookie.

The last element is a HTTP Cookie Manager . A Cookie Manager should be added to all web tests - otherwise JMeter will ignore cookies. By adding it at the Thread Group level, we ensure that all HTTP requests will share the same cookies.

来自 http://jmeter.apache.org/中的4.2.2 逻辑控制器"一章用户手册/test_plan.html.

编辑:我想你应该使用 http://jmeter.apache.org/usermanual/component_reference.html#Simple_Controller 使用 Cookie 管理器将您的请求分组.

EDIT: I guess you should use http://jmeter.apache.org/usermanual/component_reference.html#Simple_Controller to group your requests together with Cookie Manager.

这篇关于Apache JMeter 中的会话/cookie 管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆