Taurus 用户如何传入Content-Type 和base64 值?

How to pass in Content-Type and base64 value as a user in Taurus?

我正在尝试分配一个 base64 字符的用户值和 "application/x-www-form-urlencoded" 的内容类型。在我的邮递员中,Content-Type 在 Headers 下,而 user 在 body 下。因此,我将我的 yaml 脚本构造如下:

execution:
  - concurrency: 10
    ramp-up: 20S
    hold-for: 1m
    scenario: sample

scenarios:
  sample:
    requests:
      - url: 'https://www.mtn.com/umbraco/surface/loginsurface/authenticate'
        method: POST
        headers:
          Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp, application/x-www-form-urlencoded'
        Body:
          user: 'YWFkaWwuaaa2hhbkBzb3RpLdDpXZWxjb21lMTIzNA=='

然而,当我是 运行 金牛座时,这不起作用。语法错误吗?

  1. 根据Taurus documentation

    As you know, JSON is a subset of YAML

    所以 Taurus 同时支持 JSON 和 YAML 配置文件

  2. 根据JSON specification

    All names etc. are case-sensitive. Conforming implementations therefore MUST treat all names as being case-sensitive such the names "bar" and "BAR" would be seen as two distinct entities.

  3. 进一步研究 Taurus documentation on YAML 格式:

    Dictionaries are collections of key: value mappings. All keys are case-sensitive.

    因此您只需要将 Body 转换为小写字母,一切都会按预期开始工作(或者至少会导致以下 JMeter 配置)

完整的 YAML 以防万一:

execution:
  - concurrency: 10
    ramp-up: 20S
    hold-for: 1m
    scenario: sample

scenarios:
  sample:
    requests:
      - url: 'https://www.mtn.com/umbraco/surface/loginsurface/authenticate'
        method: POST
        headers:
          Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp, application/x-www-form-urlencoded'
        body:
          user: YWFkaWwuaaa2hhbkBzb3RpLdDpXZWxjb21lMTIzNA==

你总是可以open JMeter GUI被运行金牛座喜欢:

bzt test.yaml -gui

bzt -o modules.jmeter.gui=true test.yaml

这样可以更容易地检查生成的脚本。

更多信息: