-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from yandex/dev
v0.5.20
- Loading branch information
Showing
18 changed files
with
1,088 additions
and
337 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[Home](index.md) | ||
|
||
--- | ||
|
||
# gRPC generator | ||
|
||
Full gRPC generator config | ||
|
||
```yaml | ||
gun: | ||
type: http | ||
target: '[hostname]:443' | ||
timeout: 15s | ||
tls: true | ||
dial_options: | ||
timeout: 1s | ||
authority: string | ||
answlog: | ||
enabled: true | ||
path: ./answ.log | ||
filter: all # all - all http codes, warning - log 4xx and 5xx, error - log only 5xx. Default: error | ||
``` | ||
--- | ||
[Home](index.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,289 @@ | ||
[Home](../index.md) | ||
|
||
--- | ||
|
||
# Scenario generator / gRPC | ||
|
||
- [Configuration](#configuration) | ||
- [Generator](#generator) | ||
- [Provider](#provider) | ||
- [Description of the scenario format](#description-of-the-scenario-format) | ||
- [General principle](#general-principle) | ||
- [HCL example](#hcl-example) | ||
- [YAML example](#yaml-example) | ||
- [Features](#features) | ||
- [Calls](#calls) | ||
- [Templater](#templater) | ||
- [Variable names in templates](#variable-names-in-templates) | ||
- [Preprocessors](#preprocessors) | ||
- [prepare](#prepare) | ||
- [Postprocessors](#postprocessors) | ||
- [assert/response](#assertresponse) | ||
- [Scenarios](#scenarios) | ||
- [Sources](#sources) | ||
|
||
## Configuration | ||
|
||
You need to use a generator and a provider of type `grpc/scenario` | ||
|
||
```yaml | ||
pools: | ||
- id: Pool name | ||
gun: | ||
type: grpc/scenario | ||
target: localhost:8888 | ||
ammo: | ||
type: grpc/scenario | ||
file: payload.hcl | ||
``` | ||
### Generator | ||
The minimum generator configuration is as follows | ||
```yaml | ||
gun: | ||
type: http/scenario | ||
target: localhost:80 | ||
``` | ||
For a scenario gRPC generator, all settings of a regular gRPC generator are supported [gRPC generator](grpc-generator.md) | ||
### Provider | ||
The provider accepts only one parameter - the path to the file with the scenario description | ||
```yaml | ||
ammo: | ||
type: http/scenario | ||
file: payload.hcl | ||
``` | ||
Supports file extensions | ||
- hcl | ||
- yaml | ||
- json | ||
## Description of the scenario format | ||
Supports formats | ||
- hcl | ||
- yaml | ||
- json | ||
### General principle | ||
Several scenarios can be described in a single file. A script has a name by which one scenario differs from another. | ||
A script is a sequence of rpc calls. That is, you will need to describe in the script which calls | ||
should be executed in what order. | ||
The Call is a gRPC call. It has standard gRPC call fields plus additional ones. See [Calls](#calls). | ||
### HCL example | ||
```terraform | ||
variable_source "users" "file/csv" { | ||
file = "users.csv" | ||
fields = ["user_id", "login", "pass"] | ||
ignore_first_line = true | ||
delimiter = "," | ||
} | ||
variable_source "filter_src" "file/json" { | ||
file = "filter.json" | ||
} | ||
variable_source "variables" "variables" { | ||
variables = { | ||
header = "yandex" | ||
b = "s" | ||
} | ||
} | ||
|
||
call "auth_req" { | ||
call = "target.TargetService.Auth" | ||
tag = "auth" | ||
metadata = { | ||
"metadata" = "server.proto" | ||
} | ||
preprocessor "prepare" { | ||
mapping = { | ||
user = "source.users[next]" | ||
} | ||
} | ||
payload = <<EOF | ||
{"login": "{{.request.auth_req.preprocessor.user.login}}", "pass": "{{.request.auth_req.preprocessor.user.pass}}"} | ||
EOF | ||
postprocessor "assert/response" { | ||
payload = ["token"] | ||
status_code = 200 | ||
} | ||
}} | ||
} | ||
|
||
scenario "scenario_name" { | ||
weight = 1 | ||
min_waiting_time = 1000 | ||
requests = [ | ||
"auth_req", | ||
] | ||
} | ||
``` | ||
|
||
You can also see an example in the tests https://github.com/yandex/pandora/blob/dev/tests/grpc_scenario/testdata/grpc_payload.hcl | ||
|
||
|
||
### YAML example | ||
|
||
```yaml | ||
variable_sources: | ||
- type: "file/csv" | ||
name: "users" | ||
ignore_first_line: true | ||
delimiter: "," | ||
file: "file.csv" | ||
fields: ["user_id", "login", "pass"] | ||
- type: "file/json" | ||
name: "filter_src" | ||
|
||
calls: | ||
- name: "auth_req" | ||
call: 'target.TargetService.Auth' | ||
tag: auth | ||
method: POST | ||
metadata: | ||
metadata: "server.proto" | ||
preprocessors: | ||
- type: prepare | ||
mapping: | ||
new_var: source.var_name[next].0 | ||
payload: '{"login": "{{.request.auth_req.preprocessor.user.login}}", "pass": "{{.request.auth_req.preprocessor.user.pass}}"}' | ||
postprocessors: | ||
- type: assert/response | ||
payload: ["token"] | ||
status_code: 200 | ||
|
||
scenarios: | ||
- name: scenario_name | ||
weight: 1 | ||
min_waiting_time: 1000 | ||
requests: [ | ||
auth_req | ||
] | ||
``` | ||
|
||
## Features | ||
|
||
### Calls | ||
|
||
Fields | ||
|
||
- call | ||
- tag | ||
- metadata | ||
- preprocessors | ||
- payload | ||
- postprocessors | ||
|
||
### Templater | ||
|
||
The fields `metadata', `payload` are templated. | ||
|
||
The standard go template is used. | ||
|
||
#### Variable names in templates | ||
|
||
Variable names have the full path of their definition. | ||
|
||
For example | ||
|
||
Variable `users` from source `user_file` - `{% raw %}{{{.source.user_file.users}}{% endraw %}` | ||
|
||
Variable `item` from the `list_req` call preprocessor - `{% raw %}{{{.request.list_req.preprocessor.item}}{% endraw %}` | ||
|
||
> Note | ||
> To maintain similarity with http scripts, the response section from the grpc call is saved to the `postprocessor` section | ||
Variable `token` from the `list_req` call is `{% raw %}{{{.request.list_req.postprocessor.token}}{% endraw %}` | ||
|
||
#### Preprocessors | ||
|
||
Preprocessor - actions are performed before templating | ||
|
||
##### prepare | ||
|
||
It is used for creating new variable mapping | ||
|
||
The preprocessor has the ability to work with arrays using modifiers | ||
|
||
- next | ||
- last | ||
- rand | ||
|
||
##### yaml | ||
|
||
```yaml | ||
calls: | ||
- name: req_name | ||
... | ||
preprocessors: | ||
- type: prepare | ||
mapping: | ||
user_id: source.users[next].id | ||
``` | ||
##### hcl | ||
```terraform | ||
call "req_name" { | ||
preprocessor "prepare" { | ||
mapping = { | ||
user_id = "source.users[next].id" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
#### Postprocessors | ||
|
||
##### assert/response | ||
|
||
Checks header and body content | ||
|
||
Upon assertion, further scenario execution is dropped | ||
|
||
```terraform | ||
postprocessor "assert/response" { | ||
payload = ["token"] | ||
status_code = 200 | ||
} | ||
``` | ||
|
||
### Scenarios | ||
|
||
This section repeats the same [scenario in HTTP generator](./scenario-http-generator.md#scenarios) | ||
|
||
The minimum fields for the script are name and list of requests | ||
|
||
```terraform | ||
scenario "scenario_name" { | ||
requests = [ | ||
"list_call", | ||
"order_call", | ||
"order_call", | ||
"order_call" | ||
] | ||
} | ||
``` | ||
|
||
More - [scenario in HTTP generator](./scenario-http-generator.md#scenarios) | ||
|
||
|
||
### Sources | ||
|
||
Follow - [Variable sources](scenario/variable_source.md) | ||
|
||
--- | ||
|
||
[Home](../index.md) |
Oops, something went wrong.