1
1
import contextlib
2
2
import os
3
3
import pathlib
4
+ import random
4
5
import stat
5
6
import sys
6
7
import textwrap
@@ -43,7 +44,7 @@ def test_run_with_process_failing(mock_process, mock_popen, mock_check_executabl
43
44
next (run )
44
45
45
46
46
- @pytest .mark .flaky (reruns = 10 )
47
+ # @pytest.mark.flaky(reruns=10)
47
48
@pytest .mark .integration_test
48
49
@pytest .mark .usefixtures ("use_tmpdir" )
49
50
def test_cpu_seconds_can_detect_multiprocess ():
@@ -64,34 +65,39 @@ def test_cpu_seconds_can_detect_multiprocess():
64
65
"""\
65
66
import time
66
67
now = time.time()
67
- while time.time() < now + 2 :
68
+ while time.time() < now + 5 :
68
69
pass"""
69
70
)
70
71
)
71
- scriptname = "saturate_cpus.sh"
72
+ r = random .randint (1 , 1000 )
73
+ scriptname = f"saturate_cpus_{ r } .sh"
72
74
with open (scriptname , "w" , encoding = "utf-8" ) as script :
73
75
script .write (
74
76
textwrap .dedent (
75
77
"""\
76
78
#!/bin/sh
77
79
python busy.py &
80
+ python busy.py &
81
+ python busy.py &
82
+ python busy.py &
78
83
python busy.py"""
79
84
)
80
85
)
81
86
executable = os .path .realpath (scriptname )
82
87
os .chmod (scriptname , stat .S_IRWXU | stat .S_IRWXO | stat .S_IRWXG )
88
+
83
89
fmstep = ForwardModelStep (
84
90
{
85
91
"executable" : executable ,
86
92
},
87
93
0 ,
88
94
)
89
- fmstep .MEMORY_POLL_PERIOD = 0.05
95
+ fmstep .MEMORY_POLL_PERIOD = 0.01
90
96
cpu_seconds = 0.0
91
97
for status in fmstep .run ():
92
98
if isinstance (status , Running ):
93
99
cpu_seconds = max (cpu_seconds , status .memory_status .cpu_seconds )
94
- assert 2.5 < cpu_seconds < 4.5
100
+ assert 23 < cpu_seconds < 27
95
101
96
102
97
103
@pytest .mark .integration_test
0 commit comments