Skip to content

Commit

Permalink
Merge pull request #117 from ddosify/develop
Browse files Browse the repository at this point in the history
Develop - camel case to snake case
  • Loading branch information
fatihbaltaci authored Jan 26, 2023
2 parents 9f47cee + eef7759 commit 5fca361
Show file tree
Hide file tree
Showing 24 changed files with 253 additions and 183 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile_benchmark
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pipeline {
stage('Performance Test') {
steps {
lock('multi_branch_server_benchmark') {
sh 'GOCACHE=/tmp/ go test -benchmem -benchtime=1x -cpuprofile=cpu.out -memprofile=mem.out -trace=trace.out -run=^$ -bench ^BenchmarkEngines$ -count 1 | tee gobench_branch.txt'
sh 'GOCACHE=/tmp/ go test -benchmem -benchtime=1x -cpuprof=cpu.out -memprof=mem.out -tracef=trace.out -run=^$ -bench ^BenchmarkEngines/$ -count 1 | tee gobench_branch.txt'
}
}
}
Expand All @@ -29,7 +29,7 @@ pipeline {
}
steps {
lock('multi_branch_server_benchmark') {
sh 'git fetch origin develop:develop || git checkout develop && git pull && GOCACHE=/tmp/ go test -benchmem -benchtime=1x -cpuprofile=cpu_develop.out -memprofile=mem_develop.out -trace=trace_develop.out -run=^$ -bench ^BenchmarkEngines$ -count 1 | tee gobench_develop.txt'
sh 'git fetch origin develop:develop || git checkout develop && git pull && GOCACHE=/tmp/ go test -benchmem -benchtime=1x -cpuprof=cpu_develop.out -memprof=mem_develop.out -tracef=trace_develop.out -run=^$ -bench ^BenchmarkEngines/$ -count 1 | tee gobench_develop.txt'
sh "git checkout ${BRANCH_NAME}"
sh "benchstat -alpha 1.01 --sort delta gobench_develop.txt gobench_branch.txt | tee gobench_branch_result.txt"
sh "benchstat -alpha 1.01 --sort delta --html gobench_develop.txt gobench_branch.txt > 00_gobench_result.html && echo ${BUILD_URL}artifact/00_gobench_result.html"
Expand Down
54 changes: 28 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

📌 **Correlation** - Extract variables from earlier phases and pass them on to the following ones.

📌 **Test Data** - Import test data from CSV and use it in the scenario.


## Installation

Expand Down Expand Up @@ -287,10 +289,10 @@ There is an example config file at [config_examples/config.json](/config_example
"3":{"tag":"payload", "type":"json"},
"4":{"tag":"age", "type":"int"}
},
"allowQuota" : true,
"allow_quota" : true,
"order": "sequential",
"skipFirstLine" : true,
"skipEmptyLine" : true
"skip_first_line" : true,
"skip_empty_line" : true
}
}
```
Expand All @@ -299,10 +301,10 @@ There is an example config file at [config_examples/config.json](/config_example
| `path` | Local path or remote url for your csv file | `string` | - | Yes |
| `delimiter` | Delimiter for reading csv | `string` | `,` | No |
| `vars` | Tag columns using column index as key, use `type` field if you want to cast a column to a specific type, default is `string`, can be one of the following: `json`, `int`, `float`,`bool`. | `map` | - | Yes |
| `allowQuota` | If set to true, a quote may appear in an unquoted field and a non-doubled quote may appear in a quoted field | `bool` | `false` | No |
| `allow_quota` | If set to true, a quote may appear in an unquoted field and a non-doubled quote may appear in a quoted field | `bool` | `false` | No |
| `order` | Order of reading records from csv. Can be `random` or `sequential` | `string` | `random` | No |
| `skipFirstLine` | Skips first line while reading records from csv. | `bool` | `false` | No |
| `skipEmptyLine` | Skips empty lines while reading records from csv. | `bool` | `true` | No |
| `skip_first_line` | Skips first line while reading records from csv. | `bool` | `false` | No |
| `skip_empty_line` | Skips empty lines while reading records from csv. | `bool` | `true` | No |

- `steps` *mandatory*

Expand Down Expand Up @@ -403,7 +405,7 @@ There is an example config file at [config_examples/config.json](/config_example

This is the equivalent of the `-T` flag.

- `captureEnv` *optional*
- `capture_env` *optional*

Config for extraction of variables to use them in next steps.
**Example:** Capture *NUM* variable from steps response body;
Expand All @@ -412,7 +414,7 @@ There is an example config file at [config_examples/config.json](/config_example
{
"id": 1,
"url": "http://target.com/endpoint1",
"captureEnv": {
"capture_env": {
"NUM" :{"from":"body","jsonPath":"num"},
}
},
Expand Down Expand Up @@ -541,10 +543,10 @@ ddosify -config ddosify_config_dynamic.json
}
```
## Correlation
Ddosify enables you to capture variables from steps using **jsonPath**, **xPath**, or **regular expressions**. Later, in the subsequent steps, you can inject both the captured variables and the scenario-scoped global variables.
Ddosify enables you to capture variables from steps using **jsonPath**, **xpath**, or **regular expressions**. Later, in the subsequent steps, you can inject both the captured variables and the scenario-scoped global variables.

> **:warning: Points to keep in mind**
> - You must specify **'headerKey'** when capturing from header.
> - You must specify **'header_key'** when capturing from header.
> - For jsonPath syntax, please take a look at [gjson syntax](https://github.com/tidwall/gjson/blob/master/SYNTAX.md) doc.
> - Regular expression are expected in **'Golang'** style regex. For converting your existing regular expressions, you can use [regex101](https://regex101.com/).
Expand All @@ -559,7 +561,7 @@ ddosify -config ddosify_config_correlation.json -debug
{
"steps": [
{
"captureEnv": {
"capture_env": {
"NUM" :{"from":"body","jsonPath":"num"},
"NAME" :{"from":"body","jsonPath":"name"},
"SQUAD" :{"from":"body","jsonPath":"squad"},
Expand All @@ -576,8 +578,8 @@ ddosify -config ddosify_config_correlation.json -debug
{
"steps": [
{
"captureEnv": {
"TITLE" :{"from":"body","xPath":"//item/title"},
"capture_env": {
"TITLE" :{"from":"body","xpath":"//item/title"},
}
}
]
Expand All @@ -589,9 +591,9 @@ ddosify -config ddosify_config_correlation.json -debug
{
"steps": [
{
"captureEnv": {
"CONTENT_TYPE" :{"from":"header", "headerKey":"Content-Type" ,"regExp":{"exp":"application\/(\\w)+","matchNo":0}} ,
"REGEX_MATCH_ENV" :{"from":"body","regExp":{"exp" : "[a-z]+_[0-9]+", "matchNo": 1}}
"capture_env": {
"CONTENT_TYPE" :{"from":"header", "header_key":"Content-Type" ,"regexp":{"exp":"application\/(\\w)+","matchNo":0}} ,
"REGEX_MATCH_ENV" :{"from":"body","regexp":{"exp" : "[a-z]+_[0-9]+", "matchNo": 1}}
}
}
]
Expand All @@ -602,8 +604,8 @@ ddosify -config ddosify_config_correlation.json -debug
{
"steps": [
{
"captureEnv": {
"TOKEN" :{"from":"header", "headerKey":"Authorization"},
"capture_env": {
"TOKEN" :{"from":"header", "header_key":"Authorization"},
}
}
]
Expand Down Expand Up @@ -643,14 +645,14 @@ On array-like captured variables or environment vars, the **rand( )** function c
"Rand-Selected-Num" : "{{rand(NUMBERS)}}"
},
"payload" : "{{COMPANY_NAME}}",
"captureEnv": {
"capture_env": {
"NUM" :{"from":"body","jsonPath":"num"},
"NAME" :{"from":"body","jsonPath":"name"},
"SQUAD" :{"from":"body","jsonPath":"squad"},
"PLAYERS" :{"from":"body","jsonPath":"squad.players"},
"MESSI" : {"from":"body","jsonPath":"squad.players.0"},
"TOKEN" :{"from":"header", "headerKey":"Authorization"},
"CONTENT_TYPE" :{"from":"header", "headerKey":"Content-Type" ,"regExp":{"exp":"application\/(\\w)+","matchNo":0}}
"TOKEN" :{"from":"header", "header_key":"Authorization"},
"CONTENT_TYPE" :{"from":"header", "header_key":"Content-Type" ,"regexp":{"exp":"application\/(\\w)+","matchNo":0}}
}
},
{
Expand All @@ -663,9 +665,9 @@ On array-like captured variables or environment vars, the **rand( )** function c
"Content-Type" : "{{CONTENT_TYPE}}"
},
"payload_file" : "payload.json",
"captureEnv": {
"TITLE" :{"from":"body","xPath":"//item/title"},
"REGEX_MATCH_ENV" :{"from":"body","regExp":{"exp" : "[a-z]+_[0-9]+", "matchNo": 1}}
"capture_env": {
"TITLE" :{"from":"body","xpath":"//item/title"},
"REGEX_MATCH_ENV" :{"from":"body","regexp":{"exp" : "[a-z]+_[0-9]+", "matchNo": 1}}
}
}
],
Expand Down Expand Up @@ -715,9 +717,9 @@ We are using this [csv data](https://github.com/ddosify/ddosify/tree/master/conf
"3":{"tag":"payload", "type":"json"},
"4":{"tag":"age", "type":"int"}
},
"allowQuota" : true,
"allow_quota" : true,
"order": "random",
"skipFirstLine" : true
"skip_first_line" : true
}
}
```
Expand Down
16 changes: 8 additions & 8 deletions config/config_testdata/benchmark/config_correlation_load_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
},
"payload": "",
"timeout": 3,
"captureEnv": {
"NUM" :{ "from":"body","jsonPath":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","jsonPath":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","jsonPath":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","jsonPath":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","jsonPath":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "headerKey":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "headerKey":"Content-Type" ,"regExp":{"exp":"application\/(\\w)+","matchNo":0} }
"capture_env": {
"NUM" :{ "from":"body","json_path":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","json_path":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","json_path":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","json_path":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","json_path":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "header_key":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "header_key":"Content-Type" ,"regexp":{"exp":"application\/(\\w)+","matchNo":0} }
}
},
{
Expand Down
16 changes: 8 additions & 8 deletions config/config_testdata/benchmark/config_correlation_load_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
},
"payload": "",
"timeout": 3,
"captureEnv": {
"NUM" :{ "from":"body","jsonPath":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","jsonPath":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","jsonPath":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","jsonPath":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","jsonPath":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "headerKey":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "headerKey":"Content-Type" ,"regExp":{"exp":"application\/(\\w)+","matchNo":0} }
"capture_env": {
"NUM" :{ "from":"body","json_path":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","json_path":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","json_path":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","json_path":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","json_path":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "header_key":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "header_key":"Content-Type" ,"regexp":{"exp":"application\/(\\w)+","matchNo":0} }
}
},
{
Expand Down
16 changes: 8 additions & 8 deletions config/config_testdata/benchmark/config_correlation_load_3.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
},
"payload": "",
"timeout": 3,
"captureEnv": {
"NUM" :{ "from":"body","jsonPath":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","jsonPath":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","jsonPath":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","jsonPath":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","jsonPath":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "headerKey":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "headerKey":"Content-Type" ,"regExp":{"exp":"application\/(\\w)+","matchNo":0} }
"capture_env": {
"NUM" :{ "from":"body","json_path":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","json_path":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","json_path":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","json_path":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","json_path":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "header_key":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "header_key":"Content-Type" ,"regexp":{"exp":"application\/(\\w)+","matchNo":0} }
}
},
{
Expand Down
16 changes: 8 additions & 8 deletions config/config_testdata/benchmark/config_correlation_load_4.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
},
"payload": "",
"timeout": 3,
"captureEnv": {
"NUM" :{ "from":"body","jsonPath":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","jsonPath":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","jsonPath":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","jsonPath":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","jsonPath":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "headerKey":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "headerKey":"Content-Type" ,"regExp":{"exp":"application\/(\\w)+","matchNo":0} }
"capture_env": {
"NUM" :{ "from":"body","json_path":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","json_path":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","json_path":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","json_path":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","json_path":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "header_key":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "header_key":"Content-Type" ,"regexp":{"exp":"application\/(\\w)+","matchNo":0} }
}
},
{
Expand Down
16 changes: 8 additions & 8 deletions config/config_testdata/benchmark/config_correlation_load_5.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
},
"payload": "",
"timeout": 3,
"captureEnv": {
"NUM" :{ "from":"body","jsonPath":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","jsonPath":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","jsonPath":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","jsonPath":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","jsonPath":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "headerKey":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "headerKey":"Content-Type" ,"regExp":{"exp":"application\/(\\w)+","matchNo":0} }
"capture_env": {
"NUM" :{ "from":"body","json_path":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","json_path":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","json_path":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","json_path":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","json_path":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "header_key":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "header_key":"Content-Type" ,"regexp":{"exp":"application\/(\\w)+","matchNo":0} }
}
},
{
Expand Down
16 changes: 8 additions & 8 deletions config/config_testdata/benchmark/config_json.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
},
"payload": "",
"timeout": 10,
"captureEnv": {
"NUM" :{ "from":"body","jsonPath":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","jsonPath":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","jsonPath":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","jsonPath":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","jsonPath":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "headerKey":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "headerKey":"Content-Type" ,"regExp":{"exp":"application\/(\\w)+","matchNo":0} }
"capture_env": {
"NUM" :{ "from":"body","json_path":"quoteResponse.result.0.askSize"},
"STR" :{ "from":"body","json_path":"quoteResponse.result.0.currency"},
"BOOL": {"from":"body","json_path":"quoteResponse.result.0.cryptoTradeable"},
"FLOAT" : {"from":"body","json_path":"quoteResponse.result.0.epsForward"},
"ALL_RESULT" :{"from":"body","json_path":"quoteResponse.result.0"},
"CONTENT_LENGTH" :{"from":"header", "header_key":"Content-Length"},
"CONTENT_TYPE" :{"from":"header", "header_key":"Content-Type" ,"regexp":{"exp":"application\/(\\w)+","matchNo":0} }
}
}
],
Expand Down
8 changes: 4 additions & 4 deletions config/config_testdata/config_capture_environment.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"name": "Example Name 1",
"url": "http://localhost:8080/hello",
"method": "GET",
"captureEnv": {
"NUM" :{ "from":"body","jsonPath":"num"}
"capture_env": {
"NUM" :{ "from":"body","json_path":"num"}
}
},
{
Expand All @@ -21,8 +21,8 @@
"Content-Type": "application/json",
"num": "{{NUM}}"
},
"captureEnv": {
"REGEX_MATCH_ENV" :{"from":"body","regExp":{"exp" : "[a-z]+_[0-9]+", "matchNo": 1}}
"capture_env": {
"REGEX_MATCH_ENV" :{"from":"body","regexp":{"exp" : "[a-z]+_[0-9]+", "matchNo": 1}}
}
}
],
Expand Down
4 changes: 2 additions & 2 deletions config/config_testdata/config_data_csv.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
"3":{"tag":"payload", "type":"json"},
"4":{"tag":"age", "type":"int"}
},
"allowQuota" : true,
"allow_quota" : true,
"order": "random",
"skipFirstLine" : true
"skip_first_line" : true
}
},
"debug" : false
Expand Down
Loading

0 comments on commit 5fca361

Please sign in to comment.