JMeter记录的样本在重新运行时失败

时间:2018-02-22 13:48:35

标签: jmeter

我在Jmeter上录制了我的项目网站工作流程。但是在重新运行记录的样本时,所有具有POST请求的样本都会失败。我无法弄清楚为什么在录制期间传递的相同样本在重新运行时失败。

以下是其中一个失败的样本的请求:

已通过的记录样本请求


    POST https://example.com/live/v1/dashboards/promo_pa/ds/promo_program_dimensions

    POST data:
    {"query":"promo_program_dimensions.filterby(program_master_id = 'GOGGLE').filterby(dimension_name = 'channel').groupby(dimension_value).aggregate(count(dimension_value) as count).orderby(dimension_value+)"}

    [no cookies]

    Request Headers:
    Connection: keep-alive
    Referer: https://example.com/live/v1/dashboards/promo_pa/
    Accept-Language: en-US,en;q=0.5
    DNT: 1
    Accept: */*
    X-Requested-With: XMLHttpRequest
    Content-Type: application/json
    Accept-Encoding: gzip, deflate, br
    User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:58.0) Gecko/20100101 Firefox/58.0
    Content-Length: 216
    Host: example.com

取样器结果


    Thread Name: 
    Sample Start: 2018-02-22 17:32:44 IST
    Load time: 93
    Connect Time: 58
    Latency: 93
    Size in bytes: 647
    Sent bytes:1095
    Headers size in bytes: 645
    Body size in bytes: 2
    Sample Count: 1
    Error Count: 0
    Data type ("text"|"bin"|""): text
    Response code: 200
    Response message: OK

    Response headers:
    HTTP/1.1 200 OK
    Server: nginx
    Date: Thu, 22 Feb 2018 12:02:44 GMT
    Content-Type: text/html; charset=utf-8
    Content-Length: 2
    Connection: keep-alive
    Cache-Control: no-cache, no-store, must-revalidate, public, max-age=0
    Set-Cookie: live=.eJxNj11vgjAYhf_K0muzMLJdSOIFC6yBQJmuiO1Nw0cdtB0zUEAw_nfRZcbLN2_Oc85zAoGNHA9B9mlDF1gn8JQBCwTm8VD8xH0h3J7CjymFfk92vszHZZklxzpdr1bgvABBBKHrMA-x-MvdzEFVZbzRI1gAtm94WwJLNx2fr6q4wymWr9RRiuJ8iJJtRRLyQsytouJdULwREUQKJfGAkvBWkrfNnulfyes7IhTxQCGqiLkeIqeQaAqn0EElxa5B8feEoK-IkFesDLFnUMd-C4e_zVXBa13p8TntdMn0eODAqjulHj4PY8lua6RwOV6TXcubm8is2XP273q-AI7Dam4.DXBC5A.CJMLbN0B4HC4U8703ZQS50K00lk; HttpOnly; Path=/live

    HTTPSampleResult fields:
    ContentType: text/html; charset=utf-8
    DataEncoding: utf-8

重新运行失败的同一样本的请求


    POST https://example.com/live/v1/dashboards/promo_pa/ds/promo_program_dimensions

    POST data:
    {"query":"promo_program_dimensions.filterby(program_master_id = 'GOGGLE').filterby(dimension_name = 'channel').groupby(dimension_value).aggregate(count(dimension_value) as count).orderby(dimension_value+)"}

    Cookie Data:
    live=.eJxNj11vgjAYhf_K0muzuE4uJPHCBNZgaB0O1Pam4aOu5WsGCqMY__uYy4yXJ2_O857nAvw1cTyC-PsaucC-gKcE2MCHwzmroj7L3Z6htzFGm54eN0VqljI5DHUcrFbgOgP-FiHX4R7h0Ye7m4qlSkSjDZgBfmpEK4Gtm05MSWV3OK5YgR3XohXJcR4tyCgVzvdTSi0WUoshOt86HiRhcHuSts2J669C1HcEgdhgJ10wx3shI4a02uUYRiMNpSIwGFguCxyuzYR6ZaEs8SH4xp9_m1Umaq20eY47Lbk2ZwHsuivLh8vDWHrcz2O0NL_NrhXNTWTS7AX_d73-AAjCaeE.DXBNjA.Fy0Fs7zpVKg-f1qSbAljATOn64E

    Request Headers:
    Connection: keep-alive
    Content-Type: application/x-www-form-urlencoded
    Content-Length: 216
    Host: example.com
    User-Agent: Apache-HttpClient/4.5.3 (Java/1.8.0_161)

取样器结果


    Thread Name: Liberty 1-1
    Sample Start: 2018-02-22 18:24:46 IST
    Load time: 26
    Connect Time: 0
    Latency: 26
    Size in bytes: 709
    Sent bytes:868
    Headers size in bytes: 652
    Body size in bytes: 57
    Sample Count: 1
    Error Count: 1
    Data type ("text"|"bin"|""): text
    Response code: 400
    Response message: BAD REQUEST

    Response headers:
    HTTP/1.1 400 BAD REQUEST
    Server: nginx
    Date: Thu, 22 Feb 2018 12:54:46 GMT
    Content-Type: text/html; charset=utf-8
    Content-Length: 57
    Connection: keep-alive
    Cache-Control: no-cache, no-store, must-revalidate, public, max-age=0
    Set-Cookie: live=.eJxNj1tvgjAAhf_K0mezGAcPkvjg0q7B0DKciO1Lw6WGcpuBwizG_z50mfHx5ORcvgvw1hS6FIvPNUbAuYCXBDjAW5xPWR0OWYEGjj_GGG8GdtiUqVnmSXRu4mC1AtcZ8HyMERQuFeEX2k7BSiWy1QbMgDi2ssuBo9teTkplj3JS85JAZLOaFqQILTrmihT7SaU23zGbYzb3obugu-A-knbtUejvUjaPCh9Wio7vFY22ikBm0SKrCeSlDwOL79I3OpajjwOLRTRnUWh4jSz28_dZZbLRSpvXuNe50OYkgdP0VfXkPJ1lh_08xktzS_adbO8gE-YgxT_r9Rcq0WoP.DXBPFg.4Rll1tgU0GdWHWyE73uLkKM8z9c; HttpOnly; Path=/live


    HTTPSampleResult fields:
    ContentType: text/html; charset=utf-8
    DataEncoding: utf-8

响应数据


    {"error": "Failed to authenticate user for data access."}

我之前有一个成功通过的登录示例,因此用户已在此示例之前成功登录。

我用过 HTTP缓存管理器,HTTP Cookie管理器和HTTP标头管理器。 HTTP Cookie管理器将自动管理会话。我仍然收到身份验证错误。

我使用了样本的默认设置,即"自动重定向"和"使用KeepAlive"。我正在使用JMeter 3.3

欣赏任何指示。

1 个答案:

答案 0 :(得分:0)

在“成功”请求中,您有以下HTTP Headers

X-Requested-With: XMLHttpRequest
Content-Type: application/json

在“失败”中你有:

Content-Type: application/x-www-form-urlencoded

所以我的期望是您需要添加HTTP Header Manager作为“失败”请求的子项,并将其配置为发送Content-Type标头,其值为application/json