-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathJenkinsfile
1238 lines (1084 loc) · 50.7 KB
/
Jenkinsfile
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// test pipeline for https://github.com/gdemengin/pipeline-logparser/
properties([
parameters([
booleanParam(defaultValue: false, description: 'set to to true to run extra long tests (multiple hours + may fail if not enough heap)', name: 'FULL_LOGPARSER_TEST'),
booleanParam(defaultValue: false, description: 'FULL_LOGPARSER_TEST + even more aggressive: with log editing', name: 'FULL_LOGPARSER_TEST_WITH_LOG_EDIT'),
booleanParam(defaultValue: false, description: 'run multithread timing test (may last a few hours + manual check of elapsed time)', name: 'MANYTHREAD_TIMING_TEST')
])
])
// ===============
// = constants =
// ===============
// label on the instance with linux hosts and 4 executors
LABEL_TEST_AGENT='test-agent'
// set to to true to run extra long tests
// (multiple hours + may fail if not enough heap)
RUN_FULL_LOGPARSER_TEST = params.FULL_LOGPARSER_TEST == true
// even more aggressive: with log editing
RUN_FULL_LOGPARSER_TEST_WITH_LOG_EDIT = params.FULL_LOGPARSER_TEST_WITH_LOG_EDIT == true
// test with many threads to check the time spent
RUN_MANYTHREAD_TIMING_TEST = params.MANYTHREAD_TIMING_TEST == true
// ============================
// = import logparser library =
// ============================
// @Library('[email protected]') _
node(LABEL_TEST_AGENT) {
checkout scm
def rev=sh(script: 'git rev-parse --verify HEAD', returnStdout: true).trim()
library(identifier: "pipeline-logparser@${rev}", changelog: false)
}
// =============
// = globals =
// =============
// uncomment if needed
// logparser.setVerbose(true)
// is Timestamper plugin affecting the logs
GLOBAL_TIMESTAMP = null
// =====================
// = logparser tests =
// =====================
// =========================
// = run parallel branches =
// = and nested branches =
// =========================
// alternate sleeps and echo to have mixed logs
def testBranch(name, loop, expectedLogMap) {
def line
expectedLogMap."$name" = ''
for (def i=0; i < loop; i++) {
sleep 1
expectedLogMap."$name" += 'Sleeping for 1 sec\n'
line="i=$i in $name"
echo line
expectedLogMap."$name" += line + '\n'
}
line="in $name"
echo line
expectedLogMap."$name" += line + '\n'
}
def runBranches(expectedLogMap, expectedLogMapWithDuplicate) {
def line
def branches = [:]
def loop=2
// simple branch with logs
branches.branch0 = {
testBranch('branch0', loop, expectedLogMap)
}
// simple branch with logs both here and nested in branch2
branches.branch1 = {
testBranch('branch1', loop, expectedLogMap)
}
// branch with nested branches
// one of the nested branches has the same name as branch1
branches.branch2 = {
testBranch('branch2', loop, expectedLogMap)
def nestedBranches = [:]
nestedBranches.branch21 = {
testBranch('branch2.branch21', loop, expectedLogMap)
}
line='in branch2 before to run nested branches'
echo line
expectedLogMap.'branch2' += line + '\n'
nestedBranches.branch22 = {
testBranch('branch2.branch22', loop, expectedLogMap)
}
// see how we manage 2 branches with the same name (not nested)
nestedBranches.branch1 = {
testBranch('branch2.branch1', loop, expectedLogMap)
}
parallel nestedBranches
expectedLogMap.'branch2' += '<nested branch [branch2] [branch21]>\n'
expectedLogMap.'branch2' += '<nested branch [branch2] [branch22]>\n'
expectedLogMap.'branch2' += '<nested branch [branch2] [branch1]>\n'
}
// branch with no logs
expectedLogMap.'branch3' = ''
branches.branch3 = {
def k = 0
k += 1
}
// run branches
parallel branches
expectedLogMap.'null' += '<nested branch [branch0]>\n'
expectedLogMap.'null' += '<nested branch [branch1]>\n'
expectedLogMap.'null' += '<nested branch [branch2]>\n'
expectedLogMap.'null' += '<nested branch [branch2] [branch21]>\n'
expectedLogMap.'null' += '<nested branch [branch2] [branch22]>\n'
expectedLogMap.'null' += '<nested branch [branch2] [branch1]>\n'
expectedLogMap.'null' += '<nested branch [branch3]>\n'
line='this log is not in any branch'
echo line
expectedLogMap."null" += line + '\n'
expectedLogMapWithDuplicates = expectedLogMap
branches = [:]
branches.branch4 = {
def nestedBranches = [:]
// see how we manage 2 branches with the same name (nested)
nestedBranches.branch4 = {
line='in branch4.branch4'
echo line
expectedLogMap.'branch4' = line + '\n'
expectedLogMapWithDuplicates.'branch4' = line + '\n'
}
parallel nestedBranches
}
parallel branches
expectedLogMap.'null' += '<nested branch [branch4]>\n'
}
def runSingleBranches(expectedLogMap) {
def line='test single parallel branch'
print line
expectedLogMap.'null' += line + '\n'
// parallel with only one branch
// it's a way to generate block of logs (wish there was a dedicated log command to do that)
expectedLogMap.'init' = ''
parallel init: {
line=1
print line
expectedLogMap."init" += line + '\n'
}
expectedLogMap.'empty' = ''
parallel empty: {
}
expectedLogMap.'endl' = ''
parallel endl: {
print ''
expectedLogMap."endl" += '\n'
}
// same with nested tasks
expectedLogMap.'main' = ''
parallel main: {
expectedLogMap.'main.build' = ''
parallel build: {
line=2
print line
expectedLogMap."main.build" += line + '\n'
}
expectedLogMap.'main.test' = ''
parallel test: {
line='\n\ntest empty lines\n\nand more empty lines\n\n'
print line
expectedLogMap."main.test" += line + '\n'
}
expectedLogMap.'main' += '<nested branch [main] [build]>\n'
expectedLogMap.'main' += '<nested branch [main] [test]>\n'
}
expectedLogMap.'null' += '<nested branch [init]>\n'
expectedLogMap.'null' += '<nested branch [empty]>\n'
expectedLogMap.'null' += '<nested branch [endl]>\n'
expectedLogMap.'null' += '<nested branch [main]>\n'
expectedLogMap.'null' += '<nested branch [main] [build]>\n'
expectedLogMap.'null' += '<nested branch [main] [test]>\n'
}
def runBranchesWithManyLines(nblines, expectedLogMap) {
// run branches with manylines and making sure lines are mixed between branches
// without technical pipeline pieces of logs between each switch of branch in the logs
def script = '''\
set +x
echo "+ set +x" > output.txt
i=0
while [ $i -lt ''' + nblines.toString() + ''' ]
do
echo line $i
''' + (expectedLogMap != null ? 'echo line $i >> output.txt' : '') + '''
i=$(( $i+1 ))
if [ $i = 50 ]
then
# sleep once in the middle to make sure the other branch adds some logs in the middle
sleep 1
fi
done
'''
script = script.stripIndent()
print script
if (expectedLogMap != null) {
expectedLogMap.'null' += script + '\n'
expectedLogMap.'one' = ''
expectedLogMap.'two' = ''
}
def start = 0
parallel one: {
print 'STRIP_NODE_LOG_START'
node(LABEL_TEST_AGENT) {
timeout(5) { // wait for other branch ... but no more than 5 minutes to avoid deadlock
print 'STRIP_NODE_LOG_STOP'
start += 1
while (start < 2) {}
}
sh script
if (expectedLogMap != null) {
expectedLogMap.'one' += readFile('output.txt')
}
}
}, two: {
print 'STRIP_NODE_LOG_START'
node(LABEL_TEST_AGENT) {
timeout(5) { // wait for other branch ... but no more than 5 minutes to avoid deadlock
print 'STRIP_NODE_LOG_STOP'
start += 1
while (start < 2) {}
}
sh script
if (expectedLogMap != null) {
expectedLogMap.'two' += readFile('output.txt')
}
}
}
if (expectedLogMap != null) {
expectedLogMap.'null' += '<nested branch [one]>\n'
expectedLogMap.'null' += '<nested branch [two]>\n'
}
}
def runStagesAndBranches(expectedLogMapWithStages, expectedLogMap) {
def line = 'testing stages'
print line
expectedLogMap.'null' += line + '\n'
expectedLogMapWithStages.'null' += line + '\n'
expectedLogMapWithStages.'stage1' = ''
stage('stage1') {
line='in stage1'
echo line
expectedLogMap.'null' += line + '\n'
expectedLogMapWithStages.'stage1' += line + '\n'
}
expectedLogMapWithStages.'stage2' = ''
stage('stage2') {
expectedLogMap.'s2b1' = ''
expectedLogMap.'s2b2' = ''
expectedLogMapWithStages.'stage2.s2b1' = ''
expectedLogMapWithStages.'stage2.s2b2' = ''
expectedLogMapWithStages.'stage2.stage3' = ''
stage('stage3') {
line='in stage2.stage3'
echo line
expectedLogMap.'null' += line + '\n'
expectedLogMapWithStages.'stage2.stage3' += line + '\n'
}
parallel 's2b1': {
line='in stage2.s2b1'
echo line
expectedLogMap.'s2b1' += line + '\n'
expectedLogMapWithStages.'stage2.s2b1' += line + '\n'
}, 's2b2': {
line='in stage2.s2b2'
echo line
expectedLogMap.'s2b2' += line + '\n'
expectedLogMapWithStages.'stage2.s2b2' += line + '\n'
}
expectedLogMap.'null' += '<nested branch [s2b1]>\n'
expectedLogMap.'null' += '<nested branch [s2b2]>\n'
expectedLogMapWithStages.'stage2' += '<nested branch [stage2] [stage3]>\n'
expectedLogMapWithStages.'stage2' += '<nested branch [stage2] [s2b1]>\n'
expectedLogMapWithStages.'stage2' += '<nested branch [stage2] [s2b2]>\n'
}
expectedLogMapWithStages.'null' += '<nested branch [stage1]>\n'
expectedLogMapWithStages.'null' += '<nested branch [stage2]>\n'
expectedLogMapWithStages.'null' += '<nested branch [stage2] [stage3]>\n'
expectedLogMapWithStages.'null' += '<nested branch [stage2] [s2b1]>\n'
expectedLogMapWithStages.'null' += '<nested branch [stage2] [s2b2]>\n'
}
// =======================================
// = parse logs and archive/check them =
// =======================================
def archiveStringArtifact(name, buffer) {
logparser.archiveArtifactBuffer(name, buffer)
}
def checkLogs(log1, editedLog1, name1, log2, editedLog2, name2) {
def tocmp1 = editedLog1 == null ? log1 : editedLog1
def tocmp2 = editedLog2 == null ? log2 : editedLog2
if (tocmp1 != tocmp2) {
// TODO: print side by side differences
print "${name1} = '''\\\n${log1}'''"
archiveStringArtifact("check/${name1}.txt", log1)
if (log1 != tocmp1) {
print "${name1} (edited) ='''\\\n${tocmp1}'''"
archiveStringArtifact("check/${name1}.edited.txt", tocmp1)
}
print "${name2} = '''\\\n${log2}'''"
archiveStringArtifact("check/${name2}.txt", log2)
if (log2 != tocmp2) {
print "${name2} (edited) ='''\\\n${tocmp2}'''"
archiveStringArtifact("check/${name2}.edited.txt", tocmp2)
}
error "${name1} and ${name2} differ, see files in ${BUILD_URL}/artifact/check"
} else {
print "${name1} and ${name2} are identical"
}
}
def checkBranchLogs(logs, name, expected) {
checkLogs(removeShellCall(logs), null, "logs.'${name}'", expected, null, 'expected')
}
def extractMainLogs(mainLogs, begin, end) {
// add \n in case log starts or ends with begin/end
def logs = '\n' + mainLogs + '\n'
// count not allowed with older versions
//assert logs.count("\n${begin}\n").size() == 1
//assert logs.count("\n${end}\n").size() == 1
// use split to count
def parts_begin = logs.split(/\n${begin}\n/).size()
def parts_end = logs.split(/\n${end}\n/).size()
if (parts_begin != 2 || parts_end != 2) {
archiveStringArtifact("debug_extractMainLogs.txt", logs)
assert false, "parts_begin=${parts_begin} != 2 or parts_end=${parts_end} != 2 in debug_extractMainLogs.txt split by \\n${begin}\\n \\n${end}\\n"
}
return logs.replaceFirst(/(?s).*\n${begin}\n(.*\n)${end}\n.*/, /$1/)
}
// logs from node acquisition are not predictible (depend on node runtime availability)
def stripNodeLogs(logs, n) {
def begin = 'STRIP_NODE_LOG_START'
def end = 'STRIP_NODE_LOG_STOP'
// count not allowed with older versions
//assert logs.count("${begin}\n").size() == n
//assert logs.count("\n${end}\n").size() == n
// use split to count
def parts_begin = logs.split(/${begin}\n/).size()
def parts_end = logs.split(/${end}\n/).size()
if (parts_begin != n + 1 || parts_end != n + 1) {
archiveStringArtifact("debug_stripNodeLogs.txt", logs)
assert false, "parts_begin=${parts_begin} != ${n} + 1 or parts_end=${parts_end} != ${n} + 1 in debug_stripNodeLogs.txt split by ${begin}\\n ${end}\\n"
}
def regexSeparated = "(?s)\\[(one|two)\\] ${begin}((?!${begin}).)*?${end}\n"
def regexImbricated = "(?s)\\[(one|two)\\] ${begin}.*${end}\n(?!${end})"
return logs.replaceAll(/${regexSeparated}|${regexImbricated}/, '')
}
def removeTimestamps(logs) {
return logs.replaceAll(/(?m)^(?!<nested)(?!\[Pipeline\])(.*)\[[^\[\]]*\] (.*)$/, '$1$2')
}
def removeFilters(logs) {
return logs.replaceAll(/(?m)^\<nested branch \[.*\]>$\n/, '')
}
def removeShellCall(logs) {
return logs.replaceAll(/(?m)^.* Running shell script$\n/, '')
}
def expectedBranchLogs(expectedLogMap, key, branchInfo) {
if (expectedLogMap."${key}".size() == 0 ) {
return ''
}
assert expectedLogMap."${key}"[-1] == '\n'
def expected = expectedLogMap."${key}".substring(0, expectedLogMap."${key}".size() - 1).split('\n', -1).collect{
if (it.startsWith('<nested branch [')) {
return it
}
return "${branchInfo}${it}"
}.join('\n') + '\n'
return expected
}
def unsortedCompare(log1, log2) {
def sortedLog1 = log1.split('\n', -1).sort().join('\n')
def sortedLog2 = log2.split('\n', -1).sort().join('\n')
checkLogs(sortedLog1, null, 'sortedLog1', sortedLog2, null, 'sortedLog2')
}
def parseLogs(expectedLogMap, expectedLogMapWithoutStages, expectedLogMapWithDuplicates, begin, end) {
// 1/ archivelogs (for manual check)
// archive full logs
timestamps {
print 'before parsing and archiving consoleText.txt'
logparser.archiveLogsWithBranchInfo('consoleText.txt')
print 'after parsing and archiving consoleText.txt'
print 'before parsing and archiving branch0.txt'
logparser.archiveLogsWithBranchInfo('branch0.txt', [ filter: ['branch0'] ])
print 'after parsing and archiving branch0.txt'
print 'before parsing and archiving full.txt'
logparser.archiveLogsWithBranchInfo('full.txt', [ hidePipeline: false, hideVT100: false ])
print 'after parsing and archiving full.txt'
print 'before parsing and archiving fullNoStages.txt'
logparser.archiveLogsWithBranchInfo('fullNoStages.txt', [ showStages: false, hidePipeline: false, hideVT100: false ])
print 'after parsing and archiving fullNoStages.txt'
print 'before parsing and archiving branch2.txt'
logparser.archiveLogsWithBranchInfo('branch2.txt', [ filter: ['branch2'] ])
print 'after parsing and archiving branch2.txt'
print 'before parsing and archiving branch2NoNested.txt'
logparser.archiveLogsWithBranchInfo('branch2NoNested.txt', [ filter: ['branch2'], markNestedFiltered: false ])
print 'after parsing and archiving branch2NoNested.txt'
print 'before parsing and archiving branch2NoParent.txt'
logparser.archiveLogsWithBranchInfo('branch2NoParent.txt', [ filter: ['branch2'], showParents: false ])
print 'after parsing and archiving branch2NoParent.txt'
print 'before parsing and archiving branch21.txt'
logparser.archiveLogsWithBranchInfo('branch21.txt', [ filter: ['branch21'] ])
print 'after parsing and archiving branch21.txt'
print 'before parsing and archiving branch21NoParent.txt'
logparser.archiveLogsWithBranchInfo('branch21NoParent.txt', [ filter: ['branch21'], showParents: false ])
print 'after parsing and archiving branch21NoParent.txt'
print 'before parsing and archiving branch4.txt'
logparser.archiveLogsWithBranchInfo('branch4.txt', [ filter: ['branch4'] ])
print 'after parsing and archiving branch4.txt'
print 'before parsing and archiving branch4WithDuplicates.txt'
logparser.archiveLogsWithBranchInfo('branch4WithDuplicates.txt', [ filter: ['branch4'], mergeNestedDuplicates: false ])
print 'after parsing and archiving branch4WithDuplicates.txt'
}
// TODO check content of logs archived
// 2/ access logs programmatically using various options
// full logs
def fullLog = logparser.getLogsWithBranchInfo()
assert fullLog != '', 'failed to parse logs: full log cannot be empty'
// branch by branch
def logsNoBranch = logparser.getLogsWithBranchInfo(filter:[null])
def logsBranch0 = logparser.getLogsWithBranchInfo(filter:['branch0'])
def logsBranch1 = logparser.getLogsWithBranchInfo(filter:['branch1'])
def logsBranch2 = logparser.getLogsWithBranchInfo(filter:['branch2'])
def logsBranch21 = logparser.getLogsWithBranchInfo(filter:['branch21'])
def logsBranch22 = logparser.getLogsWithBranchInfo(filter:['branch22'])
def logsBranch3 = logparser.getLogsWithBranchInfo(filter:['branch3'])
def logsBranch4 = logparser.getLogsWithBranchInfo(filter:['branch4'])
def logsInit = logparser.getLogsWithBranchInfo(filter:['init'])
def logsEmpty = logparser.getLogsWithBranchInfo(filter:['empty'])
def logsEndl = logparser.getLogsWithBranchInfo(filter:['endl'])
def logsMain = logparser.getLogsWithBranchInfo(filter:['main'])
def logsBuild = logparser.getLogsWithBranchInfo(filter:['build'])
def logsTest = logparser.getLogsWithBranchInfo(filter:['test'])
def logsOne = logparser.getLogsWithBranchInfo(filter:['one'])
def logsTwo = logparser.getLogsWithBranchInfo(filter:['two'])
def logsS2b1 = logparser.getLogsWithBranchInfo(filter:['s2b1'])
def logsS2b2 = logparser.getLogsWithBranchInfo(filter:['s2b2'])
def logsStage1 = logparser.getLogsWithBranchInfo(filter:[ 'stage1' ])
def logsStage2 = logparser.getLogsWithBranchInfo(filter:[ 'stage2' ])
def logsStage3 = logparser.getLogsWithBranchInfo(filter:[ 'stage3' ])
// multiple branches
def logsBranchStar = logparser.getLogsWithBranchInfo(filter:[ 'branch.*' ])
def logsS2b1S2b2 = logparser.getLogsWithBranchInfo(filter:[ 's2b1', 's2b2' ])
def logsStar = logparser.getLogsWithBranchInfo(filter:[ '.*' ])
def logsStarWithoutStages = logparser.getLogsWithBranchInfo(filter:[ '.*' ], showStages:false)
def logsFullStar = logparser.getLogsWithBranchInfo(filter:[ null, '.*' ])
// stages
def logsNoBranchWithoutStages = logparser.getLogsWithBranchInfo(filter:[null], showStages:false)
def logsS2b1WithoutStages = logparser.getLogsWithBranchInfo(filter:[ 's2b1' ], showStages:false)
def logsS2b2WithoutStages = logparser.getLogsWithBranchInfo(filter:[ 's2b2' ], showStages:false)
// filter using parents
def logsBranch1InBranch2 = logparser.getLogsWithBranchInfo(filter:[ [ 'branch2', 'branch1' ] ])
def logsBranch1InAny = logparser.getLogsWithBranchInfo(filter:[ [ '.*', 'branch1' ] ])
// other options
def fullLogVT100 = logparser.getLogsWithBranchInfo([hideVT100:false])
def fullLogPipeline = logparser.getLogsWithBranchInfo([hidePipeline:false])
def fullLogPipelineVT100 = logparser.getLogsWithBranchInfo([hidePipeline:false, hideVT100:false])
def fullLogNoNest = logparser.getLogsWithBranchInfo([markNestedFiltered:false])
def logsBranch2NoNest = logparser.getLogsWithBranchInfo(filter:['branch2'], markNestedFiltered:false)
def logsBranch21NoParent = logparser.getLogsWithBranchInfo(filter:['branch21'], showParents:false)
def logsBranch2NoParent = logparser.getLogsWithBranchInfo(filter:['branch2'], showParents:false)
def logsBranch4WithDuplicates = logparser.getLogsWithBranchInfo(filter:['branch4'], mergeNestedDuplicates:false)
// archive the raw buffers for debug
archiveStringArtifact("dump/fullLog.txt", fullLog)
archiveStringArtifact("dump/logsNoBranch.txt", logsNoBranch)
archiveStringArtifact("dump/logsBranch0.txt", logsBranch0)
archiveStringArtifact("dump/logsBranch1.txt", logsBranch1)
archiveStringArtifact("dump/logsBranch2.txt", logsBranch2)
archiveStringArtifact("dump/logsBranch21.txt", logsBranch21)
archiveStringArtifact("dump/logsBranch22.txt", logsBranch22)
archiveStringArtifact("dump/logsBranch3.txt", logsBranch3)
archiveStringArtifact("dump/logsBranch4.txt", logsBranch4)
archiveStringArtifact("dump/logsInit.txt", logsInit)
archiveStringArtifact("dump/logsEmpty.txt", logsEmpty)
archiveStringArtifact("dump/logsEndl.txt", logsEndl)
archiveStringArtifact("dump/logsMain.txt", logsMain)
archiveStringArtifact("dump/logsBuild.txt", logsBuild)
archiveStringArtifact("dump/logsTest.txt", logsTest)
archiveStringArtifact("dump/logsOne.txt", logsOne)
archiveStringArtifact("dump/logsTwo.txt", logsTwo)
archiveStringArtifact("dump/logsS2b1.txt", logsS2b1)
archiveStringArtifact("dump/logsS2b2.txt", logsS2b2)
archiveStringArtifact("dump/logsStage1.txt", logsStage1)
archiveStringArtifact("dump/logsStage2.txt", logsStage2)
archiveStringArtifact("dump/logsStage3.txt", logsStage3)
archiveStringArtifact("dump/logsBranchStar.txt", logsBranchStar)
archiveStringArtifact("dump/logsS2b1S2b2.txt", logsS2b1S2b2)
archiveStringArtifact("dump/logsStar.txt", logsStar)
archiveStringArtifact("dump/logsStarWithoutStages.txt", logsStarWithoutStages)
archiveStringArtifact("dump/logsFullStar.txt", logsFullStar)
archiveStringArtifact("dump/logsNoBranchWithoutStages.txt", logsNoBranchWithoutStages)
archiveStringArtifact("dump/logsS2b1WithoutStages.txt", logsS2b1WithoutStages)
archiveStringArtifact("dump/logsS2b2WithoutStages.txt", logsS2b2WithoutStages)
archiveStringArtifact("dump/logsBranch1InBranch2.txt", logsBranch1InBranch2)
archiveStringArtifact("dump/logsBranch1InAny.txt", logsBranch1InAny)
archiveStringArtifact("dump/fullLogVT100.txt", fullLogVT100)
archiveStringArtifact("dump/fullLogPipeline.txt", fullLogPipeline)
archiveStringArtifact("dump/fullLogPipelineVT100.txt", fullLogPipelineVT100)
archiveStringArtifact("dump/fullLogNoNest.txt", fullLogNoNest)
archiveStringArtifact("dump/logsBranch2NoNest.txt", logsBranch2NoNest)
archiveStringArtifact("dump/logsBranch21NoParent.txt", logsBranch21NoParent)
archiveStringArtifact("dump/logsBranch2NoParent.txt", logsBranch2NoParent)
archiveStringArtifact("dump/logsBranch4WithDuplicates.txt", logsBranch4WithDuplicates)
// 3/ detect if timestamp is set for all pipelines
parallel \
'notimestamp': {
echo ''
},
'timestamp': {
timestamps {
echo ''
}
}
//print '"' + logparser.getLogsWithBranchInfo(filter:['notimestamp']) + '"'
//print '"' + logparser.getLogsWithBranchInfo(filter:['timestamp']) + '"'
def notimestampLog = logparser.getLogsWithBranchInfo(filter:['notimestamp'])
def timestampLog = logparser.getLogsWithBranchInfo(filter:['timestamp'])
// detect if global timestamp is configured at instance level
// either not configured
def noGlobalTimestamp = notimestampLog == '[notimestamp] \n'
// or configured
def globalTimestamp = notimestampLog ==~ /\[notimestamp\] \[[^\[\]]*\] \n/
// make sure they do not have the same value
// (if both are false something is wrong in the way we detected it)
assert noGlobalTimestamp != globalTimestamp, "failed to detect global timestamps status\nnotimestamp log:\n'''${notimestampLog}'''"
GLOBAL_TIMESTAMP = globalTimestamp
// now check that local timestamp always appears
def localTimestamp
if (noGlobalTimestamp) {
localTimestamp = timestampLog ==~ /\[timestamp\] \[[^\[\]]*\] \n/
} else {
// if globalTimestamp is set a warning appears on the first line
def plugin_warning = 'The timestamps step is unnecessary when timestamps are enabled for all Pipeline builds.'
localTimestamp = timestampLog ==~ /\[timestamp\] \[[^\[\]]*\] ${plugin_warning}\n\[timestamp\] \[[^\[\]]*\] \n/
}
assert localTimestamp == true, "failed to detect local timestamps\nlocal timestamp log:\n'''${timestampLog}'''"
// 3.5/ strip logs accordingly
if (globalTimestamp) {
fullLog = removeTimestamps(fullLog)
logsNoBranch = removeTimestamps(logsNoBranch)
logsBranch0 = removeTimestamps(logsBranch0)
logsBranch1 = removeTimestamps(logsBranch1)
logsBranch2 = removeTimestamps(logsBranch2)
logsBranch21 = removeTimestamps(logsBranch21)
logsBranch22 = removeTimestamps(logsBranch22)
logsBranch3 = removeTimestamps(logsBranch3)
logsBranch4 = removeTimestamps(logsBranch4)
logsInit = removeTimestamps(logsInit)
logsEmpty = removeTimestamps(logsEmpty)
logsEndl = removeTimestamps(logsEndl)
logsMain = removeTimestamps(logsMain)
logsBuild = removeTimestamps(logsBuild)
logsTest = removeTimestamps(logsTest)
logsOne = removeTimestamps(logsOne)
logsTwo = removeTimestamps(logsTwo)
logsS2b1 = removeTimestamps(logsS2b1)
logsS2b2 = removeTimestamps(logsS2b2)
logsStage1 = removeTimestamps(logsStage1)
logsStage2 = removeTimestamps(logsStage2)
logsStage3 = removeTimestamps(logsStage3)
logsBranchStar = removeTimestamps(logsBranchStar)
logsS2b1S2b2 = removeTimestamps(logsS2b1S2b2)
logsStar = removeTimestamps(logsStar)
logsStarWithoutStages = removeTimestamps(logsStarWithoutStages)
logsFullStar = removeTimestamps(logsFullStar)
logsNoBranchWithoutStages = removeTimestamps(logsNoBranchWithoutStages)
logsS2b1WithoutStages = removeTimestamps(logsS2b1WithoutStages)
logsS2b2WithoutStages = removeTimestamps(logsS2b2WithoutStages)
logsBranch1InBranch2 = removeTimestamps(logsBranch1InBranch2)
logsBranch1InAny = removeTimestamps(logsBranch1InAny)
fullLogVT100 = removeTimestamps(fullLogVT100)
fullLogPipeline = removeTimestamps(fullLogPipeline)
fullLogPipelineVT100 = removeTimestamps(fullLogPipelineVT100)
fullLogNoNest = removeTimestamps(fullLogNoNest)
logsBranch2NoNest = removeTimestamps(logsBranch2NoNest)
logsBranch21NoParent = removeTimestamps(logsBranch21NoParent)
logsBranch2NoParent = removeTimestamps(logsBranch2NoParent)
logsBranch4WithDuplicates = removeTimestamps(logsBranch4WithDuplicates)
// archive the raw buffers for debug
archiveStringArtifact("dump/removeTimestamps/fullLog.txt", fullLog)
archiveStringArtifact("dump/removeTimestamps/logsNoBranch.txt", logsNoBranch)
archiveStringArtifact("dump/removeTimestamps/logsBranch0.txt", logsBranch0)
archiveStringArtifact("dump/removeTimestamps/logsBranch1.txt", logsBranch1)
archiveStringArtifact("dump/removeTimestamps/logsBranch2.txt", logsBranch2)
archiveStringArtifact("dump/removeTimestamps/logsBranch21.txt", logsBranch21)
archiveStringArtifact("dump/removeTimestamps/logsBranch22.txt", logsBranch22)
archiveStringArtifact("dump/removeTimestamps/logsBranch3.txt", logsBranch3)
archiveStringArtifact("dump/removeTimestamps/logsBranch4.txt", logsBranch4)
archiveStringArtifact("dump/removeTimestamps/logsInit.txt", logsInit)
archiveStringArtifact("dump/removeTimestamps/logsEmpty.txt", logsEmpty)
archiveStringArtifact("dump/removeTimestamps/logsEndl.txt", logsEndl)
archiveStringArtifact("dump/removeTimestamps/logsMain.txt", logsMain)
archiveStringArtifact("dump/removeTimestamps/logsBuild.txt", logsBuild)
archiveStringArtifact("dump/removeTimestamps/logsTest.txt", logsTest)
archiveStringArtifact("dump/removeTimestamps/logsOne.txt", logsOne)
archiveStringArtifact("dump/removeTimestamps/logsTwo.txt", logsTwo)
archiveStringArtifact("dump/removeTimestamps/logsS2b1.txt", logsS2b1)
archiveStringArtifact("dump/removeTimestamps/logsS2b2.txt", logsS2b2)
archiveStringArtifact("dump/removeTimestamps/logsStage1.txt", logsStage1)
archiveStringArtifact("dump/removeTimestamps/logsStage2.txt", logsStage2)
archiveStringArtifact("dump/removeTimestamps/logsStage3.txt", logsStage3)
archiveStringArtifact("dump/removeTimestamps/logsBranchStar.txt", logsBranchStar)
archiveStringArtifact("dump/removeTimestamps/logsS2b1S2b2.txt", logsS2b1S2b2)
archiveStringArtifact("dump/removeTimestamps/logsStar.txt", logsStar)
archiveStringArtifact("dump/removeTimestamps/logsStarWithoutStages.txt", logsStarWithoutStages)
archiveStringArtifact("dump/removeTimestamps/logsFullStar.txt", logsFullStar)
archiveStringArtifact("dump/removeTimestamps/logsNoBranchWithoutStages.txt", logsNoBranchWithoutStages)
archiveStringArtifact("dump/removeTimestamps/logsS2b1WithoutStages.txt", logsS2b1WithoutStages)
archiveStringArtifact("dump/removeTimestamps/logsS2b2WithoutStages.txt", logsS2b2WithoutStages)
archiveStringArtifact("dump/removeTimestamps/logsBranch1InBranch2.txt", logsBranch1InBranch2)
archiveStringArtifact("dump/removeTimestamps/logsBranch1InAny.txt", logsBranch1InAny)
archiveStringArtifact("dump/removeTimestamps/fullLogVT100.txt", fullLogVT100)
archiveStringArtifact("dump/removeTimestamps/fullLogPipeline.txt", fullLogPipeline)
archiveStringArtifact("dump/removeTimestamps/fullLogPipelineVT100.txt", fullLogPipelineVT100)
archiveStringArtifact("dump/removeTimestamps/fullLogNoNest.txt", fullLogNoNest)
archiveStringArtifact("dump/removeTimestamps/logsBranch2NoNest.txt", logsBranch2NoNest)
archiveStringArtifact("dump/removeTimestamps/logsBranch21NoParent.txt", logsBranch21NoParent)
archiveStringArtifact("dump/removeTimestamps/logsBranch2NoParent.txt", logsBranch2NoParent)
archiveStringArtifact("dump/removeTimestamps/logsBranch4WithDuplicates.txt", logsBranch4WithDuplicates)
}
// then strip node logs
logsOne = stripNodeLogs(logsOne, 1)
logsTwo = stripNodeLogs(logsTwo, 1)
logsStar = stripNodeLogs(logsStar, 2)
logsStarWithoutStages = stripNodeLogs(logsStarWithoutStages, 2)
logsFullStar = stripNodeLogs(logsFullStar, 2)
archiveStringArtifact("dump/stripNodeLogs/logsOne.txt", logsOne)
archiveStringArtifact("dump/stripNodeLogs/logsTwo.txt", logsTwo)
archiveStringArtifact("dump/stripNodeLogs/logsStar.txt", logsStar)
archiveStringArtifact("dump/stripNodeLogs/logsStarWithoutStages.txt", logsStarWithoutStages)
archiveStringArtifact("dump/stripNodeLogs/logsFullStar.txt", logsFullStar)
// 4/ check log content
// check each branch
checkBranchLogs(extractMainLogs(logsNoBranch, begin, end), 'null', expectedLogMap.'null')
checkBranchLogs(logsBranch0, 'branch0', expectedBranchLogs(expectedLogMap, 'branch0', '[branch0] '))
checkBranchLogs(logsBranch1, 'branch1',
expectedBranchLogs(expectedLogMap, 'branch1', '[branch1] ') +
expectedBranchLogs(expectedLogMap, 'branch2.branch1', '[branch2] [branch1] ')
)
checkBranchLogs(logsBranch2, 'branch2', expectedBranchLogs(expectedLogMap, 'branch2', '[branch2] '))
checkBranchLogs(logsBranch21, 'branch21', expectedBranchLogs(expectedLogMap, 'branch2.branch21', '[branch2] [branch21] '))
checkBranchLogs(logsBranch22, 'branch22', expectedBranchLogs(expectedLogMap, 'branch2.branch22', '[branch2] [branch22] '))
checkBranchLogs(logsBranch3, 'branch3', expectedBranchLogs(expectedLogMap, 'branch3', '[branch3] '))
checkBranchLogs(logsBranch4, 'branch4', expectedBranchLogs(expectedLogMap, 'branch4', '[branch4] '))
checkBranchLogs(logsInit, 'init', expectedBranchLogs(expectedLogMap, 'init', '[init] '))
checkBranchLogs(logsEmpty, 'empty', expectedBranchLogs(expectedLogMap, 'empty', '[empty] '))
checkBranchLogs(logsEndl, 'endl', expectedBranchLogs(expectedLogMap, 'endl', '[endl] '))
checkBranchLogs(logsMain, 'main', expectedBranchLogs(expectedLogMap, 'main', '[main] '))
checkBranchLogs(logsBuild, 'build', expectedBranchLogs(expectedLogMap, 'main.build', '[main] [build] '))
checkBranchLogs(logsTest, 'test', expectedBranchLogs(expectedLogMap, 'main.test', '[main] [test] '))
checkBranchLogs(logsOne, 'one', expectedBranchLogs(expectedLogMap, 'one', '[one] '))
checkBranchLogs(logsTwo, 'two', expectedBranchLogs(expectedLogMap, 'two', '[two] '))
checkBranchLogs(logsS2b1, 's2b1', expectedBranchLogs(expectedLogMap, 'stage2.s2b1', '[stage2] [s2b1] '))
checkBranchLogs(logsS2b2, 's2b2', expectedBranchLogs(expectedLogMap, 'stage2.s2b2', '[stage2] [s2b2] '))
checkBranchLogs(logsStage1, 'stage1', expectedBranchLogs(expectedLogMap, 'stage1', '[stage1] '))
checkBranchLogs(logsStage2, 'stage2', expectedBranchLogs(expectedLogMap, 'stage2', '[stage2] '))
checkBranchLogs(logsStage3, 'stage3', expectedBranchLogs(expectedLogMap, 'stage2.stage3', '[stage2] [stage3] '))
checkBranchLogs(extractMainLogs(logsNoBranchWithoutStages, begin, end), 'null', expectedLogMapWithoutStages.'null')
checkBranchLogs(logsS2b1WithoutStages, 's2b1', expectedBranchLogs(expectedLogMapWithoutStages, 's2b1', '[s2b1] '))
checkBranchLogs(logsS2b2WithoutStages, 's2b2', expectedBranchLogs(expectedLogMapWithoutStages, 's2b2', '[s2b2] '))
checkBranchLogs(logsBranch4WithDuplicates, 'branch4', expectedBranchLogs(expectedLogMapWithDuplicates, 'branch4', '[branch4] [branch4] '))
checkBranchLogs(logsBranch1InBranch2, 'branch1', expectedBranchLogs(expectedLogMap, 'branch2.branch1', '[branch2] [branch1] '))
checkBranchLogs(logsBranch1InAny, 'branch1', expectedBranchLogs(expectedLogMap, 'branch2.branch1', '[branch2] [branch1] '))
// check full logs
print 'checking fullLog contain the same lines as each branch (different order)'
unsortedCompare(
stripNodeLogs(extractMainLogs(fullLog, begin, end), 2),
removeFilters(
extractMainLogs(logsNoBranch, begin, end) +
logsBranch0 +
logsBranch1 +
logsBranch2 +
logsBranch21 +
logsBranch22 +
logsBranch3 +
logsBranch4 +
logsInit +
logsEmpty +
logsEndl +
logsMain +
logsBuild +
logsTest +
logsOne +
logsTwo +
logsS2b1 +
logsS2b2 +
logsStage1 +
logsStage2 +
logsStage3
)
)
// check multiple branches
print 'checking logsBranchStar contain the same lines as each branch* and main thread (different order)'
unsortedCompare(
logsBranchStar,
removeFilters(
logsBranch0 +
logsBranch1 +
logsBranch2 +
logsBranch21 +
logsBranch22 +
logsBranch3 +
logsBranch4
)
)
print 'checking logsS2b1S2b2 contain the same lines as branches s2b1 and s2b2 (different order)'
unsortedCompare(
logsS2b1S2b2,
removeFilters(
logsS2b1 +
logsS2b2
)
)
print 'checking logsStarWithoutStages contain the same lines as each branch (different order)'
unsortedCompare(
logsStarWithoutStages,
removeFilters(
logsBranch0 +
logsBranch1 +
logsBranch2 +
logsBranch21 +
logsBranch22 +
logsBranch3 +
logsBranch4 +
logsInit +
logsEmpty +
logsEndl +
logsMain +
logsBuild +
logsTest +
logsOne +
logsTwo +
logsS2b1WithoutStages +
logsS2b2WithoutStages
)
)
checkLogs(extractMainLogs(logsFullStar, begin, end), null, 'logsFullStar', stripNodeLogs(extractMainLogs(fullLog, begin, end), 2), null, 'fullLog')
// check other options
assert fullLogVT100 ==~ /(?s).*\x1B\[8m.*?\x1B\[0m.*/
assert fullLog !=~ /(?s).*\x1B\[8m.*?\x1B\[0m.*/
assert fullLogVT100.replaceAll(/\x1B\[8m.*?\x1B\[0m/, '') == fullLog
assert fullLogPipeline ==~ /(?s).*\[Pipeline\] .*/
assert fullLog !=~ /(?s).*\[Pipeline\] .*/
checkLogs(fullLogPipeline.replaceAll(/(?m)^\[Pipeline\] .*$\n/, ''), null, 'fullLogPipeline without pipeline', fullLog, null, 'fullLog')
assert fullLogPipelineVT100 ==~ /(?s).*\x1B\[8m.*?\x1B\[0m.*/
checkLogs(fullLogPipelineVT100.replaceAll(/\x1B\[8m.*?\x1B\[0m/, '').replaceAll(/(?m)^\[Pipeline\] .*$\n/, ''), null, 'fullLogPipelineVT100 without pipeline', fullLog, null, 'fullLog')
checkLogs(fullLogNoNest, null, 'fullLogNoNest', fullLog, null, 'fullLog')
assert logsBranch2NoNest !=~ /(?s).*\<nested branch \[.*\]>.*/
assert logsBranch2 ==~ /(?s).*\<nested branch \[.*\]>.*/
checkLogs(logsBranch2NoNest, null, 'logsBranch2NoNest', removeFilters(logsBranch2), null, 'removeFilters(logsBranch2)')
checkBranchLogs(logsBranch21NoParent, 'branch21', expectedBranchLogs(expectedLogMap, 'branch2.branch21', '[branch21] '))
checkLogs(logsBranch2NoParent, null, 'logsBranch2NoParent', expectedBranchLogs(expectedLogMap, 'branch2', '[branch2] ').replace('<nested branch [branch2] [branch', '<nested branch [branch'), null, 'expected')
}
def printUrls(check) {
def bou
def psu
timestamps {
print 'before getBlueOceanUrls()'
bou = logparser.getBlueOceanUrls()
print 'after getBlueOceanUrls()'
print 'before getPipelineStepsUrls()'
psu = logparser.getPipelineStepsUrls()
print 'after getPipelineStepsUrls()'
}
if (check) {
[ bou, psu ].each {
assert it.findAll{ it.parent == null }.size() == 1
// check expected steps
assert it.findAll{ it.name == 'branch0' }.size() == 1
assert it.findAll{ it.name == 'branch1' }.size() == 2
assert it.findAll{ it.name == 'branch2' }.size() == 1
assert it.findAll{ it.name == 'branch21' }.size() == 1
assert it.findAll{ it.name == 'branch22' }.size() == 1
assert it.findAll{ it.name == 'branch3' }.size() == 1
assert it.findAll{ it.name == 'init' }.size() == 1
assert it.findAll{ it.name == 'empty' }.size() == 1
assert it.findAll{ it.name == 'endl' }.size() == 1
assert it.findAll{ it.name == 'main' }.size() == 1
assert it.findAll{ it.name == 'build' }.size() == 1
assert it.findAll{ it.name == 'test' }.size() == 1
assert it.findAll{ it.name == 'one' }.size() == 1
assert it.findAll{ it.name == 'two' }.size() == 1
assert it.findAll{ it.name == 's2b1' }.size() == 1
assert it.findAll{ it.name == 's2b2' }.size() == 1
assert it.findAll{ it.name == 'timestamp' }.size() == 1
assert it.findAll{ it.name == 'notimestamp' }.size() == 1
// check expected stages
assert it.findAll{ it.name == 'stage1' }.size() == 1
assert it.findAll{ it.name == 'stage1' }.findAll{ it.stage }.size() == 1
assert it.findAll{ it.stage }.findAll{ it.name == 'stage1' }.size() == 1
assert it.findAll{ it.name == 'stage2' }.size() == 1
assert it.findAll{ it.name == 'stage2' }.findAll{ it.stage }.size() == 1
assert it.findAll{ it.stage }.findAll{ it.name == 'stage2' }.size() == 1
assert it.findAll{ it.name == 'stage3' }.size() == 1
assert it.findAll{ it.name == 'stage3' }.findAll{ it.stage }.size() == 1
assert it.findAll{ it.stage }.findAll{ it.name == 'stage3' }.size() == 1
def stagesBeforeLogparserTests = 0
assert it.findAll{ it.stage }.size() == stagesBeforeLogparserTests + 3, it.findAll{ it.stage }.collect { it.name }
assert it.findAll{ it.name != null }.size() == stagesBeforeLogparserTests + 3 + 21, it.findAll{ it.name != null }.collect { it.name }
// check nested steps and stages
[ [ 'branch21', 'branch2' ], [ 'branch22', 'branch2' ], [ 's2b1', 'stage2' ], [ 's2b2', 'stage2' ], [ 'stage1', null ] ].each{ lit ->
def st = lit[0]
def exp = lit[1]
def parent = null
def parentName = null
def found = false
assert it.findAll{ it.name == st }.size() == 1, "${st} ${exp}"
it.findAll{ it.name == st }.each{ parent = it.parent }
while(!found) {
assert it.findAll{ it.id == parent }.size() == 1
it.findAll{ it.id == parent }.each{
if (it.name != null || it.parent == null) {
found = true
assert it.name == exp
} else {
parent = it.parent
}
}
}
}
// test getBranches
def getBranches = logparser.getBranches()
def getBranchesWithDuplicates = logparser.getBranches([ mergeNestedDuplicates: false ])
def getBranchesWithoutStages = logparser.getBranches([ showStages: false ])
def getBranch21 = logparser.getBranches([ filter: [ 'branch21' ] ])
def getBranch1 = logparser.getBranches([ filter: [ 'branch1' ] ])
def getNestedBranch1 = logparser.getBranches([ filter: [ [ '.*', 'branch1' ] ] ])
def getBranch0And2 = logparser.getBranches([ filter: [ 'branch0', 'branch2' ] ])
assert getBranches == [
[null],
['branch0'],
['branch1'],
['branch2'],
['branch2', 'branch21'],
['branch2', 'branch22'],
['branch2', 'branch1'],
['branch3'],
['branch4'],
['init'],
['empty'],
['endl'],
['main'],
['main', 'build'],
['main', 'test'],
['one'],
['two'],
['stage1'],
['stage2'],
['stage2', 'stage3'],
['stage2', 's2b1'],
['stage2', 's2b2'],
['notimestamp'],
['timestamp']
], getBranches
assert getBranchesWithDuplicates == [
[null],
['branch0'],
['branch1'],
['branch2'],
['branch2', 'branch21'],
['branch2', 'branch22'],
['branch2', 'branch1'],
['branch3'],
['branch4'],
['branch4', 'branch4'],
['init'],
['empty'],
['endl'],
['main'],
['main', 'build'],
['main', 'test'],
['one'],
['two'],
['stage1'],
['stage2'],
['stage2', 'stage3'],
['stage2', 's2b1'],
['stage2', 's2b2'],
['notimestamp'],
['timestamp']
], getBranchesWithDuplicates