Request
formatting...Module contains step implementations that creates requests executed by the load user in the scenario.
File with name
Create an instance of the Request task, with the same endpoint
as the previous Request task, where the
payload is defined in a template file.
See Request task documentation for more information about arguments.
Example
Then post request "test/request1.j2.json" with name "test-post1" to endpoint "/api/test"
Then post request "test/request2.j2.json" with name "test-post2"
# same as
Then post request "test/request1.j2.json" with name "test-post1" to endpoint "/api/test"
Then post request "test/request2.j2.json" with name "test-post2" to endpoint "/api/test"
Arguments
Name | Type | Description | Default |
---|---|---|---|
method
|
Method
|
type of "to" request |
required |
source
|
str
|
path to a template file relative to the directory |
required |
name
|
str
|
name of the requests in logs, can contain variables |
required |
File with name endpoint
Create an instance of the Request task, where the payload is defined in a template file.
See Request task documentation for more information about arguments.
Example
Then send request "test/request.j2.json" with name "test-send" to endpoint "queue:receive-queue"
Then post request "test/request.j2.json" with name "test-post" to endpoint "/api/test"
Then put request "test/request.j2.json" with name "test-put" to endpoint "/api/test"
Arguments
Name | Type | Description | Default |
---|---|---|---|
method
|
Method
|
type of "to" request |
required |
source
|
str
|
path to a template file relative to the directory |
required |
name
|
str
|
name of the requests in logs, can contain variables |
required |
endpoint
|
str
|
URI relative to |
required |
Text with name
Create an instance of the Request task, where optional payload is defined directly in the feature file.
See Request task documentation for more information about arguments.
If method
in the expression is post
, put
or send
the payload in the request must be defined directly in the feature file after the step.
This step is useful if method
and endpoint
are the same as previous request, but the payload should be different.
Example
# example-1
Then post request with name "test-post-1" to endpoint "/api/test"
"""
{
"value": "hello world!"
}
"""
Then post request with name "test-post-2"
"""
{
"value": "i have good news!"
}
"""
# same as example-1
Then post request with name "test-post-1" to endpoint "/api/test"
"""
{
"value": "hello world!"
}
"""
Then post request with name "test-post-2" to endpoint "/api/test"
"""
{
"value": "i have good news!"
}
"""
# example-2
Then get request with name "test-get-1" from endpoint "/api/test"
Then get request with name "test-get-2"
# same as example-2
Then get request with name "test-get-1" from endpoint "/api/test"
Then get request with name "test-get-2" from endpoint "/api/test"
Arguments
Name | Type | Description | Default |
---|---|---|---|
method
|
Method
|
type of request, either "from" or "to" |
required |
name
|
str
|
name of the requests in logs, can contain variables |
required |
Text with name endpoint
Create an instance of the Request task, where optional payload is defined directly in the feature file.
See Request task documentation for more information about arguments.
-
If
Method
in the expression isget
orreceive
; thedirection
must befrom
. -
If
Method
in the expression ispost
,pust
, orsend
; thedirection
must beto
, and payload defined in the feature file.
Example
Then post request with name "test-post" to endpoint "/api/test"
"""
{
"test": "hello world"
}
"""
Then put request with name "test-put" to endpoint "/api/test"
"""
{
"test": "hello world"
}
"""
Then get request with name "test-get" from endpoint "/api/test"
Then send request with name "test-send" to endpoint "queue:receive-queue"
"""
{
"value": "do something"
}
"""
Then receive request with name "test-receive" from endpoint "queue:receive-queue"
Arguments
Name | Type | Description | Default |
---|---|---|---|
method
|
Method
|
type of request, either of type "from" or "to" |
required |
name
|
str
|
name of the requests in logs, can contain variables |
required |
direction
|
RequestDirection
|
one of |
required |
endpoint
|
str
|
URI relative to |
required |