github.com/zoomfoo/nomad@v0.8.5-0.20180907175415-f28fd3a1a056/ui/tests/acceptance/task-logs-test.js (about)

     1  import { run } from '@ember/runloop';
     2  import { test } from 'qunit';
     3  import moduleForAcceptance from 'nomad-ui/tests/helpers/module-for-acceptance';
     4  import TaskLogs from 'nomad-ui/tests/pages/allocations/task/logs';
     5  
     6  let allocation;
     7  let task;
     8  
     9  moduleForAcceptance('Acceptance | task logs', {
    10    beforeEach() {
    11      server.create('agent');
    12      server.create('node', 'forceIPv4');
    13      const job = server.create('job');
    14  
    15      allocation = server.db.allocations.where({ jobId: job.id })[0];
    16      task = server.db.taskStates.where({ allocationId: allocation.id })[0];
    17  
    18      run.later(run, run.cancelTimers, 1000);
    19      TaskLogs.visit({ id: allocation.id, name: task.name });
    20    },
    21  });
    22  
    23  test('/allocation/:id/:task_name/logs should have a log component', function(assert) {
    24    assert.equal(currentURL(), `/allocations/${allocation.id}/${task.name}/logs`, 'No redirect');
    25    assert.ok(TaskLogs.hasTaskLog, 'Task log component found');
    26  });
    27  
    28  test('the stdout log immediately starts streaming', function(assert) {
    29    const node = server.db.nodes.find(allocation.nodeId);
    30    const logUrlRegex = new RegExp(`${node.httpAddr}/v1/client/fs/logs/${allocation.id}`);
    31    assert.ok(
    32      server.pretender.handledRequests.filter(req => logUrlRegex.test(req.url)).length,
    33      'Log requests were made'
    34    );
    35  });