Skip to content

Commit 06131c3

Browse files
committed
Fix cleanup and conflict issues in proxy tests
- SaveAndRestoreProxyConfig: skip WaitForOperatorToPickUpChanges when the proxy config already matches the original (avoids waiting for Progressing=True that never comes when the test failed before setting the proxy). - C2 test: re-fetch the operator CR before setting the proxy to avoid conflict errors from intervening operator reconciliation.
1 parent 0c8c278 commit 06131c3

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

test/e2e-component-proxy/component_proxy.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ func testWarningOnUnreachableIdP() {
343343

344344
g.By("Setting component-scoped proxy pointing to the Squid instance")
345345
startTime := time.Now()
346+
operatorAuth, err = clients.OperatorClient.OperatorV1().Authentications().Get(ctx, "cluster", metav1.GetOptions{})
347+
o.Expect(err).NotTo(o.HaveOccurred())
346348
operatorAuth.Spec.Proxy = operatorv1.AuthenticationProxyConfig{
347349
HTTPSProxy: proxyURL,
348350
}

test/library/proxy.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/x509"
66
"encoding/pem"
77
"fmt"
8+
"reflect"
89
"strings"
910
"sync"
1011
"testing"
@@ -55,27 +56,36 @@ func SaveAndRestoreProxyConfig(t testing.TB, operatorClient *operatorclient.Clie
5556

5657
return auth, sync.OnceFunc(func() {
5758
t.Log("cleaning up: restoring original proxy config")
59+
var changed bool
5860
err := wait.PollUntilContextTimeout(ctx, 1*time.Second, 30*time.Second, true, func(ctx context.Context) (bool, error) {
5961
fresh, err := operatorClient.OperatorV1().Authentications().Get(ctx, "cluster", metav1.GetOptions{})
6062
if err != nil {
6163
t.Logf("cleanup: failed to get operator auth: %v", err)
6264
return false, nil
6365
}
66+
target := operatorv1.AuthenticationProxyConfig{}
6467
if originalProxy != nil {
65-
fresh.Spec.Proxy = *originalProxy
66-
} else {
67-
fresh.Spec.Proxy = operatorv1.AuthenticationProxyConfig{}
68+
target = *originalProxy
6869
}
70+
if reflect.DeepEqual(fresh.Spec.Proxy, target) {
71+
t.Log("cleanup: proxy config already matches original, no update needed")
72+
return true, nil
73+
}
74+
fresh.Spec.Proxy = target
6975
if _, err := operatorClient.OperatorV1().Authentications().Update(ctx, fresh, metav1.UpdateOptions{}); err != nil {
7076
t.Logf("cleanup: failed to update operator auth (will retry): %v", err)
7177
return false, nil
7278
}
79+
changed = true
7380
return true, nil
7481
})
7582
if err != nil {
7683
t.Logf("cleanup: failed to restore proxy config: %v", err)
7784
return
7885
}
86+
if !changed {
87+
return
88+
}
7989
t.Log("cleanup: waiting for operator to pick up changes and stabilize")
8090
if err := WaitForOperatorToPickUpChanges(t, configClient.ConfigV1(), "authentication"); err != nil {
8191
t.Logf("cleanup: operator did not recover: %v", err)

0 commit comments

Comments
 (0)