Skip to content

Commit

Permalink
test: add simple tests to verify isolcpus allocation
Browse files Browse the repository at this point in the history
Signed-off-by: Feruzjon Muyassarov <feruzjon.muyassarov@intel.com>
  • Loading branch information
fmuyassarov committed Jun 27, 2024
1 parent 867f579 commit 3a68601
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
config:
balloonTypes:
- name: isolcpus
minBalloons: 0
minCPUs: 1
minBalloons: 1
preferIsolCpus: true
namespaces:
- default
instrumentation:
httpEndpoint: :8891
prometheusExport: true
log:
debug:
- policy
klog:
skip_headers: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
helm-terminate
helm_config=${TEST_DIR}/balloons-isolcpus.cfg helm-launch balloons

vm-command "grep isolcpus=0,1 /proc/cmdline" || {
if [ "$distro" = "generic/fedora37" ]; then
fedora-set-kernel-cmdline "isolcpus=0,1"
else
ubuntu-set-kernel-cmdline "isolcpus=0,1"
fi
vm-reboot
vm-command "grep isolcpus=0,1 /proc/cmdline" || {
error "failed to set isolcpus kernel commandline parameter"
}
vm-command "systemctl restart kubelet"
sleep 5
vm-wait-process --timeout 120 kube-apiserver
}
vm-command "kubectl create namespace isolcpus"
vm-command "kubectl create namespace non-isolcpus"

# pod0: runs on system isolated CPUs
CONTCOUNT=2 namespace=default create balloons-busybox
report allowed
verify "cpus['pod0c0'] == {'cpu00', 'cpu01'}"

# pod1: should run on non-isolated CPUs
CONTCOUNT=1 namespace="kube-system" create balloons-busybox
report allowed
verify "cpus['pod1c0'] != {'cpu00', 'cpu01'}"

cleanup

helm-terminate
30 changes: 30 additions & 0 deletions test/e2e/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -874,6 +874,36 @@ $py_assertion
return 0
}

fedora-set-kernel-cmdline() {
local e2e_defaults="$*"
vm-command "mkdir -p /etc/default; touch /etc/default/grub; sed -i '/e2e:fedora-set-kernel-cmdline/d' /etc/default/grub"
vm-command "echo 'GRUB_CMDLINE_LINUX_DEFAULT=\"\${GRUB_CMDLINE_LINUX_DEFAULT} ${e2e_defaults}\"' >> /etc/default/grub" || {
command-error "writing new command line parameters failed"
}
vm-command "grub2-mkconfig -o /boot/grub2/grub.cfg" || {
command-error "updating grub failed"
}
}

ubuntu-set-kernel-cmdline() {
local e2e_defaults="$1"
vm-command "echo 'GRUB_CMDLINE_LINUX_DEFAULT=\"\${GRUB_CMDLINE_LINUX_DEFAULT} ${e2e_defaults}\"' > /etc/default/grub.d/60-e2e-defaults.cfg" || {
command-error "writing new command line parameters failed"
}
vm-command "update-grub" || {
command-error "updating grub failed"
}
}

vm-reboot() { # script API
# Usage: vm-reboot
#
# Reboots the virtual machine and waits that the ssh server starts
# responding again.
vm-command "reboot"
sleep 5
}

# Defaults to use in case the test case does not define these values.
yaml_in_defaults="CPU=1 MEM=100M ISO=true CPUREQ=1 CPULIM=2 MEMREQ=100M MEMLIM=200M CONTCOUNT=1"

Expand Down

0 comments on commit 3a68601

Please sign in to comment.