Skip to content

Commit 35b1fc1

Browse files
committed
models/runs.py: Add flavor to runs output
Signed-off-by: Vallari Agrawal <val.agl002@gmail.com>
1 parent a2f278c commit 35b1fc1

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

paddles/models/runs.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def __json__(self):
168168
machine_type=self.machine_type,
169169
sha1=results['sha1'],
170170
priority=self.priority,
171+
flavor=results['flavor'],
171172
)
172173

173174
@classmethod
@@ -227,6 +228,7 @@ def get_results(self):
227228
unknown = jobs_status.count(None) + jobs_status.count('unknown')
228229
total = len(jobs_status)
229230
sha1 = next(self.jobs.values(Job.sha1), ['none'])[0]
231+
flavor = next(self.jobs.values(Job.flavor), ['none'])[0]
230232
return {
231233
'queued': queued,
232234
'pass': passing,
@@ -237,6 +239,7 @@ def get_results(self):
237239
'unknown': unknown,
238240
'total': total,
239241
'sha1': sha1,
242+
'flavor': flavor,
240243
}
241244

242245
def set_status(self, results=None):

paddles/tests/models/test_runs.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def test_run_results(self):
228228
run_name = 'teuthology-2014-03-27_00:00:00-x-x-x-x-x'
229229
new_run = Run(run_name)
230230
stats_in = {'pass': 9, 'fail': 1, 'dead': 6, 'running': 5, 'sha1': None,
231-
'waiting': 1, 'unknown': 1, 'queued': 1}
231+
'waiting': 1, 'unknown': 1, 'queued': 1, 'flavor': None}
232232
statuses = stats_in.keys()
233233
stats_in['total'] = sum(_ for _ in stats_in.values() if _)
234234
stats_out = {}
@@ -248,3 +248,10 @@ def test_run_priority(self):
248248
new_run = Run(run_name)
249249
Job(dict(job_id=1, id=1, status='queued', priority=99), new_run)
250250
assert new_run.priority == 99
251+
252+
def test_run_flavor(self):
253+
run_name = "run_flavor"
254+
new_run = Run(run_name)
255+
Job(dict(job_id=1, id=1, status='queued', flavor="blah"), new_run)
256+
run_result = new_run.get_results()
257+
assert run_result.get('flavor') == "blah"

0 commit comments

Comments
 (0)