Skip to content

Commit 625347c

Browse files
committed
Merged trunk@9354 to facelift copy
- Legacy-Id: 9357
2 parents a23d80e + 95f7139 commit 625347c

503 files changed

Lines changed: 13501 additions & 58298 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
/.project
1919
/.pydevproject
2020
/.settings
21+
/.coverage
2122
/unix.tag
2223
/testresult
2324
/mergelog
@@ -28,3 +29,4 @@
2829
/local
2930
/lib
3031
/include
32+
/latest-coverage.json

bin/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@
1111
/activate_this.py
1212
/pyflakes
1313
/pip2.7
14+
/coverage
15+
/coverage2
16+
/coverage-2.7

bin/mergeready

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,10 @@ ready += get_ready_commits(repo, 'personal')
247247
ready += get_ready_commits(repo, 'branch/amsl')
248248

249249
ready_commits = {}
250+
not_passed = {}
250251
for entry in ready:
251252
rev, repo, branch = entry
253+
# Get the time, committer, and commit message
252254
cmd = 'svn log -v -r %s %s/%s/' % (rev, repo, branch)
253255
if opt_verbose > 1:
254256
note("Running '%s' ..." % cmd)
@@ -261,9 +263,25 @@ for entry in ready:
261263
type, path = line[:4], line[5:]
262264
if 'M' in type or 'A' in type or 'D' in type:
263265
break
266+
# Get the test status
267+
cmd = 'svn propget --revprop -r %s "test:unittest"' % rev
268+
unittest = pipe(cmd).strip()
269+
#
264270
merge_path = os.path.join(*path.split(os.path.sep)[:4])
265271
if not (rev, repo, merge_path) in hold:
266-
ready_commits[when] = "%s %-24s %s@%s" % (when, who+":", merge_path, rev)
272+
output_line = "%s %-24s %s@%s" % (when, who+":", merge_path, rev)
273+
if unittest == 'passed':
274+
ready_commits[when] = output_line
275+
else:
276+
not_passed[when] = output_line
277+
278+
keys = not_passed.keys()
279+
keys.sort()
280+
if len(keys) > 0:
281+
sys.stderr.write("Commits marked ready which haven't passed the test suite:\n")
282+
for key in keys:
283+
sys.stderr.write(not_passed[key]+'\n')
284+
sys.stderr.write('\n')
267285

268286
keys = ready_commits.keys()
269287
keys.sort()

bin/mkrelease

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ longopts=help,dry-run,verbose,version
7979

