Skip to content

Commit

Permalink
UI: Add creation time to evaluations table (#6050)
Browse files Browse the repository at this point in the history
  • Loading branch information
backspace authored Aug 22, 2019
1 parent fbddb92 commit 2364fb2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ IMPROVEMENTS:
* agent: add `-dev=connect` parameter to support running in dev mode with Consul Connect [[GH-6126](https://github.com/hashicorp/nomad/issues/6126)]
* api: add follow parameter to file streaming endpoint to support older browsers [[GH-6049](https://github.com/hashicorp/nomad/issues/6049)]
* metrics: Add job status (pending, running, dead) metrics [[GH-6003](https://github.com/hashicorp/nomad/issues/6003)]
* ui: Add creation time to evaluations table [[GH-6050](https://github.com/hashicorp/nomad/pull/6050)]

BUG FIXES:

Expand Down
4 changes: 4 additions & 0 deletions ui/app/models/evaluation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default Model.extend({
job: belongsTo('job'),

modifyIndex: attr('number'),
modifyTime: attr('date'),

createIndex: attr('number'),
createTime: attr('date'),

waitUntil: attr('date'),
});
6 changes: 6 additions & 0 deletions ui/app/serializers/evaluation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export default ApplicationSerializer.extend({
'default';
hash.JobID = JSON.stringify([hash.JobID, hash.Namespace]);

hash.ModifyTimeNanos = hash.ModifyTime % 1000000;
hash.ModifyTime = Math.floor(hash.ModifyTime / 1000000);

hash.CreateTimeNanos = hash.CreateTime % 1000000;
hash.CreateTime = Math.floor(hash.CreateTime / 1000000);

return this._super(typeHash, hash);
},
});
2 changes: 2 additions & 0 deletions ui/app/templates/jobs/job/evaluations.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{{#t.head}}
<th>ID</th>
{{#t.sort-by prop="priority"}}Priority{{/t.sort-by}}
{{#t.sort-by prop="createTime"}}Created{{/t.sort-by}}
{{#t.sort-by prop="triggeredBy"}}Triggered By{{/t.sort-by}}
{{#t.sort-by prop="status"}}Status{{/t.sort-by}}
{{#t.sort-by prop="hasPlacementFailures"}}Placement Failures{{/t.sort-by}}
Expand All @@ -17,6 +18,7 @@
<tr data-test-evaluation="{{row.model.shortId}}">
<td data-test-id>{{row.model.shortId}}</td>
<td data-test-priority>{{row.model.priority}}</td>
<td data-test-create-time>{{format-month-ts row.model.createTime}}</td>
<td data-test-triggered-by>{{row.model.triggeredBy}}</td>
<td data-test-status>{{row.model.status}}</td>
<td data-test-blocked>
Expand Down
7 changes: 7 additions & 0 deletions ui/mirage/factories/evaluation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const EVAL_TRIGGERED_BY = [
'failed-follow-up',
'max-plan-attempts',
];
const REF_TIME = new Date();

const generateCountMap = (keysCount, list) => () => {
const sample = Array(keysCount)
Expand Down Expand Up @@ -53,6 +54,12 @@ export default Factory.extend({
failedTGAllocs: null,

modifyIndex: () => faker.random.number({ min: 10, max: 2000 }),
modifyTime: () => faker.date.past(2 / 365, REF_TIME) * 1000000,

createIndex: () => faker.random.number({ min: 10, max: 2000 }),
createTime() {
return faker.date.past(2 / 365, new Date(this.modifyTime / 1000000)) * 1000000;
},

waitUntil: null,

Expand Down
9 changes: 9 additions & 0 deletions ui/tests/unit/serializers/evaluation-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@ module('Unit | Serializer | Evaluation', function(hooks) {
this.subject = () => this.store.serializerFor('evaluation');
});

const sampleDate = new Date('2018-12-12T00:00:00');
const normalizationTestCases = [
{
name: 'Normal',
in: {
ID: 'test-eval',
CreateTime: +sampleDate * 1000000,
ModifyTime: +sampleDate * 1000000,
FailedTGAllocs: {
taskGroup: {
NodesAvailable: 10,
Expand All @@ -29,6 +32,8 @@ module('Unit | Serializer | Evaluation', function(hooks) {
id: 'test-eval',
type: 'evaluation',
attributes: {
createTime: sampleDate,
modifyTime: sampleDate,
failedTGAllocs: [
{
name: 'taskGroup',
Expand All @@ -52,6 +57,8 @@ module('Unit | Serializer | Evaluation', function(hooks) {
name: 'Dots in task group names',
in: {
ID: 'test-eval',
CreateTime: +sampleDate * 1000000,
ModifyTime: +sampleDate * 1000000,
FailedTGAllocs: {
'one.two': {
NodesAvailable: 10,
Expand All @@ -70,6 +77,8 @@ module('Unit | Serializer | Evaluation', function(hooks) {
id: 'test-eval',
type: 'evaluation',
attributes: {
modifyTime: sampleDate,
createTime: sampleDate,
failedTGAllocs: [
{
name: 'one.two',
Expand Down

0 comments on commit 2364fb2

Please sign in to comment.