forked from svanoort/pipeline-testcases
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparallel-abuse.groovy
More file actions
40 lines (36 loc) · 1.18 KB
/
Copy pathparallel-abuse.groovy
File metadata and controls
40 lines (36 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Pipeline script that will exhibit painful behavior if you handle parallels inefficiently
// Or don't ensure we only visit each node once when iterating. Generates ~1100 nodes.
// If we don't avoid visiting nodes multiple times, walking through this will require ~20*150*20*3*3 visits = ~540000
stage ('before') {
for (int i=0; i<150; i++) {
echo "running the $i step before parallel here"
}
}
int branchCount = 20;
int branchSteps = 10;
def branches = [:]
for (int i=0; i<branchCount; i++) {
branches["branch-$i"] = {
for (int j=0; j<branchSteps; j++) {
echo "Running branch $i step $j here"
}
parallel 'anotherbranch': {echo 'nested parallel'}, 'more':{echo 'nested parallel'}, 'andmore': {echo 'nested parallel'}
}
}
parallel branches
parallel branches
stage ('canfail') {
// boolean randomizer = nextBoolean()
// echo "Randomizer set to $randomizer"
// checkpoint 'before-fail' // Comment back in to test checkpoint restore
if (!randomizer) {
error("Random failure")
} else {
echo 'random pass'
}
}
stage ('after') {
for (int i=0; i<30; i++) {
echo "running the $i step here"
}
}