@@ -125,22 +125,45 @@ module('Acceptance | allocation detail', function(hooks) {
125
125
} ) ;
126
126
127
127
test ( 'each task row should list high-level information for the task' , async function ( assert ) {
128
- const task = server . db . taskStates . where ( { allocationId : allocation . id } ) . sortBy ( 'name' ) [ 0 ] ;
129
- const events = server . db . taskEvents . where ( { taskStateId : task . id } ) ;
130
- const event = events [ events . length - 1 ] ;
128
+ const job = server . create ( 'job' , {
129
+ groupsCount : 1 ,
130
+ groupTaskCount : 3 ,
131
+ withGroupServices : true ,
132
+ createAllocations : false ,
133
+ } ) ;
134
+
135
+ const allocation = server . create ( 'allocation' , 'withTaskWithPorts' , {
136
+ clientStatus : 'running' ,
137
+ jobId : job . id ,
138
+ } ) ;
131
139
132
140
const taskGroup = server . schema . taskGroups . where ( {
133
141
jobId : allocation . jobId ,
134
142
name : allocation . taskGroup ,
135
143
} ) . models [ 0 ] ;
136
144
137
- const jobTask = taskGroup . tasks . models . find ( m => m . name === task . name ) ;
138
- const volumes = jobTask . volumeMounts . map ( volume => ( {
139
- name : volume . Volume ,
140
- source : taskGroup . volumes [ volume . Volume ] . Source ,
141
- } ) ) ;
145
+ // Set the expected task states.
146
+ const states = [ 'running' , 'pending' , 'dead' ] ;
147
+ server . db . taskStates
148
+ . where ( { allocationId : allocation . id } )
149
+ . sortBy ( 'name' )
150
+ . forEach ( ( task , i ) => {
151
+ server . db . taskStates . update ( task . id , { state : states [ i ] } ) ;
152
+ } ) ;
153
+
154
+ await Allocation . visit ( { id : allocation . id } ) ;
155
+
156
+ Allocation . tasks . forEach ( ( taskRow , i ) => {
157
+ const task = server . db . taskStates . where ( { allocationId : allocation . id } ) . sortBy ( 'name' ) [ i ] ;
158
+ const events = server . db . taskEvents . where ( { taskStateId : task . id } ) ;
159
+ const event = events [ events . length - 1 ] ;
160
+
161
+ const jobTask = taskGroup . tasks . models . find ( m => m . name === task . name ) ;
162
+ const volumes = jobTask . volumeMounts . map ( volume => ( {
163
+ name : volume . Volume ,
164
+ source : taskGroup . volumes [ volume . Volume ] . Source ,
165
+ } ) ) ;
142
166
143
- Allocation . tasks [ 0 ] . as ( taskRow => {
144
167
assert . equal ( taskRow . name , task . name , 'Name' ) ;
145
168
assert . equal ( taskRow . state , task . state , 'State' ) ;
146
169
assert . equal ( taskRow . message , event . displayMessage , 'Event Message' ) ;
@@ -150,6 +173,10 @@ module('Acceptance | allocation detail', function(hooks) {
150
173
'Event Time'
151
174
) ;
152
175
176
+ const expectStats = task . state === 'running' ;
177
+ assert . equal ( taskRow . hasCpuMetrics , expectStats , 'CPU metrics' ) ;
178
+ assert . equal ( taskRow . hasMemoryMetrics , expectStats , 'Memory metrics' ) ;
179
+
153
180
const volumesText = taskRow . volumes ;
154
181
volumes . forEach ( volume => {
155
182
assert . ok ( volumesText . includes ( volume . name ) , `Found label ${ volume . name } ` ) ;
0 commit comments