Skip to content

Commit 8d758ce

Browse files
author
Vasileios Karakasis
authored
Merge pull request #2544 from vkarak/feat/improve-test-load-perf
[feat] Optimise the test case generation
2 parents faab025 + 06ac208 commit 8d758ce

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

reframe/frontend/executors/__init__.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ class TestCase:
3636

3737
def __init__(self, check, partition, environ):
3838
self._check_orig = check
39-
self._check = copy.deepcopy(check)
40-
self._partition = copy.deepcopy(partition)
41-
self._environ = copy.deepcopy(environ)
42-
self._check._case = weakref.ref(self)
39+
self._check = check
40+
self._partition = partition
41+
self._environ = environ
4342
self._deps = []
43+
self._is_ready = False
4444

4545
# Incoming dependencies
4646
self.in_degree = 0
@@ -72,6 +72,15 @@ def __repr__(self):
7272
e = self.environ.name if self.environ else None
7373
return f'({c!r}, {p!r}, {e!r})'
7474

75+
def prepare(self):
76+
'''Prepare test case for sending down the test pipeline'''
77+
if self._is_ready:
78+
return
79+
80+
self._check = copy.deepcopy(self._check)
81+
self._check._case = weakref.ref(self)
82+
self._is_ready = True
83+
7584
@property
7685
def check(self):
7786
return self._check
@@ -97,8 +106,14 @@ def clone(self):
97106
return TestCase(self._check_orig, self._partition, self._environ)
98107

99108

100-
def generate_testcases(checks):
101-
'''Generate concrete test cases from checks.'''
109+
def generate_testcases(checks, prepare=False):
110+
'''Generate concrete test cases from checks.
111+
112+
If `prepare` is true then each of the cases will also be prepared for
113+
being sent to the test pipeline. Note that setting this to true may slow down
114+
the test case generation.
115+
116+
'''
102117

103118
rt = runtime.runtime()
104119
cases = []
@@ -107,7 +122,11 @@ def generate_testcases(checks):
107122
c.valid_prog_environs)
108123
for part, environs in valid_comb.items():
109124
for env in environs:
110-
cases.append(TestCase(c, part, env))
125+
case = TestCase(c, part, env)
126+
if prepare:
127+
case.prepare()
128+
129+
cases.append(case)
111130

112131
return cases
113132

@@ -295,6 +314,7 @@ def __exit__(this, exc_type, exc_value, traceback):
295314
raise TaskExit from e
296315

297316
def setup(self, *args, **kwargs):
317+
self.testcase.prepare()
298318
self._safe_call(self.check.setup, *args, **kwargs)
299319
self._notify_listeners('on_task_setup')
300320

reframe/schemas/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@
514514
"environments/features": [],
515515
"environments/target_systems": ["*"],
516516
"general/dump_pipeline_progress": false,
517-
"general/pipeline_timeout": null,
517+
"general/pipeline_timeout": 3,
518518
"general/check_search_path": ["${RFM_INSTALL_PREFIX}/checks/"],
519519
"general/check_search_recursive": false,
520520
"general/clean_stagedir": true,

unittests/test_dependencies.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,11 @@ def assert_deps(self):
375375

376376
def test_build_deps(loader, default_exec_ctx):
377377
checks = loader.load_all(force=True)
378-
cases = executors.generate_testcases(checks)
378+
379+
# We need to prepare the test cases as if we were about to run them,
380+
# because we want to test `getdep()` as well, which normally gets resolved
381+
# during the `setup` phase of the pipeline
382+
cases = executors.generate_testcases(checks, prepare=True)
379383

380384
# Test calling getdep() before having built the graph
381385
t = find_check('Test1_fully', checks)

unittests/test_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ def sety(self, T0):
12101210
def setz(self, T0):
12111211
self.z = T0().x + 2
12121212

1213-
cases = executors.generate_testcases([T0(), T1()])
1213+
cases = executors.generate_testcases([T0(), T1()], prepare=True)
12141214
deps, _ = dependencies.build_deps(cases)
12151215
for c in dependencies.toposort(deps):
12161216
_run(*c)

0 commit comments

Comments
 (0)