Skip to content

Commit 6018011

Browse files
committed
Update distribution test detector for better balancing
1 parent 817ca4a commit 6018011

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

Jenkinsfile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,14 @@ pipeline {
511511
steps {
512512
script {
513513
def tests = [:]
514-
for (f in changedDistributionTests.collate(18)) {
514+
def tests_per_executor = 180
515+
def idx = 0
516+
// roughly 10 executors when all tests run
517+
def executors = (changedDistributionTests.size() + tests_per_executor - 1) / tests_per_executor
518+
for (f in changedDistributionTests.collate(tests_per_executor)) {
519+
idx = idx + 1
515520
def names = f.join(" ")
516-
tests["Distribution Tests: ${names}"] = { node ("linux && docker && 8core") {
521+
tests["Distribution Tests: ${idx} / ${executors}"] = { node ("linux && docker && 8core") {
517522
deleteDir()
518523
docker.image('stanorg/ci:gpu-cpp17').inside {
519524
catchError(buildResult: "FAILURE", stageResult: "FAILURE") {
@@ -536,7 +541,8 @@ pipeline {
536541
}
537542
} }
538543
}
539-
parallel(failfast: true) tests
544+
tests.failFast = true
545+
parallel tests
540546
}
541547
}
542548
post {

test/prob/getDependencies.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import sys
1010
import subprocess
1111
from pathlib import Path
12-
12+
import glob
1313

1414
def get_dependencies(file: Path) -> Set[str]:
1515
file_dot_d = file.with_suffix(".d")
@@ -36,6 +36,11 @@ def get_changed() -> Set[str]:
3636
return set(changed_files)
3737

3838

39+
def add_tests_from_hpp(tests_to_run, test):
40+
pattern = str(test).replace("_test.hpp", "_0*_test.cpp")
41+
tests = glob.glob(pattern)
42+
tests_to_run.extend(tests)
43+
3944
if __name__ == "__main__":
4045
if Path("makefile") not in Path(".").iterdir():
4146
raise ValueError("getDependencies must be ran from the top-level repository")
@@ -47,12 +52,16 @@ def get_changed() -> Set[str]:
4752

4853
distribution_tests = Path("test", "prob")
4954

55+
subprocess.run(["make", "generate-tests"], stdout=subprocess.DEVNULL)
56+
5057
for dist in distribution_tests.iterdir():
5158
if not dist.is_dir():
5259
continue
60+
print(f"Considering {dist}.", file=sys.stderr)
5361
for test in dist.iterdir():
62+
if test.suffix != ".hpp": continue
5463
if pretend:
55-
tests_to_run.append(str(test).replace("_test.hpp", "_0*_test.cpp"))
64+
add_tests_from_hpp(tests_to_run, test)
5665
else:
5766
deps = get_dependencies(test)
5867
intersection = changed & deps
@@ -61,7 +70,6 @@ def get_changed() -> Set[str]:
6170
f"{test} has {len(intersection)} changed dependencies out of {len(deps)} files #included.",
6271
file=sys.stderr,
6372
)
73+
add_tests_from_hpp(tests_to_run, test)
6474

65-
tests_to_run.append(str(test).replace("_test.hpp", "_0*_test.cpp"))
66-
67-
print("\n".join(tests_to_run))
75+
print("\n".join(set(tests_to_run)))

0 commit comments

Comments
 (0)