Skip to content
This repository was archived by the owner on Nov 18, 2020. It is now read-only.

memcached/test/e2e: use pointer to ctx, not struct #31

Merged
merged 3 commits into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions memcached-operator/Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion memcached-operator/cmd/memcached-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"runtime"
"time"

stub "github.com/operator-framework/operator-sdk-samples/memcached-operator/pkg/stub"
sdk "github.com/operator-framework/operator-sdk/pkg/sdk"
Expand Down Expand Up @@ -30,7 +31,7 @@ func main() {
if err != nil {
logrus.Fatalf("failed to get watch namespace: %v", err)
}
resyncPeriod := 5
resyncPeriod := time.Duration(5) * time.Second
logrus.Infof("Watching %s, %s, %s, %d", resource, kind, namespace, resyncPeriod)
sdk.Watch(resource, kind, namespace, resyncPeriod)
sdk.Handle(stub.NewHandler())
Expand Down
5 changes: 4 additions & 1 deletion memcached-operator/test/e2e/memcached_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestMemcached(t *testing.T) {
})
}

func memcachedScaleTest(t *testing.T, f *framework.Framework, ctx framework.TestCtx) error {
func memcachedScaleTest(t *testing.T, f *framework.Framework, ctx *framework.TestCtx) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the ctx here ctx := framework.NewTestCtx(t) is a pointer. The user is mostly likely to pass it to other place as a pointer which can force the intended behavior.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made the change in the sdk with this PR: operator-framework/operator-sdk#451

After that PR is merged, I will update this repo with the new changes

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good!

namespace, err := ctx.GetNamespace()
if err != nil {
return fmt.Errorf("could not get namespace: %v", err)
Expand All @@ -74,6 +74,9 @@ func memcachedScaleTest(t *testing.T, f *framework.Framework, ctx framework.Test
if err != nil {
return err
}
ctx.AddFinalizerFn(func() error {
return f.DynamicClient.Delete(goctx.TODO(), exampleMemcached)
})
// wait for example-memcached to reach 3 replicas
err = e2eutil.WaitForDeployment(t, f.KubeClient, namespace, "example-memcached", 3, retryInterval, timeout)
if err != nil {
Expand Down