stress-tests: improve stress tests

Implement the following improvements in the stress-tests container:

- Show a warning message if an archive file is not found for USB
read/write stress tests
- Show a warning message if Internet is not available to generate
network loads
- Uses 4 different iperf public servers, in case one fails to
connect.

Related-to: TOR-1198

Signed-off-by: Sergio Prado <sergio.prado@toradex.com>
This commit is contained in:
Sergio Prado 2020-12-11 05:09:39 -03:00
parent 720e987df8
commit 7a89de9917
2 changed files with 22 additions and 6 deletions

View File

@ -4,9 +4,9 @@ ARG IMAGE_TAG=2-bullseye
FROM --platform=$IMAGE_ARCH torizon/debian:$IMAGE_TAG
RUN apt-get update \
&& apt-get install -y --no-install-recommends iperf3 rt-tests \
&& apt-get install -y --no-install-recommends iperf3 rt-tests iputils-ping \
&& rm -rf /var/lib/apt/lists/*
COPY / /
COPY stress-tests.sh /stress-tests.sh
CMD ["/stress-tests.sh"]

View File

@ -1,5 +1,7 @@
#!/bin/sh
echo "Setting up stress tests..."
# CPU load
while true; do hackbench >/dev/null 2>&1; done &
@ -9,9 +11,15 @@ while true; do find / -name a* >/dev/null 2>&1; done &
# I/O load (USB read/write)
if mount | grep /mnt/pendrive >/dev/null; then
cd /mnt/pendrive
tar -cf file.tar -C /var/log --exclude=lost+found -p .
while true; do rm -rf output; mkdir -p output; tar xfv file.tar -C output/ >/dev/null 2>&1; done &
if [ -e /mnt/pendrive/file.tar ]; then
cd /mnt/pendrive
tar -cf file.tar -C /var/log --exclude=lost+found -p .
while true; do rm -rf output; mkdir -p output; tar xfv file.tar -C output/ >/dev/null 2>&1; done &
else
echo "Warning: Archive file.tar not found in /mnt/pendrive. USB read/write stress test will not run."
fi
else
echo "Warning: pendrive not mounted. USB read/write stress test will not run."
fi
# RTC read/write
@ -19,7 +27,15 @@ while true; do hwclock >/dev/null 2>&1; sleep 0.1; done &
while true; do hwclock -w >/dev/null 2>&1; sleep 0.1; done &
# Network load
while true; do iperf3 -c bouygues.iperf.fr -P 10 >/dev/null 2>&1; done
if ! ping -q -c 1 -W 1 8.8.8.8 >/dev/null 2>&1; then
echo "Warning: could not ping 8.8.8.8. Internet may be unavailable to generate network load."
fi
while true; do
SERVERS="bouygues.iperf.fr speedtest.wtnet.de speedtest.iveloz.net.br iperf.scottlinux.com"
for s in $SERVERS; do
iperf3 -c $s -P 10 >/dev/null 2>&1
done
done &
echo "RT stress tests started successfully!"