Skip to content

Commit

Permalink
Merged in add-pipe-memory-monitor (pull request #476)
Browse files Browse the repository at this point in the history
add BB pipe memory monitor as done for RM.

Approved-by: Randy Taylor
  • Loading branch information
jrkerns committed Nov 12, 2024
2 parents e849037 + 278f767 commit c367ca5
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
24 changes: 24 additions & 0 deletions bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ definitions:
name: Run CBCT Tests
size: 2x
script:
# set up memory monitoring
- chmod +x memory_monitor.sh
- nohup ./memory_monitor.sh &
- MONITOR_PID=$!
- uv run pytest tests_basic/test_cbct.py -n 2 --cov=pylinac.cbct --cov-report term --junitxml=./test-reports/pytest_results.xml
# clean up memory monitor
- kill $MONITOR_PID
caches:
- testfiles
condition:
Expand All @@ -49,6 +55,8 @@ definitions:
- "pylinac/core/**"
- "tests_basic/test_cbct.py"
- "pylinac/ct.py"
artifacts:
- memory_usage.log
- step: &quart-tests
name: Run Quart Tests
script:
Expand Down Expand Up @@ -189,24 +197,40 @@ definitions:
name: Run Winston-Lutz Tests
size: 2x
script:
# set up memory monitoring
- chmod +x memory_monitor.sh
- nohup ./memory_monitor.sh &
- MONITOR_PID=$!
- uv run pytest tests_basic/test_winstonlutz.py --cov-report term --junitxml=./test-reports/pytest_results.xml
# clean up memory monitor
- kill $MONITOR_PID
condition:
changesets:
includePaths:
- "pylinac/core/**"
- "tests_basic/test_winstonlutz.py"
- "pylinac/winston_lutz.py"
artifacts:
- memory_usage.log
- step: &winston-lutz-mtmf-tests
name: Run Winston-Lutz Multi-Target Multi-Field Tests
size: 2x
script:
# set up memory monitoring
- chmod +x memory_monitor.sh
- nohup ./memory_monitor.sh &
- MONITOR_PID=$!
- uv run pytest tests_basic/test_winstonlutz_mtmf.py --cov-report term --junitxml=./test-reports/pytest_results.xml
# clean up memory monitor
- kill $MONITOR_PID
condition:
changesets:
includePaths:
- "pylinac/core/**"
- "tests_basic/test_winstonlutz.py"
- "pylinac/winston_lutz.py"
artifacts:
- memory_usage.log
- step: &plan-generator-tests
name: Plan generator tests
script:
Expand Down
14 changes: 14 additions & 0 deletions memory_monitor.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

LOG_FILE="memory_usage.log"
echo "Timestamp,MemoryUsage(MB),MemoryLimit(MB)" > $LOG_FILE

while true; do
TIMESTAMP=$(date +"%Y-%m-%d %H:%M:%S")
MEMORY_USAGE=$(cat /sys/fs/cgroup/memory/memory.usage_in_bytes)
MEMORY_LIMIT=$(cat /sys/fs/cgroup/memory/memory.limit_in_bytes)
MEMORY_USAGE_MB=$((MEMORY_USAGE / 1024 / 1024))
MEMORY_LIMIT_MB=$((MEMORY_LIMIT / 1024 / 1024))
echo "$TIMESTAMP,$MEMORY_USAGE_MB,$MEMORY_LIMIT_MB" >> $LOG_FILE
sleep 10
done

0 comments on commit c367ca5

Please sign in to comment.