Skip to content

Commit f9fdefb

Browse files
committed
run.sh: add bench configuration file path argument
Signed-off-by: Bin Tang <[email protected]>
1 parent 4a55582 commit f9fdefb

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

run.sh

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ RESULT_FILE=result.txt
1616
RESULT_CSV=result.csv
1717
NYDUSIFY_BIN=$(which nydusify)
1818
NYDUS_IMAGE_BIN=$(which nydus-image)
19+
BENCH_CONFIG=bench.yaml
1920

2021
#########################################################
2122
# Could alert value via arguments
@@ -25,7 +26,7 @@ RESULT_DIR=data
2526
SOURCE_REGISTRY=docker.io/library
2627
TARGET_REGISTRY=""
2728
SKIP=false
28-
IMAGES_PATH=hello_bench_image_list.txt
29+
IMAGES_PATH=image_list.txt
2930

3031
#########################################################
3132
# Push OCI image to TARGET_REGISTRY
@@ -62,18 +63,24 @@ function convert() {
6263

6364
image=$1
6465

66+
name=$(echo ${image} | awk -F: '{print $1}')
67+
tag=$(echo ${image} | awk -F: '{print $2}')
68+
if [[ "${tag}" == "" ]];then
69+
tag=latest
70+
fi
71+
6572
sudo nerdctl pull ${TARGET_REGISTRY}/${image}
66-
echo "[INFO] Converting ${TARGET_REGISTRY}/${image} to ${TARGET_REGISTRY}/${image}:nydusv6 ..."
73+
echo "[INFO] Converting ${TARGET_REGISTRY}/${image} to ${TARGET_REGISTRY}/${name}:${tag}-nydusv6 ..."
6774
echo "sudo $NYDUSIFY_BIN convert \
6875
--fs-version 6 \
6976
--nydus-image $NYDUS_IMAGE_BIN \
7077
--source ${TARGET_REGISTRY}/${image} \
71-
--target ${TARGET_REGISTRY}/${image}:nydusv6"
78+
--target ${TARGET_REGISTRY}/${name}:${tag}-nydusv6"
7279
sudo $NYDUSIFY_BIN convert \
7380
--fs-version 6 \
7481
--nydus-image $NYDUS_IMAGE_BIN \
7582
--source ${TARGET_REGISTRY}/${image} \
76-
--target ${TARGET_REGISTRY}/${image}:nydusv6
83+
--target ${TARGET_REGISTRY}/${name}:${tag}-nydusv6
7784
}
7885

7986
#########################################################
@@ -112,6 +119,12 @@ function stop_all_containers {
112119
function run() {
113120
image=$1
114121

122+
name=$(echo ${image} | awk -F: '{print $1}')
123+
tag=$(echo ${image} | awk -F: '{print $2}')
124+
if [[ "${tag}" == "" ]];then
125+
tag=latest
126+
fi
127+
115128
stop_all_containers
116129
sudo nerdctl ps -a | awk 'NR>1 {print $1}' | xargs sudo nerdctl rm >/dev/null 2>&1
117130
sudo nerdctl container prune -f
@@ -121,7 +134,7 @@ function run() {
121134

122135
echo "[INFO] Run hello bench in ${image} ..."
123136
sudo nerdctl --snapshotter overlayfs rmi -f ${TARGET_REGISTRY}/${image} >/dev/null 2>&1
124-
result=$(sudo ./hello.py --engine nerdctl --snapshotter overlayfs --op run \
137+
result=$(sudo ./hello.py --bench-config=${BENCH_CONFIG} --engine nerdctl --snapshotter overlayfs --op run \
125138
--registry=${TARGET_REGISTRY} \
126139
--images ${image} |
127140
grep "repo")
@@ -130,16 +143,16 @@ function run() {
130143
echo "[INFO] Remove image ${TARGET_REGISTRY}/${image} ..."
131144
sudo nerdctl --snapshotter overlayfs rmi -f ${TARGET_REGISTRY}/${image} >/dev/null 2>&1
132145

133-
echo "[INFO] Run hello bench in ${image}:nydusv6 ..."
134-
sudo nerdctl --snapshotter nydus rmi -f ${TARGET_REGISTRY}/${image}:nydusv6 >/dev/null 2>&1
135-
result=$(sudo ./hello.py --engine nerdctl --snapshotter nydus --op run \
146+
echo "[INFO] Run hello bench in ${name}:${tag}-nydusv6 ..."
147+
sudo nerdctl --snapshotter nydus rmi -f ${TARGET_REGISTRY}/${name}:${tag}-nydusv6 >/dev/null 2>&1
148+
result=$(sudo ./hello.py --bench-config=${BENCH_CONFIG} --engine nerdctl --snapshotter nydus --op run \
136149
--registry=${TARGET_REGISTRY} \
137-
--images ${image}:nydusv6 |
150+
--images ${name}:${tag}-nydusv6 |
138151
grep "repo")
139152
echo ${result}
140153
echo ${result} >>${RESULT_DIR}/${RESULT_FILE}.${CURRENT_ROUND}
141-
echo "[INFO] Remove image ${TARGET_REGISTRY}/${image}:nydusv6 ..."
142-
sudo nerdctl --snapshotter nydus rmi -f ${TARGET_REGISTRY}/${image}:nydusv6 >/dev/null 2>&1
154+
echo "[INFO] Remove image ${TARGET_REGISTRY}/${name}:${tag}-nydusv6 ..."
155+
sudo nerdctl --snapshotter nydus rmi -f ${TARGET_REGISTRY}/${name}:${tag}-nydusv6 >/dev/null 2>&1
143156
}
144157

145158
#########################################################
@@ -219,6 +232,7 @@ function usage() {
219232
echo "Usage:"
220233
echo -e "run.sh -o OPERATION -s SOURCE_REGISTRY -t TARGET_REGISTRY [other options]
221234
[-o operation] \tavailable options are [ push convert run all draw ]
235+
[-c config] \tbench config file (only available for \"run\" operation)
222236
[-i images] \timages list
223237
[-p images path] \tfile path that contains images list (line by line)
224238
[-s source registry] \tsource registry for pulling image
@@ -243,7 +257,7 @@ if [ $# -eq 0 ]; then
243257
usage
244258
fi
245259

246-
while getopts o:i:p:s:t:r:d:kh OPT; do
260+
while getopts o:c:i:p:s:t:r:d:k:h OPT; do
247261
case $OPT in
248262
o)
249263
operation=${OPTARG}
@@ -252,6 +266,9 @@ while getopts o:i:p:s:t:r:d:kh OPT; do
252266
exit
253267
fi
254268

269+
;;
270+
c)
271+
BENCH_CONFIG=${OPTARG}
255272
;;
256273
i)
257274
getopts_extra "$@"

0 commit comments

Comments
 (0)