|
5 | 5 | "testing"
|
6 | 6 | "time"
|
7 | 7 |
|
8 |
| - appsv1 "k8s.io/api/apps/v1" |
9 | 8 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
10 | 9 | "k8s.io/apimachinery/pkg/runtime"
|
11 | 10 | "k8s.io/apimachinery/pkg/util/wait"
|
@@ -175,116 +174,3 @@ func TestOperatorSync_NoOp(t *testing.T) {
|
175 | 174 | })
|
176 | 175 | }
|
177 | 176 | }
|
178 |
| - |
179 |
| -func deploymentHasContainer(d *appsv1.Deployment, containerName string) bool { |
180 |
| - for _, container := range d.Spec.Template.Spec.Containers { |
181 |
| - if container.Name == containerName { |
182 |
| - return true |
183 |
| - } |
184 |
| - } |
185 |
| - return false |
186 |
| -} |
187 |
| - |
188 |
| -func TestOperatorSyncClusterAPIControllerHealthCheckController(t *testing.T) { |
189 |
| - tests := []struct { |
190 |
| - featureGate *v1.FeatureGate |
191 |
| - expectedMachineHealthCheckController bool |
192 |
| - }{{ |
193 |
| - featureGate: newFeatureGate(v1.Default), |
194 |
| - expectedMachineHealthCheckController: false, |
195 |
| - }, { |
196 |
| - featureGate: &v1.FeatureGate{}, |
197 |
| - expectedMachineHealthCheckController: false, |
198 |
| - }, { |
199 |
| - featureGate: newFeatureGate(v1.TechPreviewNoUpgrade), |
200 |
| - expectedMachineHealthCheckController: true, |
201 |
| - }} |
202 |
| - |
203 |
| - for _, tc := range tests { |
204 |
| - infra := &v1.Infrastructure{ |
205 |
| - ObjectMeta: metav1.ObjectMeta{ |
206 |
| - Name: "cluster", |
207 |
| - }, |
208 |
| - Status: v1.InfrastructureStatus{ |
209 |
| - Platform: v1.AWSPlatformType, |
210 |
| - }, |
211 |
| - } |
212 |
| - |
213 |
| - stopCh := make(<-chan struct{}) |
214 |
| - optr := newFakeOperator(nil, []runtime.Object{tc.featureGate, infra}, stopCh) |
215 |
| - go optr.Run(2, stopCh) |
216 |
| - |
217 |
| - if err := wait.PollImmediate(1*time.Second, 5*time.Second, func() (bool, error) { |
218 |
| - d, err := optr.deployLister.Deployments(targetNamespace).Get(deploymentName) |
219 |
| - if err != nil { |
220 |
| - t.Logf("Failed to get %q deployment: %v", deploymentName, err) |
221 |
| - return false, nil |
222 |
| - } |
223 |
| - if deploymentHasContainer(d, hcControllerName) != tc.expectedMachineHealthCheckController { |
224 |
| - t.Logf("Expected deploymentHasContainer for %q container to be %t", hcControllerName, tc.expectedMachineHealthCheckController) |
225 |
| - return false, nil |
226 |
| - } |
227 |
| - return true, nil |
228 |
| - }); err != nil { |
229 |
| - t.Errorf("Failed to verify %q deployment", deploymentName) |
230 |
| - } |
231 |
| - } |
232 |
| -} |
233 |
| - |
234 |
| -func TestEnableDisableOperatorSyncClusterAPIControllerHealthCheckController(t *testing.T) { |
235 |
| - infra := &v1.Infrastructure{ |
236 |
| - ObjectMeta: metav1.ObjectMeta{ |
237 |
| - Name: "cluster", |
238 |
| - }, |
239 |
| - Status: v1.InfrastructureStatus{ |
240 |
| - Platform: v1.AWSPlatformType, |
241 |
| - }, |
242 |
| - } |
243 |
| - stopCh := make(chan struct{}) |
244 |
| - defer close(stopCh) |
245 |
| - |
246 |
| - optr := newFakeOperator(nil, []runtime.Object{newFeatureGate(v1.TechPreviewNoUpgrade), infra}, stopCh) |
247 |
| - go optr.Run(2, stopCh) |
248 |
| - |
249 |
| - if err := wait.PollImmediate(1*time.Second, 5*time.Second, func() (bool, error) { |
250 |
| - d, err := optr.deployLister.Deployments(targetNamespace).Get(deploymentName) |
251 |
| - if err != nil { |
252 |
| - t.Logf("Failed to get %q deployment: %v", deploymentName, err) |
253 |
| - return false, nil |
254 |
| - } |
255 |
| - if !deploymentHasContainer(d, hcControllerName) { |
256 |
| - t.Logf("Failed to verify that deployment %q has container %q", deploymentName, hcControllerName) |
257 |
| - return false, nil |
258 |
| - } |
259 |
| - return true, nil |
260 |
| - }); err != nil { |
261 |
| - t.Fatalf("Failed to verify that deployment %q has container %q", deploymentName, hcControllerName) |
262 |
| - } |
263 |
| - |
264 |
| - t.Logf("Found %q container in %q deployment", hcControllerName, deploymentName) |
265 |
| - |
266 |
| - hcFeatureGate, err := optr.osClient.ConfigV1().FeatureGates().Get(MachineAPIFeatureGateName, metav1.GetOptions{}) |
267 |
| - if err != nil { |
268 |
| - t.Fatalf("Unable to get %q feature gate: %v", MachineAPIFeatureGateName, err) |
269 |
| - } |
270 |
| - hcFeatureGate.Spec.FeatureSet = v1.Default |
271 |
| - if _, err := optr.osClient.ConfigV1().FeatureGates().Update(hcFeatureGate); err != nil { |
272 |
| - t.Fatalf("Unable to update %q feature gate and set default feature set: %v", MachineAPIFeatureGateName, err) |
273 |
| - } |
274 |
| - |
275 |
| - if err := wait.PollImmediate(1*time.Second, 15*time.Second, func() (bool, error) { |
276 |
| - d, err := optr.deployLister.Deployments(targetNamespace).Get(deploymentName) |
277 |
| - if err != nil { |
278 |
| - t.Logf("Failed to get %q deployment: %v", deploymentName, err) |
279 |
| - return false, nil |
280 |
| - } |
281 |
| - if deploymentHasContainer(d, hcControllerName) { |
282 |
| - t.Logf("Failed to verify that deployment %q has no container with name %q", deploymentName, hcControllerName) |
283 |
| - return false, nil |
284 |
| - } |
285 |
| - return true, nil |
286 |
| - }); err != nil { |
287 |
| - t.Errorf("Failed to verify that deployment %q has no container with name %q ", deploymentName, hcControllerName) |
288 |
| - } |
289 |
| - |
290 |
| -} |
0 commit comments