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

Function Test_createVPAWithResourcePolicy

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

Source from the content-addressed store, hash-verified

192}
193
194func Test_createVPAWithResourcePolicy(t *testing.T) {
195 setupVPAForTests(t)
196 VPAClient := GetInstance().VPAClient
197
198 controller := Controller{
199 APIVersion: "apps/v1",
200 Kind: "Deployment",
201 Name: "test-vpa",
202 Unstructured: nil,
203 }
204
205 // First test the dryrun
206 rec := GetInstance()
207 rec.DryRun = false
208
209 updateMode, _ := vpaUpdateModeForResource(&nsLabeledResourcePolicy)
210 resourcePolicy, _ := vpaResourcePolicyForResource(&nsLabeledResourcePolicy)
211 minReplicas, _ := vpaMinReplicasForResource(&nsLabeledResourcePolicy)
212 testVPA := rec.getVPAObject(nil, &nsLabeledResourcePolicy, controller, updateMode, resourcePolicy, minReplicas)
213
214 errCreate := rec.createVPA(testVPA)
215 newVPA, _ := VPAClient.Client.AutoscalingV1().VerticalPodAutoscalers(nsLabeledResourcePolicy.Name).Get(context.TODO(), "goldilocks-test-vpa", metav1.GetOptions{})
216 assert.NoError(t, errCreate)
217 assert.EqualValues(t, &testVPA, newVPA)
218 assert.NotNil(t, newVPA.Spec.ResourcePolicy)
219}
220
221func Test_deleteVPA(t *testing.T) {
222 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