Skip to content

Commit 5c4ee64

Browse files
committed
fix(e2e): copy rest config from test ctx
Copy rest config from the context to prevent helm installer side effects causing codec issues with the controller-runtime client.
1 parent 1476ff1 commit 5c4ee64

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

test/e2e/ctx/ctx.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (ctx TestContext) Scheme() *runtime.Scheme {
5757
}
5858

5959
func (ctx TestContext) RESTConfig() *rest.Config {
60-
return ctx.restConfig
60+
return rest.CopyConfig(ctx.restConfig)
6161
}
6262

6363
func (ctx TestContext) KubeClient() operatorclient.ClientInterface {

test/e2e/ctx/installer_helm.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ func (a clientAdapter) ConfigAccess() clientcmd.ConfigAccess {
8080
func Install(ctx *TestContext) error {
8181
cfg := action.Configuration{}
8282
cfg.Init(clientAdapter{ctx.RESTConfig()}, "", "memory", ctx.Logf)
83-
8483
act := action.NewInstall(&cfg)
8584
act.Timeout = 5 * time.Second
8685
act.ReleaseName = fmt.Sprintf("release-%s", rand.String(8))

test/e2e/util_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -873,13 +873,12 @@ func toggleFeatureGates(deployment *appsv1.Deployment, toToggle ...featuregate.F
873873
w, err := c.Watch(clientCtx, metav1.ListOptions{})
874874
Expect(err).ToNot(HaveOccurred())
875875

876-
timeout := 1 * time.Minute
877-
Eventually(func() error {
878-
_, err := c.Update(clientCtx, deployment, metav1.UpdateOptions{})
879-
return err
880-
}, timeout).Should(Succeed())
876+
Eventually(Apply(deployment, func(d *appsv1.Deployment) error {
877+
d.Spec = deployment.Spec
878+
return nil
879+
})).Should(Succeed())
881880

882-
deadline, cancel := context.WithTimeout(context.Background(), timeout)
881+
deadline, cancel := context.WithTimeout(context.Background(), 1*time.Minute)
883882
defer cancel()
884883

885884
awaitPredicates(deadline, w, deploymentReplicas(2), deploymentAvailable, deploymentReplicas(1))
@@ -1002,6 +1001,7 @@ func Apply(obj Object, changeFunc interface{}) func() error {
10021001
}
10031002

10041003
if err := client.Patch(bg, cp, controllerclient.Apply, controllerclient.ForceOwnership, controllerclient.FieldOwner("test")); err != nil {
1004+
fmt.Printf("first patch error: %s\n", err)
10051005
return err
10061006
}
10071007

0 commit comments

Comments
 (0)