15954: Remove unused cmdArgs.
[arvados.git] / lib / dispatchcloud / scheduler / sync_test.go
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 package scheduler
6
7 import (
8         "context"
9         "time"
10
11         "git.arvados.org/arvados.git/lib/dispatchcloud/test"
12         "git.arvados.org/arvados.git/sdk/go/arvados"
13         "git.arvados.org/arvados.git/sdk/go/ctxlog"
14         check "gopkg.in/check.v1"
15 )
16
17 // Ensure the scheduler expunges containers from the queue when they
18 // are no longer relevant (completed and not running, queued with
19 // priority 0, etc).
20 func (*SchedulerSuite) TestForgetIrrelevantContainers(c *check.C) {
21         ctx := ctxlog.Context(context.Background(), ctxlog.TestLogger(c))
22         pool := stubPool{}
23         queue := test.Queue{
24                 ChooseType: chooseType,
25                 Containers: []arvados.Container{
26                         {
27                                 UUID:     test.ContainerUUID(1),
28                                 Priority: 0,
29                                 State:    arvados.ContainerStateQueued,
30                                 RuntimeConstraints: arvados.RuntimeConstraints{
31                                         VCPUs: 1,
32                                         RAM:   1 << 30,
33                                 },
34                         },
35                         {
36                                 UUID:     test.ContainerUUID(2),
37                                 Priority: 12345,
38                                 State:    arvados.ContainerStateComplete,
39                                 RuntimeConstraints: arvados.RuntimeConstraints{
40                                         VCPUs: 1,
41                                         RAM:   1 << 30,
42                                 },
43                         },
44                 },
45         }
46         queue.Update()
47
48         ents, _ := queue.Entries()
49         c.Check(ents, check.HasLen, 1)
50
51         sch := New(ctx, &queue, &pool, time.Millisecond, time.Millisecond)
52         sch.sync()
53
54         ents, _ = queue.Entries()
55         c.Check(ents, check.HasLen, 0)
56 }