11
11
from tests import test_functions as Tests
12
12
from lib .scenario_runner import ScenarioRunner
13
13
14
- #pylint: disable=unused-argument # unused arguement off for now - because there are no running tests in this file
15
- @pytest .fixture (name = "reset_config" )
16
- def reset_config_fixture ():
17
- config = GlobalConfig ().config
18
- idle_start_time = config ['measurement' ]['idle-time-start' ]
19
- idle_time_end = config ['measurement' ]['idle-time-end' ]
20
- flow_process_runtime = config ['measurement' ]['flow-process-runtime' ]
21
- yield
22
- config ['measurement' ]['idle-time-start' ] = idle_start_time
23
- config ['measurement' ]['idle-time-end' ] = idle_time_end
24
- config ['measurement' ]['flow-process-runtime' ] = flow_process_runtime
25
-
26
14
def test_global_timeout ():
27
15
28
16
measurement_total_duration = 1
29
17
30
- runner = ScenarioRunner (uri = GMT_DIR , uri_type = 'folder' , filename = 'tests/data/usage_scenarios/basic_stress.yml' , skip_system_checks = True , dev_cache_build = False , dev_no_sleeps = True , dev_no_metrics = True , dev_no_phase_stats = True , measurement_total_duration = 1 )
18
+ runner = ScenarioRunner (uri = GMT_DIR , uri_type = 'folder' , filename = 'tests/data/usage_scenarios/basic_stress.yml' , skip_system_checks = True , dev_cache_build = False , dev_no_sleeps = True , dev_no_metrics = True , dev_no_phase_stats = True , measurement_total_duration = 1 , measurement_pre_test_sleep = 1 , measurement_baseline_duration = 1 , measurement_idle_duration = 1 , measurement_post_test_sleep = 1 , measurement_wait_time_dependencies = 1 )
31
19
32
20
out = io .StringIO ()
33
21
err = io .StringIO ()
@@ -47,6 +35,13 @@ def test_global_timeout():
47
35
Tests .assertion_info ('Timeout was not raised' , str (out .getvalue ()))
48
36
49
37
38
+ def test_invalid_combination_measurement_flow_process_duration ():
39
+
40
+ with pytest .raises (ValueError ) as err :
41
+ ScenarioRunner (uri = GMT_DIR , uri_type = 'folder' , filename = 'tests/data/usage_scenarios/basic_stress.yml' , skip_system_checks = True , dev_cache_build = False , dev_no_sleeps = True , dev_no_metrics = True , dev_no_phase_stats = True , measurement_total_duration = 10 , measurement_flow_process_duration = 20 )
42
+
43
+ assert str (err .value ) == 'Cannot run flows due to configuration error. Measurement_total_duration must be >= measurement_flow_process_duration, otherwise the flow will run into a timeout in every case. Values are: measurement_flow_process_duration: 20 and measurement_total_duration: 10'
44
+
50
45
def test_provider_disabling_not_active_by_default ():
51
46
52
47
@@ -136,65 +131,3 @@ def test_phase_padding_active():
136
131
assert notes [- 7 ][0 ] - notes [- 8 ][0 ] == runner ._phase_padding_ms * FROM_MS_TO_US
137
132
138
133
assert notes [- 6 ][1 ] == 'Ending phase [RUNTIME] [UNPADDED]'
139
-
140
-
141
-
142
- # Rethink how to do this test entirely
143
- def wip_test_idle_start_time (reset_config ):
144
- GlobalConfig ().config ['measurement' ]['idle-time-start' ] = 2
145
- runner = ScenarioRunner (uri = GMT_DIR , uri_type = 'folder' , filename = 'tests/data/usage_scenarios/basic_stress.yml' , skip_system_checks = True , dev_no_metrics = True , dev_no_phase_stats = True , dev_no_sleeps = True , dev_cache_build = True )
146
- run_id = runner .run ()
147
- query = """
148
- SELECT
149
- time, note
150
- FROM
151
- notes
152
- WHERE
153
- run_id = %s
154
- ORDER BY
155
- time
156
- """
157
-
158
- notes = DB ().fetch_all (query , (run_id ,))
159
-
160
- timestamp_preidle = [note for note in notes if "Booting" in note [1 ]][0 ][0 ]
161
- timestamp_start = [note for note in notes if note [1 ] == 'Start of measurement' ][0 ][0 ]
162
-
163
- #assert that the difference between the two timestamps is roughly 2 seconds
164
- diff = (timestamp_start - timestamp_preidle )/ 1000000
165
- assert 1.9 <= diff <= 2.1 , \
166
- Tests .assertion_info ('2s apart' , f"timestamp difference of notes: { diff } s" )
167
-
168
- # Rethink how to do this test entirely
169
- def wip_test_idle_end_time (reset_config ):
170
- GlobalConfig ().config ['measurement' ]['idle-time-end' ] = 2
171
- runner = ScenarioRunner (uri = GMT_DIR , uri_type = 'folder' , filename = 'tests/data/usage_scenarios/basic_stress.yml' , skip_system_checks = True , dev_no_metrics = True , dev_no_phase_stats = True , dev_no_sleeps = True , dev_cache_build = True )
172
- run_id = runner .run ()
173
- query = """
174
- SELECT
175
- time, note
176
- FROM
177
- notes
178
- WHERE
179
- run_id = %s
180
- ORDER BY
181
- time
182
- """
183
-
184
- notes = DB ().fetch_all (query , (run_id ,))
185
- timestamp_postidle = [note for note in notes if note [1 ] == 'End of post-measurement idle' ][0 ][0 ]
186
- timestamp_end = [note for note in notes if note [1 ] == 'End of measurement' ][0 ][0 ]
187
-
188
- #assert that the difference between the two timestamps is roughly 2 seconds
189
- diff = (timestamp_postidle - timestamp_end )/ 1000000
190
- assert 1.9 <= diff <= 2.1 , \
191
- Tests .assertion_info ('2s apart' , f"timestamp difference of notes: { diff } s" )
192
-
193
- def wip_test_process_runtime_exceeded (reset_config ):
194
- GlobalConfig ().config ['measurement' ]['flow-process-runtime' ] = .1
195
- runner = ScenarioRunner (uri = GMT_DIR , uri_type = 'folder' , filename = 'tests/data/usage_scenarios/basic_stress.yml' , skip_system_checks = True , dev_no_metrics = True , dev_no_phase_stats = True , dev_no_sleeps = True , dev_cache_build = True )
196
- with pytest .raises (RuntimeError ) as err :
197
- runner .run ()
198
- expected_exception = 'Process exceeded runtime of 0.1s: stress-ng -c 1 -t 1 -q'
199
- assert expected_exception in str (err .value ), \
200
- Tests .assertion_info (expected_exception , str (err .value ))
0 commit comments