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

Feature Request: Integrate (or allow integration with) ActiveSupport::Notifications #51

Open
leehambley opened this issue Nov 18, 2015 · 3 comments

Comments

@leehambley
Copy link

I'm working on an app where there's a massive amount of random test failures due to environmental issues (large SOA app, shared final integration test environment, and lots and lots of teams deploying their services frequently)

We're trying to gauge the problem by instrumenting retries with ActiveSupport::Notifications, we have our own retrying logic localized to individual cases (e.g async message handlers, eventually refreshing a UI) and also retry handlers within our SitePrism page objects, these are already instrumented. But lacking is the general "retried the whole spec" scope.

Thoughts?

@dwbutler
Copy link
Collaborator

It sounds like you would like to instrument each individual retry attempt. Currently there isn't any way to hook into the internals of the retry execution.

There has been some interest in implementing hooks. See #50

Ideally, this would look something like

config.around(:retry) do |example|
  ActiveSupport::Notifications.instrument("run", attempt: example.attempts) do
    example.run
  end
end

Does this look like it would do what you're looking for?

@leehambley
Copy link
Author

It does indeed, I wonder if something like this could already work out of the box, around() all my tests, looking into the example.attempts (or similar) properties to make a report.

@dwbutler
Copy link
Collaborator

You could do it out of the box if all you care about is the number of attempts. Try this:

config.around(:each) do |example|
  ActiveSupport::Notifications.instrument("rspec.example") do |payload|
    example.run_with_retry
    payload[:attempts] = example.attempts
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants