Skip to content

Commit c32406a

Browse files
committed
Remove deprecated golang.org/x/net/context
1 parent 5206836 commit c32406a

File tree

6 files changed

+40
-39
lines changed

6 files changed

+40
-39
lines changed

test/certification/certify_persistence_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
package certification
88

99
import (
10-
goctx "context"
10+
"context"
1111
"encoding/json"
1212
"fmt"
13-
. "github.com/onsi/gomega"
14-
v1 "github.com/oracle/coherence-operator/api/v1"
15-
"github.com/oracle/coherence-operator/test/e2e/helper"
16-
"golang.org/x/net/context"
1713
"io"
18-
corev1 "k8s.io/api/core/v1"
19-
"k8s.io/apimachinery/pkg/util/wait"
2014
"net/http"
2115
"os"
2216
"strconv"
2317
"testing"
2418
"time"
19+
20+
. "github.com/onsi/gomega"
21+
v1 "github.com/oracle/coherence-operator/api/v1"
22+
"github.com/oracle/coherence-operator/test/e2e/helper"
23+
corev1 "k8s.io/api/core/v1"
24+
"k8s.io/apimachinery/pkg/util/wait"
2525
)
2626

2727
type snapshotActionType int
@@ -228,7 +228,7 @@ func ensurePods(g *GomegaWithT, yamlFile, ns string) (v1.Coherence, []corev1.Pod
228228
d, _ := json.Marshal(deployment)
229229
fmt.Printf("Persistence Test installing deployment:\n%s\n", string(d))
230230

231-
err = testContext.Client.Create(goctx.TODO(), &deployment)
231+
err = testContext.Client.Create(context.TODO(), &deployment)
232232
g.Expect(err).NotTo(HaveOccurred())
233233

234234
_, err = helper.WaitForStatefulSetForDeployment(testContext, ns, &deployment, helper.RetryInterval, helper.Timeout)

test/e2e/helper/e2e-helpers.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
package helper
99

1010
import (
11-
goctx "context"
11+
"context"
1212
"encoding/json"
1313
"fmt"
1414
"io"
@@ -19,7 +19,6 @@ import (
1919
. "github.com/onsi/gomega"
2020
coh "github.com/oracle/coherence-operator/api/v1"
2121
"github.com/oracle/coherence-operator/pkg/operator"
22-
"golang.org/x/net/context"
2322
appsv1 "k8s.io/api/apps/v1"
2423
batchv1 "k8s.io/api/batch/v1"
2524
corev1 "k8s.io/api/core/v1"
@@ -355,7 +354,8 @@ func WaitForCoherence(ctx TestContext, namespace, name string, retryInterval, ti
355354
func WaitForCoherenceCondition(testCtx TestContext, namespace, name string, condition DeploymentStateCondition, retryInterval, timeout time.Duration) (*coh.Coherence, error) {
356355
var deployment *coh.Coherence
357356

358-
ctx, _ := context.WithTimeout(testCtx.Context, timeout)
357+
ctx, cancel := context.WithTimeout(testCtx.Context, timeout)
358+
defer cancel()
359359

360360
err := wait.PollUntilContextTimeout(ctx, retryInterval, timeout, true, func(context.Context) (done bool, err error) {
361361
deployment, err = GetCoherence(testCtx, namespace, name)
@@ -699,7 +699,7 @@ func WaitForCoherenceCleanup(ctx TestContext, namespace string) error {
699699
}
700700

701701
list := &coh.CoherenceList{}
702-
err = ctx.Client.List(goctx.TODO(), list, client.InNamespace(namespace))
702+
err = ctx.Client.List(context.TODO(), list, client.InNamespace(namespace))
703703
if err != nil {
704704
return err
705705
}
@@ -708,14 +708,14 @@ func WaitForCoherenceCleanup(ctx TestContext, namespace string) error {
708708
for i := range list.Items {
709709
item := list.Items[i]
710710
ctx.Logf("Deleting Coherence resource %s in namespace %s", item.Name, item.Namespace)
711-
err = ctx.Client.Delete(goctx.TODO(), &item)
711+
err = ctx.Client.Delete(context.TODO(), &item)
712712
if err != nil {
713713
ctx.Logf("Error deleting Coherence resource %s - %s", item.Name, err.Error())
714714
}
715715
}
716716

717717
// Obtain any remaining Coherence resources
718-
err = ctx.Client.List(goctx.TODO(), list, client.InNamespace(namespace))
718+
err = ctx.Client.List(context.TODO(), list, client.InNamespace(namespace))
719719
if err != nil {
720720
return err
721721
}
@@ -729,15 +729,15 @@ func WaitForCoherenceCleanup(ctx TestContext, namespace string) error {
729729
ctx.Logf("error patching Coherence %s: %+v", item.Name, err)
730730
}
731731
ctx.Logf("Deleting Coherence resource %s in namespace %s", item.Name, item.Namespace)
732-
err = ctx.Client.Delete(goctx.TODO(), &item)
732+
err = ctx.Client.Delete(context.TODO(), &item)
733733
if err != nil {
734734
ctx.Logf("Error deleting Coherence resource %s - %s", item.Name, err.Error())
735735
}
736736
}
737737

738738
// Wait for removal of the Coherence resources
739739
err = wait.PollUntilContextTimeout(ctx.Context, RetryInterval, Timeout, true, func(context.Context) (done bool, err error) {
740-
err = ctx.Client.List(goctx.TODO(), list, client.InNamespace(namespace))
740+
err = ctx.Client.List(context.TODO(), list, client.InNamespace(namespace))
741741
if err == nil || isNoResources(err) || apierrors.IsNotFound(err) {
742742
if len(list.Items) > 0 {
743743
ctx.Logf("Waiting for deletion of %d Coherence resources", len(list.Items))
@@ -774,7 +774,7 @@ func waitForCoherenceJobCleanup(ctx TestContext, namespace string) error {
774774
ctx.Logf("Waiting for clean-up of CoherenceJob resources in namespace %s", namespace)
775775

776776
list := &coh.CoherenceJobList{}
777-
err := ctx.Client.List(goctx.TODO(), list, client.InNamespace(namespace))
777+
err := ctx.Client.List(context.TODO(), list, client.InNamespace(namespace))
778778
if err != nil {
779779
return err
780780
}
@@ -783,14 +783,14 @@ func waitForCoherenceJobCleanup(ctx TestContext, namespace string) error {
783783
for i := range list.Items {
784784
item := list.Items[i]
785785
ctx.Logf("Deleting CoherenceJob resource %s in namespace %s", item.Name, item.Namespace)
786-
err = ctx.Client.Delete(goctx.TODO(), &item)
786+
err = ctx.Client.Delete(context.TODO(), &item)
787787
if err != nil {
788788
ctx.Logf("Error deleting CoherenceJob resource %s - %s", item.Name, err.Error())
789789
}
790790
}
791791

792792
// Obtain any remaining CoherenceJob resources
793-
err = ctx.Client.List(goctx.TODO(), list, client.InNamespace(namespace))
793+
err = ctx.Client.List(context.TODO(), list, client.InNamespace(namespace))
794794
if err != nil {
795795
return err
796796
}
@@ -804,15 +804,15 @@ func waitForCoherenceJobCleanup(ctx TestContext, namespace string) error {
804804
ctx.Logf("error patching CoherenceJob %s: %+v", item.Name, err)
805805
}
806806
ctx.Logf("Deleting CoherenceJob resource %s in namespace %s", item.Name, item.Namespace)
807-
err = ctx.Client.Delete(goctx.TODO(), &item)
807+
err = ctx.Client.Delete(context.TODO(), &item)
808808
if err != nil {
809809
ctx.Logf("Error deleting CoherenceJob resource %s - %s", item.Name, err.Error())
810810
}
811811
}
812812

813813
// Wait for removal of the CoherenceJob resources
814814
err = wait.PollUntilContextTimeout(ctx.Context, RetryInterval, Timeout, true, func(context.Context) (done bool, err error) {
815-
err = ctx.Client.List(goctx.TODO(), list, client.InNamespace(namespace))
815+
err = ctx.Client.List(context.TODO(), list, client.InNamespace(namespace))
816816
if err == nil || isNoResources(err) || apierrors.IsNotFound(err) {
817817
if len(list.Items) > 0 {
818818
ctx.Logf("Waiting for deletion of %d CoherenceJob resources", len(list.Items))

test/e2e/helper/test_context.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package helper
88

99
import (
10+
"context"
1011
"flag"
1112
"fmt"
1213
"net/http"
@@ -23,7 +24,6 @@ import (
2324
"github.com/spf13/cobra"
2425
"github.com/spf13/pflag"
2526
"github.com/spf13/viper"
26-
"golang.org/x/net/context"
2727
corev1 "k8s.io/api/core/v1"
2828
"k8s.io/apimachinery/pkg/types"
2929
"k8s.io/client-go/kubernetes/scheme"
@@ -264,6 +264,7 @@ func NewContext(startController bool, watchNamespaces ...string) (TestContext, e
264264
Log: ctrl.Log.WithName("controllers").WithName("Coherence"),
265265
}).SetupWithManager(k8sManager, cs)
266266
if err != nil {
267+
cancel()
267268
return TestContext{}, err
268269
}
269270

@@ -273,6 +274,7 @@ func NewContext(startController bool, watchNamespaces ...string) (TestContext, e
273274
Log: ctrl.Log.WithName("controllers").WithName("CoherenceJob"),
274275
}).SetupWithManager(k8sManager, cs)
275276
if err != nil {
277+
cancel()
276278
return TestContext{}, err
277279
}
278280
}

test/e2e/remote/persistence_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@
77
package remote
88

99
import (
10-
goctx "context"
10+
"context"
1111
"encoding/json"
1212
"fmt"
13-
. "github.com/onsi/gomega"
14-
v1 "github.com/oracle/coherence-operator/api/v1"
15-
"github.com/oracle/coherence-operator/test/e2e/helper"
16-
"golang.org/x/net/context"
1713
"io"
18-
corev1 "k8s.io/api/core/v1"
19-
"k8s.io/apimachinery/pkg/util/wait"
2014
"net/http"
2115
"os"
2216
"strconv"
2317
"testing"
2418
"time"
19+
20+
. "github.com/onsi/gomega"
21+
v1 "github.com/oracle/coherence-operator/api/v1"
22+
"github.com/oracle/coherence-operator/test/e2e/helper"
23+
corev1 "k8s.io/api/core/v1"
24+
"k8s.io/apimachinery/pkg/util/wait"
2525
)
2626

2727
type snapshotActionType int
@@ -173,7 +173,7 @@ func ensurePods(g *GomegaWithT, yamlFile, ns string) (v1.Coherence, []corev1.Pod
173173
d, _ := json.Marshal(deployment)
174174
fmt.Printf("Persistence Test installing deployment:\n%s\n", string(d))
175175

176-
err = testContext.Client.Create(goctx.TODO(), &deployment)
176+
err = testContext.Client.Create(context.TODO(), &deployment)
177177
g.Expect(err).NotTo(HaveOccurred())
178178

179179
_, err = helper.WaitForStatefulSetForDeployment(testContext, ns, &deployment, helper.RetryInterval, helper.Timeout)

test/e2e/remote/scaling_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
package remote
88

99
import (
10-
goctx "context"
10+
"context"
1111
"fmt"
1212
"io"
1313
"strings"
@@ -16,7 +16,6 @@ import (
1616

1717
cohv1 "github.com/oracle/coherence-operator/api/v1"
1818
"github.com/oracle/coherence-operator/test/e2e/helper"
19-
"golang.org/x/net/context"
2019
appsv1 "k8s.io/api/apps/v1"
2120
"k8s.io/apimachinery/pkg/types"
2221
"k8s.io/utils/ptr"
@@ -113,7 +112,7 @@ var deploymentScaler = func(t *testing.T, d *cohv1.Coherence, replicas int32) er
113112
}
114113
current.Spec.SetReplicas(replicas)
115114
t.Logf("Scaling %s to %d", current.Name, replicas)
116-
return testContext.Client.Update(goctx.TODO(), current)
115+
return testContext.Client.Update(context.TODO(), current)
117116
}
118117

119118
// A scaler function that scales a deployment using the kubectl scale command

test/e2e/remote/zone_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
package remote
88

99
import (
10-
goctx "context"
10+
"context"
1111
"fmt"
12+
"net/http"
13+
"testing"
14+
"time"
15+
1216
coh "github.com/oracle/coherence-operator/api/v1"
1317
"github.com/oracle/coherence-operator/pkg/management"
1418
"github.com/oracle/coherence-operator/pkg/operator"
1519
"github.com/oracle/coherence-operator/test/e2e/helper"
16-
"golang.org/x/net/context"
17-
"net/http"
18-
"testing"
19-
"time"
2020

2121
. "github.com/onsi/gomega"
2222

@@ -110,7 +110,7 @@ func assertLabel(t *testing.T, name string, fileName string, labels, prefixLabel
110110
deployment.SetName(name + "-zone-test")
111111

112112
// deploy to k8s
113-
err = testContext.Client.Create(goctx.TODO(), &deployment)
113+
err = testContext.Client.Create(context.TODO(), &deployment)
114114
g.Expect(err).NotTo(HaveOccurred())
115115

116116
replicas := deployment.GetReplicas()

0 commit comments

Comments
 (0)