Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds the agent stability test to stability test. Signed-off-by: Gabriela Cervantes <gabriela.cervantes.tellez@intel.com> (cherry picked from commit fd19f40)
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
# | ||
# Copyright (c) 2018-2023 Intel Corporation | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# This test will perform several execs to a | ||
# running container, the main purpose of this | ||
# test is to stress the agent | ||
|
||
set -e -x | ||
|
||
cidir=$(dirname "$0") | ||
|
||
source "${cidir}/../metrics/lib/common.bash" | ||
|
||
# Environment variables | ||
IMAGE="${IMAGE:-quay.io/prometheus/busybox:latest}" | ||
CONTAINER_NAME="${CONTAINER_NAME:-test}" | ||
PAYLOAD_ARGS="${PAYLOAD_ARGS:-tail -f /dev/null}" | ||
|
||
|
||
# Timeout is the duration of this test (seconds) | ||
# We want to stress the agent for a significant | ||
# time (approximately running for two days) | ||
timeout=186400 | ||
start_time=$(date +%s) | ||
end_time=$((start_time+timeout)) | ||
|
||
function setup { | ||
restart_containerd_service | ||
sudo ctr image pull $IMAGE | ||
sudo ctr run --runtime=$CTR_RUNTIME -d $IMAGE $CONTAINER_NAME sh -c $PAYLOAD_ARGS | ||
} | ||
|
||
function exec_loop { | ||
cmd="sudo ctr t exec --exec-id 1 $CONTAINER_NAME sh -c" | ||
$cmd "echo 'hello world' > file" | ||
$cmd "rm -rf /file" | ||
$cmd "touch /tmp/execWorks" | ||
$cmd "ls /tmp | grep execWorks" | ||
$cmd "rm -rf /tmp/execWorks" | ||
$cmd "ls /etc/foo" || echo "Fail expected" | ||
$cmd "cat /tmp/one" || echo "Fail expected" | ||
$cmd "exit 42" || echo "Fail expected" | ||
} | ||
|
||
function teardown { | ||
echo "Ending stability test" | ||
clean_env_ctr | ||
} | ||
trap teardown EXIT | ||
|
||
echo "Starting stability test" | ||
setup | ||
|
||
echo "Running stability test" | ||
while [[ $end_time > $(date +%s) ]]; do | ||
exec_loop | ||
done |