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

Conversation

AlexNPavel
Copy link
Contributor

@AlexNPavel AlexNPavel commented Aug 31, 2018

Golang is pass-by-value, so passing the value of ctx meant that
any finalizer functions added in memcachedScaleTest were not being
run. This commit changes that by using a pointer instead.

This also adds a finalizer function for the example-memcached CR, which is why we need to pass a pointer instead of the value.

Golang is pass-by-value, so passing the value of ctx meant that
any finalizer functions added in memcachedScaleTest were not being
run. This commit changes that by using a pointer instead.
@@ -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!

@AlexNPavel AlexNPavel changed the title memcached/test/e2e: use pointer to ctx, not struct [DO NOT MERGE] memcached/test/e2e: use pointer to ctx, not struct Aug 31, 2018
The latest operator-sdk master includes a fix for the pointer issue
@AlexNPavel AlexNPavel changed the title [DO NOT MERGE] memcached/test/e2e: use pointer to ctx, not struct memcached/test/e2e: use pointer to ctx, not struct Aug 31, 2018
@AlexNPavel
Copy link
Contributor Author

Fixed

@fanminshi
Copy link
Contributor

lgtm

@AlexNPavel
Copy link
Contributor Author

@hasbro17 PTAL

@hasbro17
Copy link
Contributor

hasbro17 commented Sep 7, 2018

LGTM

@AlexNPavel AlexNPavel merged commit e5f7283 into operator-framework:master Sep 7, 2018
@AlexNPavel AlexNPavel deleted the pointer-fix branch September 7, 2018 00:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants