summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2022-07-05 15:40:22 +0200
committerSimon Rettberg2022-07-05 15:40:22 +0200
commit00a074b26fb1ff07cb4fad4edc26d05155f9419a (patch)
tree732224bcc94b616ff32ae9f2e701d322da64e297
parent[qemu] Make AppTest.setUp() public to JUnit happy (diff)
downloadmltk-29r2.tar.gz
mltk-29r2.tar.xz
mltk-29r2.zip
[speedcheck] Add automatic mode for dnbd3v29r2
-rwxr-xr-xcore/modules/speedcheck/data/opt/openslx/bin/image_speedcheck74
1 files changed, 50 insertions, 24 deletions
diff --git a/core/modules/speedcheck/data/opt/openslx/bin/image_speedcheck b/core/modules/speedcheck/data/opt/openslx/bin/image_speedcheck
index d092bb9e..8d66c929 100755
--- a/core/modules/speedcheck/data/opt/openslx/bin/image_speedcheck
+++ b/core/modules/speedcheck/data/opt/openslx/bin/image_speedcheck
@@ -10,6 +10,7 @@ showmsg() {
mountpoint=
servers=
+sticky=
start=
file=
nfs=
@@ -43,36 +44,23 @@ while (( $# > 0 )); do
done
if [ -z "$file" ]; then
- if mountpoint; then
+ . /opt/openslx/config
+ if mountpoint /mnt/vmstore; then
file=$( find /mnt/vmstore -type f -printf "%s\t%p\n" | sort -n | tail -n 1 | awk '{print $2}' )
+ nfs=1
+ elif [ -s "/tmp/vmchooser-benchmark" ] || [ -s "/tmp/vmchooser2/vmchooser2.xml" ] \
+ || curl -m 5 -L "$SLX_VMCHOOSER_BASE_URL/list" > "/tmp/vmchooser-benchmark"; then
+ xml="/tmp/vmchooser-benchmark"
+ [ -s "$xml" ] || xml="/tmp/vmchooser2/vmchooser2.xml"
+ file="$( xmlstarlet sel -T -t -v "//settings/eintrag/image_name/@param" "$xml" | head -n 1 )"
+ nfs=
else
- showmsg "Not using NFS, cannot test automatically"
+ showmsg "Could not automatically determine any image name, specify one via --file as relative path"
exit 1
fi
else
if [ -n "$nfs" ]; then
- file=$( find /mnt/vmstore/"$file"* -type f -printf "%s\t%p\n" | sort -n | tail -n 1 | awk '{print $2}' )
- else
- if [ -z "$servers" ]; then
- . /opt/openslx/config
- servers="$SLX_DNBD3_SERVERS"
- fi
- mountpoint="/tmp/speedtest-$$-$RANDOM"
- mkdir "$mountpoint"
- rid="${file##*:}"
- if [ "$rid" = "$file" ] || ! [ "$rid" -gt 0 ]; then
- rid=0
- fi
- file="${file%:*}"
- if ! dnbd3-fuse -S -h "$servers" -i "$file" -r "$rid" "$mountpoint"; then
- showmsg "Cannot start dnb3-fuse from $servers"
- exit 1
- fi
- if ! mountpoint "$mountpoint"; then
- showmsg "is not mountpoint"
- exit 1
- fi
- file="${mountpoint}/img"
+ file="$( find /mnt/vmstore/"$file"* -type f -printf "%s\t%p\n" | sort -n | tail -n 1 | awk '{print $2}' )"
fi
fi
@@ -81,6 +69,44 @@ if [ -z "$file" ]; then
exit 1
fi
+if [ -n "$nfs" ]; then
+ if ! [ -s "$file" ]; then
+ showmsg "Cannot access '$file'"
+ exit 1
+ fi
+else
+ if [ -z "$servers" ]; then
+ . /opt/openslx/config
+ servers="$SLX_DNBD3_SERVERS"
+ if [ "$servers" = "127.0.0.1" ]; then
+ # don't use local caching for this test
+ servers="$( awk '$1 != "127.0.0.1:5003" {printf("%s ", $1)}' "/sys/block/dnbd0/net/alt_servers" )"
+ if [ -z "$servers" ]; then
+ # poor man's way to convert \n to ' '
+ servers="$( echo $( cut -c2- "/etc/dnbd3-server/alt-servers" ) )"
+ fi
+ fi
+ else
+ sticky="-S"
+ fi
+ mountpoint="/tmp/speedtest-$$-$RANDOM"
+ mkdir "$mountpoint"
+ rid="${file##*:}"
+ if [ "$rid" = "$file" ] || ! [ "$rid" -gt 0 ]; then
+ rid=0
+ fi
+ file="${file%:*}"
+ if ! dnbd3-fuse $sticky -h "$servers" -i "$file" -r "$rid" "$mountpoint"; then
+ showmsg "Cannot start dnbd3-fuse from $servers"
+ exit 1
+ fi
+ if ! mountpoint "$mountpoint"; then
+ showmsg "is not mountpoint"
+ exit 1
+ fi
+ file="${mountpoint}/img"
+fi
+
if [ -n "$start" ]; then
now="$( date +%s )"
diff="$(( start - now ))"