Skip to content

Commit

Permalink
Add fedora fix
Browse files Browse the repository at this point in the history
Fedora tests run only on kvm-tier-0
This commit resolves #666, till full support in podman
c9s, added fix in set-ffi-env-e2e

Signed-off-by: Yariv Rachmani <[email protected]>
  • Loading branch information
Yarboa committed Dec 1, 2024
1 parent 7d48592 commit 9fe5739
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 21 deletions.
1 change: 1 addition & 0 deletions containers.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[containers]
default_ulimits = []
default_sysctls = []

cgroup_conf=[
Expand Down
3 changes: 1 addition & 2 deletions plans/e2e/kvm-tier-0.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ discover:
filter: 'tier:0&tag:kvm'

prepare+:
#Enable copr and install rpms
- name: Expose /dev kvm to QM
- name: Enable copr and install rpms
script: |
cd tests/e2e
bash ./lib/repoutils
Expand Down
9 changes: 1 addition & 8 deletions plans/main.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ prepare:
order: 20
package:
- podman
- name: Remove unsupported /dev configs
how: shell
order: 60
script: |
if ! test -e /dev/kvm; then
dnf remove -y qm_mount_bind_kvm
fi

- bc

adjust:
- when: run == manual
Expand Down
18 changes: 18 additions & 0 deletions tests/e2e/lib/repoutils
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,21 @@ install_qm_rpms() {

dnf install -y bluechi-ctl bluechi-agent bluechi-controller qm hostname
}

fix_qm_rlimits() {
###########################################################################
# Description: #
# Fix: Issue #666 need to set QM rlimit in containers.conf #
# #
# Arguments: None #
###########################################################################
local ulimit_nofile
local ulimit_nproc
info_message "fix_qm_rlimits(): prepare qm containers.conf file, update ulimits"
exec_cmd "test -e ${QM_CTR_CFG}"
ulimit_nofile=$(printf %.0f "$(echo "$(ulimit -n) * $U_NOFILE_PRCTG" | bc)")
ulimit_nproc=$(printf %.0f "$(echo "$(ulimit -u) * $U_NPROC_PRCTG" | bc)")
exec_cmd "sed -i -E 's/(default_ulimits = \[)/\1\"nproc=$ulimit_nproc:$ulimit_nproc\",\"nofile=$ulimit_nofile:$ulimit_nofile\"/' $QM_CTR_CFG"
info_message "fix_qm_rlimits(): verify limits are set"
exec_cmd "grep -oP '\(nproc.*\",\|nofile.*\"\)' ${QM_CTR_CFG} | tr -d '\t\",' "
}
1 change: 1 addition & 0 deletions tests/e2e/lib/utils
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ exec_cmd() {
local cmd="$1"
eval "$cmd"
if_error_exit "Error: Command $cmd failed"
info_message "PASS: Command $cmd successful"
}

cleanup_node_services() {
Expand Down
6 changes: 6 additions & 0 deletions tests/e2e/set-ffi-env-e2e
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export QC_SOC="${QC_SOC_TYPE:-SA8775P}"
export SOC_DISTRO_FILE="${SOC_FILE:-/sys/devices/soc0/machine}"
export QC_SOC_DISK="${QC_DISK_NAME:-sde}"
export OS_DISTRO="${CS_DISTRO:-}"
export QM_CTR_CFG="${QM_CNTR_CONFIG:-/etc/qm/containers/containers.conf}"
export U_NOFILE_PRCTG=${NOFILE_RATIO:-0.5}
export U_NPROC_PRCTG=${NPROC_RATIO:-0.75}


export BUILD_BLUECHI_FROM_GH_URL=""
export QM_GH_URL=""
Expand Down Expand Up @@ -163,6 +167,8 @@ setup_qm_services() {
# Curl files into here,
# Fix: default setup:main should be removed on next qm release
/usr/share/qm/setup --hostname localrootfs
# Fix: workaround issue #666
fix_qm_rlimits
cat > /etc/bluechi/controller.conf << 'EOF'
[bluechi-controller]
AllowedNodeNames=qm.localrootfs,localrootfs
Expand Down
14 changes: 4 additions & 10 deletions tests/qm-sanity-test/check_qm_podman_quadlet_is_ok.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,12 @@ Exec=sleep 1000
WantedBy=multi-user.target default.target
EOF
info_message "check_qm_podman_quadlet_is_ok(): qm-sanity-test container reload & restart"
exec_cmd_with_pass_info "podman exec qm systemctl daemon-reload"
exec_cmd_with_pass_info "podman exec qm systemctl start qm-sanity-test"
exec_cmd_with_pass_info "podman exec qm systemctl status qm-sanity-test | grep -i started"
exec_cmd_with_pass_info "podman exec qm podman run fedora echo Hello QM"
exec_cmd "podman exec qm systemctl daemon-reload"
exec_cmd "podman exec qm systemctl start qm-sanity-test"
exec_cmd "podman exec qm systemctl status qm-sanity-test | grep -i started"
exec_cmd "podman exec qm podman run fedora echo Hello QM"
info_message "PASS: check_qm_podman_quadlet_is_ok()"
exit 0
}

exec_cmd_with_pass_info(){
local command="$1"
exec_cmd "${command}"
info_message "PASS: Command ${command} successful"
}

check_qm_podman_quadlet_is_ok
8 changes: 8 additions & 0 deletions tests/qm-sanity-test/check_qm_podman_ulimits_are_set.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
summary: Test podman ulimits qm are set
test: /bin/bash ./check_qm_podman_ulimits_are_set.sh
duration: 10m
tier: 0
tag: [kvm,setup]
#Need to run first for Fedora use case
order: 40
framework: shell
27 changes: 27 additions & 0 deletions tests/qm-sanity-test/check_qm_podman_ulimits_are_set.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash -x

# shellcheck disable=SC1091
source ../e2e/lib/utils

U_NOFILE_PRCTG=${NOFILE_RATIO:-0.5}
U_NPROC_PRCTG=${NPROC_RATIO:-0.75}
QM_CTR_CFG=/etc/qm/containers/containers.conf

# Verify podman run and exec container inside qm with service file
check_qm_podman_ulimits_are_set(){
local ulimit_nofile
local ulimit_nproc=
info_message "check_qm_podman_ulimits_are_set(): \
prepare qm containers.conf file
refer issue #666"
info_message "check_qm_podman_ulimits_are_set(): qm-sanity-test update qm ulimits"
exec_cmd "test -e ${QM_CTR_CFG}"
ulimit_nofile=$(printf %.0f "$(echo "$(ulimit -n) * $U_NOFILE_PRCTG" | bc)")
ulimit_nproc=$(printf %.0f "$(echo "$(ulimit -u) * $U_NPROC_PRCTG" | bc)")
exec_cmd "sed -i -E 's/(default_ulimits = \[)/\1\"nproc=$ulimit_nproc:$ulimit_nproc\",\"nofile=$ulimit_nofile:$ulimit_nofile\"/' $QM_CTR_CFG"
info_message "check_qm_podman_ulimits_are_set(): qm-sanity-test verify limits are set"
exec_cmd "grep -oP \(nproc.*\",\|nofile.*\"\) ${QM_CTR_CFG} | tr -d '\t\",' "
exit 0
}

check_qm_podman_ulimits_are_set
2 changes: 1 addition & 1 deletion tests/qm-sanity-test/check_qm_setup_succeeds.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ duration: 10m
tier: 0
#Need to run first for Fedora use case
tag: [kvm,setup]
order: 40
order: 30
framework: shell
id: 310b2af2-6661-4b00-a563-67cc021e732b

0 comments on commit 9fe5739

Please sign in to comment.