1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
8 "git.curoverse.com/arvados.git/sdk/go/arvados"
9 check "gopkg.in/check.v1"
12 var _ = check.Suite(&NodeSizeSuite{})
14 type NodeSizeSuite struct{}
16 func (*NodeSizeSuite) TestChooseNotConfigured(c *check.C) {
17 _, err := ChooseInstanceType(&arvados.Cluster{}, &arvados.Container{
18 RuntimeConstraints: arvados.RuntimeConstraints{
23 c.Check(err, check.Equals, ErrInstanceTypesNotConfigured)
26 func (*NodeSizeSuite) TestChooseUnsatisfiable(c *check.C) {
27 for _, rc := range []arvados.RuntimeConstraints{
28 {RAM: 9876543210, VCPUs: 2},
29 {RAM: 1234567890, VCPUs: 20},
30 {RAM: 1234567890, VCPUs: 2, KeepCacheRAM: 9876543210},
32 _, err := ChooseInstanceType(&arvados.Cluster{InstanceTypes: []arvados.InstanceType{
33 {Price: 1.1, RAM: 1000000000, VCPUs: 2, Name: "small1"},
34 {Price: 2.2, RAM: 2000000000, VCPUs: 4, Name: "small2"},
35 {Price: 4.4, RAM: 4000000000, VCPUs: 8, Name: "small4"},
36 }}, &arvados.Container{RuntimeConstraints: rc})
37 c.Check(err, check.Equals, ErrConstraintsNotSatisfiable)
41 func (*NodeSizeSuite) TestChoose(c *check.C) {
42 for _, menu := range [][]arvados.InstanceType{
44 {Price: 4.4, RAM: 4000000000, VCPUs: 8, Name: "costly"},
45 {Price: 2.2, RAM: 2000000000, VCPUs: 4, Name: "best"},
46 {Price: 1.1, RAM: 1000000000, VCPUs: 2, Name: "small"},
49 {Price: 4.4, RAM: 4000000000, VCPUs: 8, Name: "costly"},
50 {Price: 2.2, RAM: 2000000000, VCPUs: 4, Name: "goodenough"},
51 {Price: 2.2, RAM: 4000000000, VCPUs: 4, Name: "best"},
52 {Price: 1.1, RAM: 1000000000, VCPUs: 2, Name: "small"},
55 {Price: 1.1, RAM: 1000000000, VCPUs: 2, Name: "small"},
56 {Price: 2.2, RAM: 2000000000, VCPUs: 4, Name: "goodenough"},
57 {Price: 2.2, RAM: 4000000000, VCPUs: 4, Name: "best"},
58 {Price: 4.4, RAM: 4000000000, VCPUs: 8, Name: "costly"},
61 best, err := ChooseInstanceType(&arvados.Cluster{InstanceTypes: menu}, &arvados.Container{
62 RuntimeConstraints: arvados.RuntimeConstraints{
65 KeepCacheRAM: 123456789,
68 c.Check(err, check.IsNil)
69 c.Check(best.Name, check.Equals, "best")
70 c.Check(best.RAM >= 1234567890, check.Equals, true)
71 c.Check(best.VCPUs >= 2, check.Equals, true)