Skip to content

Commit 217aba5

Browse files
committed
CI: move the memory monitor into a script, and add an ASAN constant
The memory logging loop was duplicated in the valgrind and sanitizer jobs. Move it to .github/scripts/mem-monitor.sh so each job starts it with one line. Add ASAN to pyln.testing.utils next to VALGRIND, and use it in test_connection.py in place of reading the variable directly. Changelog-None Signed-off-by: daywalker90 <daywalker990@gmx.de>
1 parent 1a1dc8d commit 217aba5

4 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎.github/scripts/mem-monitor.sh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# Log memory to the job log every 15s during a test run, so readings made
3+
# before a VM kill survive. Run in the background and kill it when done.
4+
while sleep 15; do
5+
printf '\n[mem %s] %s\n' "$(date +%T)" "$(free -m | awk '/Mem:/{print "used="$3"MB avail="$7"MB"}')"
6+
ps -eo rss=,comm= | awk '{s[$2]+=$1; c[$2]++} END{for(k in s) printf "%d %d %s\n", s[k]/1024, c[k], k}' | sort -rn | head -n 5 | awk '{printf "[mem] %6d MB x%-4d %s\n", $1, $2, $3}'
7+
done

‎.github/workflows/ci.yaml‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -707,11 +707,7 @@ jobs:
707707
TEST_DEBUG: 1
708708
PYTEST_OPTS: ${{ env.PYTEST_OPTS_BASE }} --test-group-random-seed=42
709709
run: |
710-
# Memory is logged to the job log during the run, so readings before a VM kill survive.
711-
(while sleep 15; do
712-
printf '\n[mem %s] %s\n' "$(date +%T)" "$(free -m | awk '/Mem:/{print "used="$3"MB avail="$7"MB"}')"
713-
ps -eo rss=,comm= | awk '{s[$2]+=$1; c[$2]++} END{for(k in s) printf "%d %d %s\n", s[k]/1024, c[k], k}' | sort -rn | head -n 5 | awk '{printf "[mem] %6d MB x%-4d %s\n", $1, $2, $3}'
714-
done) &
710+
.github/scripts/mem-monitor.sh &
715711
mem_pid=$!
716712
trap 'kill $mem_pid 2>/dev/null' EXIT
717713
# -n $(nproc) rather than $(nproc)+1: one fewer parallel node-cluster
@@ -780,11 +776,7 @@ jobs:
780776
env:
781777
PYTEST_OPTS: ${{ env.PYTEST_OPTS_BASE }} --test-group-random-seed=42
782778
run: |
783-
# Memory is logged to the job log during the run, so readings before a VM kill survive.
784-
(while sleep 15; do
785-
printf '\n[mem %s] %s\n' "$(date +%T)" "$(free -m | awk '/Mem:/{print "used="$3"MB avail="$7"MB"}')"
786-
ps -eo rss=,comm= | awk '{s[$2]+=$1; c[$2]++} END{for(k in s) printf "%d %d %s\n", s[k]/1024, c[k], k}' | sort -rn | head -n 5 | awk '{printf "[mem] %6d MB x%-4d %s\n", $1, $2, $3}'
787-
done) &
779+
.github/scripts/mem-monitor.sh &
788780
mem_pid=$!
789781
trap 'kill $mem_pid 2>/dev/null' EXIT
790782
# loadgroup: tests marked heavy run one at a time on a single worker.

‎contrib/pyln-testing/pyln/testing/utils.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def env(name, default=None):
8181

8282

8383
VALGRIND = env("VALGRIND") == "1"
84+
ASAN = env("ASAN", "0") == "1"
8485
TEST_NETWORK = env("TEST_NETWORK", 'regtest')
8586
TEST_DEBUG = env("TEST_DEBUG", "0") == "1"
8687

‎tests/test_connection.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
mine_funding_to_announce, first_scid,
1616
CHANNEL_SIZE
1717
)
18-
from pyln.testing.utils import VALGRIND, EXPERIMENTAL_DUAL_FUND, FUNDAMOUNT, RUST, SLOW_MACHINE, env
18+
from pyln.testing.utils import VALGRIND, ASAN, EXPERIMENTAL_DUAL_FUND, FUNDAMOUNT, RUST, SLOW_MACHINE
1919

2020
import coincurve
2121
import hashlib
@@ -1491,7 +1491,7 @@ def test_funding_cancel_race(node_factory, bitcoind, executor):
14911491

14921492
if VALGRIND:
14931493
num = 5
1494-
elif env('ASAN') == '1':
1494+
elif ASAN:
14951495
num = 10
14961496
elif SLOW_MACHINE:
14971497
num = 20
@@ -5530,7 +5530,7 @@ def test_parallel_opens(node_factory, bitcoind, executor):
55305530
"""On macOS a socket closed by its sender while in flight over SCM_RIGHTS
55315531
could arrive unable to read, losing a subdaemon its hsmd or peer
55325532
connection under load (#5808)."""
5533-
if env('ASAN') == '1':
5533+
if ASAN:
55345534
pairs, opens = 2, 10
55355535
else:
55365536
pairs, opens = 6, 50

0 commit comments

Comments
 (0)