(t *testing.T)
| 159 | } |
| 160 | |
| 161 | func 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 | |
| 194 | func Test_createVPAWithResourcePolicy(t *testing.T) { |
| 195 | setupVPAForTests(t) |
nothing calls this directly
no test coverage detected