Skip to content

Commit

Permalink
TestRouteAdmissionPolicy: Wait for rolling update
Browse files Browse the repository at this point in the history
Poll the ingress controller's deployment after changing the route admission
policy to make sure that the deployment is updated and rolled out before
checking that the new policy is in effect.

This commit fixes bug 1835025.

https://bugzilla.redhat.com/show_bug.cgi?id=1835025

* test/e2e/operator_test.go (TestRouteAdmissionPolicy): Add polling to make
sure that the ingress controller deployment is updated and rolled out.
  • Loading branch information
Miciah committed May 13, 2020
1 parent 3c30ec4 commit 17c6350
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/e2e/operator_test.go
Expand Up @@ -774,6 +774,28 @@ func TestRouteAdmissionPolicy(t *testing.T) {
t.Fatalf("failed to update ingresscontroller: %v", err)
}

// The updated ingresscontroller deployment may take a few minutes to
// roll out, so make sure that it is updated, and then make sure that it
// has finished rolling out before checking the route.
err := wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) {
deployment := &appsv1.Deployment{}
if err := kclient.Get(context.TODO(), controller.RouterDeploymentName(ic), deployment); err != nil {
return false, err
}
for _, v := range deployment.Spec.Template.Spec.Containers[0].Env {
if v.Name == "ROUTER_DISABLE_NAMESPACE_OWNERSHIP_CHECK" {
return strconv.ParseBool(v.Value)
}
}
return false, nil
})
if err != nil {
t.Fatalf("failed to observe ROUTER_DISABLE_NAMESPACE_OWNERSHIP_CHECK=true: %v", err)
}
if err := waitForIngressControllerCondition(kclient, 3*time.Minute, icName, conditions...); err != nil {
t.Fatalf("failed to observe expected conditions: %v", err)
}

// The second route should eventually be admitted because of the new policy
if err := waitForRouteIngressConditions(kclient, route2Name, ic.Name, admittedCondition); err != nil {
t.Fatalf("failed to observe expected conditions: %v", err)
Expand Down Expand Up @@ -818,6 +840,24 @@ func TestRouteAdmissionPolicy(t *testing.T) {
if err := kclient.Update(context.TODO(), ic); err != nil {
t.Fatalf("failed to update ingresscontroller: %v", err)
}
err = wait.PollImmediate(1*time.Second, 1*time.Minute, func() (bool, error) {
deployment := &appsv1.Deployment{}
if err := kclient.Get(context.TODO(), controller.RouterDeploymentName(ic), deployment); err != nil {
return false, err
}
for _, v := range deployment.Spec.Template.Spec.Containers[0].Env {
if v.Name == "ROUTER_ALLOW_WILDCARD_ROUTES" {
return strconv.ParseBool(v.Value)
}
}
return false, nil
})
if err != nil {
t.Fatalf("failed to observe ROUTER_ALLOW_WILDCARD_ROUTES=true: %v", err)
}
if err := waitForIngressControllerCondition(kclient, 3*time.Minute, icName, conditions...); err != nil {
t.Fatalf("failed to observe expected conditions: %v", err)
}

// Recreate the route since the failed route will not automatically get
// readmitted and a route wildcard policy is immutable.
Expand Down

0 comments on commit 17c6350

Please sign in to comment.