Skip to content

Commit aaba549

Browse files
bsheedy-workDawn LUCI CQ
authored andcommitted
Delay dawn.node failure until results are reported
Updates run_dawn_node_cts.py to delay surfacing test failures until test results have been reported. Without this change, a test failure would result in a failed Swarming task but no data in ResultDB. With this change, a test failure results in both a failed Swarming task and a failed result in ResultDB. Bug: 441328362 Change-Id: Ic46ef6312e0541d227bbc728d65378982bf8c478 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/264594 Auto-Submit: Brian Sheedy <[email protected]> Reviewed-by: Yuly Novikov <[email protected]> Commit-Queue: Yuly Novikov <[email protected]>
1 parent 5d9b8e2 commit aaba549

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

scripts/dawn_node_cts/run_dawn_node_cts.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def install_npm_deps_in_current_dir() -> None:
5555

5656

5757
def run_node_cts(output_directory: str, args_to_forward: list[str],
58-
output_filepath: str) -> None:
58+
output_filepath: str) -> subprocess.CompletedProcess:
5959
logging.info('Running CTS via node in %s', os.getcwd())
6060
npx_wrapper = os.path.join(THIS_DIR, 'run_npx.py')
6161
if sys.platform == 'win32':
@@ -71,7 +71,7 @@ def run_node_cts(output_directory: str, args_to_forward: list[str],
7171
'-npx',
7272
npx_wrapper,
7373
] + args_to_forward
74-
subprocess.run(cmd, check=True)
74+
return subprocess.run(cmd, check=False)
7575

7676

7777
def convert_results_for_resultdb_ingestion(
@@ -81,7 +81,18 @@ def convert_results_for_resultdb_ingestion(
8181
# improved, this conversion can likely be substituted for native ResultDB
8282
# integration instead of relying on result_adapter.
8383
with open(test_output_filepath, encoding='utf-8') as infile:
84-
test_results = json.load(infile)
84+
try:
85+
test_results = json.load(infile)
86+
except json.JSONDecodeError:
87+
logging.error(
88+
'Could not decode test output file. Tests likely did not run '
89+
'properly')
90+
test_results = [
91+
{
92+
'TestCase': 'result_conversion',
93+
'Status': 'fail',
94+
},
95+
]
8596

8697
converted_test_results = {
8798
'failures': [],
@@ -108,7 +119,7 @@ def main() -> None:
108119
help='Output directory to use. Passed to the underlying runner as -bin.'
109120
)
110121
parser.add_argument('--isolated-script-test-output',
111-
help='Currently unused, needed for bot support.')
122+
help='Path to the location to output JSON results.')
112123
parser.add_argument('--isolated-script-test-perf-output',
113124
help='Currently unused, needed for bot support.')
114125
args, unknown_args = parser.parse_known_args()
@@ -119,10 +130,12 @@ def main() -> None:
119130
output_fd, output_filepath = tempfile.mkstemp()
120131
os.close(output_fd)
121132
try:
122-
run_node_cts(args.output_directory, unknown_args, output_filepath)
133+
proc = run_node_cts(args.output_directory, unknown_args,
134+
output_filepath)
123135
if args.isolated_script_test_output:
124136
convert_results_for_resultdb_ingestion(
125137
output_filepath, args.isolated_script_test_output)
138+
proc.check_returncode()
126139
finally:
127140
os.remove(output_filepath)
128141

0 commit comments

Comments
 (0)