properly count hosts based on job event task state

the intention of the host summary view is that each host belongs in at
most *one* state - determined by the state of the tasks that ran on it.
this change examines each host for a job and determines its state based
on whether tasks passed, resulted in changes, were skipped, failed,
etc...

see: #5407
This commit is contained in:
Ryan Petrello
2017-02-17 11:36:52 -05:00
parent 68fc75070d
commit bda089e3f5
2 changed files with 71 additions and 22 deletions

View File

@@ -0,0 +1,50 @@
'use strict';
describe('jobResultsService', () => {
let jobResultsService;
beforeEach(angular.mock.module('Tower'));
beforeEach(angular.mock.inject(( _jobResultsService_) => {
jobResultsService = _jobResultsService_;
}));
describe('getCountsFromStatsEvent()', () => {
it('properly counts hosts based on task state', () => {
let event_data = {
"skipped": {
"skipped-host": 5 // this host skipped all 5 tasks
},
"ok": {
"ok-host": 5, // this host was ok on all 5 tasks
"changed-host": 4 // this host had 4 ok tasks, had 1 changed task
},
"changed": {
"changed-host": 1
},
"failures": {
"failed-host": 1 // this host had a failed task
},
"dark": {
"unreachable-host": 1 // this host was unreachable
},
"processed": {
"ok-host": 1,
"changed-host": 1,
"skipped-host": 1,
"failed-host": 1,
"unreachable-host": 1
},
"playbook_uuid": "c23d8872-c92a-4e96-9f78-abe6fef38f33",
"playbook": "some_playbook.yml",
};
expect(jobResultsService.getCountsFromStatsEvent(event_data)).toEqual({
'ok': 1,
'skipped': 1,
'unreachable': 1,
'failures': 1,
'changed': 1
});
});
});
});