@@ -122,22 +122,45 @@ module('Acceptance | allocation detail', function(hooks) {
122
122
} ) ;
123
123
124
124
test ( 'each task row should list high-level information for the task' , async function ( assert ) {
125
- const task = server . db . taskStates . where ( { allocationId : allocation . id } ) . sortBy ( 'name' ) [ 0 ] ;
126
- const events = server . db . taskEvents . where ( { taskStateId : task . id } ) ;
127
- const event = events [ events . length - 1 ] ;
125
+ const job = server . create ( 'job' , {
126
+ groupsCount : 1 ,
127
+ groupTaskCount : 3 ,
128
+ withGroupServices : true ,
129
+ createAllocations : false ,
130
+ } ) ;
131
+
132
+ const allocation = server . create ( 'allocation' , 'withTaskWithPorts' , {
133
+ clientStatus : 'running' ,
134
+ jobId : job . id ,
135
+ } ) ;
128
136
129
137
const taskGroup = server . schema . taskGroups . where ( {
130
138
jobId : allocation . jobId ,
131
139
name : allocation . taskGroup ,
132
140
} ) . models [ 0 ] ;
133
141
134
- const jobTask = taskGroup . tasks . models . find ( m => m . name === task . name ) ;
135
- const volumes = jobTask . volumeMounts . map ( volume => ( {
136
- name : volume . Volume ,
137
- source : taskGroup . volumes [ volume . Volume ] . Source ,
138
- } ) ) ;
142
+ // Set the expected task states.
143
+ const states = [ 'running' , 'pending' , 'dead' ] ;
144
+ server . db . taskStates
145
+ . where ( { allocationId : allocation . id } )
146
+ . sortBy ( 'name' )
147
+ . forEach ( ( task , i ) => {
148
+ server . db . taskStates . update ( task . id , { state : states [ i ] } ) ;
149
+ } ) ;
150
+
151
+ await Allocation . visit ( { id : allocation . id } ) ;
152
+
153
+ Allocation . tasks . forEach ( ( taskRow , i ) => {
154
+ const task = server . db . taskStates . where ( { allocationId : allocation . id } ) . sortBy ( 'name' ) [ i ] ;
155
+ const events = server . db . taskEvents . where ( { taskStateId : task . id } ) ;
156
+ const event = events [ events . length - 1 ] ;
157
+
158
+ const jobTask = taskGroup . tasks . models . find ( m => m . name === task . name ) ;
159
+ const volumes = jobTask . volumeMounts . map ( volume => ( {
160
+ name : volume . Volume ,
161
+ source : taskGroup . volumes [ volume . Volume ] . Source ,
162
+ } ) ) ;
139
163
140
- Allocation . tasks [ 0 ] . as ( taskRow => {
141
164
assert . equal ( taskRow . name , task . name , 'Name' ) ;
142
165
assert . equal ( taskRow . state , task . state , 'State' ) ;
143
166
assert . equal ( taskRow . message , event . displayMessage , 'Event Message' ) ;
@@ -147,6 +170,10 @@ module('Acceptance | allocation detail', function(hooks) {
147
170
'Event Time'
148
171
) ;
149
172
173
+ const expectStats = task . state === 'running' ;
174
+ assert . equal ( taskRow . hasCpuMetrics , expectStats , 'CPU metrics' ) ;
175
+ assert . equal ( taskRow . hasMemoryMetrics , expectStats , 'Memory metrics' ) ;
176
+
150
177
const volumesText = taskRow . volumes ;
151
178
volumes . forEach ( volume => {
152
179
assert . ok ( volumesText . includes ( volume . name ) , `Found label ${ volume . name } ` ) ;
@@ -271,7 +298,9 @@ module('Acceptance | allocation detail', function(hooks) {
271
298
await Allocation . stop . confirm ( ) ;
272
299
273
300
assert . equal (
274
- server . pretender . handledRequests . reject ( request => request . url . includes ( 'fuzzy' ) ) . findBy ( 'method' , 'POST' ) . url ,
301
+ server . pretender . handledRequests
302
+ . reject ( request => request . url . includes ( 'fuzzy' ) )
303
+ . findBy ( 'method' , 'POST' ) . url ,
275
304
`/v1/allocation/${ allocation . id } /stop` ,
276
305
'Stop request is made for the allocation'
277
306
) ;
0 commit comments