Skip to content

Commit

Permalink
add some integrate tests for cpu and memory limits update
Browse files Browse the repository at this point in the history
Signed-off-by: lifubang <lifubang@acmcoder.com>
  • Loading branch information
lifubang committed Mar 17, 2024
1 parent 44114d3 commit 0e7f7f5
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/integration/update.bats
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,50 @@ EOF
check_cpu_shares 100
}

@test "update cpu period and memory with no quota" {
[ $EUID -ne 0 ] && requires rootless_cgroup

update_config '.linux.resources.cpu |= {}'

runc run -d --console-socket "$CONSOLE_SOCKET" test_update
[ "$status" -eq 0 ]
check_cpu_quota max 100000 "infinity"

runc update test_update --cpu-period 900000
[ "$status" -eq 0 ]
check_cpu_quota max 900000 "infinity"

runc update test_update --memory 500M
[ "$status" -eq 0 ]
check_cpu_quota max 900000 "infinity"
}

@test "update cpu period and memory" {
[ $EUID -ne 0 ] && requires rootless_cgroup

update_config '.linux.resources.cpu |= {}'

runc run -d --console-socket "$CONSOLE_SOCKET" test_update
[ "$status" -eq 0 ]
check_cpu_quota max 100000 "infinity"

runc update test_update --cpu-period 900000 --cpu-quota 504000
[ "$status" -eq 0 ]
check_cpu_quota 504000 900000 "560ms"

runc update test_update --cpu-period 900000
[ "$status" -eq 0 ]
check_cpu_quota 504000 900000 "560ms"

runc update test_update --memory 500M
[ "$status" -eq 0 ]
check_cpu_quota 504000 900000 "560ms"

runc update test_update --cpu-period 900000
[ "$status" -eq 0 ]
check_cpu_quota 504000 900000 "560ms"
}

@test "cpu burst" {
[ $EUID -ne 0 ] && requires rootless_cgroup
requires cgroups_cpu_burst
Expand Down

0 comments on commit 0e7f7f5

Please sign in to comment.