open-nomad/ui/tests/acceptance/task-logs-test.js

41 lines
1.5 KiB
JavaScript
Raw Normal View History

2019-03-13 00:08:16 +00:00
import { currentURL } from '@ember/test-helpers';
import { run } from '@ember/runloop';
2019-03-13 00:04:16 +00:00
import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit';
2019-03-13 01:09:19 +00:00
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
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;
2019-03-13 00:04:16 +00:00
module('Acceptance | task logs', function(hooks) {
setupApplicationTest(hooks);
2019-03-13 01:09:19 +00:00
setupMirage(hooks);
2019-03-13 00:04:16 +00:00
hooks.beforeEach(async function() {
2017-11-16 02:13:28 +00:00
server.create('agent');
server.create('node', 'forceIPv4');
const job = server.create('job', { createAllocations: false });
2017-11-16 02:13:28 +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);
await TaskLogs.visit({ id: allocation.id, name: task.name });
2019-03-13 00:04:16 +00:00
});
2017-11-16 02:13:28 +00:00
test('/allocation/:id/:task_name/logs should have a log component', async function(assert) {
2019-03-13 00:04:16 +00:00
assert.equal(currentURL(), `/allocations/${allocation.id}/${task.name}/logs`, 'No redirect');
assert.ok(TaskLogs.hasTaskLog, 'Task log component found');
});
2017-11-16 02:13:28 +00:00
test('the stdout log immediately starts streaming', async function(assert) {
2019-03-13 00:04:16 +00:00
const node = server.db.nodes.find(allocation.nodeId);
const logUrlRegex = new RegExp(`${node.httpAddr}/v1/client/fs/logs/${allocation.id}`);
assert.ok(
server.pretender.handledRequests.filter(req => logUrlRegex.test(req.url)).length,
'Log requests were made'
);
});
2017-11-16 02:13:28 +00:00
});