MCPcopy
hub / github.com/FairwindsOps/goldilocks / Test_createVPA

Function Test_createVPA

pkg/vpa/vpa_test.go:161–192  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

159}
160
161func Test_createVPA(t *testing.T) {
162 setupVPAForTests(t)
163 VPAClient := GetInstance().VPAClient
164
165 // First test the dryrun
166 rec := GetInstance()
167 rec.DryRun = true
168
169 controller := Controller{
170 APIVersion: "apps/v1",
171 Kind: "Deployment",
172 Name: "test-vpa",
173 Unstructured: nil,
174 }
175
176 updateMode, _ := vpaUpdateModeForResource(&nsTesting)
177 resourcePolicy, _ := vpaResourcePolicyForResource(&nsTesting)
178 minReplicas, _ := vpaMinReplicasForResource(&nsTesting)
179 testVPA := rec.getVPAObject(nil, &nsTesting, controller, updateMode, resourcePolicy, minReplicas)
180
181 err := rec.createVPA(testVPA)
182 assert.NoError(t, err)
183 _, err = VPAClient.Client.AutoscalingV1().VerticalPodAutoscalers(nsTesting.Name).Get(context.TODO(), "goldilocks-test-vpa", metav1.GetOptions{})
184 assert.EqualError(t, err, "verticalpodautoscalers.autoscaling.k8s.io \"goldilocks-test-vpa\" not found")
185
186 // Now actually create and compare
187 rec.DryRun = false
188 errCreate := rec.createVPA(testVPA)
189 newVPA, _ := VPAClient.Client.AutoscalingV1().VerticalPodAutoscalers(nsTesting.Name).Get(context.TODO(), "goldilocks-test-vpa", metav1.GetOptions{})
190 assert.NoError(t, errCreate)
191 assert.EqualValues(t, &testVPA, newVPA)
192}
193
194func Test_createVPAWithResourcePolicy(t *testing.T) {
195 setupVPAForTests(t)

Callers

nothing calls this directly

Calls 7

setupVPAForTestsFunction · 0.85
vpaUpdateModeForResourceFunction · 0.85
getVPAObjectMethod · 0.80
createVPAMethod · 0.80
GetInstanceFunction · 0.70

Tested by

no test coverage detected