Skip to content

Commit

Permalink
Merge pull request #595 from mihalicyn/github_actions_2204
Browse files Browse the repository at this point in the history
github: start using ubuntu-22.04 image
  • Loading branch information
stgraber authored Apr 15, 2023
2 parents 6dc14b6 + 9a65231 commit 79e15d6
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/commits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
permissions:
pull-requests: read # for tim-actions/get-pr-commits to get list of commits from the PR
name: Signed-off-by (DCO)
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Get PR Commits
id: 'get-pr-commits'
Expand All @@ -27,7 +27,7 @@ jobs:
permissions:
contents: none
name: Branch target
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- name: Check branch target
env:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- gcc
- clang
os:
- ubuntu-18.04
- ubuntu-20.04
- ubuntu-22.04
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
Expand Down Expand Up @@ -60,6 +60,7 @@ jobs:
- clang
os:
- ubuntu-20.04
- ubuntu-22.04
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
Expand Down
11 changes: 11 additions & 0 deletions tests/test_cgroup.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ if ! mountpoint -q ${LXCFSDIR}; then
exit 1
fi

IS_CGROUP_V2=0
grep -qF 'cgroup cgroup' /proc/1/mountinfo || IS_CGROUP_V2=1

#
# LXCFS cgroupfs emulation doesn't make any sense with cgroup2
#
if [ "$IS_CGROUP_V2" = "1" ]; then
PASS=1
exit 0
fi

