mirror of
https://github.com/kemko/nomad.git
synced 2026-01-03 17:05:43 +03:00
* Hook and latch on the initial index * Serialization and restart of controller and table * de-log * allocBlocks reimplemented at job model level * totalAllocs doesnt mean on jobmodel what it did in steady.js * Hamburgers to sausages * Hacky way to bring new jobs back around and parent job handling in list view * Getting closer to hook/latch * Latch from update on hook from initialize, but fickle * Note on multiple-watch problem * Sensible monday morning comment removal * use of abortController to handle transition and reset events * Next token will now update when there's an on-page shift * Very rough anti-jostle technique * Demoable, now to move things out of route and into controller * Into the controller, generally * Smarter cancellations * Reset abortController on index models run, and system/sysbatch jobs now have an improved groupCountSum computed property * Prev Page reverse querying * n+1th jobs existing will trigger nextToken/pagination display * Start of a GET/POST statuses return * Namespace fix * Unblock tests * Realizing to my small horror that this skipURLModification flag may be too heavy handed * Lintfix * Default liveupdates localStorage setting to true * Pagination and index rethink * Big uncoupling of watchable and url-append stuff * Testfixes for region, search, and keyboard * Job row class for test purposes * Allocations in test now contain events * Starting on the jobs list tests in earnest * Forbidden state de-bubbling cleanup * Job list page size fixes * Facet/Search/Filter jobs list tests skipped * Maybe it's the automatic mirage logging * Unbreak task unit test * Pre-sort sort * styling for jobs list pagination and general PR cleanup * moving from Job.ActiveDeploymentID to Job.LatestDeployment.ID * modifyIndex-based pagination (#20350) * modifyIndex-based pagination * modifyIndex gets its own column and pagination compacted with icons * A generic withPagination handler for mirage * Some live-PR changes * Pagination and button disabled tests * Job update handling tests for jobs index * assertion timeout in case of long setTimeouts * assert.timeouts down to 500ms * de-to-do * Clarifying comment and test descriptions * Bugfix: resizing your browser on the new jobs index page would make the viz grow forever (#20458) * [ui] Searching and filtering options (#20459) * Beginnings of a search box for filter expressions * jobSearchBox integration test * jobs list updateFilter initial test * Basic jobs list filtering tests * First attempt at side-by-side facets and search with a computed filter * Weirdly close to an iterative approach but checked isnt tracked properly * Big rework to make filter composition and decomposition work nicely with the url * Namespace facet dropdown added * NodePool facet dropdown added * hdsFacet for future testing and basic namespace filtering test * Namespace filter existence test * Status filtering * Node pool/dynamic facet test * Test patchups * Attempt at optimize test fix * Allocation re-load on optimize page explainer * The Big Un-Skip * Post-PR-review cleanup * todo-squashing * [ui] Handle parent/child jobs with the paginated Jobs Index route (#20493) * First pass at a non-watchQuery version * Parameterized jobs get child fetching and jobs index status style for parent jobs * Completed allocs vs Running allocs in a child-job context, and fix an issue where moving from parent to parent would not reset index * Testfix and better handling empty-child-statuses-list * Parent/child test case * Dont show empty allocation-status bars for parent jobs with no children * Splits Settings into 2 sections, sign-in/profile and user settings (#20535) * Changelog
409 lines
10 KiB
JavaScript
409 lines
10 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { module, test } from 'qunit';
|
|
import { setupTest } from 'ember-qunit';
|
|
import AllocationModel from 'nomad-ui/models/allocation';
|
|
|
|
module('Unit | Serializer | Allocation', function (hooks) {
|
|
setupTest(hooks);
|
|
hooks.beforeEach(function () {
|
|
this.store = this.owner.lookup('service:store');
|
|
this.subject = () => this.store.serializerFor('allocation');
|
|
});
|
|
|
|
const sampleDate = new Date('2018-12-12T00:00:00');
|
|
const normalizationTestCases = [
|
|
{
|
|
name: 'Normal',
|
|
in: {
|
|
ID: 'test-allocation',
|
|
JobID: 'test-summary',
|
|
Name: 'test-summary[1]',
|
|
Namespace: 'test-namespace',
|
|
TaskGroup: 'test-group',
|
|
CreateTime: +sampleDate * 1000000,
|
|
ModifyTime: +sampleDate * 1000000,
|
|
TaskStates: {
|
|
testTask: {
|
|
State: 'running',
|
|
Failed: false,
|
|
},
|
|
},
|
|
},
|
|
out: {
|
|
data: {
|
|
id: 'test-allocation',
|
|
type: 'allocation',
|
|
attributes: {
|
|
taskGroupName: 'test-group',
|
|
name: 'test-summary[1]',
|
|
namespace: 'test-namespace',
|
|
modifyTime: sampleDate,
|
|
createTime: sampleDate,
|
|
states: [
|
|
{
|
|
name: 'testTask',
|
|
state: 'running',
|
|
failed: false,
|
|
events: [],
|
|
},
|
|
],
|
|
wasPreempted: false,
|
|
allocationTaskGroup: null,
|
|
},
|
|
relationships: {
|
|
followUpEvaluation: {
|
|
data: null,
|
|
},
|
|
nextAllocation: {
|
|
data: null,
|
|
},
|
|
previousAllocation: {
|
|
data: null,
|
|
},
|
|
preemptedAllocations: {
|
|
data: [],
|
|
},
|
|
preemptedByAllocation: {
|
|
data: null,
|
|
},
|
|
job: {
|
|
data: {
|
|
id: '["test-summary","test-namespace"]',
|
|
type: 'job',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
{
|
|
name: 'Dots in task names',
|
|
in: {
|
|
ID: 'test-allocation',
|
|
JobID: 'test-summary',
|
|
Name: 'test-summary[1]',
|
|
Namespace: 'test-namespace',
|
|
TaskGroup: 'test-group',
|
|
CreateTime: +sampleDate * 1000000,
|
|
ModifyTime: +sampleDate * 1000000,
|
|
TaskStates: {
|
|
'one.two': {
|
|
State: 'running',
|
|
Failed: false,
|
|
},
|
|
'three.four': {
|
|
State: 'pending',
|
|
Failed: true,
|
|
},
|
|
},
|
|
},
|
|
out: {
|
|
data: {
|
|
id: 'test-allocation',
|
|
type: 'allocation',
|
|
attributes: {
|
|
taskGroupName: 'test-group',
|
|
name: 'test-summary[1]',
|
|
namespace: 'test-namespace',
|
|
modifyTime: sampleDate,
|
|
createTime: sampleDate,
|
|
states: [
|
|
{
|
|
name: 'one.two',
|
|
state: 'running',
|
|
failed: false,
|
|
events: [],
|
|
},
|
|
{
|
|
name: 'three.four',
|
|
state: 'pending',
|
|
failed: true,
|
|
events: [],
|
|
},
|
|
],
|
|
wasPreempted: false,
|
|
allocationTaskGroup: null,
|
|
},
|
|
relationships: {
|
|
followUpEvaluation: {
|
|
data: null,
|
|
},
|
|
nextAllocation: {
|
|
data: null,
|
|
},
|
|
previousAllocation: {
|
|
data: null,
|
|
},
|
|
preemptedAllocations: {
|
|
data: [],
|
|
},
|
|
preemptedByAllocation: {
|
|
data: null,
|
|
},
|
|
job: {
|
|
data: {
|
|
id: '["test-summary","test-namespace"]',
|
|
type: 'job',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
{
|
|
name: 'With preemptions',
|
|
in: {
|
|
ID: 'test-allocation',
|
|
JobID: 'test-summary',
|
|
Name: 'test-summary[1]',
|
|
Namespace: 'test-namespace',
|
|
TaskGroup: 'test-group',
|
|
CreateTime: +sampleDate * 1000000,
|
|
ModifyTime: +sampleDate * 1000000,
|
|
TaskStates: {
|
|
task: {
|
|
State: 'running',
|
|
Failed: false,
|
|
},
|
|
},
|
|
PreemptedByAllocation: 'preempter-allocation',
|
|
PreemptedAllocations: [
|
|
'preempted-one-allocation',
|
|
'preempted-two-allocation',
|
|
],
|
|
},
|
|
out: {
|
|
data: {
|
|
id: 'test-allocation',
|
|
type: 'allocation',
|
|
attributes: {
|
|
taskGroupName: 'test-group',
|
|
name: 'test-summary[1]',
|
|
namespace: 'test-namespace',
|
|
modifyTime: sampleDate,
|
|
createTime: sampleDate,
|
|
states: [
|
|
{
|
|
name: 'task',
|
|
state: 'running',
|
|
failed: false,
|
|
events: [],
|
|
},
|
|
],
|
|
wasPreempted: true,
|
|
allocationTaskGroup: null,
|
|
},
|
|
relationships: {
|
|
followUpEvaluation: {
|
|
data: null,
|
|
},
|
|
nextAllocation: {
|
|
data: null,
|
|
},
|
|
previousAllocation: {
|
|
data: null,
|
|
},
|
|
preemptedAllocations: {
|
|
data: [
|
|
{ id: 'preempted-one-allocation', type: 'allocation' },
|
|
{ id: 'preempted-two-allocation', type: 'allocation' },
|
|
],
|
|
},
|
|
preemptedByAllocation: {
|
|
data: {
|
|
id: 'preempter-allocation',
|
|
type: 'allocation',
|
|
},
|
|
},
|
|
job: {
|
|
data: {
|
|
id: '["test-summary","test-namespace"]',
|
|
type: 'job',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
{
|
|
name: 'Derives task group from embedded job when available',
|
|
in: {
|
|
ID: 'test-allocation',
|
|
JobID: 'test-summary',
|
|
Name: 'test-summary[1]',
|
|
Namespace: 'test-namespace',
|
|
TaskGroup: 'test-group',
|
|
CreateTime: +sampleDate * 1000000,
|
|
ModifyTime: +sampleDate * 1000000,
|
|
TaskStates: {
|
|
task: {
|
|
State: 'running',
|
|
Failed: false,
|
|
},
|
|
},
|
|
Job: {
|
|
ID: 'test-summary',
|
|
Name: 'test-summary',
|
|
TaskGroups: [
|
|
{
|
|
Name: 'fake-group',
|
|
Count: 2,
|
|
Tasks: [],
|
|
EphemeralDisk: {},
|
|
},
|
|
{
|
|
Name: 'test-group',
|
|
Count: 3,
|
|
Tasks: [],
|
|
EphemeralDisk: {},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
out: {
|
|
data: {
|
|
id: 'test-allocation',
|
|
type: 'allocation',
|
|
attributes: {
|
|
taskGroupName: 'test-group',
|
|
name: 'test-summary[1]',
|
|
namespace: 'test-namespace',
|
|
modifyTime: sampleDate,
|
|
createTime: sampleDate,
|
|
states: [
|
|
{
|
|
name: 'task',
|
|
state: 'running',
|
|
failed: false,
|
|
events: [],
|
|
},
|
|
],
|
|
wasPreempted: false,
|
|
allocationTaskGroup: {
|
|
name: 'test-group',
|
|
count: 3,
|
|
tasks: [],
|
|
services: [],
|
|
volumes: [],
|
|
},
|
|
},
|
|
relationships: {
|
|
followUpEvaluation: {
|
|
data: null,
|
|
},
|
|
nextAllocation: {
|
|
data: null,
|
|
},
|
|
previousAllocation: {
|
|
data: null,
|
|
},
|
|
preemptedAllocations: {
|
|
data: [],
|
|
},
|
|
preemptedByAllocation: {
|
|
data: null,
|
|
},
|
|
job: {
|
|
data: {
|
|
id: '["test-summary","test-namespace"]',
|
|
type: 'job',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
{
|
|
name: 'TaskStates are sorted for stable fragments',
|
|
in: {
|
|
ID: 'test-allocation',
|
|
JobID: 'test-summary',
|
|
Name: 'test-summary[1]',
|
|
Namespace: 'test-namespace',
|
|
TaskGroup: 'test-group',
|
|
CreateTime: +sampleDate * 1000000,
|
|
ModifyTime: +sampleDate * 1000000,
|
|
TaskStates: {
|
|
xyz: {
|
|
State: 'running',
|
|
Failed: false,
|
|
},
|
|
abc: {
|
|
State: 'running',
|
|
Failed: false,
|
|
},
|
|
},
|
|
},
|
|
out: {
|
|
data: {
|
|
id: 'test-allocation',
|
|
type: 'allocation',
|
|
attributes: {
|
|
taskGroupName: 'test-group',
|
|
name: 'test-summary[1]',
|
|
namespace: 'test-namespace',
|
|
modifyTime: sampleDate,
|
|
createTime: sampleDate,
|
|
states: [
|
|
{
|
|
name: 'abc',
|
|
state: 'running',
|
|
failed: false,
|
|
events: [],
|
|
},
|
|
{
|
|
name: 'xyz',
|
|
state: 'running',
|
|
failed: false,
|
|
events: [],
|
|
},
|
|
],
|
|
wasPreempted: false,
|
|
allocationTaskGroup: null,
|
|
},
|
|
relationships: {
|
|
followUpEvaluation: {
|
|
data: null,
|
|
},
|
|
nextAllocation: {
|
|
data: null,
|
|
},
|
|
previousAllocation: {
|
|
data: null,
|
|
},
|
|
preemptedAllocations: {
|
|
data: [],
|
|
},
|
|
preemptedByAllocation: {
|
|
data: null,
|
|
},
|
|
job: {
|
|
data: {
|
|
id: '["test-summary","test-namespace"]',
|
|
type: 'job',
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
];
|
|
|
|
normalizationTestCases.forEach((testCase) => {
|
|
test(`normalization: ${testCase.name}`, async function (assert) {
|
|
assert.deepEqual(
|
|
this.subject().normalize(AllocationModel, testCase.in),
|
|
testCase.out
|
|
);
|
|
});
|
|
});
|
|
});
|