Skip to content

Commit

Permalink
add another test where we use higher limit and expect the stress test…
Browse files Browse the repository at this point in the history
… to pass
  • Loading branch information
xingyaoww committed Feb 10, 2025
1 parent bf5dcbf commit ac5ee21
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/runtime/test_runtime_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,41 @@ def test_stress_docker_runtime_hit_memory_limits(temp_dir, runtime_cls):
assert obs.exit_code == 3 # OOM killed!

_close_test_runtime(runtime)


def test_stress_docker_runtime_within_memory_limits(temp_dir, runtime_cls):
"""Test runtime behavior under resource constraints."""
runtime, config = _load_runtime(
temp_dir,
runtime_cls,
docker_runtime_kwargs={
'cpu_period': 100000, # 100ms
'cpu_quota': 100000, # Can use 100ms out of each 100ms period (1 CPU)
'mem_limit': '4G', # 4 GB of memory
'memswap_limit': '0', # No swap
'mem_swappiness': 0, # Disable swapping
'oom_kill_disable': False, # Enable OOM killer
},
runtime_startup_env_vars={
'RUNTIME_MAX_MEMORY_GB': '7',
},
)

action = CmdRunAction(
command='sudo apt-get update && sudo apt-get install -y stress-ng'
)
logger.info(action, extra={'msg_type': 'ACTION'})
obs = runtime.run_action(action)
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
assert obs.exit_code == 0

action = CmdRunAction(
command='stress-ng --vm 1 --vm-bytes 6G --timeout 30s --metrics'
)
action.set_hard_timeout(120)
logger.info(action, extra={'msg_type': 'ACTION'})
obs = runtime.run_action(action)
logger.info(obs, extra={'msg_type': 'OBSERVATION'})
assert obs.exit_code == 0

_close_test_runtime(runtime)

0 comments on commit ac5ee21

Please sign in to comment.