echo "==> Setting up memory, freeze and cpuset cgroups"
for c in memory freezer cpuset; do
[ ! -d /sys/fs/cgroup/${c} ] && exit 0
Expand Down
41 changes: 32 additions & 9 deletions tests/test_meminfo_hierarchy.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,46 @@ cleanup() {
FAILED=1
trap cleanup EXIT HUP INT TERM

[ ! -d /sys/fs/cgroup/memory ] && exit 0
echo "==> Setting up memory cgroup"
initmemory=`awk -F: '/memory/ { print $3 }' /proc/1/cgroup`
mempath=/sys/fs/cgroup/memory/${initmemory}
IS_CGROUP_V2=0
grep -qF 'cgroup cgroup' /proc/1/mountinfo || IS_CGROUP_V2=1

if [ "$IS_CGROUP_V2" = "1" ]; then
[ ! -d /sys/fs/cgroup ] && exit 0
echo "==> Setting up cgroup"
mempath=/sys/fs/cgroup/

memory_limit_file=memory.max
tasks_file=cgroup.procs
else
[ ! -d /sys/fs/cgroup/memory ] && exit 0
echo "==> Setting up memory cgroup"
initmemory=$(awk -F: '/memory/ { print $3 }' /proc/1/cgroup)
mempath=/sys/fs/cgroup/memory/${initmemory}

memory_limit_file=memory.limit_in_bytes
tasks_file=tasks
fi

rmdir ${mempath}/${cg1} 2>/dev/null || true
rmdir ${mempath}/${cg2} 2>/dev/null || true

echo "==> Testing /proc/meminfo with limit"
mkdir ${mempath}/${cg1}
echo 500000000 > ${mempath}/${cg1}/memory.limit_in_bytes
echo 1 > ${mempath}/${cg1}/tasks
m1=`awk '/^MemTotal:/ { print $2 }' ${LXCFSDIR}/proc/meminfo`
echo 500000000 > ${mempath}/${cg1}/${memory_limit_file}
echo 1 > ${mempath}/${cg1}/${tasks_file}
m1=$(awk '/^MemTotal:/ { print $2 }' ${LXCFSDIR}/proc/meminfo)

if [ "$IS_CGROUP_V2" = "1" ]; then
# temporary move to the root cgroup because of
# "no internal process" constraint
echo 1 > ${mempath}/${tasks_file}
echo '+memory' > ${mempath}/${cg1}/cgroup.subtree_control
fi

echo "==> Testing /proc/meminfo with sub-cgroup"
mkdir ${mempath}/${cg1}/${cg2}
echo 1 > ${mempath}/${cg1}/${cg2}/tasks
m2=`awk '/^MemTotal:/ { print $2 }' ${LXCFSDIR}/proc/meminfo`
echo 1 > ${mempath}/${cg1}/${cg2}/${tasks_file}
m2=$(awk '/^MemTotal:/ { print $2 }' ${LXCFSDIR}/proc/meminfo)

echo "==> Confirming same limits"
[ $m1 -eq $m2 ]
Expand Down
53 changes: 39 additions & 14 deletions tests/test_proc.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,50 @@ if ! mountpoint -q ${LXCFSDIR}; then
exit 1
fi

echo "==> Setting up memory/cpuset cgroup in lxcfs_test_proc"
[ ! -d /sys/fs/cgroup/memory ] && exit 0
[ ! -d /sys/fs/cgroup/cpuset ] && exit 0
IS_CGROUP_V2=0
grep -qF 'cgroup cgroup' /proc/1/mountinfo || IS_CGROUP_V2=1

initcpuset=`awk -F: '/cpuset/ { print $3 }' /proc/1/cgroup`
initmemory=`awk -F: '/memory/ { print $3 }' /proc/1/cgroup`
if [ "$IS_CGROUP_V2" = "1" ]; then
echo "==> Setting up cgroup in lxcfs_test_proc"
[ ! -d /sys/fs/cgroup ] && exit 0

cpupath=/sys/fs/cgroup/cpuset/${initcpuset}
mempath=/sys/fs/cgroup/memory/${initmemory}
default_hierarchy="/"

rmdir ${cpupath}/lxcfs_test_proc 2>/dev/null || true
rmdir ${mempath}/lxcfs_test_proc 2>/dev/null || true
mkdir ${cpupath}/lxcfs_test_proc
mkdir ${mempath}/lxcfs_test_proc
hierarchy_path=/sys/fs/cgroup/${default_hierarchy}
cpupath=${hierarchy_path}
mempath=${hierarchy_path}

echo 1 > ${cpupath}/lxcfs_test_proc/tasks
echo 1 > ${mempath}/lxcfs_test_proc/tasks
rmdir ${hierarchy_path}/lxcfs_test_proc 2>/dev/null || true
mkdir ${hierarchy_path}/lxcfs_test_proc

echo $((64*1024*1024)) > ${mempath}/lxcfs_test_proc/memory.limit_in_bytes
echo 1 > ${hierarchy_path}/lxcfs_test_proc/cgroup.procs

echo '+cpu +memory' > ${hierarchy_path}/cgroup.subtree_control

memory_limit_file=memory.max
else
echo "==> Setting up memory/cpuset cgroup in lxcfs_test_proc"
[ ! -d /sys/fs/cgroup/memory ] && exit 0
[ ! -d /sys/fs/cgroup/cpuset ] && exit 0

initcpuset=$(awk -F: '/cpuset/ { print $3 }' /proc/1/cgroup)
initmemory=$(awk -F: '/memory/ { print $3 }' /proc/1/cgroup)

cpupath=/sys/fs/cgroup/cpuset/${initcpuset}
mempath=/sys/fs/cgroup/memory/${initmemory}

rmdir ${cpupath}/lxcfs_test_proc 2>/dev/null || true
rmdir ${mempath}/lxcfs_test_proc 2>/dev/null || true
mkdir ${cpupath}/lxcfs_test_proc
mkdir ${mempath}/lxcfs_test_proc

echo 1 > ${cpupath}/lxcfs_test_proc/tasks
echo 1 > ${mempath}/lxcfs_test_proc/tasks

memory_limit_file=memory.limit_in_bytes
fi

echo $((64*1024*1024)) > ${mempath}/lxcfs_test_proc/${memory_limit_file}
echo 0 > ${cpupath}/lxcfs_test_proc/cpuset.cpus

# Test uptime
Expand Down
36 changes: 27 additions & 9 deletions tests/test_sigusr2.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,34 @@ if ! mountpoint -q ${LXCFSDIR}; then
exit 1
fi

echo "==> Setting up memory cgroup in lxcfs_test_proc"
[ ! -d /sys/fs/cgroup/memory ] && exit 0

initmemory=`awk -F: '/memory/ { print $3 }' /proc/1/cgroup`
mempath=/sys/fs/cgroup/memory/${initmemory}
rmdir ${mempath}/lxcfs_test_proc 2>/dev/null || true
mkdir ${mempath}/lxcfs_test_proc
echo 1 > ${mempath}/lxcfs_test_proc/tasks
IS_CGROUP_V2=0
grep -qF 'cgroup cgroup' /proc/1/mountinfo || IS_CGROUP_V2=1

if [ "$IS_CGROUP_V2" = "1" ]; then
echo "==> Setting up cgroup in lxcfs_test_proc"
[ ! -d /sys/fs/cgroup ] && exit 0

mempath=/sys/fs/cgroup
rmdir ${mempath}/lxcfs_test_proc 2>/dev/null || true
mkdir ${mempath}/lxcfs_test_proc

memory_limit_file=memory.max
tasks_file=cgroup.procs
else
echo "==> Setting up memory cgroup in lxcfs_test_proc"
[ ! -d /sys/fs/cgroup/memory ] && exit 0

initmemory=$(awk -F: '/memory/ { print $3 }' /proc/1/cgroup)
mempath=/sys/fs/cgroup/memory/${initmemory}
rmdir ${mempath}/lxcfs_test_proc 2>/dev/null || true
mkdir ${mempath}/lxcfs_test_proc

memory_limit_file=memory.limit_in_bytes
tasks_file=tasks
fi

echo $((64*1024*1024)) > ${mempath}/lxcfs_test_proc/memory.limit_in_bytes
echo 1 > ${mempath}/lxcfs_test_proc/${tasks_file}
echo $((64*1024*1024)) > ${mempath}/lxcfs_test_proc/${memory_limit_file}

# Test meminfo
echo "==> Testing /proc/meminfo"
Expand Down

0 comments on commit 79e15d6

Please sign in to comment.