Skip to content

Commit

Permalink
feat: test many files (#63)
Browse files Browse the repository at this point in the history
* feat: test many files

* fix

* fix

* improve reporting

* cleanup
  • Loading branch information
Arqu authored Aug 26, 2024
1 parent 3056617 commit b018e27
Show file tree
Hide file tree
Showing 6 changed files with 284 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/netsim_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
cd netsim
sudo kill -9 $(pgrep ovs)
sudo mn --clean
sudo python3 main.py --integration sims/standard/iroh.json
sudo python3 main.py --integration sims/iroh/iroh_many_files.json
- name: Setup Environment (PR)
if: ${{ github.event_name == 'pull_request' }}
Expand Down
9 changes: 9 additions & 0 deletions fixtures/bulk_files_test_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

./generate_files.sh 1000 10000 bulk_1k_x_10k
./generate_files.sh 5000 10000 bulk_5k_x_10k
./generate_files.sh 1000 1000000 bulk_1k_x_1m
./generate_files.sh 1000 10000 bulk_mix #1kx10k
./generate_files.sh 1000 1000000 bulk_mix #1kx1m
./generate_files.sh 100 10000000 bulk_mix #100x10m
./generate_files.sh 2 1000000000 bulk_mix #2x1g
27 changes: 27 additions & 0 deletions fixtures/generate_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

# Check if the correct number of arguments are provided
if [ "$#" -ne 3 ]; then
echo "Usage: $0 <number_of_files> <file_size_in_bytes> <output_folder>"
exit 1
fi

# Assign arguments to variables
NUMBER_OF_FILES=$1
FILE_SIZE=$2
OUTPUT_FOLDER=$3

# Create the output folder if it doesn't exist
mkdir -p "$OUTPUT_FOLDER"

# Generate a random 4-character string
RANDOM_STRING=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 4)

# Generate the files
for (( i=1; i<=$NUMBER_OF_FILES; i++ ))
do
# Generate a file with the specified size
dd if=/dev/urandom of="$OUTPUT_FOLDER/file_${RANDOM_STRING}_$i.bin" bs=$FILE_SIZE count=1
done

echo "Generated $NUMBER_OF_FILES files of size $FILE_SIZE bytes in $OUTPUT_FOLDER with prefix file_$RANDOM_STRING"
11 changes: 7 additions & 4 deletions netsim/netsim_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def parse_time_output(lines, size):

def parse_humanized_output(line):
p = line.split(', ')[-1]
v_bytes = humanfriendly.parse_size(p)
v_bytes = humanfriendly.parse_size(p, binary=True)
v_mbits = float(v_bytes*8) / (1024*1024)
return v_mbits

Expand Down Expand Up @@ -124,7 +124,7 @@ def aggregate_stats(stats):

