2017-12-15 21:39:18 +00:00
|
|
|
import { run } from '@ember/runloop';
|
2017-11-16 02:13:28 +00:00
|
|
|
import { test } from 'qunit';
|
|
|
|
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
|
2018-07-11 19:31:37 +00:00
|
|
|
import TaskLogs from 'nomad-ui/tests/pages/allocations/task/logs';
|
2017-11-16 02:13:28 +00:00
|
|
|
|
|
|
|
let allocation;
|
|
|
|
let task;
|
|
|
|
|
|
|
|
moduleForAcceptance('Acceptance | task logs', {
|
|
|
|
beforeEach() {
|
|
|
|
server.create('agent');
|
|
|
|
server.create('node', 'forceIPv4');
|
2018-11-10 01:13:08 +00:00
|
|
|
const job = server.create('job', { createAllocations: false });
|
2017-11-16 02:13:28 +00:00
|
|
|
|
2018-11-10 01:13:08 +00:00
|
|
|
allocation = server.create('allocation', { jobId: job.id, clientStatus: 'running' });
|
2017-11-16 02:13:28 +00:00
|
|
|
task = server.db.taskStates.where({ allocationId: allocation.id })[0];
|
|
|
|
|
|
|
|
run.later(run, run.cancelTimers, 1000);
|
2018-07-11 19:31:37 +00:00
|
|
|
TaskLogs.visit({ id: allocation.id, name: task.name });
|
2017-11-16 02:13:28 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
test('/allocation/:id/:task_name/logs should have a log component', function(assert) {
|
|
|
|
assert.equal(currentURL(), `/allocations/${allocation.id}/${task.name}/logs`, 'No redirect');
|
2018-07-11 19:31:37 +00:00
|
|
|
assert.ok(TaskLogs.hasTaskLog, 'Task log component found');
|
2017-11-16 02:13:28 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
test('the stdout log immediately starts streaming', function(assert) {
|
|
|
|
const node = server.db.nodes.find(allocation.nodeId);
|
|
|
|
const logUrlRegex = new RegExp(`${node.httpAddr}/v1/client/fs/logs/${allocation.id}`);
|
|
|
|
assert.ok(
|
2017-11-17 00:31:18 +00:00
|
|
|
server.pretender.handledRequests.filter(req => logUrlRegex.test(req.url)).length,
|
2017-11-16 02:13:28 +00:00
|
|
|
'Log requests were made'
|
|
|
|
);
|
|
|
|
});
|