Skip to content

Commit

Permalink
Merge pull request #1070 from marquiz/release-0.8
Browse files Browse the repository at this point in the history
[release-0.8] backport e2e test fixes from master
  • Loading branch information
klihub authored Aug 25, 2023
2 parents 246d9f1 + 130ab68 commit acee70b
Show file tree
Hide file tree
Showing 42 changed files with 242 additions and 220 deletions.
18 changes: 1 addition & 17 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -472,23 +472,7 @@ e2e-tests: build-static
fi

packaging-tests: cross-packages
$(Q)for dir in test/e2e/packages.test-suite/*; do \
cleanup=1 omit_agent=1 $(E2E_RUN) $$dir; \
echo "--------------------------------------"; \
for r in $(find $$dir -name summary.txt); do \
t="$${r#*.test-suite/}"; t="$${t%/output/summary.txt}"; \
echo "$$t:"; \
cat $$r | sed 's/^/ /g'; \
done; \
echo "======================================"; \
done; \
for dir in test/e2e/packages.test-suite/*; do \
for r in $(find $$dir -name summary.txt); do \
t="$${r#*.test-suite/}"; t="$${t%/output/summary.txt}"; \
echo "$$t:"; \
cat $$r | sed 's/^/ /g'; \
done; \
done;
$(Q)cleanup=1 omit_agent=1 $(E2E_RUN) test/e2e/packages.test-suite

#
# Rules for building distro packages.
Expand Down
24 changes: 13 additions & 11 deletions demo/lib/distro.bash
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ ubuntu-22_04-image-url() {
}

debian-10-image-url() {
echo "https://cloud.debian.org/images/cloud/buster/20200803-347/debian-10-generic-amd64-20200803-347.qcow2"
echo "https://cloud.debian.org/images/cloud/buster/latest/debian-10-generic-amd64.qcow2"
}

debian-11-image-url() {
Expand Down Expand Up @@ -381,21 +381,17 @@ centos-8-install-containerd-pre() {
distro-install-repo https://download.docker.com/linux/centos/docker-ce.repo
}

centos-7-k8s-cni() {
echo "weavenet"
}

centos-install-golang() {
distro-install-pkg wget tar gzip git-core
from-tarball-install-golang
}

fedora-image-url() {
fedora-36-image-url
fedora-38-image-url
}

fedora-36-image-url() {
echo "https://mirrors.xtom.de/fedora/releases/36/Cloud/x86_64/images/Fedora-Cloud-Base-36-1.5.x86_64.qcow2"
fedora-38-image-url() {
echo "https://mirrors.xtom.de/fedora/releases/38/Cloud/x86_64/images/Fedora-Cloud-Base-38-1.6.x86_64.qcow2"
}

fedora-35-image-url() {
Expand Down Expand Up @@ -686,7 +682,11 @@ opensuse-image-url() {
}

opensuse-15_4-image-url() {
echo "https://download.opensuse.org/pub/opensuse/distribution/leap/15.4/appliances/openSUSE-Leap-15.4-JeOS.x86_64-15.4-OpenStack-Cloud-Current.qcow2"
echo "https://download.opensuse.org/pub/opensuse/distribution/leap/15.4/appliances/openSUSE-Leap-15.4-Minimal-VM.x86_64-OpenStack-Cloud.qcow2"
}

opensuse-15_5-image-url() {
echo "https://download.opensuse.org/pub/opensuse/distribution/leap/15.5/appliances/openSUSE-Leap-15.5-Minimal-VM.x86_64-Cloud.qcow2"
}

opensuse-tumbleweed-image-url() {
Expand Down Expand Up @@ -781,7 +781,9 @@ opensuse-wait-for-zypper() {
opensuse-require-repo-virtualization-containers() {
vm-command "zypper ls"
if ! grep -q Virtualization_containers <<< "$COMMAND_OUTPUT"; then
opensuse-install-repo https://download.opensuse.org/repositories/Virtualization:containers/15.4/Virtualization:containers.repo
vm-command 'source /etc/os-release; echo $VERSION'
local opensuse_version=$COMMAND_OUTPUT
opensuse-install-repo https://download.opensuse.org/repositories/Virtualization:containers/${opensuse_version}/Virtualization:containers.repo
opensuse-refresh-pkg-db
fi
}
Expand Down Expand Up @@ -1053,7 +1055,7 @@ default-install-utils() {
}

default-k8s-cni() {
echo ${k8scni:-cilium}
echo ${k8scni:-bridge}
}

default-k8s-cni-subnet() {
Expand Down
2 changes: 1 addition & 1 deletion demo/lib/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

_bash_topology_dump = """for cpu in /sys/devices/system/cpu/cpu[0-9]*; do cpu_id=${cpu#/sys/devices/system/cpu/cpu}; echo "cpu p:$(< ${cpu}/topology/physical_package_id) d:$(< ${cpu}/topology/die_id) n:$(basename ${cpu}/node* | sed 's:node::g') c:$(< ${cpu}/topology/core_id) t:$(< ${cpu}/topology/thread_siblings) cpu:${cpu_id}" ; done; for node in /sys/devices/system/node/node[0-9]*; do node_id=${node#/sys/devices/system/node/node}; echo "dist n:$node_id d:$(< $node/distance)"; echo "mem n:$node_id s:$(awk '/MemTotal/{print $4/1024}' < $node/meminfo)"; done"""

_bash_res_allowed = r"""for process in '%s'; do for pid in $(pgrep -f "$process"); do name=$(cat /proc/$pid/cmdline | tr '\0 ' '\n' | grep -E "^$process" | head -n 1); [ -n "$name" ] && [ "$pid" != "$$" ] && [ "$pid" != "$PPID" ] && echo "${name}/${pid} $(awk '/Cpus_allowed:/{c=$2}/Mems_allowed:/{m=$2}END{print "c:"c" m:"m}' < /proc/$pid/status)"; done; done"""
_bash_res_allowed = r"""for process in '%s'; do for pid in $(pgrep -f "$process"); do proc_pid_cmdline=$(< /proc/$pid/cmdline) || continue; proc_pid_status=$(< /proc/$pid/status) || continue; name=$(echo "$proc_pid_cmdline" | tr '\0 ' '\n' | grep -E "^$process" | head -n 1); [ -n "$name" ] && [ "$pid" != "$$" ] && [ "$pid" != "$PPID" ] && echo "${name}/${pid} $(awk '/Cpus_allowed:/{c=$2}/Mems_allowed:/{m=$2}END{print "c:"c" m:"m}' <<< "$proc_pid_status")"; done 2>/dev/null; done"""

def error(msg, exit_status=1):
"""Print error message and exit."""
Expand Down
39 changes: 22 additions & 17 deletions demo/lib/vm.bash
Original file line number Diff line number Diff line change
Expand Up @@ -616,25 +616,10 @@ vm-reboot() { # script API
# Reboots the virtual machine and waits that the ssh server starts
# responding again.
vm-command "reboot"
sleep 5
host-wait-vm-ssh-server
}

vm-force-restart() { # script API
# Usage: vm-force-restart
#
# Give the virtual machine a chance to shut itself down, then
# forcibly restart it using govm stop/start. Wait for the ssh
# server to start responding again after restarting. If VM_NAME
# is not set assume the target machine to not be govm-managed
# and fall back to vm-reboot instead.
if vm-is-govm; then
vm-command "shutdown -h now"
sleep 10
sleep 10
if ! host-wait-vm-ssh-server; then
vm-monitor system_reset
host-wait-vm-ssh-server
else
vm-reboot
fi
}

Expand Down Expand Up @@ -1024,6 +1009,7 @@ vm-create-singlenode-cluster() {
if ! vm-command "kubectl wait --for=condition=Ready node/\$(hostname) --timeout=240s"; then
command-error "kubectl waiting for node readiness timed out"
fi
vm-run-until --timeout 30 "kubectl get sa default > /dev/null" || error "serviceaccount 'default' not found"
}

vm-create-cluster() {
Expand All @@ -1046,6 +1032,25 @@ vm-destroy-cluster() {
vm-command "yes | kubeadm reset; rm -f ~$user/.kube/config ~root/.kube/config /etc/kubernetes"
}

vm-install-cni-bridge() {
vm-command "rm -rf /etc/cni/net.d/* && mkdir -p /etc/cni/net.d && cat > /etc/cni/net.d/10-bridge.conf <<EOF
{
\"cniVersion\": \"0.4.0\",
\"name\": \"demonet\",
\"type\": \"bridge\",
\"isGateway\": true,
\"ipMasq\": true,
\"ipam\": {
\"type\": \"host-local\",
\"subnet\": \"$CNI_SUBNET\",
\"routes\": [
{ \"dst\": \"0.0.0.0/0\" }
]
}
}
EOF"
}

vm-install-cni-cilium() {
if ! vm-command "curl -L --remote-name-all https://github.com/cilium/cilium-cli/releases/latest/download/cilium-linux-amd64.tar.gz && tar xzvfC cilium-linux-amd64.tar.gz /usr/local/bin && cilium install && rm -f cilium-linux-amd64.tar.gz"; then
command-error "installing cilium CNI to Kubernetes failed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# reserved and shared CPUs.

cleanup() {
vm-command "kubectl delete pods -n kube-system pod0; kubectl delete pods -n three --all --now; kubectl delete pods --all --now; kubectl delete namespace three"
vm-command "kubectl delete pods -n kube-system pod0; kubectl delete pods --all --now --wait; kubectl delete namespace three --now --wait --ignore-not-found"
return 0
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This test verifies prometheus metrics from the balloons policy.

cleanup() {
vm-command "kubectl delete pods --all --now"
vm-command "kubectl delete pods --all --now --wait"
return 0
}

Expand Down Expand Up @@ -55,17 +55,17 @@ verify-metrics-has-line 'balloon_type="flex"'
verify-metrics-has-line 'balloon_type="flex".* 5'

# check deflating a balloon in metrics
kubectl delete pods --now pod3
kubectl delete pods --now --wait --ignore-not-found pod3
verify-metrics-has-line 'balloon_type="flex"'
verify-metrics-has-line 'balloon_type="flex".* 2'

kubectl delete pods --now pod4
kubectl delete pods --now --wait --ignore-not-found pod4
sleep 5
# check popping a balloon from metrics
verify-metrics-has-no-line 'balloon_type="flex"'

# pop fast-dualcore[0], keep fast-dualcore[1]
kubectl delete pods --now pod1
kubectl delete pods --now --wait --ignore-not-found pod1
verify-metrics-has-line 'balloon="fast-dualcore\[1\]"'
sleep 5
verify-metrics-has-no-line 'balloon="fast-dualcore\[0\]"'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ cri_resmgr_cfg=${TEST_DIR}/balloons-reserved.cfg launch cri-resmgr

cleanup() {
vm-command \
"kubectl delete pod -n kube-system --now pod0
kubectl delete pod -n monitor-mypods --now pod1
kubectl delete pod -n system-logs --now pod2
kubectl delete pod -n kube-system --now pod3
kubectl delete pods --now pod4 pod5 pod6
kubectl delete pod -n kube-system --now pod7
kubectl delete namespace monitor-mypods
kubectl delete namespace system-logs
kubectl delete namespace my-exact-name"
"kubectl delete pod -n kube-system --now --wait --ignore-not-found pod0
kubectl delete pod -n monitor-mypods --now --wait --ignore-not-found pod1
kubectl delete pod -n system-logs --now --wait --ignore-not-found pod2
kubectl delete pod -n kube-system --now --wait --ignore-not-found pod3
kubectl delete pods --now --wait --ignore-not-found pod4 pod5 pod6
kubectl delete pod -n kube-system --now --wait --ignore-not-found pod7
kubectl delete namespace monitor-mypods --wait --ignore-not-found
kubectl delete namespace system-logs --wait --ignore-not-found
kubectl delete namespace my-exact-name --wait --ignore-not-found"
return 0
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@ cri_resmgr_cfg=${TEST_DIR}/balloons-namespace.cfg launch cri-resmgr

cleanup() {
vm-command \
"kubectl delete pods -n e2e-a --all --now
kubectl delete pods -n e2e-b --all --now
kubectl delete pods -n e2e-c --all --now
kubectl delete pods -n e2e-d --all --now
kubectl delete pods --all --now
kubectl delete namespace e2e-a
kubectl delete namespace e2e-b
kubectl delete namespace e2e-c
kubectl delete namespace e2e-d"
"kubectl delete pods --all --now --wait
kubectl delete namespace e2e-a --wait --ignore-not-found
kubectl delete namespace e2e-b --wait --ignore-not-found
kubectl delete namespace e2e-c --wait --ignore-not-found
kubectl delete namespace e2e-d --wait --ignore-not-found"
return 0
}
cleanup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
testns=e2e-balloons-test06

cleanup() {
vm-command "kubectl delete pods --all --now; \
kubectl delete pods -n $testns --all --now; \
kubectl delete pods -n btype1ns0 --all --now; \
kubectl delete namespace $testns || :; \
kubectl delete namespace btype1ns0 || :"
vm-command "kubectl delete pods --all --now --wait; \
kubectl delete namespace $testns --now --wait --ignore-not-found || :; \
kubectl delete namespace btype1ns0 --now --wait --ignore-not-found || :"
terminate cri-resmgr
terminate cri-resmgr-agent
vm-command "cri-resmgr -reset-policy; cri-resmgr -reset-config"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cleanup() {
vm-command "kubectl delete pods --all --now"
vm-command "kubectl delete pods --all --now --wait"
return 0
}

Expand Down Expand Up @@ -30,7 +30,7 @@ vm-command "kubectl describe pod pod2"
if ! grep -q 'no suitable balloon instance available' <<< "$COMMAND_OUTPUT"; then
error "could not find 'no suitable balloon instance available' in pod2 description"
fi
vm-command "kubectl delete pod pod2 --now"
vm-command "kubectl delete pod pod2 --now --wait --ignore-not-found"

# pod2: create dynamically the first dynamictwo balloon
CPUREQ="800m" CPULIM="800m"
Expand Down Expand Up @@ -59,7 +59,7 @@ vm-command "kubectl describe pod pod5"
if ! grep -q 'no suitable balloon instance available' <<< "$COMMAND_OUTPUT"; then
error "could not find 'no suitable balloon instance available' in pod6 description"
fi
vm-command "kubectl delete pod pod5 --now"
vm-command "kubectl delete pod pod5 --now --wait --ignore-not-found"

cleanup

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ verify 'len(cpus["pod0c0"]) == 4' \
'disjoint_sets(cpus["pod0c0"], cpus["pod6c0"])'

# Leave only one guaranteed container to the first balloon.
kubectl delete pods pod1 pod2 pod3 --now
kubectl delete pods pod1 pod2 pod3 --now --wait --ignore-not-found
report allowed
verify 'len(cpus["pod0c0"]) == 1' \
'len(cpus["pod4c0"]) == 1' \
Expand All @@ -87,7 +87,7 @@ verify 'len(cpus["pod0c0"]) == 1' \

# Leave only bestefforts to the first balloon. Make sure they still
# have a CPU.
kubectl delete pods pod4 --now
kubectl delete pods pod4 --now --wait --ignore-not-found
report allowed
verify 'len(cpus["pod0c0"]) == 1' \
'len(cpus["pod5c0"]) == 1' \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ verify-metrics-has-line 'sharedidlecpus_count="1"'
verify 'len(nodes["pod8c0"])==2' \
'len(dies["pod8c0"])==1' \
'len(packages["pod8c0"])==1'
kubectl delete pod pod8 --now
kubectl delete pod pod8 --now --wait --ignore-not-found
verify-metrics-has-no-line 'cpus_count="5"'

# pod9: Add one more pod with 4 CPUs to inflate over dies, which should cross
Expand All @@ -54,7 +54,7 @@ create multicontainerpod
verify 'len(nodes["pod9c0"])==4' \
'len(dies["pod9c0"])==2' \
'len(packages["pod9c0"])==1'
kubectl delete pod pod9 --now
kubectl delete pod pod9 --now --wait --ignore-not-found
verify 'disjoint_sets(nodes["pod0c0"], nodes["pod1c0"], nodes["pod2c0"], nodes["pod3c0"], nodes["pod4c0"], nodes["pod5c0"], nodes["pod6c0"], nodes["pod7c0"])' \

# pod9: Add one more pod with 7 CPUs to inflate over packages, which should cross
Expand All @@ -71,6 +71,6 @@ verify-metrics-has-no-line 'sharedidlecpus_count="1"'

# pod0, pod9 deflate. This should free up 10 CPUs that will cause having
# shared CPUs available again.
kubectl delete pod pod10 --now
kubectl delete pod pod0 --now
kubectl delete pod pod10 --now --wait --ignore-not-found
kubectl delete pod pod0 --now --wait --ignore-not-found
verify-metrics-has-line 'sharedidlecpus_count="1"'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Test placing containers with and without annotations to correct pools
# reserved and shared CPUs.

( kubectl delete pods pod3 -n kube-system --now ) || true
( kubectl delete pods pod3 -n kube-system --now --wait --ignore-not-found ) || true

# pod0: singlecpu
out ""
Expand Down Expand Up @@ -42,7 +42,7 @@ verify 'cpus["pod3c0"] == cpus["pod3c1"] == cpus["pod3c2"]' \
'cpus["pod3c0"] == expected.cpus.reserved[0]' \
'mems["pod3c0"] == expected.mems.reserved[0]'

kubectl delete pods pod3 -n kube-system --now
kubectl delete pods pod3 -n kube-system --now --wait --ignore-not-found

# pod4: bad pool name
out ""
Expand All @@ -52,4 +52,4 @@ report allowed
verify 'cpus["pod4c0"] == expected.cpus.default[0]' \
'mems["pod4c0"] == expected.mems.default[0]'

kubectl delete pods pod0 pod1 pod2 --now
kubectl delete pods pod0 pod1 pod2 --now --wait --ignore-not-found
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ verify 'cpus["pod0c0"] == cpus["pod0c1"]' \
'cpus["pod5c0"] == cpus["pod2c0"]' # the last pool should have been filled by pods 2 and 5

# make a little room to the first pool and clear the last pool
kubectl delete pods pod0 pod2 pod5 --now
kubectl delete pods pod0 pod2 pod5 --now --wait --ignore-not-found

# pod6: Balanced fill order should place this pod to the last pool (it has maximal free space)
POD_ANNOTATION="pool.podpools.cri-resource-manager.intel.com: singlecpu" CONTCOUNT=1 create podpools-busybox
report allowed
verify 'disjoint_sets(cpus["pod6c0"],
set.union(cpus["pod1c0"], cpus["pod3c0"], cpus["pod4c0"]))'

kubectl delete pods --all --now
kubectl delete pods --all --now --wait
reset counters

out "### Filling dualcpu pool in Packed fill order"
Expand All @@ -60,7 +60,7 @@ verify 'cpus["pod0c0"] == cpus["pod1c0"] == cpus["pod2c0"]' \
'disjoint_sets(cpus["pod0c0"], cpus["pod3c0"])'

# Deleting two pods from the first pool, one from the last.
kubectl delete pods pod0 pod1 pod5
kubectl delete pods pod0 pod1 pod5 --now --wait --ignore-not-found

# pod6: Packed fill order should place this to the last pool (it has minimal free space)
POD_ANNOTATION="pool.podpools.cri-resource-manager.intel.com: dualcpu" CONTCOUNT=1 create podpools-busybox
Expand Down
Loading

0 comments on commit acee70b

Please sign in to comment.