8080
# Default values
8181
MSG=""
82+
PROJ=ietfdb
8283
VERFILE=ietf/__init__.py
8384
SETTINGS=ietf/settings.py
8485
do=""
@@ -158,25 +159,33 @@ SRC=${SRC#/} # remove leading slash
158159
MAJOR=${VER%%.*}
159160
REST=${VER#*.}
160161
MINOR=${REST%%.*}
161-
CHANGE=${REST#*.}
162-
VER="$(printf %d.%d.%d $MAJOR $MINOR $CHANGE)"
163-
NEXT=$(( $CHANGE + 1 ))
164-
DEV="$(printf %d.%d.%d-dev0 $MAJOR $MINOR $NEXT)"
162+
MAINT=${REST#*.}
163+
VER="$(printf %d.%d.%d $MAJOR $MINOR $MAINT)"
164+
NEXT=$(( $MAINT + 1 ))
165+
DEV="$(printf %d.%d.%d.dev0 $MAJOR $MINOR $NEXT)"
165166

166-
note "Checking that there's a recent test-crawler log"
167-
touch -d $RDATE .svn/.latest-commit
168-
TCLOG=$(ls -t ../test-crawl-*.log | head -n 1)
169-
[ $TCLOG -nt .svn/.latest-commit ] || die "Looked for ../test-crawl-*.log, but didn't find one newer than the latest repository commit ($RDATE)"
167+
#cd $DIR ??
168+
169+
note "Running the tests suite and writing release coverage data ..."
170+
$do ietf/manage.py test --settings=ietf.settings_releasetest --save-version-coverage=$VER
171+
172+
note "Committing the release coverage data ..."
173+
$do svn commit release-coverage.json -m "Code coverage data for release $VER"
174+
175+
# note "Checking that there's a recent test-crawler log"
176+
# touch -d $RDATE .svn/.latest-commit
177+
# TCLOG=$(ls -t ../test-crawl-*.log | head -n 1)
178+
# [ $TCLOG -nt .svn/.latest-commit ] || die "Looked for ../test-crawl-*.log, but didn't find one newer than the latest repository commit ($RDATE)"
170179

171180
note "Checking that changelog information is available"
172-
changes=$( sed -n "/^ietfdb ($VER.*)/,/^ -- /p" changelog )
181+
changes=$( sed -n "/^$PROJ ($VER.*)/,/^ -- /p" changelog )
173182
[ "$changes" ] || die "No changelog information for $VER found"
174183
note "$changes"
175184

176185
contributors=$(echo "$changes" | sed 's/\.[ \t\n]/ /'| tr -c "a-z0-9.@-" "\n" | sort | uniq | grep '@' | sed -r -e 's/^\.+//' -e 's/\.+$//' -e 's/^/-c /' || true)
177186

178187
note "Set the current time on the release notes in the changelog file"
179-
sed -r -i -e "1,/^ -- /s/([A-Za-z-]+ <[a-z0-9.-]+@[a-z0-9.-]+> ).*$/\1$(TZ=UTC date +'%d %b %Y %H:%M:%S %z')/" changelog
188+
$do sed -r -i -e "1,/^ -- /s/([A-Za-z-]+ <[a-z0-9.-]+@[a-z0-9.-]+> ).*$/\1$(TZ=UTC date +'%d %b %Y %H:%M:%S %z')/" changelog
180189
note " $(grep -m1 "^ -- " changelog)"
181190

182191
note "Verifying that version $VER doesn't already exist..."
@@ -190,7 +199,7 @@ note "Verifying there's no uncommitted changes..."
190199
$do svn st | grep "^[AMGRD] " && die "There seems to be uncommitted changes in this working copy"
191200

192201
note "\nUpdating the version info in $VERFILE and making sure'\$Rev\$' is Ok"
193-
$do sed -i -r -e "/^__version__/s/\"[.0-9]+(-dev[0-9]*)?\"/\"$VER\"/" \
202+
$do sed -i -r -e "/^__version__/s/\"[.0-9]+(dev[0-9]+)?\"/\"$VER\"/" \
194203
-e "/^__rev__/s/\".*\"/\"\$Rev:\$\"/" \
195204
$VERFILE
196205

@@ -234,10 +243,10 @@ Release notes:
234243
$changes
235244
236245
The new version is available for installation through SVN checkout, with
237-
'svn checkout http://svn.tools.ietf.org/svn/tools/ietfdb/tags/$VER'
246+
'svn checkout http://svn.tools.ietf.org/svn/tools/$PROJ/tags/$VER'
238247
239248
For development, check out the new development version instead:
240-
'svn checkout http://svn.tools.ietf.org/svn/tools/ietfdb/tags/dev/$DEV'
249+
'svn checkout http://svn.tools.ietf.org/svn/tools/$PROJ/tags/dev/$DEV'
241250
242251
Regards,
243252

bin/test-crawl

Lines changed: 50 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22

3-
import os, sys, re, datetime, argparse, traceback, tempfile
3+
import os, sys, re, datetime, argparse, traceback, tempfile, json
44

55
# args
66
parser = argparse.ArgumentParser(
@@ -14,6 +14,7 @@ parser.add_argument('--urls', '-u', dest='url_file',
1414
parser.add_argument('--slow', dest='slow_threshold', type=float, default=1.0,
1515
help='responses taking longer than this (in seconds) results in SLOW being printed')
1616
parser.add_argument('--settings', dest='settings', help='custom settings file')
17+
parser.add_argument('--logfile', dest='logfile', help='write to logfile')
1718

1819
args = parser.parse_args()
1920

@@ -51,6 +52,7 @@ if args.url_file:
5152

5253
if not initial_urls:
5354
initial_urls.append("/")
55+
initial_urls.append("/api/v1")
5456

5557
visited = set()
5658
urls = {} # url -> referrer
@@ -78,8 +80,30 @@ def extract_html_urls(content):
7880

7981
yield url
8082

83+
def extract_tastypie_urls(content):
84+
VISIT_OBJECTS = False
85+
VISIT_NEXT = False
86+
data = json.loads(content)
87+
for item in data:
88+
if type(data[item]) is dict:
89+
if "list_endpoint" in data[item]:
90+
uri = data[item]["list_endpoint"]
91+
yield uri
92+
if VISIT_NEXT:
93+
if "meta" in data and "next" in data["meta"]:
94+
uri = data["meta"]["next"]
95+
if uri != None:
96+
yield uri
97+
if VISIT_OBJECTS:
98+
if "objects" in data:
99+
object_list = data["objects"]
100+
for i in range(len(object_list)):
101+
if "resource_uri" in object_list[i]:
102+
uri = object_list[i]["resource_uri"]
103+
yield uri
104+
81105
django.setup()
82-
client = django.test.Client()
106+
client = django.test.Client(Accept='text/html,text/plain,application/json')
83107

84108
for url in initial_urls:
85109
urls[url] = "[initial]"
@@ -88,14 +112,16 @@ errors = 0
88112
count = 0
89113

90114
start_time = datetime.datetime.now()
91-
fh, fn = tempfile.mkstemp(prefix="test-crawl-", suffix=".log", dir="../")
92-
logfile = open(fn, "w")
93-
os.close(fh)
115+
116+
logfile = None
117+
if args.logfile:
118+
logfile = open(args.logfile, "w")
94119

95120
def log(s):
96121
print(s)
97-
logfile.write(s)
98-
logfile.write('\n')
122+
if logfile:
123+
logfile.write(s)
124+
logfile.write('\n')
99125

100126
def get_referrers(url):
101127
ref_list = []
@@ -150,8 +176,19 @@ while urls:
150176
log("=============")
151177
log(traceback.format_exc())
152178
log("=============")
179+
elif ctype == "application/json":
180+
try:
181+
for u in extract_tastypie_urls(r.content):
182+
if u not in visited and u not in urls:
183+
urls[u] = url
184+
referrers[u] = url
185+
except:
186+
log("error extracting urls from %s" % url)
187+
log("=============")
188+
log(traceback.format_exc())
189+
log("=============")
153190
else:
154-
tags.append(u"FAIL (from %s)" % referrer)
191+
tags.append(u"FAIL for %s\n (from %s)" % (url, referrer))
155192
errors += 1
156193

157194
if elapsed.total_seconds() > slow_threshold:
@@ -164,12 +201,13 @@ while urls:
164201
sec = acc_secs % 60
165202

166203
if (len(visited) % 100) == 1:
167-
log("\nElapsed Visited Queue Code Time Url ... Notes")
204+
log("\nElapsed Visited Queue Code Time Url ... Notes")
168205

169-
log("%2d:%02d:%02d %7d %6d %s %.3fs %s %s" % (hrs,min,sec, len(visited), len(urls), r.status_code, elapsed.total_seconds(), url, " ".join(tags)))
206+
log("%2d:%02d:%02d %7d %6d %s %6.3fs %s %s" % (hrs,min,sec, len(visited), len(urls), r.status_code, elapsed.total_seconds(), url, " ".join(tags)))
170207

171-
logfile.close()
172-
sys.stderr.write("Output written to %s\n\n" % logfile.name)
208+
if logfile:
209+
logfile.close()
210+
sys.stderr.write("Output written to %s\n\n" % logfile.name)
173211

174212
if errors > 0:
175213
sys.stderr.write("Found %s errors, grep output for FAIL for details\n" % errors)

0 commit comments

Comments
 (0)