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

Have TestPlayerConnectWithCapacityZero use framework to wait #3062

Merged

Conversation

zmerlynn
Copy link
Collaborator

I'm seeing e2e failures in this test, which I'm trying to track down, but it seems like when this test fails, it explodes, e.g.:

panic: Fail in goroutine after TestPlayerConnectWithCapacityZero has completed [...]
 agones.dev/agones/test/e2e.TestPlayerConnectWithCapacityZero.func1()
     /go/src/agones.dev/agones/test/e2e/gameserver_test.go:1111 +0x2d3

It then ends up wrecking status of several other tests and makes the output noisier than it actually is. I think this is largely due to using require, which panics. Instead, we have a framework function that does exactly what this is looping on, just use that.

@google-oss-prow google-oss-prow bot added the lgtm label Mar 31, 2023
@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: gongmax, zmerlynn
Once this PR has been reviewed and has the lgtm label, please assign ericfortin for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@markmandel
Copy link
Member

FYI: require doesn't panic, it just stops the test at that point, rather than continuing on.


return assert.Equal(t, gs.Status.State, agonesv1.GameServerStateUnhealthy)
}, time.Minute, time.Second)
if assert.Error(t, err) {
Copy link
Member

Choose a reason for hiding this comment

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

This if statement is doing exactly the same thing require.NoError does 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Actually - digging into FailNow, actually explains things!!!
https://pkg.go.dev/testing#T.FailNow

(emphasis mine)

FailNow marks the function as having failed and stops its execution by calling runtime.Goexit (which then runs all deferred calls in the current goroutine). Execution will continue at the next test or benchmark. FailNow must be called from the goroutine running the test or benchmark function, not from other goroutines created during the test. Calling FailNow does not stop those other goroutines.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right.. and testify does doc that: https://github.com/stretchr/testify/tree/v1.8.2#require-package

Basically require is to assert as t.Fatal is to t.Error, AFAICT.

Copy link
Member

Choose a reason for hiding this comment

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

The thing that doesn't make sense... is Eventually shouldn't be starting a go routine? Or does it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah that one I didn't look up yet, but it sure does: https://github.com/stretchr/testify/blob/v1.8.2/assert/assertions.go#L1737

How weird!

Copy link
Collaborator Author

@zmerlynn zmerlynn Mar 31, 2023

Choose a reason for hiding this comment

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

I think it's so the timeout has precedence over the condition - i.e. if you set a 1m timeout, it always fires if the condition takes too long to evaluate.

Copy link
Member

@markmandel markmandel Mar 31, 2023

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah.. the framework code just leans on https://pkg.go.dev/k8s.io/apimachinery/pkg/util/wait

@zmerlynn
Copy link
Collaborator Author

FYI: require doesn't panic, it just stops the test at that point, rather than continuing on.

Given that stack traces, it seems to be causing some nasty interaction, especially in the Eventually loop. The test report is showing that it seems to leave the test with a goroutine still running and then hard panics after. The panic is very much in testify assertion code.

@markmandel
Copy link
Member

Might need to file a bug on testify!

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 4e5d44e1-8d24-433b-9d33-9af929dc9291

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@google-oss-prow google-oss-prow bot removed the lgtm label Apr 4, 2023
@google-oss-prow
Copy link

New changes are detected. LGTM label has been removed.

@google-oss-prow google-oss-prow bot added size/XL and removed size/S labels Apr 4, 2023
I'm seeing e2e failures in this test, which I'm trying to track
down, but it seems like when this test fails, it explodes, e.g.:

panic: Fail in goroutine after TestPlayerConnectWithCapacityZero has completed
[...]
 agones.dev/agones/test/e2e.TestPlayerConnectWithCapacityZero.func1()
     /go/src/agones.dev/agones/test/e2e/gameserver_test.go:1111 +0x2d3

I think this is largely due to using `require`, which panics. Instead,
we have a framework function that does exactly what this is looping
on, just use that.
@zmerlynn zmerlynn force-pushed the use-framework-instead-of-eventually branch from 2e558a7 to 1d5d431 Compare April 4, 2023 15:46
@google-oss-prow google-oss-prow bot added size/S and removed size/XL labels Apr 4, 2023
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 60534a1d-4304-4893-82b4-2535817b0ce3

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/googleforgames/agones.git pull/3062/head:pr_3062 && git checkout pr_3062
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.31.0-1d5d431-amd64

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 1f52f19f-1b6d-450d-9cdb-df5cfec19bdc

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/googleforgames/agones.git pull/3062/head:pr_3062 && git checkout pr_3062
  • helm install agones ./install/helm/agones --namespace agones-system --agones.image.release=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.31.0-c634d06-amd64

@zmerlynn zmerlynn merged commit 16c6a31 into googleforgames:main Apr 5, 2023
chiayi pushed a commit to chiayi/agones that referenced this pull request Apr 5, 2023
…orgames#3062)

I'm seeing e2e failures in this test, which I'm trying to track
down, but it seems like when this test fails, it explodes, e.g.:

panic: Fail in goroutine after TestPlayerConnectWithCapacityZero has completed
[...]
 agones.dev/agones/test/e2e.TestPlayerConnectWithCapacityZero.func1()
     /go/src/agones.dev/agones/test/e2e/gameserver_test.go:1111 +0x2d3

I think this is largely due to using `require`, which panics. Instead,
we have a framework function that does exactly what this is looping
on, just use that.
@Kalaiselvi84 Kalaiselvi84 added the kind/feature New features for Agones label Apr 10, 2023
@Kalaiselvi84 Kalaiselvi84 added this to the 1.31.0 milestone Apr 10, 2023
Kalaiselvi84 pushed a commit to Kalaiselvi84/agones that referenced this pull request Apr 11, 2023
…orgames#3062)

I'm seeing e2e failures in this test, which I'm trying to track
down, but it seems like when this test fails, it explodes, e.g.:

panic: Fail in goroutine after TestPlayerConnectWithCapacityZero has completed
[...]
 agones.dev/agones/test/e2e.TestPlayerConnectWithCapacityZero.func1()
     /go/src/agones.dev/agones/test/e2e/gameserver_test.go:1111 +0x2d3

I think this is largely due to using `require`, which panics. Instead,
we have a framework function that does exactly what this is looping
on, just use that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New features for Agones size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants