Skip to content

Commit bb4ecfd

Browse files
author
Gabriel Loewen
authored
Update aggregatorService.py
1 parent db544d2 commit bb4ecfd

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

statsproj/openstack_stats/aggregatorService.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from time import sleep
99

1010
# Add headers to url request to masquerade as a JSON request
11-
def addHeaders(req):
11+
def addheaders(req):
1212
req.add_header('Content-Disposition', 'attachment')
1313
req.add_header('X-Content-Type-Options', 'nosniff')
1414
req.add_header('Cache-Control', 'no-cache, no-store, max-age=0, must-revalidate')
@@ -19,7 +19,7 @@ def addHeaders(req):
1919
# Retrieve a list of details about a particular change ID
2020
def getGerritChangeRequest(cid):
2121
url = "https://review.openstack.org/changes/"+str(cid)+"/detail"
22-
req = addHeaders(urllib2.Request(url))
22+
req = addheaders(urllib2.Request(url))
2323
res = urllib2.urlopen(req)
2424
# ignore first line
2525
for line in res:
@@ -30,19 +30,16 @@ def getGerritChangeRequest(cid):
3030
def getChanges(project):
3131
# get all open and merged changes (ignoring abandoned)
3232
url = "https://review.openstack.org/changes/?q=status:open+project:"+project+"&q=status:merged+project:"+project
33-
req = addHeaders(urllib2.Request(url))
33+
req = addheaders(urllib2.Request(url))
3434
res = urllib2.urlopen(req)
35-
3635
# ignore first line
3736
for line in res:
3837
break
39-
4038
parser = ijson.parse(res)
4139
cids = []
4240
for prefix, event, value in parser:
4341
if "_number" in prefix:
4442
cids.append(value)
45-
4643
return cids
4744

4845
# Merge the change details for a worker/project into the DB
@@ -68,15 +65,20 @@ def mergeDetails(cids, worker, project):
6865
if 'patch' in dat[0].lower():
6966
patch = dat[0].split()
7067
patch = re.sub("[^0-9]","",patch[len(patch)-1])
71-
if 'build successful' in value.lower() or 'build succeeded' in value.lower():
72-
success = True
73-
elif 'build failed' in value.lower() or 'build unsuccessful' in value.lower():
68+
#if ('build successful' in value.lower() or 'build succeeded' in value.lower()) and not ('failure' in value.lower()):
69+
# if the build failed, the test has failed
70+
if 'build failed' in value.lower() or 'build unsuccessful' in value.lower():
7471
success = False
72+
# if the build succeeded but test failed...
73+
elif ('build successful' in value.lower() or 'build succeeded' in value.lower()) and 'failure' in value.lower():
74+
success = False
75+
elif ('build successful' in value.lower() or 'build succeeded' in value.lower()) and not ('failure' in value.lower()):
76+
success = True
7577
else:
7678
continue
7779
try:
7880
item = [int(cid),int(patch),date.date(),date.time(),success]
79-
data += [item]
81+
data += [item]
8082
except:
8183
continue
8284
elif prefix == 'messages.item.message' and author != worker:
@@ -99,7 +101,7 @@ def mergeDetails(cids, worker, project):
99101

100102
# Merge a chunk of changes. Helps with making the output seem to be more realtime
101103
def mergeChunk(data, missed, worker, project):
102-
missed = [x for x in missed if not match(x,data)]
104+
missed = [x for x in missed if not match(x,data)]
103105
missed = unique(missed)
104106
for item in data:
105107
try:
@@ -118,7 +120,7 @@ def mergeChunk(data, missed, worker, project):
118120
success=False,missed=True)
119121
except Exception, e:
120122
print str(e)
121-
continue
123+
continue
122124

123125
# Get a list of unique changes (i.e. matching CID and PID across a list)
124126
def unique(data):
@@ -154,9 +156,9 @@ def foundIn(item, objects):
154156

155157
# Look for any jobs marked as missed that were later submitted
156158
# (i.e. fix up the false negatives)
157-
def fixup(project,worker):
158-
missed = Change.objects.filter(project=project,worker=worker,missed=True)
159-
unMissed = Change.objects.filter(project=project,worker=worker,missed=False)
159+
def fixup(project,worker, change):
160+
missed = change.objects.filter(project=project,worker=worker,missed=True)
161+
unMissed = change.objects.filter(project=project,worker=worker,missed=False)
160162
erroneous = [x for x in missed if foundIn(x,unMissed)]
161163
for c in erroneous:
162164
c.delete()
@@ -170,7 +172,7 @@ def fixup(project,worker):
170172
for source in sources:
171173
project = source.project
172174
worker = source.worker
173-
fixup(project, worker)
175+
fixup(project, worker, Change)
174176
threads.append(threading.Thread(target=workerThread, args=(project, worker)))
175177
# start threads
176178
for thread in threads:

0 commit comments

Comments
 (0)