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

Always cleanup agents after each test #9603

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andrewvc
Copy link
Contributor

This code enforces a single active Agent at any time. It's not a singleton, since instances can be removed, but only one can be active.
I'd say it's a pseudo-singleton.

This is here to prevent one agent staying live and leaking its state causing another to fail in a different test.

I'm not quite sure how this may be causing other tests to break, but it seems like a good sanity check for the time being since we do have some evidence of this.

Some tests seem to fail when two agents, that shouldn't share PQs, somehow do. I suspect its a weird race when two agents are active.

@andrewvc andrewvc added the tests label May 17, 2018
Copy link
Member

@yaauie yaauie left a comment

Choose a reason for hiding this comment

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

Approach makes sense and should help us stabilise; I've added a note about how we can get the backtrace without going through a raise/rescue.

begin
raise "fake"
rescue => e
CURRENT_INITIALIZED_BACKTRACE.set(e.backtrace);
Copy link
Member

Choose a reason for hiding this comment

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

We can get the backtrace and avoid the overhead of raise/rescue with Kernel#caller, which also allows us to skip the current frame which will always be the same:

if (CURRENT.compare_and_set(nil,self))
  backtrace = caller(1) # don't include the current frame
  CURRENT_INITIALIZED_BACKTRACE.set(backtrace)
else
  raise # ...
end

@@ -52,6 +52,17 @@ def puts(payload)
example.run
end
end

c.after(:each) do
Copy link
Member

Choose a reason for hiding this comment

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

much better 🎉

@andrewvc andrewvc force-pushed the strict-agent-cleanup branch from eeeb434 to 33ac41f Compare May 17, 2018 19:47
@andrewvc
Copy link
Contributor Author

jenkins, please retest this

@andrewvc
Copy link
Contributor Author

jenkins, please retest this.

@andrewvc
Copy link
Contributor Author

jenkins, please test this

@andrewvc
Copy link
Contributor Author

jenkins, please retest this

This code enforces a single active Agent at any time. It's not a singleton, since instances can be removed, but only one can be active.
I'd say it's a pseudo-singleton.

This is here to prevent one agent staying live and leaking its state causing another to fail in a different test.

I'm not quite sure *how* this may be causing other tests to break, but it seems like a good sanity check for the time being since we do have some evidence of this.

Some tests seem to fail when two agents, that shouldn't share PQs, somehow do. I suspect its a weird race when two agents are active.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants