github.com/yandex/pandora@v0.5.32/components/providers/scenario/testdata/http_payload.hcl (about)

     1  locals {
     2    common_headers = {
     3      Content-Type  = "application/json"
     4      Useragent     = "Yandex"
     5    }
     6    next = "next"
     7  }
     8  locals {
     9    auth_headers = merge(local.common_headers, {
    10      Authorization = "Bearer {{.request.auth_req.postprocessor.token}}"
    11    })
    12    next = "next"
    13  }
    14  variable_source "users" "file/csv" {
    15    file              = "testdata/users.csv"
    16    fields            = ["user_id", "name", "pass"]
    17    ignore_first_line = true
    18    delimiter         = ","
    19  }
    20  variable_source "filter_src" "file/json" {
    21    file = "testdata/filter.json"
    22  }
    23  variable_source "variables" "variables" {
    24    variables = {
    25      header = "yandex"
    26      b = "s"
    27    }
    28  }
    29  request "auth_req" {
    30    method = "POST"
    31    uri    = "/auth"
    32    headers   = local.common_headers
    33    tag       = "auth"
    34    body      = <<EOF
    35  {"user_id":  {{.request.auth_req.preprocessor.user_id}}}
    36  EOF
    37    templater {
    38      type = "html"
    39    }
    40  
    41    preprocessor {
    42      mapping = {
    43        user_id = "source.users[${local.next}].user_id"
    44      }
    45    }
    46    postprocessor "var/header" {
    47      mapping = {
    48        Content-Type      = "Content-Type|upper"
    49        httpAuthorization = "Http-Authorization"
    50      }
    51    }
    52    postprocessor "var/jsonpath" {
    53      mapping = {
    54        token = "$.auth_key"
    55      }
    56    }
    57    postprocessor "assert/response" {
    58      headers = {
    59        Content-Type = "json"
    60      }
    61      body = ["key"]
    62      size {
    63        val = 40
    64        op  = ">"
    65      }
    66    }
    67    postprocessor "assert/response" {
    68      body = ["auth"]
    69    }
    70  }
    71  request "list_req" {
    72    method = "GET"
    73    headers = merge(local.common_headers, {
    74      Authorization = "Bearer {{.request.auth_req.postprocessor.token}}"
    75    })
    76    tag = "list"
    77    uri = "/list"
    78  
    79    postprocessor "var/jsonpath" {
    80      mapping = {
    81        item_id = "$.items[0]"
    82        items   = "$.items"
    83      }
    84    }
    85  }
    86  request "order_req" {
    87    method = "POST"
    88    uri    = "/order"
    89    headers = local.auth_headers
    90    tag  = "order_req"
    91    body = <<EOF
    92  {"item_id": {{.request.order_req.preprocessor.item}}}
    93  EOF
    94  
    95    preprocessor {
    96      mapping = {
    97        item = "request.list_req.postprocessor.items[next]"
    98      }
    99    }
   100  }
   101  
   102  request "order_req2" {
   103    method = "POST"
   104    uri    = "/order"
   105    headers = {
   106      Authorization = "Bearer {{.request.auth_req.postprocessor.token}}"
   107      Content-Type  = "application/json"
   108      Useragent     = "Yandex"
   109    }
   110    tag  = "order_req"
   111    body = <<EOF
   112  {"item_id": {{.request.order_req2.preprocessor.item}}  }
   113  EOF
   114  
   115    preprocessor {
   116      mapping = {
   117        item = "request.list_req.postprocessor.items[next]"
   118      }
   119    }
   120  }
   121  
   122  scenario "scenario_name" {
   123    weight           = 50
   124    min_waiting_time = 10
   125    requests         = [
   126      "auth_req(1)",
   127      "sleep(100)",
   128      "list_req(1)",
   129      "sleep(100)",
   130      "order_req(3)"
   131    ]
   132  }
   133  
   134  scenario "scenario_2" {
   135    requests         = [
   136      "auth_req(1)",
   137      "sleep(100)",
   138      "list_req(1)",
   139      "sleep(100)",
   140      "order_req(2)"
   141    ]
   142  }