forked from mozilla/neqo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add upload_test.sh script (mozilla#1529)
- Loading branch information
1 parent
895f15d
commit abe45df
Showing
2 changed files
with
157 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,33 @@ | ||
## Steps to run an upload test with neqo-client and neqo-server: | ||
|
||
1. Build the release version of neqo-client and neqo-server by running | ||
`cargo build --release` | ||
1. Start neqo-server. `./target/release/neqo-server --db ./test-fixture/db` | ||
1. Start neqo-client and specify parameters to start the upload test. | ||
` ./target/release/neqo-client http://127.0.0.1:4433/ --test upload --upload-size ${size_in_bytes}` | ||
|
||
## To enable log messages for analyzing upload performance | ||
|
||
This can be done by setting the `RUST_LOG` environment variable to `neqo_transport=info`. | ||
For example, the command below starts neqo-client and uploads 8MB of content to the server. | ||
``` | ||
RUST_LOG=neqo_transport=info ./target/release/neqo-client http://127.0.0.1:4433/ --test upload --upload-size 8388608 &>upload.log | ||
``` | ||
|
||
## To run the upload test with `upload_test.sh` script | ||
|
||
### Overview | ||
The `upload_test.sh` script automates testing network conditions for `neqo-client` and `neqo-server`. It runs the upload test under various network parameters like bandwidth, RTT (Round-Trip Time), and PLR (Packet Loss Rate). | ||
|
||
### Configuration | ||
- **Server Address and Port**: Defaults to `127.0.0.1` and `4433`. | ||
- **Upload Size**: Set to 8MB by default. | ||
- **Network Conditions**: Modify `network_conditions`, `network_bandwidths`, `network_rtts`, and `plrs` arrays for different conditions. | ||
- **Runs**: Number of test iterations, default is `1`. | ||
|
||
### Usage | ||
1. **Start the Script**: Execute with `./upload_test.sh`. | ||
2. **Root Password Prompt**: Enter the root password when prompted for executing network configuration commands. | ||
3. **Automated Test Execution**: The script sets up network conditions and runs `neqo-client` and `neqo-server` tests. | ||
4. **Cleanup**: At the end, it resets network conditions and stops the server. | ||
|
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,124 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
server_address=127.0.0.1 | ||
server_port=4433 | ||
upload_size=8388608 | ||
client="cargo run --release --bin neqo-client -- http://$server_address:$server_port/ --test upload --upload-size $upload_size" | ||
server="cargo run --release --bin neqo-server -- --db ../test-fixture/db $server_address:$server_port" | ||
server_pid=0 | ||
|
||
# Define two indexed arrays to store network conditions | ||
network_conditions=("cable" "3g_slow" "DSL" "LTE" "fast wifi") | ||
network_bandwidths=("5Mbit/s" "400Kbit/s" "2Mbit/s" "12Mbit/s" "100Mbit/s") | ||
network_rtts=("14" "200" "25" "35" "10") | ||
plrs=("0.0001" "0.0005" "0.001" "0.002" "0.005") | ||
|
||
runs=1 | ||
|
||
echo -n "Enter root password: " | ||
read -s root_password | ||
echo | ||
|
||
setup_network_conditions() { | ||
bw="$1" | ||
delay_ms="$2" | ||
plr="$3" | ||
delay_s=$(echo "scale=5; $delay_ms / 1000" | bc -l) | ||
if [[ $bw == *"Mbit/s"* ]]; then | ||
bw_value=$(echo "$bw" | sed 's/Mbit\/s//') # Remove 'Mbit/s' | ||
bw_bits_per_second=$(echo "$bw_value * 1000000" | bc) # Convert from Mbits to bits | ||
elif [[ $bw == *"Kbit/s"* ]]; then | ||
bw_value=$(echo "$bw" | sed 's/Kbit\/s//') # Remove 'Kbit/s' | ||
bw_bits_per_second=$(echo "$bw_value * 1000" | bc) # Convert from Kbits to bits | ||
fi | ||
|
||
bdp_bits=$(echo "$bw_bits_per_second * $delay_s" | bc) | ||
|
||
# Convert BDP to kilobytes | ||
bdp_kb=$(echo "scale=2; $bdp_bits / 8 / 1024" | bc) | ||
bdp_kb_rounded_up=$(printf "%.0f" "$bdp_kb") | ||
|
||
# if we are on MacOS X, configure the firewall to add delay and queue traffic | ||
if [ -x /usr/sbin/dnctl ]; then | ||
set_condition_commands=( | ||
"sudo dnctl pipe 1 config bw $bw delay $delay_ms plr $plr queue ${bdp_kb_rounded_up}Kbytes noerror" | ||
"sudo dnctl pipe 2 config bw $bw delay $delay_ms plr $plr queue ${bdp_kb_rounded_up}Kbytes noerror" | ||
"sudo echo 'dummynet in proto {udp} from any to localhost pipe 1' | sudo pfctl -f -" | ||
"sudo echo 'dummynet in proto {udp} from localhost to any pipe 2' | sudo pfctl -f -" | ||
"sudo pfctl -e || true" | ||
) | ||
else | ||
# TODO implement commands for linux | ||
return 0 | ||
fi | ||
|
||
for command in "${set_condition_commands[@]}"; do | ||
echo $command | ||
echo $root_password | sudo -S bash -c "$command" | ||
done | ||
} | ||
|
||
stop_network_conditions() { | ||
if [ -x /usr/sbin/dnctl ]; then | ||
stop_condition_commands=( | ||
"sudo pfctl -f /etc/pf.conf" | ||
"sudo dnctl -q flush" | ||
) | ||
else | ||
# TODO implement commands for linux | ||
return 0 | ||
fi | ||
|
||
for command in "${set_condition_commands[@]}"; do | ||
echo $root_password | sudo -S bash -c "$command" | ||
done | ||
} | ||
|
||
stop_server() { | ||
echo "stop server" | ||
server_pid=$(pgrep -f "neqo-server") | ||
# Kill the server | ||
kill $server_pid | ||
} | ||
|
||
start_test() { | ||
echo "start_test" | ||
eval "$server" > /dev/null 2>&1 & sleep 1 | ||
|
||
# Run the client command and capture its output | ||
echo "Running client..." | ||
client_output=$(eval "$client") | ||
echo "Client output: $client_output" | ||
} | ||
|
||
cleanup() { | ||
echo "clean up" | ||
stop_server | ||
stop_network_conditions | ||
} | ||
|
||
trap cleanup SIGINT | ||
|
||
for i in "${!network_conditions[@]}"; do | ||
condition=${network_conditions[$i]} | ||
bandwidth=${network_bandwidths[$i]} | ||
rtt=${network_rtts[$i]} | ||
|
||
for plr in "${plrs[@]}"; do | ||
echo "Setting up tests for condition: $condition, Bandwidth: $bandwidth, RTT: $rtt, Packet Loss Rate: $plr" | ||
|
||
for r in $(seq 1 $runs); do | ||
echo "Test Run: $r | Condition: $condition | Bandwidth: $bandwidth | RTT: $rtt | PLR: $plr | Start" | ||
setup_network_conditions "$bandwidth" "$rtt" "$plr" | ||
start_test | ||
cleanup | ||
echo "Test Run: $r | Condition: $condition | Bandwidth: $bandwidth | RTT: $rtt | PLR: $plr | End" | ||
done | ||
done | ||
|
||
echo "Completed tests for condition: $condition." | ||
done | ||
|
||
echo "All test runs completed." |