Commit 616e9386 authored by Ryan Hitchman's avatar Ryan Hitchman

Address PR comments, randomly assign owners for new tests.

parent 3d485098
...@@ -14,21 +14,26 @@ ...@@ -14,21 +14,26 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import collections
import csv import csv
import re import re
import json import json
import os import os
import random
import sys import sys
import time import time
import urllib2 import urllib2
import zlib import zlib
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.dirname(os.path.abspath(__file__))
OWNERS_PATH = os.path.abspath(os.path.join(BASE_DIR, '..', 'test', 'test_owners.csv')) 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(): def get_test_history():
url = time.strftime('https://storage.googleapis.com/kubernetes-test-history/logs/%Y-%m-%d.json') url = time.strftime(GCS_URL_BASE + 'logs/%Y-%m-%d.json')
resp = urllib2.urlopen(url) resp = urllib2.urlopen(url)
content = resp.read() content = resp.read()
if resp.headers.get('content-encoding') == 'gzip': if resp.headers.get('content-encoding') == 'gzip':
...@@ -44,42 +49,47 @@ def normalize(name): ...@@ -44,42 +49,47 @@ def normalize(name):
def load_owners(fname): def load_owners(fname):
owners = {} owners = {}
for n, (name, owner, random_assignment) in enumerate(csv.reader(open(fname))): with open(fname) as f:
if n == 0: for n, (name, owner, random_assignment) in enumerate(csv.reader(f)):
continue # header if n == 0:
owners[normalize(name)] = (owner, int(random_assignment)) continue # header
return owners owners[normalize(name)] = (owner, int(random_assignment))
return owners
def write_owners(fname, owners): def write_owners(fname, owners):
out = csv.writer(open(fname, 'w')) with open(fname, 'w') as f:
out.writerow(['name', 'owner', 'auto-assigned']) out = csv.writer(f, lineterminator='\n')
for name, (owner, random_assignment) in sorted(owners.items()): out.writerow(['name', 'owner', 'auto-assigned'])
out.writerow([name, owner, int(random_assignment)]) for name, (owner, random_assignment) in sorted(owners.items()):
out.writerow([name, owner, int(random_assignment)])
def get_maintainers(): def get_maintainers():
# Github doesn't seem to support team membership listing without org admin privileges. # Github doesn't seem to support team membership listing without a key with
# Instead, we do it manually: # org admin privileges. Instead, we do it manually:
# Open https://github.com/orgs/kubernetes/teams/kubernetes-maintainers # Open https://github.com/orgs/kubernetes/teams/kubernetes-maintainers
# Run this in the js console: # Run this in the js console:
# [].slice.call(document.querySelectorAll('.team-member-username a')).map(e => e.textContent.trim()) # [].slice.call(document.querySelectorAll('.team-member-username a')).map(
return ["a-robinson", "alex-mohr", "amygdala", "andyzheng0831", "apelisse", "aronchick", # e => e.textContent.trim())
"ArtfulCoder", "bgrant0607", "bgrant0607-nocc", "bprashanth", "brendandburns", ret = {"a-robinson", "alex-mohr", "amygdala", "andyzheng0831", "apelisse",
"caesarxuchao", "childsb", "cjcullen", "david-mcmahon", "davidopp", "dchen1107", "aronchick", "ArtfulCoder", "bgrant0607", "bgrant0607-nocc",
"deads2k", "derekwaynecarr", "dubstack", "eparis", "erictune", "fabioy", "bprashanth", "brendandburns", "caesarxuchao", "childsb", "cjcullen",
"fejta", "fgrzadkowski", "freehan", "ghodss", "girishkalele", "gmarek", "david-mcmahon", "davidopp", "dchen1107", "deads2k", "derekwaynecarr",
"goltermann", "grodrigues3", "hurf", "ingvagabund", "ixdy", "dubstack", "eparis", "erictune", "fabioy", "fejta", "fgrzadkowski",
"jackgr", "janetkuo", "jbeda", "jdef", "jingxu97", "jlowdermilk", "freehan", "ghodss", "girishkalele", "gmarek", "goltermann",
"jsafrane", "jszczepkowski", "justinsb", "kargakis", "karlkfi", "grodrigues3", "hurf", "ingvagabund", "ixdy",
"kelseyhightower", "kevin-wangzefeng", "krousey", "lavalamp", "jackgr", "janetkuo", "jbeda", "jdef", "jingxu97", "jlowdermilk",
"liggitt", "luxas", "madhusudancs", "maisem", "mansoorj", "jsafrane", "jszczepkowski", "justinsb", "kargakis", "karlkfi",
"matchstick", "mikedanese", "mml", "mtaufen", "mwielgus", "ncdc", "kelseyhightower", "kevin-wangzefeng", "krousey", "lavalamp",
"nikhiljindal", "piosz", "pmorie", "pwittrock", "Q-Lee", "quinton-hoole", "liggitt", "luxas", "madhusudancs", "maisem", "mansoorj", "matchstick",
"Random-Liu", "rmmh", "roberthbailey", "ronnielai", "saad-ali", "sarahnovotny", "mikedanese", "mml", "mtaufen", "mwielgus", "ncdc", "nikhiljindal",
"smarterclayton", "soltysh", "spxtr", "sttts", "swagiaal", "thockin", "piosz", "pmorie", "pwittrock", "Q-Lee", "quinton-hoole", "Random-Liu",
"timothysc", "timstclair", "tmrts", "vishh", "vulpecula", "wojtek-t", "xiang90", "rmmh", "roberthbailey", "ronnielai", "saad-ali", "sarahnovotny",
"yifan-gu", "yujuhong", "zmerlynn"] "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(): def main():
...@@ -99,10 +109,25 @@ def main(): ...@@ -99,10 +109,25 @@ def main():
for name in outdated_tests: for name in outdated_tests:
owners.pop(name) owners.pop(name)
print '# UNEXPECTED MAINTAINERS (randomly assigned, not in kubernetes-maintainers)' print '# UNEXPECTED MAINTAINERS ',
print '(randomly assigned, but not in kubernetes-maintainers)'
for name, (owner, random_assignment) in sorted(owners.iteritems()): for name, (owner, random_assignment) in sorted(owners.iteritems()):
if random_assignment and owner not in maintainers: if random_assignment and owner not in maintainers:
print '%-16s %s' % (owner, name) print '%-16s %s' % (owner, name)
owners.pop(name)
print
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) write_owners(OWNERS_PATH + '.new', owners)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment