Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit 669472a

Browse files
authored
Merge pull request #726 from GabyCT/topic/checkenv
tests: Verify processes (hypervisor, shim and proxy)
2 parents 6baac89 + ad498cb commit 669472a

File tree

8 files changed

+41
-25
lines changed

8 files changed

+41
-25
lines changed

integration/cri-o/cri-o.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ set -e
1010
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
1111
source "${SCRIPT_PATH}/../../.ci/lib.sh"
1212
source "${SCRIPT_PATH}/crio_skip_tests.sh"
13+
source "${SCRIPT_PATH}/../../metrics/lib/common.bash"
1314
source /etc/os-release || source /usr/lib/os-release
1415

1516
crio_repository="github.com/kubernetes-incubator/cri-o"
1617
crio_repository_path="$GOPATH/src/${crio_repository}"
1718

19+
# Check no processes are left behind
20+
check_processes
21+
1822
# devicemapper device and options
1923
LVM_DEVICE=${LVM_DEVICE:-/dev/vdb}
2024
DM_STORAGE_OPTIONS="--storage-driver devicemapper --storage-opt dm.directlvm_device=${LVM_DEVICE}

integration/kubernetes/cleanup_env.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
# SPDX-License-Identifier: Apache-2.0
66
#
77

8+
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
9+
source "${SCRIPT_PATH}/../../metrics/lib/common.bash"
10+
811
export KUBECONFIG=/etc/kubernetes/admin.conf
912
sudo -E kubeadm reset --cri-socket=/var/run/crio/crio.sock
1013

@@ -26,3 +29,6 @@ sudo ip link set dev cni0 down
2629
sudo ip link set dev flannel.1 down
2730
sudo ip link del cni0
2831
sudo ip link del flannel.1
32+
33+
# Check no processes are left behind
34+
check_processes

integration/kubernetes/init.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ set -e
99

1010
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
1111
source "${SCRIPT_PATH}/../../.ci/lib.sh"
12+
source "${SCRIPT_PATH}/../../metrics/lib/common.bash"
13+
14+
# Check no processes are left behind
15+
check_processes
1216

1317
# The next workaround is to be able to communicate between pods
1418
# Issue: https://github.com/kubernetes/kubernetes/issues/40182

integration/openshift/init.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ set -e
1010
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
1111
source "${SCRIPT_PATH}/openshiftrc"
1212
source "${SCRIPT_PATH}/../../.ci/lib.sh"
13+
source "${SCRIPT_PATH}/../../metrics/lib/common.bash"
14+
15+
# Check no processes are left behind
16+
check_processes
1317

1418
echo "Start crio service"
1519
sudo systemctl start crio

integration/openshift/teardown.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ set -e
99

1010
SCRIPT_PATH=$(dirname "$(readlink -f "$0")")
1111
source "${SCRIPT_PATH}/openshiftrc"
12+
source "${SCRIPT_PATH}/../../metrics/lib/common.bash"
1213

1314
echo "Terminate Openshift master and node processes"
1415
pgrep openshift | xargs sudo kill -9
1516

1617
echo "Stop cri-o service"
1718
sudo systemctl stop crio
19+
20+
# Check no processes are left behind
21+
check_processes

integration/popular_docker_hub_images/popular_docker_images.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
source ${BATS_TEST_DIRNAME}/../../metrics/lib/common.bash
1111

1212
setup() {
13+
# Check that processes are not running
14+
run check_processes
15+
echo "$output"
16+
[ "$status" -eq 0 ]
1317
clean_env
1418
}
1519

@@ -372,4 +376,8 @@ setup() {
372376

373377
teardown() {
374378
clean_env
379+
# Check that processes are not running
380+
run check_processes
381+
echo "$output"
382+
[ "$status" -eq 0 ]
375383
}

integration/swarm/swarm.bats

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,8 @@ number_of_retries=5
2323

2424
setup() {
2525
# Check that processes are not running
26-
run check_processes ${PROXY_PATH}
27-
[ "$status" -eq 0 ]
28-
29-
run check_processes ${SHIM_PATH}
30-
[ "$status" -eq 0 ]
31-
32-
run check_processes ${HYPERVISOR_PATH}
26+
run check_processes
27+
echo "$output"
3328
[ "$status" -eq 0 ]
3429

3530
interfaces=$(basename -a /sys/class/net/*)
@@ -69,13 +64,8 @@ teardown() {
6964
docker service remove "${SERVICE_NAME}"
7065
docker swarm leave --force
7166

72-
# Check that processes are not left by Swarm
73-
run check_processes ${PROXY_PATH}
74-
[ "$status" -eq 0 ]
75-
76-
run check_processes ${SHIM_PATH}
77-
[ "$status" -eq 0 ]
78-
79-
run check_processes ${HYPERVISOR_PATH}
67+
# Check that processes are not running
68+
run check_processes
69+
echo "$output"
8070
[ "$status" -eq 0 ]
8171
}

metrics/lib/common.bash

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,12 @@ kill_processes_before_start() {
246246
# Normally used to look for errant processes, and hence prints
247247
# a warning
248248
check_processes() {
249-
process=$1
250-
251-
[[ -z "${process}" ]] && return 0
252-
253-
pgrep -f "$process"
254-
if [ $? -eq 0 ]; then
255-
warning "Found unexpected ${process} present"
256-
ps -ef | grep $process
257-
return 1
258-
fi
249+
general_processes=( ${PROXY_PATH} ${HYPERVISOR_PATH} ${SHIM_PATH} )
250+
for i in "${general_processes[@]}"; do
251+
if pgrep -f "$i"; then
252+
die "Found unexpected ${i} present"
253+
fi
254+
done
259255
}
260256

261257
# Generate a random name - generally used when creating containers, but can

0 commit comments

Comments
 (0)