Skip to content

Commit

Permalink
scheduler: refactor system util tests (#16416)
Browse files Browse the repository at this point in the history
The tests for the system allocs reconciling code path (`diffSystemAllocs`)
include many impossible test environments, such as passing allocs for the wrong
node into the function. This makes the test assertions nonsensible for use in
walking yourself through the correct behavior.

I've pulled this changeset out of PR #16097 so that we can merge these
improvements and revisit the right approach to fix the problem in #16097 with
less urgency now that the PFNR bug fix has been merged. This changeset breaks up
a couple of tests, expands test coverage, and makes test assertions more
clear. It also corrects one bit of production code that behaves fine in
production because of canonicalization, but forces us to remember to set values
in tests to compensate.
  • Loading branch information
tgross authored Mar 13, 2023
1 parent 12688f2 commit b6d6cc4
Show file tree
Hide file tree
Showing 2 changed files with 307 additions and 201 deletions.
4 changes: 4 additions & 0 deletions nomad/structs/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6441,6 +6441,10 @@ func (tg *TaskGroup) Canonicalize(job *Job) {
tg.EphemeralDisk = DefaultEphemeralDisk()
}

if job.Type == JobTypeSystem && tg.Count == 0 {
tg.Count = 1
}

if tg.Scaling != nil {
tg.Scaling.Canonicalize()
}
Expand Down
Loading

0 comments on commit b6d6cc4

Please sign in to comment.