-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MINOR Move scripts into committer-tools (#17162)
Moving reviewers.py and kafka-merge-pr.py into committer-tools. Also include a new find-unfinished-test.py script which can be used for finding hanging tests on Jenkins or Github Actions. Reviewers: Chia-Ping Tsai <[email protected]>
- Loading branch information
Showing
5 changed files
with
134 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import argparse | ||
from datetime import datetime | ||
|
||
|
||
def pretty_time_duration(seconds: float) -> str: | ||
time_min, time_sec = divmod(int(seconds), 60) | ||
time_hour, time_min = divmod(time_min, 60) | ||
time_fmt = "" | ||
if time_hour > 0: | ||
time_fmt += f"{time_hour}h" | ||
if time_min > 0: | ||
time_fmt += f"{time_min}m" | ||
time_fmt += f"{time_sec}s" | ||
return time_fmt | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Parse Gradle log output to find hanging tests") | ||
parser.add_argument("file", type=argparse.FileType("r"), help="Text file containing Gradle stdout") | ||
args = parser.parse_args() | ||
|
||
started = dict() | ||
last_test_line = None | ||
for line in args.file.readlines(): | ||
if "Gradle Test Run" not in line: | ||
continue | ||
last_test_line = line | ||
|
||
toks = line.strip().split(" > ") | ||
name, status = toks[-1].rsplit(" ", 1) | ||
name_toks = toks[2:-1] + [name] | ||
test = " > ".join(name_toks) | ||
if status == "STARTED": | ||
started[test] = line | ||
else: | ||
started.pop(test) | ||
|
||
last_timestamp, _ = last_test_line.split(" ", 1) | ||
last_dt = datetime.fromisoformat(last_timestamp) | ||
|
||
if len(started) > 0: | ||
print("Found tests that were started, but apparently not finished") | ||
|
||
for started_not_finished, line in started.items(): | ||
print("-"*80) | ||
timestamp, _ = line.split(" ", 1) | ||
dt = datetime.fromisoformat(timestamp) | ||
dur_s = (last_dt - dt).total_seconds() | ||
print(f"Test: {started_not_finished}") | ||
print(f"Duration: {pretty_time_duration(dur_s)}") | ||
print(f"Raw line: {line}") |
File renamed without changes.
File renamed without changes.