def stats_parser(nodes, prefix):
files = []
valid_parsers = ['iroh_client', 'iperf_server', 'iperf_udp_server', 'time_1gb', 'iroh_1gb']
valid_parsers = ['iroh_client', 'iperf_server', 'iperf_udp_server', 'time_1gb', 'iroh_1gb', 'iroh_cust_']
for root, dirs, fs in os.walk('logs'):
for f in fs:
if f.startswith(prefix + '__'):
Expand All @@ -133,7 +133,7 @@ def stats_parser(nodes, prefix):
if 'parser' in node:
stats = []
try:
if node['parser'] in valid_parsers:
if any(node['parser'].startswith(prefix) for prefix in valid_parsers):
for i in range(int(node['count'])):
log_path = 'logs/%s__%s_%d.txt' %(prefix, node['name'], i)
f = open(log_path, 'r')
Expand All @@ -150,13 +150,16 @@ def stats_parser(nodes, prefix):
if node['parser'] == 'time_1gb':
s = parse_time_output(lines, 1024*1024*1024)
stats.append(s)
if node['parser'] in ['iroh_1gb', 'iroh_1mb']:
if node['parser'] in ['iroh_1gb', 'iroh_1mb'] or node['parser'].startswith('iroh_cust_'):
is_ok = 0
reported = 0
reported_time = 0
f_size = 1024*1024*1024
if node['parser'] == 'iroh_1mb':
f_size = 1024*1024
if node['parser'].startswith('iroh_cust_'):
f_size_str = node['parser'].split('_')[-1]
f_size = humanfriendly.parse_size(f_size_str, binary=True)
for line in lines:
if 'Transferred' in line and 'in' in line and '/s' in line:
is_ok += 1
Expand Down
3 changes: 3 additions & 0 deletions netsim/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ cp ../../fixtures/direct_relay.cfg direct_relay.cfg
cp ../../fixtures/relay.direct.config.toml relay.direct.config.toml
cp ../../fixtures/1MB.bin 1MB.bin
cp ../../fixtures/hello.bin hello.bin
cp ../../fixtures/generate_files.sh generate_files.sh
cp ../../fixtures/bulk_files_test_setup.sh bulk_files_test_setup.sh
./bulk_files_test_setup.sh
237 changes: 237 additions & 0 deletions netsim/sims/iroh/iroh_many_files.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
{
"name": "iroh_many_files",
"cases": [
{
"name": "1_to_1_1k_10k",
"description": "",
"nodes": [
{
"name": "iroh_srv",
"count": 1,
"cmd": "./bins/iroh start --add data/bulk_1k_x_10k",
"type": "public",
"wait": 10,
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket"
},
{
"name": "iroh_get",
"count": 1,
"cmd": "time ./bins/iroh blobs get --start %s",
"type": "public",
"connect": {
"strategy": "params",
"node": "iroh_srv"
},
"process": "short",
"parser": "iroh_cust_10mb"
}
]
},
{
"name": "1_to_3_1k_10k",
"description": "",
"nodes": [
{
"name": "iroh_srv",
"count": 1,
"cmd": "./bins/iroh start --add data/bulk_1k_x_10k",
"type": "public",
"wait": 10,
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket"
},
{
"name": "iroh_get",
"count": 3,
"cmd": "time ./bins/iroh blobs get --start %s",
"type": "public",
"connect": {
"strategy": "params",
"node": "iroh_srv"
},
"process": "short",
"parser": "iroh_cust_10mb"
}
]
},
{
"name": "1_to_1_5k_10k",
"description": "",
"nodes": [
{
"name": "iroh_srv",
"count": 1,
"cmd": "./bins/iroh start --add data/bulk_5k_x_10k",
"type": "public",
"wait": 10,
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket"
},
{
"name": "iroh_get",
"count": 1,
"cmd": "time ./bins/iroh blobs get --start %s",
"type": "public",
"connect": {
"strategy": "params",
"node": "iroh_srv"
},
"process": "short",
"parser": "iroh_cust_50mb"
}
]
},
{
"name": "1_to_3_5k_10k",
"description": "",
"nodes": [
{
"name": "iroh_srv",
"count": 1,
"cmd": "./bins/iroh start --add data/bulk_5k_x_10k",
"type": "public",
"wait": 10,
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket"
},
{
"name": "iroh_get",
"count": 3,
"cmd": "time ./bins/iroh blobs get --start %s",
"type": "public",
"connect": {
"strategy": "params",
"node": "iroh_srv"
},
"process": "short",
"parser": "iroh_cust_50mb"
}
]
},
{
"name": "1_to_1_1k_1m",
"description": "",
"nodes": [
{
"name": "iroh_srv",
"count": 1,
"cmd": "./bins/iroh start --add data/bulk_1k_x_1m",
"type": "public",
"wait": 10,
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket"
},
{
"name": "iroh_get",
"count": 1,
"cmd": "time ./bins/iroh blobs get --start %s",
"type": "public",
"connect": {
"strategy": "params",
"node": "iroh_srv"
},
"process": "short",
"parser": "iroh_1gb"
}
]
},
{
"name": "1_to_3_1k_1m",
"description": "",
"nodes": [
{
"name": "iroh_srv",
"count": 1,
"cmd": "./bins/iroh start --add data/bulk_1k_x_1m",
"type": "public",
"wait": 10,
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket"
},
{
"name": "iroh_get",
"count": 3,
"cmd": "time ./bins/iroh blobs get --start %s",
"type": "public",
"connect": {
"strategy": "params",
"node": "iroh_srv"
},
"process": "short",
"parser": "iroh_1gb"
}
]
},
{
"name": "1_to_1_mix",
"description": "",
"nodes": [
{
"name": "iroh_srv",
"count": 1,
"cmd": "./bins/iroh start --add data/bulk_mix",
"type": "public",
"wait": 10,
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket"
},
{
"name": "iroh_get",
"count": 1,
"cmd": "time ./bins/iroh blobs get --start %s",
"type": "public",
"connect": {
"strategy": "params",
"node": "iroh_srv"
},
"process": "short",
"parser": "iroh_cust_4.01gb"
}
]
},
{
"name": "1_to_3_mix",
"description": "",
"nodes": [
{
"name": "iroh_srv",
"count": 1,
"cmd": "./bins/iroh start --add data/bulk_mix",
"type": "public",
"wait": 10,
"connect": {
"strategy": "none"
},
"param_parser": "iroh_ticket"
},
{
"name": "iroh_get",
"count": 3,
"cmd": "time ./bins/iroh blobs get --start %s",
"type": "public",
"connect": {
"strategy": "params",
"node": "iroh_srv"
},
"process": "short",
"parser": "iroh_cust_4.01gb"
}
]
}
]
}

0 comments on commit b018e27

Please sign in to comment.