Skip to content

Commit 57144ee

Browse files
committed
added EKS perf test
1 parent a49cdd0 commit 57144ee

20 files changed

+11300
-0
lines changed

tests/perf/eksperf/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM python:3.11.9
2+
RUN pip install git+https://github.com/hdfgroup/h5pyd.git
3+
RUN pip install pyyaml
4+
RUN pip install h5py
5+
RUN pip install s3fs
6+
COPY entrypoint.sh /
7+
RUN chmod 555 /entrypoint.sh
8+
RUN mkdir /app
9+
COPY read_shots.py /app
10+
COPY config.py /app
11+
COPY config.yml /app
12+
WORKDIR /app
13+
ENTRYPOINT ["/entrypoint.sh"]

tests/perf/eksperf/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
This folder contains files used to create a EKS based performance test.
2+
3+
Based on fusion data from the cmod reactor which is not yet public.
4+
Will update once the data files have been published.

tests/perf/eksperf/build_image.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker build -t psfc/hsperftest .

tests/perf/eksperf/config.py

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import os
2+
import sys
3+
import yaml
4+
5+
cfg = {}
6+
7+
8+
def eprint(*args, **kwargs):
9+
print(*args, file=sys.stderr, **kwargs)
10+
11+
def debug(*args, **kwargs):
12+
# can't use log.debug since that calls back to cfg
13+
if "LOG_LEVEL" in os.environ and os.environ["LOG_LEVEL"] == "DEBUG":
14+
print(*args, **kwargs)
15+
16+
def _load_cfg():
17+
# load config yaml
18+
yml_file = None
19+
config_dirs = []
20+
# check if there is a command line optionfor config directory
21+
for i in range(1, len(sys.argv)):
22+
#print(i, sys.argv[i])
23+
if sys.argv[i].startswith("--config-dir"):
24+
# use the given directory
25+
arg = sys.argv[i]
26+
config_dirs.append(arg[len("--config-dir")+1:]) # return text after option string
27+
debug(f"got cmd line override for config-dir: {config_dirs[0]}")
28+
break
29+
if not config_dirs and "CONFIG_DIR" in os.environ:
30+
config_dirs.append(os.environ["CONFIG_DIR"])
31+
debug(f"got environment override for config-dir: {config_dirs[0]}")
32+
if not config_dirs:
33+
config_dirs = [".", "/config", "/etc/hsds/"] # default locations
34+
for config_dir in config_dirs:
35+
file_name = os.path.join(config_dir, "config.yml")
36+
debug("checking config path:", file_name)
37+
if os.path.isfile(file_name):
38+
yml_file = file_name
39+
break
40+
if not yml_file:
41+
msg = "unable to find config file"
42+
eprint(msg)
43+
raise FileNotFoundError(msg)
44+
debug(f"_load_cfg with '{yml_file}'")
45+
try:
46+
with open(yml_file, "r") as f:
47+
yml_config = yaml.safe_load(f)
48+
except yaml.scanner.ScannerError as se:
49+
msg = f"Error parsing config.yml: {se}"
50+
eprint(msg)
51+
raise KeyError(msg)
52+
53+
# load override yaml
54+
yml_override = None
55+
if "CONFIG_OVERRIDE_PATH" in os.environ:
56+
override_yml_filepath = os.environ["CONFIG_OVERRIDE_PATH"]
57+
else:
58+
override_yml_filepath = "/config/override.yml"
59+
if os.path.isfile(override_yml_filepath):
60+
debug(f"loading override configuation: {override_yml_filepath}")
61+
try:
62+
with open(override_yml_filepath, "r") as f:
63+
yml_override = yaml.safe_load(f)
64+
except yaml.scanner.ScannerError as se:
65+
msg = f"Error parsing '{override_yml_filepath}': {se}"
66+
eprint(msg)
67+
raise KeyError(msg)
68+
69+
70+
# apply overrides for each key and store in cfg global
71+
for x in yml_config:
72+
cfgval = yml_config[x]
73+
# see if there is a command-line override
74+
option = '--'+x+'='
75+
override = None
76+
for i in range(1, len(sys.argv)):
77+
if sys.argv[i].startswith(option):
78+
# found an override
79+
arg = sys.argv[i]
80+
override = arg[len(option):] # return text after option string
81+
debug(f"got cmd line override for {x}")
82+
83+
84+
# see if there are an environment variable override
85+
if override is None and x.upper() in os.environ:
86+
override = os.environ[x.upper()]
87+
debug(f"got env value override for {x} ")
88+
89+
# see if there is a yml override
90+
if override is None and yml_override and x in yml_override:
91+
override = yml_override[x]
92+
debug(f"got config override for {x}")
93+
94+
if override:
95+
if cfgval is not None:
96+
try:
97+
override = type(cfgval)(override) # convert to same type as yaml
98+
except ValueError as ve:
99+
msg = f"Error applying command line override value for key: {x}: {ve}"
100+
eprint(msg)
101+
# raise KeyError(msg)
102+
cfgval = override # replace the yml value
103+
104+
if isinstance(cfgval, str) and len(cfgval) > 1 and cfgval[-1] in ('g', 'm', 'k') and cfgval[:-1].isdigit():
105+
# convert values like 512m to corresponding integer
106+
u = cfgval[-1]
107+
n = int(cfgval[:-1])
108+
if u == 'k':
109+
cfgval = n * 1024
110+
elif u == 'm':
111+
cfgval = n * 1024*1024
112+
else: # u == 'g'
113+
cfgval = n * 1024*1024*1024
114+
cfg[x] = cfgval
115+
116+
def get(x):
117+
if not cfg:
118+
_load_cfg()
119+
if x not in cfg:
120+
raise KeyError(f"config value {x} not found")
121+
return cfg[x]

