| 1 |
package Test2::Harness::Log; |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
|
| 5 |
our $VERSION = '1.000179'; |
| 6 |
|
| 7 |
1; |
| 8 |
|
| 9 |
__END__ |
| 10 |
|
| 11 |
=pod |
| 12 |
|
| 13 |
=encoding UTF-8 |
| 14 |
|
| 15 |
=head1 NAME |
| 16 |
|
| 17 |
Test2::Harness::Log - Documentation about the L<Test2::Harness> log file. |
| 18 |
|
| 19 |
=head1 DESCRIPTION |
| 20 |
|
| 21 |
L<Test2::Harness> aka L<App::Yath> produces a rich/complete log when asked to |
| 22 |
do so. This module documents the log format. |
| 23 |
|
| 24 |
=head1 COMPRESSION |
| 25 |
|
| 26 |
Test2::Harness can output log files uncompressed, compressed in gzip, or |
| 27 |
compressed in bzip2. |
| 28 |
|
| 29 |
=head1 FORMAT |
| 30 |
|
| 31 |
The log file is in jsonl format. Each line of the log can be independently |
| 32 |
parsed as json. Each line represents a single event Test2::Harness processed |
| 33 |
during a run. These events will be in the original order Test2::Harness |
| 34 |
processed them in (may not be chronological to when they were generated as |
| 35 |
generation, collection, processing, and rendering are handled in different |
| 36 |
processes. A complete log will be terminated by the string C<null>, which is |
| 37 |
also valid json. If a log is missing this terminator it is considered an |
| 38 |
incomplete log. |
| 39 |
|
| 40 |
=head2 EVENTS |
| 41 |
|
| 42 |
B<Please note:> Older versions of Test2::Harness produced less complete events, |
| 43 |
this covers all current fields, if you are attempting to handle very old logs |
| 44 |
some of these fields may be missing. |
| 45 |
|
| 46 |
Each event will have the following fields: |
| 47 |
|
| 48 |
{ |
| 49 |
"event_id" : "CD01CD30-D535-11EA-9B6A-D90F9664FE12", |
| 50 |
"job_id" : 0, |
| 51 |
"job_try" : null, |
| 52 |
"run_id" : "CCF98E54-D535-11EA-915A-D70F9664FE12", |
| 53 |
"stamp" : 1596423763.76517, |
| 54 |
|
| 55 |
"facet_data" : { |
| 56 |
"harness" : { |
| 57 |
"event_id" : "CD01CD30-D535-11EA-9B6A-D90F9664FE12", |
| 58 |
"job_id" : 0, |
| 59 |
"job_try" : null, |
| 60 |
"run_id" : "CCF98E54-D535-11EA-915A-D70F9664FE12" |
| 61 |
}, |
| 62 |
|
| 63 |
... |
| 64 |
} |
| 65 |
} |
| 66 |
|
| 67 |
=over 4 |
| 68 |
|
| 69 |
=item event_id : "UUID_OR_STRING" |
| 70 |
|
| 71 |
Typically this will be a UUID, but when UUIDs cannot be generated it may have a |
| 72 |
different unique identifier. This will always be a string. This may never be |
| 73 |
NULL, if it is NULL then that is a bug and should be reported. |
| 74 |
|
| 75 |
=item job_id : "0_OR_UUID_OR_STRING" |
| 76 |
|
| 77 |
ID C<0> is special in that it represents the test harness itself, and not an |
| 78 |
actual test being run. Normally the job_id will be a UUID, but may be another |
| 79 |
unique string if UUID generation is disabled or not available. |
| 80 |
|
| 81 |
=item job_try : INTEGER_OR_NULL |
| 82 |
|
| 83 |
For C<< job_id => 0 >> this will be C<NULL> for any other job this will be an |
| 84 |
integer of 0 or greater. This is 0 for the first time a test job is run, if a |
| 85 |
job is re-run due to failure (or any other reason) this will be incremented to |
| 86 |
tell you what run it is. When a job is re-run it keeps the same job ID, you can |
| 87 |
use this to distinguish events from each run of the job. |
| 88 |
|
| 89 |
=item run_id : "UUID_OR_STRING" |
| 90 |
|
| 91 |
This is the run_id of the entire yath test run. This should be the same for |
| 92 |
every event in any given log. |
| 93 |
|
| 94 |
=item stamp : UNIX_TIME_STAMP |
| 95 |
|
| 96 |
Timestamp of the event. This is NORMALLY set when an event is generated, |
| 97 |
however if an event does not have its own time stamp yath will give it a |
| 98 |
timestamp upon collection. Events without timestamps happen if the test outputs |
| 99 |
TAP instead of L<Test2::Event> objects, or if a tool misbehaves in some way. |
| 100 |
|
| 101 |
=item facet_data : HASH |
| 102 |
|
| 103 |
This contains all the the data of the event, such as if an assertion was made, |
| 104 |
what file name and line number generated it, etc. |
| 105 |
|
| 106 |
In addition to the original facets of the event, Test2::Harness may inject the |
| 107 |
following facets (or generate completely new events to convey these facets). |
| 108 |
|
| 109 |
=over 4 |
| 110 |
|
| 111 |
=item harness_final |
| 112 |
|
| 113 |
This will contain the final summary data from the end of the test run. |
| 114 |
|
| 115 |
{ |
| 116 |
# Was the test run a success, or were there failures? |
| 117 |
pass => $BOOL, |
| 118 |
|
| 119 |
# What tests failed? |
| 120 |
failed => [ |
| 121 |
[ |
| 122 |
$job_id, # Job id of the job that failed |
| 123 |
$file, # Test filename |
| 124 |
], |
| 125 |
... |
| 126 |
], |
| 127 |
|
| 128 |
# What tests had to be retried, and did they eventually pass? |
| 129 |
retried => [ |
| 130 |
[ |
| 131 |
$job_id, # Job id of the job that was retied |
| 132 |
$tries, # Number of tries attempted |
| 133 |
$file, # Test filename |
| 134 |
$eventually_passed, # 'YES' if it eventually passed, 'NO' if no try ever passed. |
| 135 |
], |
| 136 |
... |
| 137 |
], |
| 138 |
|
| 139 |
# What tests setn a halt event (such as bail-out, or skip the rest) |
| 140 |
halted => [ |
| 141 |
[ |
| 142 |
$job_id, # Job id of the test |
| 143 |
$file, # Test filename |
| 144 |
$halt, # Halt code |
| 145 |
], |
| 146 |
... |
| 147 |
], |
| 148 |
|
| 149 |
# What tests were never run (maybe because of a bail-out, or an internal error) |
| 150 |
unseen => [ |
| 151 |
[ |
| 152 |
$job_id, # Job id of the test |
| 153 |
$file, # Test filename |
| 154 |
], |
| 155 |
... |
| 156 |
], |
| 157 |
} |
| 158 |
|
| 159 |
=item harness_watcher |
| 160 |
|
| 161 |
Internal use only, subject to change, do not rely on it. |
| 162 |
|
| 163 |
=item harness_job |
| 164 |
|
| 165 |
A hash representation of an L<Test2::Harness::Runner::Job> object. |
| 166 |
|
| 167 |
B<Note:> This is done via a transformation, several methods have their values |
| 168 |
stored in this hash when the original object does not directly store them. |
| 169 |
|
| 170 |
=item harness_job_end |
| 171 |
|
| 172 |
{ |
| 173 |
file => $provided_path_to_test_file, |
| 174 |
rel_file => $relative_path_to_test_file, |
| 175 |
abs_file => $absolute_path_to_test_file, |
| 176 |
|
| 177 |
fail => $BOOL, |
| 178 |
retry => $INTEGER, # Number of retries left |
| 179 |
stamp => $UNIX_TIMESTAMP, # Timestamp of when the test completed |
| 180 |
|
| 181 |
# May not be present |
| 182 |
skip => $STRING, # Reason test was skipped (if it was skipped) |
| 183 |
times => $TIMING_DATA, # See below |
| 184 |
} |
| 185 |
|
| 186 |
The C<times> field is populated by calling C<data_dump()> on an |
| 187 |
L<Test2::Harness::Auditor::TimeTracker> Object. |
| 188 |
|
| 189 |
=item harness_job_exit |
| 190 |
|
| 191 |
This represents when the test job exited. |
| 192 |
|
| 193 |
{ |
| 194 |
exit => $WSTAT, |
| 195 |
retry => $INTEGER |
| 196 |
stamp => $UNIX_TIMESTAMP |
| 197 |
} |
| 198 |
|
| 199 |
=item harness_job_fields |
| 200 |
|
| 201 |
Extra data attached to the harness job, usually from an |
| 202 |
L<Test2::Harness::Plugin> via C<inject_run_data()>. |
| 203 |
|
| 204 |
=item harness_job_launch |
| 205 |
|
| 206 |
This facet is almost always in the same event as the C<harness_job_start> |
| 207 |
facet. I<NOTE:> While writing these docs the author wonders if this facet is |
| 208 |
unnecessary... |
| 209 |
|
| 210 |
{ |
| 211 |
stamp => $UNIX_TIMESTAMP, |
| 212 |
rety => $INTEGER, |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
=item harness_job_queued |
| 217 |
|
| 218 |
This data is produced by the C<queue_item> method in |
| 219 |
L<Test2::Harness::TestFile>. |
| 220 |
|
| 221 |
This contains the data about a test job conveyed by the queue. This usually |
| 222 |
contains data that will later be used by L<Test2::Harness::Runner::Job>. It is |
| 223 |
better to use the C<harness_job> facet, which contains the final data used to |
| 224 |
run the job. |
| 225 |
|
| 226 |
The following 3 fields are the only ones likely to be useful to most people: |
| 227 |
|
| 228 |
{ |
| 229 |
file => $ORIGINAL_PATH_TO_FILE, |
| 230 |
job_id => $UUID_OR_STRING, |
| 231 |
stamp => $UNIX_TIMESTAMP, |
| 232 |
} |
| 233 |
|
| 234 |
=item harness_job_start |
| 235 |
|
| 236 |
This facet is sent in an event as soon as a job starts. The data in this facet |
| 237 |
is mainly intended to convey necessary information to a renderer so that it can |
| 238 |
render the fact that a job started. |
| 239 |
|
| 240 |
{ |
| 241 |
file => $provided_path_to_test_file, |
| 242 |
rel_file => $relative_path_to_test_file, |
| 243 |
abs_file => $absolute_path_to_test_file, |
| 244 |
|
| 245 |
stamp => $UNIX_TIMESTAMP, # Timestamp of when the test completed |
| 246 |
job_id => $UUID_OR_STRING, |
| 247 |
|
| 248 |
details => "Job UUID_OR_STRING started at $UNIX_TIMESTAMP", |
| 249 |
} |
| 250 |
|
| 251 |
=item harness_run |
| 252 |
|
| 253 |
A hash representation of an L<Test2::Harness::Run> object. |
| 254 |
|
| 255 |
=back |
| 256 |
|
| 257 |
=back |
| 258 |
|
| 259 |
=head1 SOURCE |
| 260 |
|
| 261 |
The source code repository for Test2-Harness can be found at |
| 262 |
F<http://github.com/Test-More/Test2-Harness/>. |
| 263 |
|
| 264 |
=head1 MAINTAINERS |
| 265 |
|
| 266 |
=over 4 |
| 267 |
|
| 268 |
=item Chad Granum E<lt>[email protected]<gt> |
| 269 |
|
| 270 |
=back |
| 271 |
|
| 272 |
=head1 AUTHORS |
| 273 |
|
| 274 |
=over 4 |
| 275 |
|
| 276 |
=item Chad Granum E<lt>[email protected]<gt> |
| 277 |
|
| 278 |
=back |
| 279 |
|
| 280 |
=head1 COPYRIGHT |
| 281 |
|
| 282 |
Copyright 2020 Chad Granum E<lt>[email protected]<gt>. |
| 283 |
|
| 284 |
This program is free software; you can redistribute it and/or |
| 285 |
modify it under the same terms as Perl itself. |
| 286 |
|
| 287 |
See F<http://dev.perl.org/licenses/> |
| 288 |
|
| 289 |
=cut |