@@ -103,50 +103,44 @@ func TestUpdatePodFromAllocation(t *testing.T) {
103
103
tests := []struct {
104
104
name string
105
105
pod * v1.Pod
106
- allocs state.PodResourceInfoMap
106
+ allocated state.PodResourceInfo
107
107
expectPod * v1.Pod
108
108
expectUpdate bool
109
109
}{{
110
110
name : "steady state" ,
111
111
pod : pod ,
112
- allocs : state.PodResourceInfoMap {
113
- pod .UID : state.PodResourceInfo {
114
- ContainerResources : map [string ]v1.ResourceRequirements {
115
- "c1" : * pod .Spec .Containers [0 ].Resources .DeepCopy (),
116
- "c2" : * pod .Spec .Containers [1 ].Resources .DeepCopy (),
117
- "c1-restartable-init" : * pod .Spec .InitContainers [0 ].Resources .DeepCopy (),
118
- "c1-init" : * pod .Spec .InitContainers [1 ].Resources .DeepCopy (),
119
- },
112
+ allocated : state.PodResourceInfo {
113
+ ContainerResources : map [string ]v1.ResourceRequirements {
114
+ "c1" : * pod .Spec .Containers [0 ].Resources .DeepCopy (),
115
+ "c2" : * pod .Spec .Containers [1 ].Resources .DeepCopy (),
116
+ "c1-restartable-init" : * pod .Spec .InitContainers [0 ].Resources .DeepCopy (),
117
+ "c1-init" : * pod .Spec .InitContainers [1 ].Resources .DeepCopy (),
120
118
},
121
119
},
122
120
expectUpdate : false ,
123
121
}, {
124
122
name : "no allocations" ,
125
123
pod : pod ,
126
- allocs : state.PodResourceInfoMap {},
124
+ allocated : state.PodResourceInfo {},
127
125
expectUpdate : false ,
128
126
}, {
129
127
name : "missing container allocation" ,
130
128
pod : pod ,
131
- allocs : state.PodResourceInfoMap {
132
- pod .UID : state.PodResourceInfo {
133
- ContainerResources : map [string ]v1.ResourceRequirements {
134
- "c2" : * pod .Spec .Containers [1 ].Resources .DeepCopy (),
135
- },
129
+ allocated : state.PodResourceInfo {
130
+ ContainerResources : map [string ]v1.ResourceRequirements {
131
+ "c2" : * pod .Spec .Containers [1 ].Resources .DeepCopy (),
136
132
},
137
133
},
138
134
expectUpdate : false ,
139
135
}, {
140
136
name : "resized container" ,
141
137
pod : pod ,
142
- allocs : state.PodResourceInfoMap {
143
- pod .UID : state.PodResourceInfo {
144
- ContainerResources : map [string ]v1.ResourceRequirements {
145
- "c1" : * resizedPod .Spec .Containers [0 ].Resources .DeepCopy (),
146
- "c2" : * resizedPod .Spec .Containers [1 ].Resources .DeepCopy (),
147
- "c1-restartable-init" : * resizedPod .Spec .InitContainers [0 ].Resources .DeepCopy (),
148
- "c1-init" : * resizedPod .Spec .InitContainers [1 ].Resources .DeepCopy (),
149
- },
138
+ allocated : state.PodResourceInfo {
139
+ ContainerResources : map [string ]v1.ResourceRequirements {
140
+ "c1" : * resizedPod .Spec .Containers [0 ].Resources .DeepCopy (),
141
+ "c2" : * resizedPod .Spec .Containers [1 ].Resources .DeepCopy (),
142
+ "c1-restartable-init" : * resizedPod .Spec .InitContainers [0 ].Resources .DeepCopy (),
143
+ "c1-init" : * resizedPod .Spec .InitContainers [1 ].Resources .DeepCopy (),
150
144
},
151
145
},
152
146
expectUpdate : true ,
@@ -156,7 +150,7 @@ func TestUpdatePodFromAllocation(t *testing.T) {
156
150
for _ , test := range tests {
157
151
t .Run (test .name , func (t * testing.T ) {
158
152
pod := test .pod .DeepCopy ()
159
- allocatedPod , updated := updatePodFromAllocation (pod , test .allocs )
153
+ allocatedPod , updated := updatePodFromAllocation (pod , test .allocated )
160
154
161
155
if test .expectUpdate {
162
156
assert .True (t , updated , "updated" )
0 commit comments