-
Notifications
You must be signed in to change notification settings - Fork 38.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test/test_owners.csv, for automatic assignment of test failures. #28402
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright 2016 The Kubernetes Authors. | ||
# | ||
# Licensed 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 collections | ||
import csv | ||
import re | ||
import json | ||
import os | ||
import random | ||
import sys | ||
import time | ||
import urllib2 | ||
import zlib | ||
|
||
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
OWNERS_PATH = os.path.abspath( | ||
os.path.join(BASE_DIR, '..', 'test', 'test_owners.csv')) | ||
GCS_URL_BASE = 'https://storage.googleapis.com/kubernetes-test-history/' | ||
SKIP_MAINTAINERS = { | ||
'aronchick', 'bgrant0607-nocc', 'goltermann', 'sarahnovotny'} | ||
|
||
def get_test_history(): | ||
url = time.strftime(GCS_URL_BASE + 'logs/%Y-%m-%d.json') | ||
resp = urllib2.urlopen(url) | ||
content = resp.read() | ||
if resp.headers.get('content-encoding') == 'gzip': | ||
content = zlib.decompress(content, 15 | 16) | ||
return json.loads(content) | ||
|
||
|
||
def normalize(name): | ||
name = re.sub(r'\[.*?\]|\{.*?\}', '', name) | ||
name = re.sub(r'\s+', ' ', name) | ||
return name.strip() | ||
|
||
|
||
def load_owners(fname): | ||
owners = {} | ||
with open(fname) as f: | ||
for n, (name, owner, random_assignment) in enumerate(csv.reader(f)): | ||
if n == 0: | ||
continue # header | ||
owners[normalize(name)] = (owner, int(random_assignment)) | ||
return owners | ||
|
||
|
||
def write_owners(fname, owners): | ||
with open(fname, 'w') as f: | ||
out = csv.writer(f, lineterminator='\n') | ||
out.writerow(['name', 'owner', 'auto-assigned']) | ||
for name, (owner, random_assignment) in sorted(owners.items()): | ||
out.writerow([name, owner, int(random_assignment)]) | ||
|
||
|
||
def get_maintainers(): | ||
# Github doesn't seem to support team membership listing without a key with | ||
# org admin privileges. Instead, we do it manually: | ||
# Open https://github.com/orgs/kubernetes/teams/kubernetes-maintainers | ||
# Run this in the js console: | ||
# [].slice.call(document.querySelectorAll('.team-member-username a')).map( | ||
# e => e.textContent.trim()) | ||
ret = {"a-robinson", "alex-mohr", "amygdala", "andyzheng0831", "apelisse", | ||
"aronchick", "ArtfulCoder", "bgrant0607", "bgrant0607-nocc", | ||
"bprashanth", "brendandburns", "caesarxuchao", "childsb", "cjcullen", | ||
"david-mcmahon", "davidopp", "dchen1107", "deads2k", "derekwaynecarr", | ||
"dubstack", "eparis", "erictune", "fabioy", "fejta", "fgrzadkowski", | ||
"freehan", "ghodss", "girishkalele", "gmarek", "goltermann", | ||
"grodrigues3", "hurf", "ingvagabund", "ixdy", | ||
"jackgr", "janetkuo", "jbeda", "jdef", "jingxu97", "jlowdermilk", | ||
"jsafrane", "jszczepkowski", "justinsb", "kargakis", "karlkfi", | ||
"kelseyhightower", "kevin-wangzefeng", "krousey", "lavalamp", | ||
"liggitt", "luxas", "madhusudancs", "maisem", "mansoorj", "matchstick", | ||
"mikedanese", "mml", "mtaufen", "mwielgus", "ncdc", "nikhiljindal", | ||
"piosz", "pmorie", "pwittrock", "Q-Lee", "quinton-hoole", "Random-Liu", | ||
"rmmh", "roberthbailey", "ronnielai", "saad-ali", "sarahnovotny", | ||
"smarterclayton", "soltysh", "spxtr", "sttts", "swagiaal", "thockin", | ||
"timothysc", "timstclair", "tmrts", "vishh", "vulpecula", "wojtek-t", | ||
"xiang90", "yifan-gu", "yujuhong", "zmerlynn"} | ||
return sorted(ret - SKIP_MAINTAINERS) | ||
|
||
|
||
def main(): | ||
test_history = get_test_history() | ||
test_names = sorted(set(map(normalize, test_history['test_names']))) | ||
owners = load_owners(OWNERS_PATH) | ||
|
||
outdated_tests = sorted(set(owners) - set(test_names)) | ||
new_tests = sorted(set(test_names) - set(owners)) | ||
maintainers = get_maintainers() | ||
|
||
print '# OUTDATED TESTS (%d):' % len(outdated_tests) | ||
print '\n'.join(outdated_tests) | ||
print '# NEW TESTS (%d):' % len(new_tests) | ||
print '\n'.join(new_tests) | ||
|
||
for name in outdated_tests: | ||
owners.pop(name) | ||
|
||
print '# UNEXPECTED MAINTAINERS ', | ||
print '(randomly assigned, but not in kubernetes-maintainers)' | ||
for name, (owner, random_assignment) in sorted(owners.iteritems()): | ||
if random_assignment and owner not in maintainers: | ||
print '%-16s %s' % (owner, name) | ||
owners.pop(name) | ||
|
||
owner_counts = collections.Counter( | ||
owner for name, (owner, random) in owners.iteritems() | ||
if owner in maintainers) | ||
for test_name in set(test_names) - set(owners): | ||
new_owner, _count = random.choice(owner_counts.most_common()[-4:]) | ||
owner_counts[new_owner] += 1 | ||
owners[test_name] = (new_owner, True) | ||
|
||
print '# Tests per maintainer:' | ||
for owner, count in owner_counts.most_common(): | ||
print '%-20s %3d' % (owner, count) | ||
|
||
write_owners(OWNERS_PATH + '.new', owners) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. consider using % instead |
||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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 @@ | ||
test_owners.csv merge=union |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting so this prints info about new and outdated tests as well as random assignments who are no longer maintainers, and it removes outdated tests but otherwise just prints warnings?