mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
Acceptance tests for task logs
This commit is contained in:
@@ -8,7 +8,7 @@ const { Component, computed, inject, run } = Ember;
|
||||
export default Component.extend(WindowResizable, {
|
||||
token: inject.service(),
|
||||
|
||||
classNames: ['boxed-section'],
|
||||
classNames: ['boxed-section', 'task-log'],
|
||||
|
||||
allocation: null,
|
||||
task: null,
|
||||
|
||||
@@ -173,9 +173,9 @@ export default function() {
|
||||
{ params, queryParams }
|
||||
) {
|
||||
const allocation = server.allocations.find(params.allocation_id);
|
||||
const groups = server.taskGroups.findBy({ jobId: allocation.jobId });
|
||||
const tasks = allocation.taskStateIds.map(id => server.taskStates.find(id));
|
||||
|
||||
if (!groups.mapBy('name').includes(queryParams.task)) {
|
||||
if (!tasks.mapBy('name').includes(queryParams.task)) {
|
||||
return new Response(400, {}, 'must include task name');
|
||||
}
|
||||
|
||||
|
||||
37
ui/tests/acceptance/task-logs-test.js
Normal file
37
ui/tests/acceptance/task-logs-test.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import Ember from 'ember';
|
||||
import { find } from 'ember-native-dom-helpers';
|
||||
import { test } from 'qunit';
|
||||
import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
|
||||
|
||||
const { run } = Ember;
|
||||
|
||||
let allocation;
|
||||
let task;
|
||||
|
||||
moduleForAcceptance('Acceptance | task logs', {
|
||||
beforeEach() {
|
||||
server.create('agent');
|
||||
server.create('node', 'forceIPv4');
|
||||
const job = server.create('job');
|
||||
|
||||
allocation = server.db.allocations.where({ jobId: job.id })[0];
|
||||
task = server.db.taskStates.where({ allocationId: allocation.id })[0];
|
||||
|
||||
run.later(run, run.cancelTimers, 1000);
|
||||
visit(`/allocations/${allocation.id}/${task.name}/logs`);
|
||||
},
|
||||
});
|
||||
|
||||
test('/allocation/:id/:task_name/logs should have a log component', function(assert) {
|
||||
assert.equal(currentURL(), `/allocations/${allocation.id}/${task.name}/logs`, 'No redirect');
|
||||
assert.ok(find('.task-log'), 'Task log component found');
|
||||
});
|
||||
|
||||
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(
|
||||
server.pretender.handledRequests.filter(req => logUrlRegex.test(req.url).length),
|
||||
'Log requests were made'
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user