tests/perf/eksperf/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# bucket loader configuration
2+
inventory_domain: /home/mdsplus/eksperftest/s3shots.h5 # the HSDS domain used to store the list of domains
3+
hs_username: null # This value should be supplied by a Kubernetes secret or environment variable
4+
hs_password: null # This value should be supplied by a Kubernetes secret or environment variable
5+
public_read: true # make new domains public read, if false, only the hs_username user will have access
6+
hs_global: http://10.100.32.2 # e.g: http://10.100.32.2 # run: set the IP here to the CLUSTER_IP you get when running kubectl get service hsds
7+
hs_local: http://localhost:5101 # e.g: http://localhost:5101 # this is the pod-local address, set to null if running loader outside of kubernetes
8+
log_level: DEBUG

tests/perf/eksperf/docker_run.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docker run --rm -e HS_GLOBAL=$HS_GLOBAL -e HS_LOCAL=$HS_LOCAL -e HS_USERNAME=$HS_USERNAME -e HS_PASSWORD=$HS_PASSWORD -it psfc/hsperftest
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from datetime import datetime
2+
import sys
3+
import h5pyd
4+
import config
5+
6+
def formatTime(timestamp):
7+
# local_timezone = tzlocal.get_localzone() # get pytz timezone
8+
local_time = datetime.fromtimestamp(timestamp) # , local_timezone)
9+
return local_time
10+
11+
if len(sys.argv) > 1:
12+
if sys.argv[1] in ("-h", "--help"):
13+
print(f"usage: python {sys.argv[0]} [inventory_domain]")
14+
sys.exit(0)
15+
else:
16+
inventory_domain = sys.argv[1]
17+
else:
18+
inventory_domain = config.get("inventory_domain")
19+
20+
f = h5pyd.File(inventory_domain, "r")
21+
print(f"{inventory_domain} found, owner: {f.owner}, last madified: {datetime.fromtimestamp(f.modified)}")
22+
print("Contents")
23+
print("\tfilename\tStart\tDone\tRuntime\tStatus\tPod")
24+
print("-"*160)
25+
table = f["inventory"]
26+
num_succeeded = 0
27+
num_failed = 0
28+
num_inprogress = 0
29+
num_not_started = 0
30+
31+
for row in table:
32+
filename = row[0].decode('utf-8')
33+
if row[1]:
34+
start = formatTime(row[1])
35+
else:
36+
start = 0
37+
if row[2]:
38+
stop = formatTime(row[2])
39+
else:
40+
stop = 0
41+
rc = row[3]
42+
podname = row[4].decode('utf-8')
43+
if row[2] > 0:
44+
runtime = f"{int(row[2] - row[1]) // 60:4d}m {(row[2] - row[1]) % 60:2}s"
45+
else:
46+
runtime = "0"
47+
48+
if row[1] == 0:
49+
num_not_started += 1
50+
elif row[2] > 0:
51+
if rc == 0:
52+
num_succeeded += 1
53+
else:
54+
num_failed += 1
55+
else:
56+
num_inprogress += 1
57+
58+
59+
print(f"{filename}\t{start}\t{stop}\t{runtime}\t{rc}\t{podname}")
60+
61+
print("="*80)
62+
print(f"{table.nrows} rows")
63+
print(f"succeeded: \t{num_succeeded}")
64+
print(f"failed: \t {num_failed}")
65+
print(f"in progress: \t {num_inprogress}")
66+
print(f"not started: \t {num_not_started}")

tests/perf/eksperf/entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
echo "hsperf entrypoint"
3+
export PYTHONUNBUFFERED="1"
4+
cd /app
5+
python read_shots.py 0
6+
echo "unexpected exit of read_shots.py"

tests/perf/eksperf/get_pods.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
kubectl -n hsperf get pods

0 commit comments

Comments
 (0)