@@ -35,6 +35,7 @@ import (
35
35
)
36
36
37
37
func TestBuildNodeFromTemplateSetsResources (t * testing.T ) {
38
+ var thirtyPodsPerNode int64 = 30
38
39
type testCase struct {
39
40
scenario string
40
41
kubeEnv string
@@ -46,6 +47,7 @@ func TestBuildNodeFromTemplateSetsResources(t *testing.T) {
46
47
reservedCpu string
47
48
reservedMemory string
48
49
expectedErr bool
50
+ pods * int64
49
51
}
50
52
testCases := []testCase {
51
53
{
@@ -87,6 +89,14 @@ func TestBuildNodeFromTemplateSetsResources(t *testing.T) {
87
89
scenario : "totally messed up kube-env" ,
88
90
kubeEnv : "This kube-env is totally messed up" ,
89
91
expectedErr : true ,
92
+ }, {
93
+ scenario : "max pods per node specified" ,
94
+ kubeEnv : "" ,
95
+ physicalCpu : 8 ,
96
+ physicalMemory : 200 * units .MiB ,
97
+ pods : & thirtyPodsPerNode ,
98
+ kubeReserved : false ,
99
+ expectedErr : false ,
90
100
},
91
101
}
92
102
for _ , tc := range testCases {
@@ -110,7 +120,7 @@ func TestBuildNodeFromTemplateSetsResources(t *testing.T) {
110
120
if tc .kubeEnv != "" {
111
121
template .Properties .Metadata .Items = []* gce.MetadataItems {{Key : "kube-env" , Value : & tc .kubeEnv }}
112
122
}
113
- node , err := tb .BuildNodeFromTemplate (mig , template , tc .physicalCpu , tc .physicalMemory )
123
+ node , err := tb .BuildNodeFromTemplate (mig , template , tc .physicalCpu , tc .physicalMemory , tc . pods )
114
124
if tc .expectedErr {
115
125
assert .Error (t , err )
116
126
} else {
@@ -119,7 +129,7 @@ func TestBuildNodeFromTemplateSetsResources(t *testing.T) {
119
129
assert .NotNil (t , node .Status )
120
130
assert .NotNil (t , node .Status .Capacity )
121
131
assert .NotNil (t , node .Status .Allocatable )
122
- capacity , err := tb .BuildCapacity (tc .physicalCpu , tc .physicalMemory , tc .accelerators , OperatingSystemLinux )
132
+ capacity , err := tb .BuildCapacity (tc .physicalCpu , tc .physicalMemory , tc .accelerators , OperatingSystemLinux , tc . pods )
123
133
assert .NoError (t , err )
124
134
assertEqualResourceLists (t , "Capacity" , capacity , node .Status .Capacity )
125
135
if ! tc .kubeReserved {
@@ -361,7 +371,7 @@ func TestBuildCapacityMemory(t *testing.T) {
361
371
t .Run (fmt .Sprintf ("%v" , idx ), func (t * testing.T ) {
362
372
tb := GceTemplateBuilder {}
363
373
noAccelerators := make ([]* gce.AcceleratorConfig , 0 )
364
- buildCapacity , err := tb .BuildCapacity (tc .physicalCpu , tc .physicalMemory , noAccelerators , tc .os )
374
+ buildCapacity , err := tb .BuildCapacity (tc .physicalCpu , tc .physicalMemory , noAccelerators , tc .os , nil )
365
375
assert .NoError (t , err )
366
376
expectedCapacity , err := makeResourceList2 (tc .physicalCpu , tc .expectedCapacityMemory , 0 , 110 )
367
377
assert .NoError (t , err )
0 commit comments