-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathcheck-patch.e2e-k8s.sh
More file actions
executable file
·69 lines (57 loc) · 3.09 KB
/
check-patch.e2e-k8s.sh
File metadata and controls
executable file
·69 lines (57 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash -xe
# This script should be able to execute functional tests against Kubernetes
# cluster on any environment with basic dependencies listed in
# check-patch.packages installed and podman / docker running.
#
# yum -y install automation/check-patch.packages
# automation/check-patch.e2e-k8s.sh
teardown() {
./cluster/kubectl.sh get nmstate -A -o yaml > $ARTIFACTS/nmstate.yaml || true
./cluster/kubectl.sh get pod -n nmstate -o wide > $ARTIFACTS/kubernetes-nmstate.pod.list.txt || true
for pod in $(./cluster/kubectl.sh get pod -n nmstate -o name); do
pod_name=$(echo $pod|sed "s#pod/##")
./cluster/kubectl.sh -n nmstate logs --prefix=true $pod > $ARTIFACTS/$pod_name.log || true
./cluster/kubectl.sh -n nmstate logs -p --prefix=true $pod > $ARTIFACTS/$pod_name.previous.log || true
./cluster/kubectl.sh -n nmstate describe $pod > $ARTIFACTS/$pod_name.describe.log || true
done
./cluster/kubectl.sh get events -n nmstate > $ARTIFACTS/nmstate-events.logs || true
./cluster/kubectl.sh get events > $ARTIFACTS/cluster-events.logs || true
# Collect kube-apiserver logs from kube-system namespace
for pod in $(./cluster/kubectl.sh get pod -n kube-system -l component=kube-apiserver -o name 2>/dev/null); do
pod_name=$(echo $pod|sed "s#pod/##")
./cluster/kubectl.sh -n kube-system logs $pod > $ARTIFACTS/$pod_name.log || true
./cluster/kubectl.sh -n kube-system logs -p $pod > $ARTIFACTS/$pod_name.previous.log || true
done
# Collect etcd logs from kube-system namespace
for pod in $(./cluster/kubectl.sh get pod -n kube-system -l component=etcd -o name 2>/dev/null); do
pod_name=$(echo $pod|sed "s#pod/##")
./cluster/kubectl.sh -n kube-system logs $pod > $ARTIFACTS/$pod_name.log || true
./cluster/kubectl.sh -n kube-system logs -p $pod > $ARTIFACTS/$pod_name.previous.log || true
done
# Collect kubelet logs, journalctl, dmesg, and resource usage from each node
for node_num in $(seq 1 $KUBEVIRT_NUM_NODES); do
node=$(printf "node%02d" $node_num)
./cluster/ssh.sh $node -- sudo journalctl -u kubelet --no-pager > $ARTIFACTS/${node}-kubelet.log 2>/dev/null || true
./cluster/ssh.sh $node -- sudo journalctl --no-pager > $ARTIFACTS/${node}-journalctl.log 2>/dev/null || true
./cluster/ssh.sh $node -- sudo dmesg > $ARTIFACTS/${node}-dmesg.log 2>/dev/null || true
done
make cluster-down
# Don't fail if there is no logs
cp -r ${E2E_LOGS}/handler/* ${ARTIFACTS} || true
}
main() {
export KUBEVIRT_NUM_NODES=4 # 1 control-plane, 3 workers
export NMSTATE_MAX_UNAVAILABLE=2
source automation/check-patch.setup.sh
cd ${TMP_PROJECT_PATH}
# Let's fail fast if generated files differ
make check-gen
# Let's fail fast if it's not compiling
make handler
make cluster-down
make cluster-up
trap teardown EXIT SIGINT SIGTERM SIGSTOP
make cluster-sync
make E2E_TEST_TIMEOUT=2h E2E_TEST_ARGS="--no-color --output-dir=$ARTIFACTS --junit-report=junit.functest.xml" test-e2e-handler
}
[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@"