-
Notifications
You must be signed in to change notification settings - Fork 0
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 #3 from copyleftdev/examples
adding sample script for bash load tests
- Loading branch information
Showing
5 changed files
with
173 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Load Testing Scripts | ||
|
||
This folder contains bash scripts for performing different types of load tests on a specified TCP server using the `kali` tool. Each script generates a JSON report with the results. | ||
|
||
## Prerequisites | ||
|
||
Ensure that `kali` has been built and is either in the same current working directory (CWD) or in your `$PATH`. | ||
|
||
## Test Types | ||
|
||
### Stress Test | ||
|
||
This script performs a stress test by generating a high number of requests per second (RPS) for a given duration to evaluate the server's performance under heavy load. | ||
|
||
#### Usage | ||
|
||
```sh | ||
./stress_test.sh --host 192.168.0.109 --port 8080 --duration 60 --rps 1000 --payload "Hello World" --jitter 50 | ||
``` | ||
|
||
### Spike Test | ||
|
||
This script performs a spike test by generating a sudden burst of requests to simulate a spike in traffic and measure the server's response. | ||
|
||
#### Usage | ||
|
||
```sh | ||
./spike_test.sh --host 192.168.0.109 --port 8080 --duration 10 --rps 5000 --payload "Hello World" --jitter 50 | ||
``` | ||
|
||
### Soak Test | ||
|
||
This script performs a soak test by generating a moderate number of requests per second (RPS) over an extended period to measure the server's long-term stability and performance. | ||
|
||
#### Usage | ||
|
||
```sh | ||
./soak_test.sh --host 192.168.0.109 --port 8080 --duration 3600 --rps 100 --payload "Hello World" --jitter 50 | ||
``` | ||
|
||
### Volume Test | ||
|
||
This script performs a volume test by generating a high number of requests per second (RPS) for a given duration to evaluate the server's ability to handle a large volume of traffic. | ||
|
||
#### Usage | ||
|
||
```sh | ||
./volume_test.sh --host 192.168.0.109 --port 8080 --duration 300 --rps 1000 --payload "Hello World" --jitter 50 | ||
``` | ||
|
||
## Parameters | ||
|
||
- `--host`: The IP address or hostname of the TCP server. | ||
- `--hosts-and-biases`: A comma-separated list of hosts and biases in the format `HOST1:BIAS1,HOST2:BIAS2`. (Optional) | ||
- `--port`: The port number of the TCP server. | ||
- `--duration`: The duration of the test in seconds. | ||
- `--rps`: The number of requests per second to be generated. | ||
- `--payload`: The payload to be sent with each request. | ||
- `--jitter`: The maximum jitter (in milliseconds) to be added to the sleep duration between requests. Default is 50ms. | ||
|
||
## Output | ||
|
||
The results of each test are saved in a JSON file with a timestamp, e.g., `test_type_output_20230710153045.json`. | ||
|
||
## Example Commands | ||
|
||
### Stress Test | ||
|
||
```sh | ||
./stress_test.sh --host 192.168.0.109 --port 8080 --duration 60 --rps 1000 --payload "Hello World" --jitter 50 | ||
``` | ||
|
||
### Spike Test | ||
|
||
```sh | ||
./spike_test.sh --host 192.168.0.109 --port 8080 --duration 10 --rps 5000 --payload "Hello World" --jitter 50 | ||
``` | ||
|
||
### Soak Test | ||
|
||
```sh | ||
./soak_test.sh --host 192.168.0.109 --port 8080 --duration 3600 --rps 100 --payload "Hello World" --jitter 50 | ||
``` | ||
|
||
### Volume Test | ||
|
||
```sh | ||
./volume_test.sh --host 192.168.0.109 --port 8080 --duration 300 --rps 1000 --payload "Hello World" --jitter 50 | ||
``` |
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,21 @@ | ||
#!/bin/sh | ||
|
||
# Usage: ./soak_test.sh --host 192.168.0.109 --port 8080 --duration 3600 --rps 100 --payload "Hello World" --jitter 50 | ||
|
||
timestamp=$(date +%Y%m%d%H%M%S) | ||
output_file="soak_output_${timestamp}.json" | ||
|
||
while [ "$#" -gt 0 ]; do | ||
case "$1" in | ||
--host) HOST="$2"; shift 2;; | ||
--hosts-and-biases) HOSTS_AND_BIASES="$2"; shift 2;; | ||
--port) PORT="$2"; shift 2;; | ||
--duration) DURATION="$2"; shift 2;; | ||
--rps) RPS="$2"; shift 2;; | ||
--payload) PAYLOAD="$2"; shift 2;; | ||
--jitter) JITTER="$2"; shift 2;; | ||
*) echo "Unknown parameter passed: $1"; exit 1;; | ||
esac | ||
done | ||
|
||
kali --host "$HOST" --hosts-and-biases "$HOSTS_AND_BIASES" --port "$PORT" --duration "$DURATION" --rps "$RPS" --load-test-type tcp --output-file "$output_file" --payload "$PAYLOAD" --jitter "$JITTER" |
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,21 @@ | ||
#!/bin/sh | ||
|
||
# Usage: ./spike_test.sh --host 192.168.0.109 --port 8080 --duration 10 --rps 5000 --payload "Hello World" --jitter 50 | ||
|
||
timestamp=$(date +%Y%m%d%H%M%S) | ||
output_file="spike_output_${timestamp}.json" | ||
|
||
while [ "$#" -gt 0 ]; do | ||
case "$1" in | ||
--host) HOST="$2"; shift 2;; | ||
--hosts-and-biases) HOSTS_AND_BIASES="$2"; shift 2;; | ||
--port) PORT="$2"; shift 2;; | ||
--duration) DURATION="$2"; shift 2;; | ||
--rps) RPS="$2"; shift 2;; | ||
--payload) PAYLOAD="$2"; shift 2;; | ||
--jitter) JITTER="$2"; shift 2;; | ||
*) echo "Unknown parameter passed: $1"; exit 1;; | ||
esac | ||
done | ||
|
||
kali --host "$HOST" --hosts-and-biases "$HOSTS_AND_BIASES" --port "$PORT" --duration "$DURATION" --rps "$RPS" --load-test-type tcp --output-file "$output_file" --payload "$PAYLOAD" --jitter "$JITTER" |
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,21 @@ | ||
#!/bin/sh | ||
|
||
# Usage: ./stress_test.sh --host 192.168.0.109 --port 8080 --duration 60 --rps 1000 --payload "Hello World" --jitter 50 | ||
|
||
timestamp=$(date +%Y%m%d%H%M%S) | ||
output_file="stress_output_${timestamp}.json" | ||
|
||
while [ "$#" -gt 0 ]; do | ||
case "$1" in | ||
--host) HOST="$2"; shift 2;; | ||
--hosts-and-biases) HOSTS_AND_BIASES="$2"; shift 2;; | ||
--port) PORT="$2"; shift 2;; | ||
--duration) DURATION="$2"; shift 2;; | ||
--rps) RPS="$2"; shift 2;; | ||
--payload) PAYLOAD="$2"; shift 2;; | ||
--jitter) JITTER="$2"; shift 2;; | ||
*) echo "Unknown parameter passed: $1"; exit 1;; | ||
esac | ||
done | ||
|
||
kali --host "$HOST" --hosts-and-biases "$HOSTS_AND_BIASES" --port "$PORT" --duration "$DURATION" --rps "$RPS" --load-test-type tcp --output-file "$output_file" --payload "$PAYLOAD" --jitter "$JITTER" |
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,21 @@ | ||
#!/bin/sh | ||
|
||
# Usage: ./volume_test.sh --host 192.168.0.109 --port 8080 --duration 300 --rps 1000 --payload "Hello World" --jitter 50 | ||
|
||
timestamp=$(date +%Y%m%d%H%M%S) | ||
output_file="volume_output_${timestamp}.json" | ||
|
||
while [ "$#" -gt 0 ]; do | ||
case "$1" in | ||
--host) HOST="$2"; shift 2;; | ||
--hosts-and-biases) HOSTS_AND_BIASES="$2"; shift 2;; | ||
--port) PORT="$2"; shift 2;; | ||
--duration) DURATION="$2"; shift 2;; | ||
--rps) RPS="$2"; shift 2;; | ||
--payload) PAYLOAD="$2"; shift 2;; | ||
--jitter) JITTER="$2"; shift 2;; | ||
*) echo "Unknown parameter passed: $1"; exit 1;; | ||
esac | ||
done | ||
|
||
kali --host "$HOST" --hosts-and-biases "$HOSTS_AND_BIASES" --port "$PORT" --duration "$DURATION" --rps "$RPS" --load-test-type tcp --output-file "$output_file" --payload "$PAYLOAD" --jitter "$JITTER" |