Skip to content

Commit

Permalink
Merge pull request #145 from ddosify/develop
Browse files Browse the repository at this point in the history
Add Engine modes
  • Loading branch information
fatihbaltaci authored Feb 27, 2023
2 parents ab8fa74 + 0a15bf1 commit 71f891c
Show file tree
Hide file tree
Showing 28 changed files with 662 additions and 109 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 -cpuprof=cpu.out -memprof=mem.out -tracef=trace.out -run=^$ -bench ^BenchmarkEngines/$ -count 1 | tee gobench_branch.txt'
sh 'set -o pipefail && 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 -cpuprof=cpu_develop.out -memprof=mem_develop.out -tracef=trace_develop.out -run=^$ -bench ^BenchmarkEngines/$ -count 1 | tee gobench_develop.txt'
sh 'git fetch origin develop:develop || git checkout develop && git pull && set -o pipefail && 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
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ The features you can use by config file;
- Custom load type creation
- Payload from a file
- Multipart/form-data payload
- Extra connection configuration, like *keep-alive* enable/disable logic
- Extra connection configuration
- HTTP2 support


Expand Down Expand Up @@ -274,6 +274,12 @@ There is an example config file at [config_examples/config.json](/config_example
- `output` *optional*

This is the equivalent of the `-o` flag.
- `engine_mode` *optional*
Can be one of `distinct-user`, `repeated-user`, or default mode `ddosify`.
- `distinct-user` mode simulates a new user for every iteration.
- `repeated-user` mode can use pre-used user in subsequent iterations.
- `ddosify` mode is default mode of the engine. In this mode engine runs in its max capacity, and does not show user simulation behaviour.

- `env` *optional*
Scenario-scoped global variables. Note that dynamic variables changes every iteration.
```json
Expand All @@ -282,6 +288,7 @@ There is an example config file at [config_examples/config.json](/config_example
"randomCountry" : "{{_randomCountry}}"
}
```

- `data` *optional*
Config for loading test data from a CSV file.
[CSV data](https://github.com/ddosify/ddosify/tree/master/config/config_testdata/test.csv) used in below config.
Expand Down Expand Up @@ -494,7 +501,6 @@ There is an example config file at [config_examples/config.json](/config_example

```json
"others": {
"keep-alive": true, // Default true
"disable-compression": false, // Default true
"h2": true, // Enables HTTP/2. Default false.
"disable-redirect": true // Default false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"iteration_count": 100,
"engine_mode": "ddosify",
"load_type": "waved",
"duration": 10,
"steps": [
Expand All @@ -10,7 +11,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand All @@ -36,7 +36,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand All @@ -55,7 +54,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"iteration_count": 1000,
"load_type": "waved",
"engine_mode": "ddosify",
"duration": 10,
"steps": [
{
Expand All @@ -10,7 +11,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand All @@ -36,7 +36,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand All @@ -55,7 +54,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"iteration_count": 5000,
"load_type": "waved",
"engine_mode": "ddosify",
"duration": 10,
"steps": [
{
Expand All @@ -10,7 +11,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand All @@ -36,7 +36,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand All @@ -55,7 +54,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"iteration_count": 10000,
"load_type": "waved",
"engine_mode": "ddosify",

"duration": 10,
"steps": [
{
Expand All @@ -10,7 +12,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand All @@ -36,7 +37,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand All @@ -55,7 +55,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"iteration_count": 20000,
"load_type": "waved",
"engine_mode": "ddosify",

"duration": 10,
"steps": [
{
Expand All @@ -10,7 +12,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand All @@ -36,7 +37,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand All @@ -55,7 +55,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand Down
1 change: 0 additions & 1 deletion config/config_testdata/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"timeout": 3,
"sleep": "1000",
"others": {
"keep-alive": true
}
},
{
Expand Down
1 change: 0 additions & 1 deletion config/config_testdata/config_data_csv.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"method": "GET",
"others": {
"h2": false,
"keep-alive": true,
"disable-redirect": true,
"disable-compression": false
},
Expand Down
1 change: 0 additions & 1 deletion config/config_testdata/config_debug_false.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"timeout": 3,
"sleep": "1000",
"others": {
"keep-alive": true
}
},
{
Expand Down
1 change: 0 additions & 1 deletion config/config_testdata/config_debug_mode.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"timeout": 3,
"sleep": "1000",
"others": {
"keep-alive": true
}
},
{
Expand Down
1 change: 0 additions & 1 deletion config/config_testdata/config_env_vars.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"timeout": 3,
"sleep": "1000",
"others": {
"keep-alive": true
},
"capture_env": {
"ENV_VAR1" :{"json_path":""},
Expand Down
2 changes: 0 additions & 2 deletions config/config_testdata/config_incorrect.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"payload": "body yt kanl adnlandlandaln",
"timeout": 1,
"others": {
"keep-alive": true
}
},
{
Expand All @@ -33,7 +32,6 @@
"payload_file": "config_examples/payload.txt",
"timeout": 1,
"others": {
"keep-alive": false
}
},
],
Expand Down
1 change: 0 additions & 1 deletion config/config_testdata/config_iteration_count.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"timeout": 3,
"sleep": "1000",
"others": {
"keep-alive": true
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"timeout": 3,
"sleep": "1000",
"others": {
"keep-alive": true
}
},
{
Expand Down
9 changes: 6 additions & 3 deletions config/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,14 +156,16 @@ type JsonReader struct {
Data map[string]CsvConf `json:"data"`
Debug bool `json:"debug"`
SamplingRate *int `json:"sampling_rate"`
EngineMode string `json:"engine_mode"`
}

func (j *JsonReader) UnmarshalJSON(data []byte) error {
type jsonReaderAlias JsonReader
defaultFields := &jsonReaderAlias{
LoadType: types.DefaultLoadType,
Duration: types.DefaultDuration,
Output: types.DefaultOutputType,
LoadType: types.DefaultLoadType,
Duration: types.DefaultDuration,
Output: types.DefaultOutputType,
EngineMode: types.EngineModeDdosify,
}

err := json.Unmarshal(data, defaultFields)
Expand Down Expand Up @@ -274,6 +276,7 @@ func (j *JsonReader) CreateHammer() (h types.Hammer, err error) {
ReportDestination: j.Output,
Debug: j.Debug,
SamplingRate: samplingRate,
EngineMode: j.EngineMode,
TestDataConf: testDataConf,
}
return
Expand Down
Loading

0 comments on commit 71f891c

Please sign in to comment.