Add sched CLI and update readme.

This commit is contained in:
Tom Wilkie
2015-11-03 15:01:33 +00:00
parent 6b3c7353f5
commit f250a3b0e1
2 changed files with 40 additions and 0 deletions

View File

@@ -17,6 +17,8 @@ Included in this repo are tools shared by weave.git and scope.git. They include
suffixed with the number of hosts it requires, and the hosts available are
contained in the environment variable HOSTS, the tool will run tests in
parallel, on different hosts.
- ```scheduler```: an appengine application that can be used to distribute
tests across different shards in CircleCI.
## Using build-tools.git

38
sched Executable file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/python
import sys, string, json, urllib
import requests
BASE_URL="http://positive-cocoa-90213.appspot.com"
def test_time(test_name, runtime):
r = requests.post(BASE_URL + "/record/%s/%f" % (urllib.quote(test_name, safe=""), runtime))
print r.text
assert r.status_code == 204
def test_sched(test_run, shard_count, shard_id):
tests = json.dumps({'tests': string.split(sys.stdin.read())})
r = requests.post(BASE_URL + "/schedule/%s/%d/%d" % (test_run, shard_count, shard_id), data=tests)
assert r.status_code == 200
result = r.json()
for test in sorted(result['tests']):
print test
def usage():
print "%s <cmd> <args..>" % sys.argv[0]
print " time <test name> <run time>"
print " sched <test run> <num shards> <shard id>"
def main():
if len(sys.argv) < 4:
usage()
sys.exit(1)
if sys.argv[1] == "time":
test_time(sys.argv[2], float(sys.argv[3]))
elif sys.argv[1] == "sched":
test_sched(sys.argv[2], int(sys.argv[3]), int(sys.argv[4]))
else:
usage()
if __name__ == '__main__':
main()