This commit is contained in:
alex
2023-09-06 12:23:40 +02:00
parent 8c87f4049a
commit 6dadb2da03
4 changed files with 96 additions and 49 deletions

79
run.py
View File

@@ -1,27 +1,68 @@
"Test connectivity on a small subset of files."
"Run the bench cases."
# copyright: Canonical
import datetime
import json
import subprocess
from pathlib import Path
from loguru import logger as log
SERV_URL = "172.172.0.196::share_rsync"
TARGET = "/mnt/inststo/test"
from definitions import BENCH_DIR_NAMES, CEPH_ROOT, INST_STO_ROOT, REMOTE_INST_STO_ROOT, SERV_URL
RESULTS = [["Run num", "test_case", "files", "MB/s", "time", "full size"]]
def run_single_bench(
runnum,
test_case,
files_type,
source,
target,
):
log.info(f"Syncing {runnum} {test_case} {files_type}")
start = datetime.datetime.now()
subprocess.run(
[
"rsync",
"-a",
f"{source}",
f"{target}",
],
capture_output=True,
# shell=True,
)
time = datetime.datetime.now() - start
size = sum(f.stat().st_size for f in Path(target).glob("**/*") if f.is_file())
size_MB = size / 1000 / 1000 / 8
speed = size_MB / time.total_seconds()
log.info(f"{files_type} - {speed} MB/s")
subprocess.run(["rm", "-rf", target])
RESULTS.append([runnum, test_case, files_type, speed, time.total_seconds(), size_MB])
if __name__ == "__main__":
for x in range(10):
start = datetime.datetime.now()
subprocess.run(
[
"rsync",
"-a",
f"{SERV_URL}/inststo/test",
f"/mnt/inststo",
],
capture_output=True,
# shell=True,
)
time = datetime.datetime.now() - start
size = sum(f.stat().st_size for f in Path(TARGET).glob("**/*") if f.is_file())
log.info(f"{size/time.total_seconds()/1000/1000/8} MB/s")
subprocess.run(["rm", "-rf", TARGET])
for runnum in range(50):
for files_type in BENCH_DIR_NAMES:
test_case = "Distant-InsSto to InsSto"
source = f"{SERV_URL}/{REMOTE_INST_STO_ROOT}/{files_type}"
target = INST_STO_ROOT + files_type
run_single_bench(
runnum,
test_case,
files_type,
source,
target,
)
test_case = "Distant-InsSto to CEPH"
source = f"{SERV_URL}/{REMOTE_INST_STO_ROOT}/{files_type}"
target = CEPH_ROOT + files_type
run_single_bench(
runnum,
test_case,
files_type,
source,
target,
)
json.dump(RESULTS, open("results.json", "w"))