Skip to content

Commit a552128

Browse files
Merge pull request #1153 from openshift-cherrypick-robot/cherry-pick-1150-to-release-4.14
[release-4.14] OCPBUGS-44048: fix proxy config and leader election test flakes
2 parents e41516d + f79610f commit a552128

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

test/e2e/configuration_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ func TestRouteConfiguration(t *testing.T) {
265265

266266
func TestOperatorProxyConfiguration(t *testing.T) {
267267
te := framework.SetupAvailableImageRegistry(t, nil)
268-
defer framework.TeardownImageRegistry(te)
268+
// this test sometimes fails during tear down because some components
269+
// (unrelated to the image registry) do not recover within the default
270+
// timeout.
271+
defer framework.TeardownImageRegistryWithTimeoutIncrement(te, 5*time.Minute)
269272
defer framework.ResetClusterProxyConfig(te)
270273

271274
// Get the service network to set as NO_PROXY so that the

test/e2e/leaderelection_test.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package e2e_test
22

33
import (
44
"context"
5-
"strings"
5+
"regexp"
66
"testing"
77
"time"
88

@@ -50,22 +50,17 @@ func TestLeaderElection(t *testing.T) {
5050
t.Fatalf("error reading operator logs: %v", err)
5151
}
5252

53-
awaitingPods := int32(0)
53+
re := regexp.MustCompile(".*successfully acquired lease.*")
54+
acquiredLease := 0
5455
for _, podLogs := range allLogs {
5556
for _, containerLogs := range podLogs {
56-
lastLine := len(containerLogs) - 1
57-
if lastLine < 0 {
58-
continue
59-
}
60-
61-
if strings.Contains(containerLogs[lastLine], "attempting to acquire leader lease") {
62-
awaitingPods++
57+
if containerLogs.Contains(re) {
58+
acquiredLease++
6359
}
6460
}
6561
}
6662

67-
numberOfAwaitingPods := numberOfReplicas - 1
68-
if awaitingPods != numberOfAwaitingPods {
69-
t.Errorf("multiple operators running at the same time")
63+
if acquiredLease > 1 {
64+
t.Errorf("multiple operators running at the same time, %d pods acquired lease, expected 1.", acquiredLease)
7065
}
7166
}

test/framework/imageregistry.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,8 @@ func SetupAvailableImageRegistry(t *testing.T, spec *imageregistryapiv1.ImageReg
580580
return te
581581
}
582582

583-
func TeardownImageRegistry(te TestEnv) {
584-
defer WaitUntilClusterOperatorsAreHealthy(te, 10*time.Second, AsyncOperationTimeout)
583+
func TeardownImageRegistryWithTimeoutIncrement(te TestEnv, timeoutIncrement time.Duration) {
584+
defer WaitUntilClusterOperatorsAreHealthy(te, 10*time.Second, AsyncOperationTimeout+timeoutIncrement)
585585
defer CheckAbsenceOfOperatorPods(te)
586586
defer RemoveImageRegistry(te)
587587
defer CheckPodsAreNotRestarted(te, labels.Everything())
@@ -591,3 +591,7 @@ func TeardownImageRegistry(te TestEnv) {
591591
DumpOperatorLogs(context.Background(), te)
592592
}
593593
}
594+
595+
func TeardownImageRegistry(te TestEnv) {
596+
TeardownImageRegistryWithTimeoutIncrement(te, 0)
597+
}

0 commit comments

Comments
 (0)