Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E test for Ready->Allocated->Ready #834

Merged
merged 2 commits into from
Jun 18, 2019

Conversation

markmandel
Copy link
Member

We said that using SDK.Ready() to go back to being ready once you were Allocated would work.

Wrote a test to prove it actually works!

Also relevant for #660 so people can exit out of Reserved state if they need to manually do so.

@markmandel markmandel added the area/tests Unit tests, e2e tests, anything to make sure things don't break label Jun 15, 2019
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: cac451a8-ae92-4c98-a2e3-1397c41cea4a

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/834/head:pr_834 && git checkout pr_834
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.11.0-490ee93

@@ -120,7 +120,10 @@ func (f *Framework) WaitForGameServerState(gs *v1alpha1.GameServer, state v1alph
return false, nil
})
if err != nil {
return nil, errors.Wrapf(pollErr, "waiting for GameServer to be %v %v/%v: %v",
if pollErr != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should the line 113 be updated to return the poll error instead? There is no where that PollImmediate is returning err.

Copy link
Member Author

Choose a reason for hiding this comment

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

If we do that, then the retry will stop, and we could get race conditions. We may get an error because the GS isn't created yet (most likely option), but we want to wait for it to show up, and then wait for it to be Ready.

My change here allows for if the err != nil (which will happen on timeout), but the pollErr could also be nil, which means you end up with both a nil gameserver and a nil error, and very little idea what happened 😄

(This should probably have been it's own PR admittedly. I got a little lazy on this one)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Can you please add documentation on why err is replaced with pollErr?

Copy link
Member Author

Choose a reason for hiding this comment

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

So I looked at this code again, and made it much simpler. I don't think we don't need the pollErr juggling - we have a warn log at that point, so we have visibility, so I got rid of it.

I think this makes the code far cleaner, and easier to read. PTAL 👍

@@ -120,7 +120,10 @@ func (f *Framework) WaitForGameServerState(gs *v1alpha1.GameServer, state v1alph
return false, nil
})
if err != nil {
return nil, errors.Wrapf(pollErr, "waiting for GameServer to be %v %v/%v: %v",
if pollErr != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I see. Can you please add documentation on why err is replaced with pollErr?

We said that using SDK.Ready() to go back to being ready once you
were Allocated would work.

Wrote a test to prove it actually works!

Also relevant for googleforgames#660 so people can exit out of Reserved state if they
need to manually do so.
@markmandel markmandel force-pushed the e2e/test-alloc-ready branch from 490ee93 to 8782a0a Compare June 18, 2019 00:06
var readyGs *stable.GameServer

err := wait.PollImmediate(2*time.Second, timeout, func() (bool, error) {
readyGs, pollErr = f.AgonesClient.StableV1alpha1().GameServers(gs.Namespace).Get(gs.Name, metav1.GetOptions{})
var err error
readyGs, err = f.AgonesClient.StableV1alpha1().GameServers(gs.Namespace).Get(gs.Name, metav1.GetOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

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

readyGs, err := ...
and remove var err error?

return readyGs, nil

return readyGs, errors.Wrapf(err, "waiting for GameServer to be %v %v/%v",
state, gs.Namespace, gs.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this would replace your previous change. pollErr is replaced with err which is local to the PollImmediate method.
err := wait.PollImmediate --> this error will still be timeout as it is different that the err inside PollImmediate.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that was my intent with this change. I'm saying I don't think we need to do replace err with pollErr at all.

The original code was in place to make the pollErr error visible, in case it is the cause of the test failing -- but we already have logging in place to show that error, so it seems redundant to do do both logging and bubble the error up.

If we remove the bubble up, the code is cleaner, and we don't sacrifice the ability to discover the reasons for issues.

At least - that is my intent 😄

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 31051768-fcee-425d-ada5-cd01a00a2ec5

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/834/head:pr_834 && git checkout pr_834
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.11.0-8782a0a

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 3030f74e-6123-430b-8390-75ab7eac8e41

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

  • git fetch https://github.com/GoogleCloudPlatform/agones.git pull/834/head:pr_834 && git checkout pr_834
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.11.0-cb4d8dc

@markmandel markmandel merged commit 0336f3e into googleforgames:master Jun 18, 2019
@markmandel markmandel deleted the e2e/test-alloc-ready branch June 18, 2019 02:29
@markmandel markmandel added this to the 0.11.0 milestone Jun 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tests Unit tests, e2e tests, anything to make sure things don't break
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants