harness_20230721.diff
new/src/com/goldencode/harness/BarrierElement.java 2023-07-21 09:28:30 +0000 | ||
---|---|---|
2 | 2 |
** Module : BarrierElement.java |
3 | 3 |
** Abstract : represents a barrier element in a larger queue |
4 | 4 |
** |
5 |
** Copyright (c) 2009, Golden Code Development Corporation. |
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- -----------------------Description------------------------ |
8 | 8 |
** 001 GES 20090318 Represents a barrier element in a larger queue. |
9 |
** 002 TJD 20230119 Allow restarting of Driver threads |
|
9 | 10 |
*/ |
10 | 11 | |
11 | 12 |
/* |
... | ... | |
113 | 114 |
{ |
114 | 115 |
return null; |
115 | 116 |
} |
117 | ||
118 |
@Override |
|
119 |
public boolean isIgnored() |
|
120 |
{ |
|
121 |
return false; |
|
122 |
} |
|
116 | 123 |
} |
new/src/com/goldencode/harness/ConcurrentElements.java 2023-07-21 09:28:40 +0000 | ||
---|---|---|
2 | 2 |
** Module : ConcurrentElements.java |
3 | 3 |
** Abstract : represents multiple elements which must execute simultaneously |
4 | 4 |
** |
5 |
** Copyright (c) 2009, Golden Code Development Corporation. |
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- -----------------------Description------------------------ |
8 | 8 |
** 001 GES 20090318 Represents multiple elements which must execute |
9 | 9 |
** simultaneously. |
10 |
** 002 TJD 20230119 Allow restarting of Driver threads |
|
10 | 11 |
*/ |
11 | 12 | |
12 | 13 |
/* |
... | ... | |
215 | 216 |
|
216 | 217 |
return element; |
217 | 218 |
} |
219 |
@Override |
|
220 |
public boolean isIgnored() |
|
221 |
{ |
|
222 |
return false; |
|
223 |
} |
|
224 | ||
218 | 225 |
} |
new/src/com/goldencode/harness/Driver.java 2023-07-21 09:29:06 +0000 | ||
---|---|---|
2 | 2 |
** Module : Driver.java |
3 | 3 |
** Abstract : thread that reads tests from a job queue and executes them |
4 | 4 |
** |
5 |
** Copyright (c) 2009-2022, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------- |
8 | 8 |
** 001 GES 20090122 Thread that reads tests from a job queue and executes them. |
... | ... | |
14 | 14 |
** 005 TJD 20220808 Changed log format, added option to abort TestSet |
15 | 15 |
** 006 TJD 20220815 Abort anytime if RC failed |
16 | 16 |
** 007 TJD 20220817 Implement test skip list feature, logging tweaks |
17 |
** 008 TJD 20220820 Terminate thread when in backout fails to prevent further failures |
|
18 |
** 009 TJD 20230119 Allow restarting of Driver threads |
|
17 | 19 |
*/ |
18 | 20 | |
19 | 21 |
/* |
... | ... | |
55 | 57 |
private JobQueue<Test> queue = null; |
56 | 58 |
|
57 | 59 |
/** Object to notify when complete. */ |
58 |
private CountDownLatch latch = null;
|
|
60 |
private Phaser phaser = null;
|
|
59 | 61 | |
60 | 62 |
/** Mapping of test executors based on their type. */ |
61 | 63 |
private Map<Class<TestExecutor>, TestExecutor> executors; |
... | ... | |
75 | 77 |
* The driver's configurations. |
76 | 78 |
* @param queue |
77 | 79 |
* Job queue from which tests to be executed are obtained. |
78 |
* @param latch
|
|
80 |
* @param phaser
|
|
79 | 81 |
* Object to notify when complete. |
80 | 82 |
* @param rc |
81 | 83 |
* Object in which to store the details of non-testing failures. |
82 | 84 |
*/ |
83 | 85 |
public Driver(Map<String, SessionSettings> cfgs, |
84 | 86 |
JobQueue<Test> queue, |
85 |
CountDownLatch latch,
|
|
87 |
Phaser phaser,
|
|
86 | 88 |
FailureNotification rc) |
87 | 89 |
{ |
88 | 90 |
this.queue = queue; |
89 |
this.latch = latch;
|
|
91 |
this.phaser = phaser;
|
|
90 | 92 |
this.cfgs = cfgs; |
91 | 93 |
this.rc = rc; |
92 | 94 |
} |
... | ... | |
109 | 111 |
{ |
110 | 112 |
try |
111 | 113 |
{ |
112 |
LogHelper.finer(this.getName() + " Start");
|
|
114 |
LogHelper.finer("DRIVERSTART|" + this.getName());
|
|
113 | 115 |
executors = buildExecutors(cfgs, rc); |
114 | 116 |
|
115 | 117 |
if (!pre()) |
... | ... | |
127 | 129 |
|
128 | 130 |
if (test == null) |
129 | 131 |
{ |
132 |
LogHelper.finer(this.getName() + " Queue is empty, exiting"); |
|
130 | 133 |
break; |
131 | 134 |
} |
132 | 135 |
|
... | ... | |
136 | 139 |
break; |
137 | 140 |
} |
138 | 141 |
// check it test is to be skipped |
139 |
if (Harness.isTestOnSkipList(test.getName())) |
|
142 |
if (Harness.isTestOnSkipList(test.getName()) || !Harness.isTestOnWhiteList(test.getName()))
|
|
140 | 143 |
{ |
141 | 144 |
// Skipped tests are considered as passed |
142 | 145 |
LogHelper.info("Skipping test: "+ test.getName()); |
... | ... | |
145 | 148 |
} |
146 | 149 |
|
147 | 150 |
test.setDriver(this); |
148 |
LogHelper.fine(this.getName() + "[" + test.getName() + "/" + test.getDependency().toString() + "] execute"); |
|
151 |
LogHelper.finer("DRIVER|" + this.getName() + "|" + test.getName() + "/" |
|
152 |
+ test.getDependency().toString() + "| execute"); |
|
149 | 153 |
test.execute(); |
150 | 154 |
|
151 | 155 |
Status status = test.getStatus(); |
152 |
LogHelper.fine(this.getName() + "[" + test.getName() + "] " + status.toString()
|
|
153 |
+ (status.equals(Status.FAILED)?" reason: " + test.getReason():""));
|
|
156 |
LogHelper.finer("RESULT|" + this.getName() + "|" + test.getName() + "|" + status.toString()
|
|
157 |
+ "|" + (status.equals(Status.FAILED)?" reason: " + test.getReason():""));
|
|
154 | 158 |
if (status == Status.FAILED) |
155 | 159 |
{ |
156 | 160 |
FailureMode fail = test.getFailureMode(); |
... | ... | |
170 | 174 |
{ |
171 | 175 |
backout.setDriver(this); |
172 | 176 |
backout.execute(); |
177 |
Status backoutStatus = backout.getStatus(); |
|
178 |
if (backoutStatus != Status.PASSED && Harness.isDebugMode()) |
|
179 |
{ |
|
180 |
LogHelper.warn("BACKOUTFAIL|" + this.getName() + "|" + test.getName() |
|
181 |
+ "|" + test.getDependency().toString() |
|
182 |
+ "| Backout failed or not run, terminating thread"); |
|
183 |
break loop; |
|
184 |
} |
|
173 | 185 |
} |
174 | 186 |
|
175 | 187 |
break; |
... | ... | |
179 | 191 |
} |
180 | 192 |
catch (Throwable e) |
181 | 193 |
{ |
182 |
LogHelper.warn(this.getName() + " Exception:", e);
|
|
194 |
LogHelper.warn("DRIVERERROR|" + this.getName() + "| Exception:", e);
|
|
183 | 195 |
} |
184 | 196 |
finally |
185 | 197 |
{ |
186 |
LogHelper.finer(this.getName() + " End");
|
|
198 |
LogHelper.finer("DRIVEREND|" + this.getName() + "| End");
|
|
187 | 199 |
post(); |
188 | 200 |
|
189 |
latch.countDown();
|
|
201 |
phaser.arriveAndDeregister();
|
|
190 | 202 |
} |
191 | 203 |
} |
192 | 204 |
|
new/src/com/goldencode/harness/Harness.java 2023-07-21 09:32:12 +0000 | ||
---|---|---|
2 | 2 |
** Module : Harness.java |
3 | 3 |
** Abstract : test execution master driver |
4 | 4 |
** |
5 |
** Copyright (c) 2008-2022, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2008-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------- |
8 | 8 |
** 001 GES 20090126 Test execution master driver. |
... | ... | |
22 | 22 |
** 010 TJD 20220817 Implement performance test mode and some logging tweaks |
23 | 23 |
** 011 TJD 20220817 Added missing javadoc, include completionMsg |
24 | 24 |
** 012 TJD 20220819 Allow configuring max timeout for single test that require idle waiting |
25 |
** 013 TJD 20230119 Timeout multiplier and trace mode support |
|
26 |
** 014 TJD 20230119 Allow restarting of Driver threads |
|
27 |
** 015 TJD 20230621 Tests white list support |
|
25 | 28 |
*/ |
26 | 29 | |
27 | 30 |
/* |
... | ... | |
81 | 84 |
/** Performance mode enabled flag, enabled with "-m" option, default *false* */ |
82 | 85 |
private static boolean benchmarkMode = false; |
83 | 86 |
|
87 |
/** Global limit on number of threads */ |
|
88 |
private static double timeoutMultiplier = 1.0; |
|
89 |
|
|
84 | 90 |
/** Set of names of test to skip */ |
85 | 91 |
private static HashSet<String> skipFileSet = new HashSet<>(); |
86 | 92 |
|
87 | 93 |
/** Debug mode enabled flag, enabled with "-d" option, default *false* */ |
88 | 94 |
private static boolean debugMode = false; |
95 | ||
96 |
/** Debug mode enabled flag, enabled with "-d -d" option, default *false* */ |
|
97 |
private static boolean traceMode = false; |
|
98 |
/** requested maximum for number of parallel test */ |
|
99 |
private static int maximumParallelTests = Integer.MAX_VALUE; |
|
100 |
/** tests white list - tests names allowed to execute */ |
|
101 |
private static Set<String> testsListWhite = null; |
|
89 | 102 |
|
90 | 103 |
static |
91 | 104 |
{ |
... | ... | |
103 | 116 |
"", |
104 | 117 |
"-? = display this help screen", |
105 | 118 |
"-d = enable verbose output", |
119 |
"-d -d = enable even more verbose output", |
|
106 | 120 |
"-l <log_level> = set log level: WARN,INFO,FINE,FINER", |
121 |
"-g <integer > = timeout multiplier", |
|
122 |
"-q <integer > = maximum parallel TestSet, set 1 for sequential ", |
|
107 | 123 |
"-c = enable dumping reports on CTRL-C", |
108 | 124 |
"-x = abort anytime when RC fails", |
109 | 125 |
"-m [timeout] = enable performance test mode with optional user I/O wait timeout {60s}", |
126 |
"-f <test_list> = comma separated names of tests to be included in the whitelist", |
|
110 | 127 |
"-b <path_list> = specify a default set of baseline search", |
111 | 128 |
" paths; <path_list> is a list of one or more", |
112 | 129 |
" paths separated by the platform specific", |
... | ... | |
416 | 433 |
* -c = enable dump reports on CTRL-C |
417 | 434 |
* -m [timeout] = enable performance test mode with optional user I/O wait timeout {60s} |
418 | 435 |
* -x = abort anytime when RC fails, |
419 |
* -b <path_list> = specify a default set of baseline search |
|
436 |
* -f <test_list> = comma separated names of tests to be included in the whitelist |
|
437 |
* -b <path_list> = specify a default set of baseline search |
|
420 | 438 |
* paths; <path_list> is a list of one or more |
421 | 439 |
* paths separated by the platform specific |
422 | 440 |
* path separator character (e.g. on UNIX or |
423 | 441 |
* Linux this would be the colon ':') |
442 |
* -g <integer> = timeout multiplier", |
|
443 |
* -q <integer> = maximum parallel TestSet, set 1 for sequential ", |
|
424 | 444 |
* -e = force separate host/port/userid/password prompts |
425 | 445 |
* for each target system (the default is to only |
426 | 446 |
* prompt once and to use the same responses |
... | ... | |
511 | 531 |
|
512 | 532 |
break; |
513 | 533 |
case "d": |
514 |
// enable debug output |
|
515 |
LogHelper.enableDebug(); |
|
516 |
debugMode = true; |
|
517 |
LogHelper.info("Enable debug mode"); |
|
534 |
if (debugMode) |
|
535 |
{ |
|
536 |
// enable trace mode if debug mode is already enabled |
|
537 |
LogHelper.enableTrace(); |
|
538 |
traceMode = true; |
|
539 |
LogHelper.info("Enable trace mode"); |
|
540 |
} |
|
541 |
else |
|
542 |
{ |
|
543 |
// enable debug output |
|
544 |
LogHelper.enableDebug(); |
|
545 |
debugMode = true; |
|
546 |
LogHelper.info("Enable debug mode"); |
|
547 |
} |
|
518 | 548 |
break; |
519 | 549 |
case "s": |
520 | 550 |
// skip file |
... | ... | |
525 | 555 |
String skipFileName = args[++idx]; |
526 | 556 |
if ((skipFileName != null) && (skipFileName.length() > 0)) |
527 | 557 |
{ |
528 |
LogHelper.fine("Reading names of tests to skip from file: "+skipFileName);
|
|
558 |
LogHelper.fine("Reading names of tests to skip from file: " + skipFileName);
|
|
529 | 559 |
readSkipFile(skipFileName); |
530 | 560 |
} |
531 | 561 |
break; |
... | ... | |
534 | 564 |
failOnRCFailure = true; |
535 | 565 |
LogHelper.info("Enable immediate fail on any non-testing error mode"); |
536 | 566 |
break; |
567 |
case "f": |
|
568 |
if (idx == args.length - 1) |
|
569 |
{ |
|
570 |
syntax(ExitCode.MISSING_OPTION_DATA, null); |
|
571 |
} |
|
572 |
String testWhiteList = args[++idx]; |
|
573 |
testsListWhite = new HashSet<String>(); |
|
574 |
testsListWhite.addAll( Arrays.asList(testWhiteList.split(","))); |
|
575 |
break; |
|
576 |
case "q": |
|
577 |
// set maximum number of allowed parallel TestSets |
|
578 |
if (idx == args.length - 1) |
|
579 |
{ |
|
580 |
syntax(ExitCode.MISSING_OPTION_DATA, null); |
|
581 |
} |
|
582 |
String parallelTestSetsParam = args[++idx]; |
|
583 |
if ((parallelTestSetsParam != null) && (parallelTestSetsParam.length() > 0)) |
|
584 |
{ |
|
585 |
try |
|
586 |
{ |
|
587 |
maximumParallelTests = Integer.parseInt(parallelTestSetsParam); |
|
588 |
LogHelper.fine("Setting maximum number of allowed parallel TestSets: " + maximumParallelTests); |
|
589 |
} |
|
590 |
catch(NumberFormatException e) |
|
591 |
{ |
|
592 |
final String spec = "Invalid value for maximum number of allowed parallel TestSets"; |
|
593 |
syntax(ExitCode.MISSING_OPTION_DATA, String.format(spec, parallelTestSetsParam)); |
|
594 |
} |
|
595 |
} |
|
596 |
break; |
|
597 |
case "g": |
|
598 |
// set timeout multiplier |
|
599 |
if (idx == args.length - 1) |
|
600 |
{ |
|
601 |
syntax(ExitCode.MISSING_OPTION_DATA, null); |
|
602 |
} |
|
603 |
String timeoutMultiplierString = args[++idx]; |
|
604 |
if ((timeoutMultiplierString != null) && (timeoutMultiplierString.length() > 0)) |
|
605 |
{ |
|
606 |
try |
|
607 |
{ |
|
608 |
timeoutMultiplier = Double.parseDouble(timeoutMultiplierString); |
|
609 |
LogHelper.fine("Setting timeout multiplier: " + timeoutMultiplier); |
|
610 |
} |
|
611 |
catch(NumberFormatException e) |
|
612 |
{ |
|
613 |
final String spec = "Invalid value for timeout multiplier"; |
|
614 |
syntax(ExitCode.MISSING_OPTION_DATA, String.format(spec, timeoutMultiplierString)); |
|
615 |
} |
|
616 |
} |
|
617 |
break; |
|
537 | 618 |
case "l": |
538 | 619 |
// set log level from string |
539 | 620 |
if (idx == args.length - 1) |
... | ... | |
982 | 1063 |
} |
983 | 1064 |
|
984 | 1065 |
/** |
1066 |
* Return true if traceMode flag value. |
|
1067 |
* |
|
1068 |
* @return debugMode value. |
|
1069 |
*/ |
|
1070 |
public static boolean isTraceMode() |
|
1071 |
{ |
|
1072 |
return traceMode; |
|
1073 |
} |
|
1074 | ||
1075 |
/** |
|
985 | 1076 |
* Check if test identified by name is to be skipped |
986 | 1077 |
* @param name |
987 | 1078 |
* test name to be checked |
... | ... | |
1003 | 1094 |
} |
1004 | 1095 |
|
1005 | 1096 |
/** |
1097 |
* Return test timeout multiplier |
|
1098 |
* |
|
1099 |
* @return test timeout multiplier |
|
1100 |
*/ |
|
1101 |
public static int scaleTimeoutMultiplier(int timeout) |
|
1102 |
{ |
|
1103 |
boolean timeoutIsZero = timeout == 0; |
|
1104 |
timeout = (int) ((double) timeout * timeoutMultiplier); |
|
1105 |
if (timeout == 0 && !timeoutIsZero) |
|
1106 |
{ |
|
1107 |
return 1; |
|
1108 |
} |
|
1109 |
return timeout; |
|
1110 |
} |
|
1111 |
|
|
1112 |
/** |
|
1113 |
* Return requested maximum for number of parallel test |
|
1114 |
* |
|
1115 |
* @return requested maximum for number of parallel test |
|
1116 |
*/ |
|
1117 |
public static int getMaxParallelTests() |
|
1118 |
{ |
|
1119 |
return maximumParallelTests; |
|
1120 |
} |
|
1121 | ||
1122 |
/** |
|
1006 | 1123 |
* Generate a completion message that describes the length of time in |
1007 | 1124 |
* human readable terms. |
1008 | 1125 |
* |
... | ... | |
1072 | 1189 |
} |
1073 | 1190 |
} |
1074 | 1191 | |
1192 |
/** |
|
1193 |
* Check if a test with a given name is on whitelist |
|
1194 |
* @param testName |
|
1195 |
* name of test to check |
|
1196 |
* @return true if test with a given name is on whitelist |
|
1197 |
* or whitelist is not configured at all |
|
1198 |
*/ |
|
1199 |
public static boolean isTestOnWhiteList(String testName) |
|
1200 |
{ |
|
1201 |
return (testsListWhite == null || testsListWhite.contains(testName)); |
|
1202 |
} |
|
1203 | ||
1075 | 1204 |
} |
new/src/com/goldencode/harness/JobQueue.java 2023-07-21 09:27:54 +0000 | ||
---|---|---|
2 | 2 |
** Module : JobQueue.java |
3 | 3 |
** Abstract : queue tests and allow them to be dequeued based on dependencies |
4 | 4 |
** |
5 |
** Copyright (c) 2009-2022, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- -----------------------Description------------------------ |
8 | 8 |
** 001 GES 20090318 Queue tests and allow them to be dequeued based on |
9 | 9 |
** dependencies. |
10 | 10 |
** 002 TJD 20220809 Support for aborting the queue |
11 | 11 |
** 003 TJD 20220817 Implement performance test mode |
12 |
** 004 TJD 20230119 Allow restarting of Driver threads |
|
12 | 13 |
*/ |
13 | 14 | |
14 | 15 |
/* |
... | ... | |
52 | 53 |
/** Flag indicating queue abort was requested */ |
53 | 54 |
private final AtomicBoolean abort = new AtomicBoolean(false); |
54 | 55 |
|
56 |
/** Flag preventing starting new threads */ |
|
57 |
volatile private boolean isEmptyForNewThreads = false; |
|
58 |
|
|
55 | 59 |
/** |
56 | 60 |
* Construct an instance. |
57 | 61 |
* |
... | ... | |
97 | 101 |
synchronized (lock) |
98 | 102 |
{ |
99 | 103 |
ListIterator<SubQueue<E>> list = queue.listIterator(); |
100 |
|
|
104 |
int ignoredSubqueues = 0; |
|
101 | 105 |
// walk through all sub-queues |
102 | 106 |
while (list.hasNext()) |
103 | 107 |
{ |
... | ... | |
116 | 120 |
// do not go past any barrier sub-queues |
117 | 121 |
if (subQueue.isBarrier()) |
118 | 122 |
{ |
119 |
if (queue.indexOf(subQueue) == 0)
|
|
123 |
if (queue.indexOf(subQueue) == ignoredSubqueues)
|
|
120 | 124 |
{ |
121 | 125 |
// all previous sub-queues are finished, remove the |
122 | 126 |
// barrier and allow processing to continue |
... | ... | |
137 | 141 |
|
138 | 142 |
// reserve the next element and allow us to safely exit the |
139 | 143 |
// synchronized block |
140 |
ready.reserve(); |
|
141 |
|
|
142 |
break outer; |
|
144 |
if (ready.reserve()) |
|
145 |
{ |
|
146 |
break outer; |
|
147 |
} |
|
148 |
// if not ready - repeat the cycle until its ready |
|
149 |
} |
|
150 |
// check if subqueue can be ignored for this thread |
|
151 |
if (subQueue.isIgnored()) |
|
152 |
{ |
|
153 |
ignoredSubqueues ++; |
|
143 | 154 |
} |
144 | 155 |
} |
145 | 156 |
|
146 |
sz = queue.size(); |
|
157 |
sz = queue.size() - ignoredSubqueues;
|
|
147 | 158 |
} |
148 | 159 |
|
149 | 160 |
// no sub-queues are ready yet, the current thread must wait for an |
... | ... | |
167 | 178 |
break; |
168 | 179 |
} |
169 | 180 |
} |
181 |
else |
|
182 |
{ |
|
183 |
// if any of thread has reached here no new threads should be started |
|
184 |
isEmptyForNewThreads = true; |
|
185 |
} |
|
170 | 186 |
} |
171 | 187 |
|
172 | 188 |
// the dequeuing is intentionally done outside of the synchronized block |
... | ... | |
187 | 203 |
{ |
188 | 204 |
abort.set(true); |
189 | 205 |
} |
206 | ||
207 |
public boolean isEmpty() |
|
208 |
{ |
|
209 |
synchronized (lock) |
|
210 |
{ |
|
211 |
return (queue == null || (queue.size() == 0) || isEmptyForNewThreads); |
|
212 |
} |
|
213 |
} |
|
190 | 214 |
} |
new/src/com/goldencode/harness/PerThreadElement.java 2023-01-23 08:40:46 +0000 | ||
---|---|---|
8 | 8 |
** -#- -I- --Date-- -----------------------Description------------------------ |
9 | 9 |
** 001 GES 20090318 Represents a set of duplicate elements which are assigned |
10 | 10 |
** to a specific thread. |
11 |
** 002 TJD 20230119 Allow restarting of Driver threads |
|
11 | 12 |
*/ |
12 | 13 | |
13 | 14 |
/* |
... | ... | |
46 | 47 |
/** Reservation list. */ |
47 | 48 |
private final Map<Thread, E> reserved = new HashMap<Thread, E>(); |
48 | 49 |
|
50 |
/** Tasks pending recycling. */ |
|
51 |
private final Map<Thread, E> pendingRecycling = new HashMap<Thread, E>(); |
|
52 | ||
49 | 53 |
/** Already serviced list (each thread is only ever serviced once). */ |
50 | 54 |
private final Set<Thread> serviced = new HashSet<Thread>(); |
51 | 55 |
|
... | ... | |
75 | 79 |
public boolean isEmpty() |
76 | 80 |
{ |
77 | 81 |
boolean empty = false; |
78 |
|
|
79 |
synchronized (lock) |
|
82 |
synchronized(lock) |
|
80 | 83 |
{ |
81 |
empty = (queue.size() == 0); |
|
84 |
if (pendingRecycling.containsKey(Thread.currentThread())) |
|
85 |
{ |
|
86 |
// recycle test used by this thread |
|
87 |
queue.add(pendingRecycling.remove(Thread.currentThread())); |
|
88 |
} |
|
82 | 89 |
} |
83 |
|
|
90 |
// per thread elements are never empty and thus they are never removed from master queue |
|
91 |
// as they can be reused for restarting threads |
|
84 | 92 |
return empty; |
85 | 93 |
} |
86 | 94 |
|
... | ... | |
95 | 103 |
public boolean isReady() |
96 | 104 |
{ |
97 | 105 |
boolean prev = false; |
98 |
|
|
106 |
boolean isEmpty = false; |
|
99 | 107 |
synchronized (lock) |
100 | 108 |
{ |
101 | 109 |
prev = serviced.contains(Thread.currentThread()); |
110 |
isEmpty = queue.isEmpty(); |
|
102 | 111 |
} |
103 | 112 |
|
104 |
return !isEmpty() && !prev;
|
|
113 |
return !isEmpty && !prev; |
|
105 | 114 |
} |
106 | 115 |
|
107 | 116 |
/** |
... | ... | |
170 | 179 |
synchronized (lock) |
171 | 180 |
{ |
172 | 181 |
element = reserved.remove(Thread.currentThread()); |
182 |
pendingRecycling.put(Thread.currentThread(), element); |
|
173 | 183 |
} |
174 | 184 |
|
175 | 185 |
return element; |
176 | 186 |
} |
177 |
} |
|
187 |
|
|
188 |
/** |
|
189 |
* Reports if the subqueue can be ignored when checking if queue is empty |
|
190 |
* |
|
191 |
* @return <code>true</code> if the queue can be ignored. |
|
192 |
*/ |
|
193 |
@Override |
|
194 |
public boolean isIgnored() |
|
195 |
{ |
|
196 |
// once executed it can be ignored |
|
197 |
return !isReady(); |
|
198 |
}} |
new/src/com/goldencode/harness/Report.java 2023-07-21 09:33:46 +0000 | ||
---|---|---|
2 | 2 |
** Module : Report.java |
3 | 3 |
** Abstract : helpful base class for implementing a report |
4 | 4 |
** |
5 |
** Copyright (c) 2009-2017, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- -----------------------Description------------------------ |
8 | 8 |
** 001 GES 20090113 Helpful base class for implementing a report. |
9 | 9 |
** 002 CA 20170404 Add the failed test name in the result summary. |
10 |
** 003 TJD 20230119 Timeout multiplier and trace mode support |
|
10 | 11 |
*/ |
11 | 12 | |
12 | 13 |
/* |
... | ... | |
478 | 479 |
|
479 | 480 |
return num; |
480 | 481 |
} |
482 | ||
483 |
/** |
|
484 |
* Get the maximum number of milliseconds that this testable activity is allowed to run. |
|
485 |
* Valid for some of Tests only, -1 if not applicable |
|
486 |
* @return The maximum number of milliseconds. |
|
487 |
*/ |
|
488 |
@Override |
|
489 |
public long getMaxElapsed() |
|
490 |
{ |
|
491 |
return -1; |
|
492 |
} |
|
481 | 493 |
} |
new/src/com/goldencode/harness/Reportable.java 2023-07-21 09:33:57 +0000 | ||
---|---|---|
2 | 2 |
** Module : Reportable.java |
3 | 3 |
** Abstract : API for delegating the tracking of a testable activity |
4 | 4 |
** |
5 |
** Copyright (c) 2009-2021, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------- |
8 | 8 |
** 001 GES 20090113 API for delegating tracking of a testable activity. |
9 | 9 |
** 002 CA 20210906 The content for description and failure is wrapped only for web tests. |
10 |
** 003 TJD 20230119 Timeout multiplier and trace mode support |
|
10 | 11 |
*/ |
11 | 12 | |
12 | 13 |
/* |
... | ... | |
148 | 149 |
public long getElapsed(); |
149 | 150 |
|
150 | 151 |
/** |
152 |
* Get the maximum number of milliseconds that this testable activity is allowed to run. |
|
153 |
* Valid for some of Tests only, -1 if not applicable |
|
154 |
* @return The maximum number of milliseconds. |
|
155 |
*/ |
|
156 |
public long getMaxElapsed(); |
|
157 |
|
|
158 |
/** |
|
151 | 159 |
* Get the short name for the testable activity. |
152 | 160 |
* |
153 | 161 |
* @return A name of the testable activity. |
new/src/com/goldencode/harness/SequentialElements.java 2023-01-23 08:40:37 +0000 | ||
---|---|---|
7 | 7 |
** -#- -I- --Date-- -----------------------Description------------------------ |
8 | 8 |
** 001 GES 20090319 Represents elements to be processed in order on a single |
9 | 9 |
** thread. |
10 |
** 002 TJD 20230119 Allow restarting of Driver threads |
|
10 | 11 |
*/ |
11 | 12 | |
12 | 13 |
/* |
... | ... | |
215 | 216 |
} |
216 | 217 |
} |
217 | 218 |
} |
219 |
|
|
220 |
/** |
|
221 |
* Reports if the queue can be ignored, usually for given thread. |
|
222 |
* |
|
223 |
* @return <code>true</code> if the queue can be ignored. |
|
224 |
*/ |
|
225 |
@Override |
|
226 |
public boolean isIgnored() |
|
227 |
{ |
|
228 |
return false; |
|
229 |
} |
|
218 | 230 |
} |
new/src/com/goldencode/harness/SingleElement.java 2023-01-23 08:40:28 +0000 | ||
---|---|---|
2 | 2 |
** Module : SingleElement.java |
3 | 3 |
** Abstract : represents a single element in a larger queue |
4 | 4 |
** |
5 |
** Copyright (c) 2009, Golden Code Development Corporation. |
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- -----------------------Description------------------------ |
8 | 8 |
** 001 GES 20090318 Represents a single element in a larger queue. |
9 |
** 002 TJD 20230119 Allow restarting of Driver threads |
|
9 | 10 |
*/ |
10 | 11 | |
11 | 12 |
/* |
... | ... | |
157 | 158 |
{ |
158 | 159 |
this.element = element; |
159 | 160 |
} |
161 |
|
|
162 |
/** |
|
163 |
* Reports if the queue can be ignored, usually for given thread. |
|
164 |
* |
|
165 |
* @return <code>true</code> if the queue can be ignored. |
|
166 |
*/ |
|
167 |
@Override |
|
168 |
public boolean isIgnored() |
|
169 |
{ |
|
170 |
return false; |
|
171 |
} |
|
160 | 172 |
} |
new/src/com/goldencode/harness/Status.java 2023-06-12 09:32:56 +0000 | ||
---|---|---|
2 | 2 |
** Module : Status.java |
3 | 3 |
** Abstract : encodes all possible test and step status codes |
4 | 4 |
** |
5 |
** Copyright (c) 2008, Golden Code Development Corporation. |
|
5 |
** Copyright (c) 2008-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- -----------------------Description------------------------ |
8 | 8 |
** 001 GES 20081218 Encodes all possible test and step status codes. |
9 |
** 002 TJD 20230612 Support for IN_PROGRESS test status |
|
9 | 10 |
*/ |
10 | 11 | |
11 | 12 |
/* |
... | ... | |
33 | 34 |
NOT_RUN, |
34 | 35 |
PASSED, |
35 | 36 |
FAILED, |
36 |
FAILED_DEPENDENCY |
|
37 |
FAILED_DEPENDENCY, |
|
38 |
IN_PROGRESS |
|
37 | 39 |
} |
new/src/com/goldencode/harness/SubQueue.java 2023-01-23 08:40:15 +0000 | ||
---|---|---|
2 | 2 |
** Module : SubQueue.java |
3 | 3 |
** Abstract : API for objects that represent a portion of a larger queue |
4 | 4 |
** |
5 |
** Copyright (c) 2009, Golden Code Development Corporation. |
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- -----------------------Description------------------------ |
8 | 8 |
** 001 GES 20090318 An API for objects that contain one or more elements that |
9 | 9 |
** represent a portion of a larger queue. |
10 |
** 002 TJD 20230119 Allow restarting of Driver threads |
|
10 | 11 |
*/ |
11 | 12 | |
12 | 13 |
/* |
... | ... | |
93 | 94 |
* @return The next element in the queue. |
94 | 95 |
*/ |
95 | 96 |
public E dequeue(); |
97 |
|
|
98 |
/** |
|
99 |
* Reports if the queue can be ignored, usually for given thread. |
|
100 |
* |
|
101 |
* @return <code>true</code> if the queue can be ignored. |
|
102 |
*/ |
|
103 |
public boolean isIgnored(); |
|
96 | 104 |
} |
new/src/com/goldencode/harness/TerminalTestExecutor.java 2023-01-19 16:09:03 +0000 | ||
---|---|---|
7 | 7 |
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------- |
8 | 8 |
** 001 CA 20210827 Created initial version. |
9 | 9 |
** 002 RFB 20230111 Added finer logging which helps with debug (plus review). |
10 |
** 003 TJD 20230119 Added log level trace |
|
10 | 11 |
*/ |
11 | 12 | |
12 | 13 |
/* |
... | ... | |
31 | 32 |
import com.goldencode.harness.terminal.*; |
32 | 33 |
import com.goldencode.harness.test.*; |
33 | 34 |
import com.goldencode.harness.transport.*; |
34 |
import com.goldencode.util.LogHelper;
|
|
35 |
import com.goldencode.util.*;
|
|
35 | 36 | |
36 | 37 |
/** |
37 | 38 |
* The executor for terminal tests. |
... | ... | |
76 | 77 |
// failure details are already in the rc |
77 | 78 |
return; |
78 | 79 |
} |
79 |
|
|
80 |
LogHelper.finer("outputstream/inputstream before Terminal os=" + os + " is=" + is); |
|
80 |
if (LogHelper.isFinestLoggable()) |
|
81 |
{ |
|
82 |
LogHelper.finest("outputstream/inputstream before Terminal os=" + os + " is=" + is); |
|
83 |
} |
|
81 | 84 |
term = new Terminal(new DataSource(is, os), cfg); |
82 |
LogHelper.finer("terminal created term=" + term); |
|
85 |
if (LogHelper.isFinestLoggable()) |
|
86 |
{ |
|
87 |
LogHelper.finest("terminal created term=" + term); |
|
88 |
} |
|
83 | 89 |
} |
84 | 90 |
|
85 | 91 |
/** |
new/src/com/goldencode/harness/TestPlan.java 2023-06-15 08:39:42 +0000 | ||
---|---|---|
2 | 2 |
** Module : TestPlan.java |
3 | 3 |
** Abstract : stores the data needed to execute a list of test sets |
4 | 4 |
** |
5 |
** Copyright (c) 2009-2022, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- -----------------------Description------------------------ |
8 | 8 |
** 001 GES 20090122 Stores the data needed to execute a list of test sets. |
... | ... | |
11 | 11 |
** 004 TJD 20220815 Abort anytime if RC failed |
12 | 12 |
** 005 TJD 20220817 Logging tweaks |
13 | 13 |
** 006 TJD 20220819 TestSet are executing sequentially in benchmark mode |
14 |
** 007 TJD 20230612 Support for IN_PROGRESS test status |
|
14 | 15 |
*/ |
15 | 16 | |
16 | 17 |
/* |
... | ... | |
229 | 230 |
|
230 | 231 |
/** |
231 | 232 |
* Execute each of the test sets that belong to a specific dependency |
232 |
* type. PM version (executes TestPlan-s sequentially)
|
|
233 |
* type. |
|
233 | 234 |
* |
234 | 235 |
* @param sb |
235 | 236 |
* Buffer in which to accumulate error text from failures. |
... | ... | |
240 | 241 |
* |
241 | 242 |
* @return The number of failures. |
242 | 243 |
*/ |
243 |
private int processTestSetsPM(StringBuilder sb,
|
|
244 |
private int processTestSets(StringBuilder sb, |
|
244 | 245 |
Dependency type, |
245 | 246 |
FailureNotification rc) |
246 | 247 |
{ |
247 | 248 |
int num = 0; |
248 |
LogHelper.info("Start: " + this.getName() + "/" + type.toString());
|
|
249 |
LogHelper.info("STARTSET|" + this.getName() + "/" + type.toString());
|
|
249 | 250 |
|
250 | 251 |
List<TestSet> list = new ArrayList<TestSet>(); |
251 | 252 |
|
... | ... | |
263 | 264 |
// create a specific latch of the right size |
264 | 265 |
|
265 | 266 |
iter = list.iterator(); |
266 |
|
|
267 |
// execute each of the sets in the group |
|
268 |
while (iter.hasNext()) |
|
267 |
int maxParallelTests = Harness.isBenchmarkMode() ? 1 : Harness.getMaxParallelTests(); |
|
268 |
// execute each of the sets in the group in sequence |
|
269 |
Semaphore sem = new Semaphore(maxParallelTests); |
|
270 |
try |
|
269 | 271 |
{ |
270 |
if (rc.isFailed() && Harness.isFailOnRCFailure()) |
|
271 |
{ |
|
272 |
LogHelper.warn("RC failed, stopping TestPlan"); |
|
273 |
break; |
|
274 |
} |
|
275 |
CountDownLatch sem = new CountDownLatch(1); |
|
276 |
TestSet set = iter.next(); |
|
277 |
set.execute(sem, rc); |
|
278 |
try |
|
279 |
{ |
|
272 |
while(iter.hasNext()) |
|
273 |
{ |
|
274 |
if (rc.isFailed() && Harness.isFailOnRCFailure()) |
|
275 |
{ |
|
276 |
LogHelper.warn("RC failed, stopping TestPlan"); |
|
277 |
break; |
|
278 |
} |
|
280 | 279 |
// wait for test set to finish |
281 |
while(sem.getCount() != 0)
|
|
280 |
while(!sem.tryAcquire(60, TimeUnit.SECONDS))
|
|
282 | 281 |
{ |
283 |
sem.await(60, TimeUnit.SECONDS); |
|
284 | 282 |
// dump statistics every 60 seconds |
285 | 283 |
dumpStatistics(list, type); |
286 | 284 |
} |
287 |
} |
|
288 |
|
|
289 |
catch (InterruptedException ie) |
|
290 |
{ |
|
291 |
sb.append("test plan thread interrupted before driver ") |
|
292 |
.append(" threads finished"); |
|
293 |
num = 1; |
|
294 |
} |
|
295 | ||
296 |
} |
|
297 |
|
|
298 |
LogHelper.info("End: " + this.getName() + "/" + type.toString()); |
|
299 |
dumpStatistics(list, type); |
|
300 |
|
|
301 |
return checkResults(sets, sb, num); |
|
302 |
} |
|
303 |
/** |
|
304 |
* Execute each of the test sets that belong to a specific dependency |
|
305 |
* type. |
|
306 |
* |
|
307 |
* @param sb |
|
308 |
* Buffer in which to accumulate error text from failures. |
|
309 |
* @param type |
|
310 |
* Dependency group to execute. |
|
311 |
* @param rc |
|
312 |
* Object in which to store the details of non-testing failures. |
|
313 |
* |
|
314 |
* @return The number of failures. |
|
315 |
*/ |
|
316 |
private int processTestSets(StringBuilder sb, |
|
317 |
Dependency type, |
|
318 |
FailureNotification rc) |
|
319 |
{ |
|
320 |
if (Harness.isBenchmarkMode()) |
|
321 |
return processTestSetsPM(sb, type, rc); |
|
322 |
int num = 0; |
|
323 |
LogHelper.info("Start: " + this.getName() + "/" + type.toString()); |
|
324 |
|
|
325 |
List<TestSet> list = new ArrayList<TestSet>(); |
|
326 |
|
|
327 |
Iterator<TestSet> iter = sets.iterator(); |
|
328 |
|
|
329 |
// subset the list of test-sets from the specified dependency group |
|
330 |
while (iter.hasNext()) |
|
331 |
{ |
|
332 |
TestSet set = iter.next(); |
|
333 |
|
|
334 |
if (set.getDependency() == type) |
|
335 |
list.add(set); |
|
336 |
} |
|
337 |
|
|
338 |
// create a specific latch of the right size |
|
339 |
CountDownLatch sem = new CountDownLatch(list.size()); |
|
340 |
|
|
341 |
iter = list.iterator(); |
|
342 |
|
|
343 |
// execute each of the sets in the group |
|
344 |
while (iter.hasNext()) |
|
345 |
{ |
|
346 |
if (rc.isFailed() && Harness.isFailOnRCFailure()) |
|
347 |
{ |
|
348 |
LogHelper.warn("RC failed, stopping TestPlan"); |
|
349 |
break; |
|
350 |
} |
|
351 |
TestSet set = iter.next(); |
|
352 |
set.execute(sem, rc); |
|
353 |
} |
|
354 |
|
|
355 |
try |
|
356 |
{ |
|
357 |
// wait for test set to finish |
|
358 |
while(sem.getCount() != 0) |
|
359 |
{ |
|
360 |
sem.await(60, TimeUnit.SECONDS); |
|
285 |
TestSet set = iter.next(); |
|
286 |
set.execute(sem, rc); |
|
287 |
} |
|
288 |
//wait for all to finish |
|
289 |
while(!sem.tryAcquire(maxParallelTests, 60, TimeUnit.SECONDS)) |
|
290 |
{ |
|
361 | 291 |
// dump statistics every 60 seconds |
362 | 292 |
dumpStatistics(list, type); |
363 | 293 |
} |
364 | 294 |
} |
365 |
|
|
366 | 295 |
catch (InterruptedException ie) |
367 | 296 |
{ |
368 | 297 |
sb.append("test plan thread interrupted before driver ") |
369 |
.append(" threads finished");
|
|
298 |
.append(" threads finished"); |
|
370 | 299 |
num = 1; |
371 | 300 |
} |
372 |
LogHelper.info("End: " + this.getName() + "/" + type.toString()); |
|
301 |
|
|
302 |
LogHelper.info("ENDSET|" + this.getName() + "/" + type.toString()); |
|
373 | 303 |
dumpStatistics(list, type); |
374 | 304 |
|
375 | 305 |
return checkResults(sets, sb, num); |
... | ... | |
391 | 321 |
int testsFailed = 0; |
392 | 322 |
int testsNotRun = 0; |
393 | 323 |
int testsTotal = 0; |
394 |
|
|
324 |
int testsInProgress = 0; |
|
325 |
Set<String> testsInProgressNames = new HashSet<String>(); |
|
395 | 326 |
for(TestSet testSet:list) |
396 | 327 |
{ |
397 | 328 |
List<Test> tests = testSet.getTests(); |
... | ... | |
407 | 338 |
case NOT_RUN: |
408 | 339 |
testsNotRun ++; |
409 | 340 |
break; |
341 |
case IN_PROGRESS: |
|
342 |
testsInProgress ++; |
|
343 |
testsInProgressNames.add(t.getName()); |
|
344 |
break; |
|
410 | 345 |
case PASSED: |
411 | 346 |
testsPassed ++; |
412 | 347 |
break; |
... | ... | |
418 | 353 |
} |
419 | 354 |
double successRate = (testsTotal == testsNotRun) |
420 | 355 |
? 0.0d |
421 |
: (double)testsPassed/((double)testsTotal-(double)testsNotRun) * 100.0d; |
|
356 |
: (double) testsPassed/ ((double) testsTotal - (double) testsNotRun |
|
357 |
- (double) testsInProgress) * 100.0d; |
|
422 | 358 |
double executionRate = (testsTotal == testsNotRun) |
423 | 359 |
? 0.0d |
424 | 360 |
:(double) (testsPassed + testsFailed)/((double)testsTotal) * 100.0d; |
425 |
LogHelper.finer(this.getName()+"/"+type.toString() |
|
426 |
+ " Total: " + testsTotal |
|
427 |
+ " left: " + testsNotRun |
|
428 |
+ " failed: " + testsFailed |
|
429 |
+ " passed: " + testsPassed |
|
430 |
+ " successful: " + String.format("%2.2f%%", successRate) |
|
431 |
+ " progress: " + String.format("%2.2f%%", executionRate)); |
|
361 |
LogHelper.finer("TESTPLANREPORT|" + this.getName()+"/"+type.toString() |
|
362 |
+ " Total: " + testsTotal |
|
363 |
+ " left: " + testsNotRun |
|
364 |
+ " in progress: " + testsInProgress |
|
365 |
+ " failed: " + testsFailed |
|
366 |
+ " passed: " + testsPassed |
|
367 |
+ " successful: " + String.format("%2.2f%%", successRate) |
|
368 |
+ " progress: " + String.format("%2.2f%%", executionRate)); |
|
369 |
LogHelper.finer("TESTPLANREPORT|" + this.getName()+"/"+type.toString() |
|
370 |
+ " Tests in progress: " |
|
371 |
+ Arrays.toString(testsInProgressNames.toArray())); |
|
432 | 372 |
} |
433 | 373 |
} |
new/src/com/goldencode/harness/TestPlanFactory.java 2023-06-21 07:16:47 +0000 | ||
---|---|---|
2 | 2 |
** Module : TestPlanFactory.java |
3 | 3 |
** Abstract : instantiates a test plan from an XML definition |
4 | 4 |
** |
5 |
** Copyright (c) 2009-2022, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------- |
8 | 8 |
** 001 GES 20090122 Instantiates a test plan from an XML definition. |
... | ... | |
11 | 11 |
** 003 CA 20210906 Allow override via command line arguments, for: web endpoint, variable initial values and |
12 | 12 |
** oauth1 parameters. |
13 | 13 |
** 004 CA 20220118 Added Basic authorization. |
14 |
** 005 TJD 20230119 Allow restarting of Driver threads |
|
14 | 15 |
*/ |
15 | 16 | |
16 | 17 |
/* |
... | ... | |
200 | 201 |
|
201 | 202 |
processOutputDirectory(root, plan); |
202 | 203 |
|
204 |
// add output dorectory as variable |
|
205 |
String outputDirectory = plan.getOutputDirectory(); |
|
206 |
if (outputDirectory != null && outputDirectory.trim().length()>0) |
|
207 |
{ |
|
208 |
pool.createVariable("outputDirectory", Variable.getSupportedType("String"), outputDirectory); |
|
209 |
} |
|
203 | 210 |
// preload default search paths |
204 | 211 |
if (testPaths != null) |
205 | 212 |
index.addTestPathList(testPaths); |
new/src/com/goldencode/harness/TestSet.java 2023-07-21 10:24:15 +0000 | ||
---|---|---|
3 | 3 |
** Abstract : stores the data needed to execute a set of tests on a given |
4 | 4 |
** target host |
5 | 5 |
** |
6 |
** Copyright (c) 2009-2022, Golden Code Development Corporation.
|
|
6 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
7 | 7 |
** |
8 | 8 |
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------- |
9 | 9 |
** 001 GES 20090122 Stores the data needed to execute a set of tests on a given target host. |
... | ... | |
12 | 12 |
** 003 TJD 20220803 Added logging, updated for Java 11 |
13 | 13 |
** 004 TJD 20220808 Changed log format, added option to abort TestSet |
14 | 14 |
** 004 TJD 20220815 Logging tweaks |
15 |
** 005 TJD 20230119 Updated logging data |
|
16 |
** 005 TJD 20230119 Allow restarting of Driver threads |
|
15 | 17 |
*/ |
16 | 18 | |
17 | 19 |
/* |
... | ... | |
33 | 35 | |
34 | 36 |
import java.util.*; |
35 | 37 |
import java.util.concurrent.*; |
36 |
import java.util.concurrent.atomic.*; |
|
37 | 38 | |
38 | 39 |
import com.goldencode.harness.test.*; |
39 | 40 |
import com.goldencode.util.*; |
... | ... | |
61 | 62 |
private ResourcePool pool = null; |
62 | 63 |
|
63 | 64 |
/** Semaphore to notify when complete. */ |
64 |
private CountDownLatch sem = null;
|
|
65 |
private Semaphore sem = null;
|
|
65 | 66 |
|
66 | 67 |
/** Object in which to log non-testing failures. */ |
67 | 68 |
private FailureNotification rc = null; |
... | ... | |
197 | 198 |
/** |
198 | 199 |
* Start the thread that executes this test set. See {@link #run}. |
199 | 200 |
* |
200 |
* @param sem |
|
201 |
* @param sem2
|
|
201 | 202 |
* Semaphore to notify when the test set completes processing. |
202 | 203 |
* @param rc |
203 | 204 |
* Object in which to store the details of non-testing failures. |
204 | 205 |
*/ |
205 |
public void execute(CountDownLatch sem, FailureNotification rc)
|
|
206 |
public void execute(Semaphore sem2, FailureNotification rc)
|
|
206 | 207 |
{ |
207 |
this.sem = sem; |
|
208 |
this.sem = sem2;
|
|
208 | 209 |
this.rc = rc; |
209 | 210 | |
210 | 211 |
if (cfgs == null || cfgs.isEmpty()) |
211 | 212 |
{ |
212 | 213 |
if (sem != null) |
213 |
sem.countDown();
|
|
214 |
sem.release();;
|
|
214 | 215 |
|
215 | 216 |
rc.setResult(ExitCode.MISSING_CONTENT); |
216 | 217 |
rc.setDetails("Missing session configuration for test set execution."); |
217 | 218 |
return; |
218 | 219 |
} |
219 | 220 |
|
220 |
if (sem == null) |
|
221 |
if (sem2 == null)
|
|
221 | 222 |
{ |
222 | 223 |
rc.setResult(ExitCode.MISSING_CONTENT); |
223 | 224 |
rc.setDetails("Missing semaphore for test set execution."); |
... | ... | |
240 | 241 |
setThreadName(Thread.currentThread().getName()); |
241 | 242 |
|
242 | 243 |
StringBuilder sb = new StringBuilder(); |
243 |
CountDownLatch latch = new CountDownLatch(threads); |
|
244 |
|
|
244 |
Phaser phaser = new Phaser(); |
|
245 | 245 |
int num = 0; |
246 |
int threadIndex = 0; |
|
246 | 247 |
|
247 | 248 |
// start test set timer |
248 | 249 |
setStartTime(System.currentTimeMillis()); |
249 |
LogHelper.info("Start: "+ this.getName()); |
|
250 | 250 |
|
251 | 251 |
// start each of the driver threads (there will be at least 1 started) |
252 | 252 |
for (int i = 0; i < threads; i++) |
253 | 253 |
{ |
254 |
Driver driver = new Driver(cfgs, queue, latch, rc); |
|
255 |
driver.setName(String.format("[%s/%d]", this.getName(), i)); |
|
256 |
driver.start(); |
|
254 |
if (phaser.register() == 0) |
|
255 |
{ |
|
256 |
Driver driver = new Driver(cfgs, queue, phaser, rc); |
|
257 |
driver.setName(String.format("%s/%d", this.getName(), threadIndex++)); |
|
258 |
driver.start(); |
|
259 |
} |
|
257 | 260 |
} |
258 | 261 |
|
259 | 262 |
try |
260 | 263 |
{ |
261 |
// wait for each driver thread to finish |
|
262 |
latch.await(); |
|
264 |
while (true) |
|
265 |
{ |
|
266 |
try |
|
267 |
{ |
|
268 |
// wait for each driver thread to finish |
|
269 |
phaser.awaitAdvanceInterruptibly(0, 1, TimeUnit.MINUTES); |
|
270 |
// all threads arrived, we are done |
|
271 |
break; |
|
272 |
} |
|
273 |
catch (TimeoutException e) |
|
274 |
{ |
|
275 |
// we have timeout so we can check how many threads has already arrived |
|
276 |
if (!queue.isEmpty() && phaser.getRegisteredParties() < threads) |
|
277 |
{ |
|
278 |
for (int i = phaser.getRegisteredParties(); i < threads; i++) |
|
279 |
{ |
|
280 |
if (phaser.register() == 0) |
|
281 |
{ |
|
282 |
LogHelper.finer("DRIVERSTART|" + this.getName() + "| Starting new driver"); |
|
283 |
Driver driver = new Driver(cfgs, queue, phaser, rc); |
|
284 |
driver.setName(String.format("%s/%d", this.getName(), threadIndex++)); |
|
285 |
driver.start(); |
|
286 |
} |
|
287 |
else |
|
288 |
{ |
|
289 |
LogHelper.finer("DRIVERSTART|" + this.getName() + "| Not starting new driver, phased out"); |
|
290 |
} |
|
291 |
} |
|
292 |
} |
|
293 |
} |
|
294 |
} |
|
263 | 295 |
} |
264 | 296 |
|
265 | 297 |
catch (InterruptedException ie) |
... | ... | |
271 | 303 |
|
272 | 304 |
// end test set timer |
273 | 305 |
setEndTime(System.currentTimeMillis()); |
274 |
LogHelper.info("End: "+ this.getName() + Harness.completionMsg(getElapsed())); |
|
275 | 306 |
|
276 | 307 |
num = checkResults(tests, sb, num); |
277 | 308 |
|
278 | 309 |
setStatus((num > 0) ? Status.FAILED : Status.PASSED, |
279 | 310 |
(sb.length() > 0) ? sb.toString() : null); |
280 | 311 |
|
281 |
sem.countDown();
|
|
312 |
sem.release();;
|
|
282 | 313 |
} |
283 | 314 |
} |
284 | 315 |
new/src/com/goldencode/harness/terminal/Terminal.java 2023-07-21 09:16:59 +0000 | ||
---|---|---|
17 | 17 |
** 007 TJD 20220918 SendText drain mode optimization - shared variable needs to be volatile |
18 | 18 |
** 008 RFB 20230111 Added finer logging which helps with debug. Also removed a return value in a comment |
19 | 19 |
** to fix javadoc (plus review). |
20 |
** 009 TJD 20230119 Implemented trace log level |
|
20 | 21 |
*/ |
21 | 22 | |
22 | 23 |
/* |
... | ... | |
160 | 161 |
this.session = session; |
161 | 162 |
|
162 | 163 |
setTerminalID(cfg.termType); |
163 |
LogHelper.finer("setTerminalID termType=" + cfg.termType);
|
|
164 |
LogHelper.finer("SETTERMINALTYPE|" + cfg.termType);
|
|
164 | 165 |
|
165 | 166 |
// insert a display processor that copies the current screen to a |
166 | 167 |
// secondary buffer during redrawing |
... | ... | |
171 | 172 |
|
172 | 173 |
public void redraw() |
173 | 174 |
{ |
174 |
LogHelper.finer("merging new drawing into buffer");
|
|
175 |
LogHelper.finest("merging new drawing into buffer");
|
|
175 | 176 |
// merge the newly drawn updates into our buffer |
176 | 177 |
for (int n = 0; n < height; n++) |
177 | 178 |
{ |
... | ... | |
203 | 204 |
// lines have a flag at line number + 1 in the array |
204 | 205 |
update[0] = false; |
205 | 206 |
|
206 |
LogHelper.finer("new screen, height=" + height + ", width=" + width);
|
|
207 |
LogHelper.finest("new screen, height=" + height + ", width=" + width);
|
|
207 | 208 |
synchronized (lock) |
208 | 209 |
{ |
209 | 210 |
// create a new, empty snapshot |
... | ... | |
234 | 235 |
|
235 | 236 |
try |
236 | 237 |
{ |
237 |
LogHelper.finer("polling for screen data");
|
|
238 |
LogHelper.finest("polling for screen data");
|
|
238 | 239 |
int x=0; |
239 | 240 |
while (true) |
240 | 241 |
{ |
241 | 242 |
int i = Terminal.this.session.read(buffer); |
242 |
LogHelper.finer("read results in i=" + i); |
|
243 |
|
|
243 |
if (LogHelper.isFinestLoggable()) |
|
244 |
{ |
|
245 |
LogHelper.finest("read results in i=" + i); |
|
246 |
} |
|
244 | 247 |
// watch for EOF |
245 | 248 |
if (i < 0) |
246 | 249 |
break; |
... | ... | |
268 | 271 |
} |
269 | 272 |
}; |
270 | 273 |
|
271 |
LogHelper.finer("starting readerThread");
|
|
274 |
LogHelper.finest("starting readerThread");
|
|
272 | 275 |
Thread readerThread = new Thread(reader); |
273 | 276 |
readerThread.setDaemon(true); |
274 | 277 |
readerThread.setName("Terminal Reader"); |
275 | 278 |
readerThread.start(); |
276 | 279 |
|
277 | 280 |
// wait up to 30 seconds for the 1st screen to come through |
278 |
LogHelper.finer("waiting for up to 30 seconds for the first screen...");
|
|
281 |
LogHelper.finest("waiting for up to 30 seconds for the first screen...");
|
|
279 | 282 |
waitForScreen(30000); |
280 | 283 |
} |
281 | 284 |
|
... | ... | |
562 | 565 |
{ |
563 | 566 |
if (text == null || text.length() == 0) |
564 | 567 |
return; |
565 |
|
|
566 |
LogHelper.finer("sendText: text=" + text); |
|
568 |
if (LogHelper.isFinestLoggable()) |
|
569 |
{ |
|
570 |
LogHelper.finest("SENDTEXT|" + text +"|"); |
|
571 |
} |
|
567 | 572 |
delay = Math.max(delay, 50); |
568 | 573 |
if (Harness.isBenchmarkMode() && delay > 50) |
569 | 574 |
{ |
... | ... | |
792 | 797 |
|
793 | 798 |
if (timeout == 0 || waitForScreen(timeout)) |
794 | 799 |
{ |
795 |
LogHelper.finer("getScreen: timeout=" + timeout + ", clear=" + clear + ", (screen == null)=" + (screen == null)); |
|
800 |
if (LogHelper.isFinestLoggable()) |
|
801 |
{ |
|
802 |
LogHelper.finest("getScreen: timeout=" + timeout + ", clear=" + clear + ", (screen == null)=" + (screen == null)); |
|
803 |
} |
|
796 | 804 |
synchronized (lock) |
797 | 805 |
{ |
798 | 806 |
current = screen; |
... | ... | |
802 | 810 |
} |
803 | 811 |
} |
804 | 812 |
|
805 |
LogHelper.finer((current != null) ? "getScreen: returning screen data" : "getScreen: no screen data to return"); |
|
806 | 813 |
return current; |
807 | 814 |
} |
808 | 815 |
|
new/src/com/goldencode/harness/test/LogScreenBuffer.java 2023-06-15 19:18:46 +0000 | ||
---|---|---|
2 | 2 |
** Module : LogScreenBuffer.java |
3 | 3 |
** Abstract : directive to query the current screen and store it in the report |
4 | 4 |
** |
5 |
** Copyright (c) 2009-2021, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------- |
8 | 8 |
** 001 GES 20090126 Directive to query the current screen and store it in the report. |
9 | 9 |
** 002 CA 20210827 Refactored to allow other test types, beside terminal (which can be executed from the same |
10 | 10 |
** test suite). Added SOAP and REST web service tests. |
11 |
** 003 TJD 20230119 Test timeout multiplier support |
|
11 | 12 |
*/ |
12 | 13 | |
13 | 14 |
/* |
... | ... | |
73 | 74 |
@Override |
74 | 75 |
public void execute(Terminal term) |
75 | 76 |
{ |
76 |
setDescription(term.getScreen(clear, millis));
|
|
77 |
setDescription(term.getScreen(clear, Harness.scaleTimeoutMultiplier(millis)));
|
|
77 | 78 |
setStatus(Status.PASSED, ""); |
78 | 79 |
} |
79 | 80 |
|
new/src/com/goldencode/harness/test/Pause.java 2023-07-21 09:18:15 +0000 | ||
---|---|---|
2 | 2 |
** Module : Pause.java |
3 | 3 |
** Abstract : directive to pause for a fixed time interval in milliseconds |
4 | 4 |
** |
5 |
** Copyright (c) 2009-2021, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------- |
8 | 8 |
** 001 GES 20090114 Directive to pause for a fixed time interval in milliseconds. |
9 | 9 |
** 002 CA 20210827 Refactored to allow other test types, beside terminal (which can be executed from the same |
10 | 10 |
** test suite). Added SOAP and REST web service tests. |
11 | 11 |
** 003 TJD 20220817 Implement performance test mode |
12 |
** 004 TJD 20230119 Test timeout multiplier support |
|
12 | 13 |
*/ |
13 | 14 | |
14 | 15 |
/* |
... | ... | |
112 | 113 |
|
113 | 114 |
setStatus(status, reason); |
114 | 115 |
} |
116 |
|
|
117 |
/** |
|
118 |
* Get the maximum number of milliseconds that this testable activity is allowed to run. |
|
119 |
* Valid for some of Tests only, -1 if not applicable |
|
120 |
* @return The maximum number of milliseconds. |
|
121 |
*/ |
|
122 |
@Override |
|
123 |
public long getMaxElapsed() |
|
124 |
{ |
|
125 |
if (millis > 0) |
|
126 |
{ |
|
127 |
return Harness.scaleTimeoutMultiplier(millis); |
|
128 |
} |
|
129 |
return millis; |
|
130 |
} |
|
115 | 131 |
} |
new/src/com/goldencode/harness/test/ScreenPoller.java 2023-07-19 07:40:17 +0000 | ||
---|---|---|
2 | 2 |
** Module : ScreenPoller.java |
3 | 3 |
** Abstract : base class to handle common polling logic when examining screens |
4 | 4 |
** |
5 |
** Copyright (c) 2009-2022, Golden Code Development Corporation.
|
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- ---------------------------------------Description---------------------------------------- |
8 | 8 |
** 001 GES 20090210 Base class to handle common polling logic when examining screens. |
... | ... | |
13 | 13 |
** 005 TJD 20220817 implemented performance test mode with experimental remove of waits from screen polling, |
14 | 14 |
** 006 TJD 20220818 Fix for performance mode bug |
15 | 15 |
** 007 TJD 20220819 Allow configuring max timeout for single test that require idle waiting |
16 |
** 008 TJD 20230119 Test timeout multiplier support |
|
17 |
** 009 TJD 20230719 Reduce screen poll delay, increase screen poll frequency |
|
16 | 18 |
**/ |
17 | 19 | |
18 | 20 |
/* |
... | ... | |
43 | 45 |
implements TerminalTestable |
44 | 46 |
{ |
45 | 47 |
/** Milliseconds to wait in polling loop. */ |
46 |
private static final int INTERVAL = 500;
|
|
48 |
private static final int INTERVAL = 100;
|
|
47 | 49 |
|
48 | 50 |
/** Maximum number of milliseconds to wait. */ |
49 | 51 |
private final int millis; |
... | ... | |
231 | 233 |
String reason = null; |
232 | 234 |
|
233 | 235 |
int amt = 0; |
234 |
int timeout = millis; |
|
235 | 236 |
boolean oneTime = (millis == 0); |
236 | 237 |
boolean indefinite = (millis == -1); |
238 |
int timeout = Harness.scaleTimeoutMultiplier(millis); |
|
237 | 239 |
boolean failure = false; |
238 | 240 |
char[][] screen = null; |
239 | 241 |
|
... | ... | |
393 | 395 |
} |
394 | 396 |
setDescription(sb.toString()); |
395 | 397 |
} |
398 |
|
|
399 |
/** |
|
400 |
* Get the maximum number of milliseconds that this testable activity is allowed to run. |
|
401 |
* Valid for some of Tests only, -1 if not applicable |
|
402 |
* @return The maximum number of milliseconds. |
|
403 |
*/ |
|
404 |
@Override |
|
405 |
public long getMaxElapsed() |
|
406 |
{ |
|
407 |
return millis; |
|
408 |
} |
|
396 | 409 |
} |
new/src/com/goldencode/harness/test/SendText.java 2023-07-21 09:19:08 +0000 | ||
---|---|---|
2 | 2 |
** Module : SendText.java |
3 | 3 |
** Abstract : implement the send-text step in a test |
4 | 4 |
** |
5 |
** Copyright (c) 2009, Golden Code Development Corporation. |
|
5 |
** Copyright (c) 2009-2023, Golden Code Development Corporation.
|
|
6 | 6 |
** |
7 | 7 |
** -#- -I- --Date-- -----------------------Description------------------------ |
8 | 8 |
** 001 GES 20090113 Implement the send-text step in a test. |
9 |
** 002 TJD 20230615 Trace mode additions |
|
9 | 10 |
*/ |
10 | 11 | |
11 | 12 |
/* |
... | ... | |
27 | 28 | |
28 | 29 |
import com.goldencode.harness.*; |
29 | 30 |
import com.goldencode.harness.terminal.*; |
31 |
import com.goldencode.util.*; |
|
30 | 32 | |
31 | 33 |
/** |
32 | 34 |
* Implement the send-text step in a test. This directive has the |