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

Add --retry option to retry failed tests as part of the same run #920

Merged
merged 15 commits into from
May 17, 2016

Conversation

danascheider
Copy link
Contributor

Here are the features I wrote up for #882. Let me know what you think, @mattwynne and @brasmusson. Travis isn't passing but it's those wire protocol features again - shouldn't have been affected by what I wrote.

@mattwynne
Copy link
Member

Looks like a good start but there's no implementation right? So the tests should not be passing... or did I misunderstand something?

@mattwynne
Copy link
Member

You could usefully rebase your branch (you can use git rebase -i) then push --force to clean up the commit history on this PR - it makes it easier to read.

@danascheider
Copy link
Contributor Author

I think I was the one who misunderstood something. A while ago you said something about failing features being the first step, and I assumed that meant you wanted a PR with the tests. I’m giving a 45-minute talk tonight so things have been kind of crazy, but I’ll have a chance to work on this more later this week. And re: git rebase -i - I meant to do that before, sorry!

On Oct 6, 2015, at 8:48 AM, Matt Wynne [email protected] wrote:

Looks like a good start but there's no implementation right? So the tests should not be passing... or did I misunderstand something?


Reply to this email directly or view it on GitHub #920 (comment).

@mattwynne
Copy link
Member

Comprende! I was confused because the branch was green, but that's because you've changed the travis config is it?

So yeah I think those scenarios are a good place to start. We need to update the description a bit to align with what we've decided (i.e. deferring things like using tags).

@mattwynne
Copy link
Member

You happy to have a crack at an implementation Dana? Give me a shout if you need some support. Thanks for taking interest in this!

@brasmusson
Copy link
Contributor

@mattwynne retry_failing_tests.feature is tagged @wip, therefore build is green.

@danascheider
Copy link
Contributor Author

I'm totally working on it already, just didn't want to pollute the existing PR with all the new commits so I switched to a different branch & will merge later.

@danascheider
Copy link
Contributor Author

Happy to help!

@mattwynne mattwynne added the WIP label Oct 15, 2015
@mattwynne
Copy link
Member

I'm totally working on it already, just didn't want to pollute the existing PR with all the new commits so I switched to a different branch & will merge later.

OK. I've put the WIP tag on this PR, so it would work well for me if you just use this branch as you work on the solution, rebase and push --force as much as you like and just keep sharing the latest with us. That way I can stay involved and help. That's if you want any help of course!

@danascheider
Copy link
Contributor Author

That works for me. I should have some time to work on this tomorrow as I just finished a couple other projects that were taking up my time.

On Oct 14, 2015, at 11:39 PM, Matt Wynne [email protected] wrote:

I'm totally working on it already, just didn't want to pollute the existing PR with all the new commits so I switched to a different branch & will merge later.

OK. I've put the WIP tag on this PR, so it would work well for me if you just use this branch as you work on the solution, rebase and push --force as much as you like and just keep sharing the latest with us. That way I can stay involved and help. That's if you want any help of course!


Reply to this email directly or view it on GitHub.

@danascheider
Copy link
Contributor Author

OK, I didn't end up getting to this today because my server got rooted and I had to fix everything. Keeping my fingers crossed for tomorrow!

@mattwynne
Copy link
Member

Friday is OSS day so that's good. Grab me in https://gitter.im/cucumber/cucumber-ruby if you want to chat.

def test_case(test_case)
super

configuration.on_event(:after_test_case) do |event|
Copy link
Member

Choose a reason for hiding this comment

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

I'd have thought you'd need to register the event listener earlier than this, like maybe in the filter's constructor. Does it work?

@danascheider
Copy link
Contributor Author

@mattwynne I got a little stuck trying to figure out why the one spec on this still fails. It seems to be saying that when there's a failing test (not a flaky one), it's only retrying once, even though the configuration options say it should be retried twice. Am I missing something obvious?

@mattwynne
Copy link
Member

I have a flight on Monday when I should be able to give this some focus. Can you push up whatever you have (use another branch if you want) and I'll get my head around it then?

Thanks for your patience @danascheider.

@danascheider
Copy link
Contributor Author

@mattwynne No problem, I'm pretty sure what's on this branch is all I have at this point, but I'll check my home laptop for more and push anything I find. I've been really busy too, so no worries.

@mattwynne
Copy link
Member

@danascheider FINALLY I got a chance to look at this 😀. I'm lucky enough to have @brasmusson in the same room as me today, and we figured out some subtle problems that were preventing the retry filter from working quite right. We pushed them here: 8f9445f for you to take a look at. I wouldn't copy the changes line-for-line as we were messing around quite a bit and probably changed more than is necessary. I'll put some comments on that diff to show you the interesting bits.

FYI, the acceptance test now seems to be failing for another reason - even when a test has been retried, the summary still shows 1 scenario. @brasmusson and I are looking into that now.

@danascheider
Copy link
Contributor Author

@mattwynne Thank you! I'll take a look at it too.

@mattwynne mattwynne changed the title Features for --retry Add --retry option to retry failed tests as part of the same run Apr 10, 2016
@mattwynne
Copy link
Member

Hi @danascheider, just checking in to see how you're feeling about this one. I'm deliberately leaving it so you can get the sense of satisfaction from finishing it. Is there anything blocking you right now that I can help with?

@danascheider
Copy link
Contributor Author

Oh, thanks, @mattwynne. It's on my list, I'm just working a lot and in the middle of moving so I had it on the back burner.

@mattwynne
Copy link
Member

👍🚚💼

Take your time @danascheider, I think you have most of the puzzle pieces now. The existing code for the summary numbers in the formatters is a bit of a muddle but that's a problem we can deal with when you've got the main behaviour working.

Change Retry filter to have attribute :configuration and first pass at setting up a listener

Reorganize spec file

Finish adding tests for re-running flaky test cases - all but one pass

Fix spec that said to test what happens when a test case passes but actually didn't make sure it did pass
Define steps for the retry feature
@danascheider
Copy link
Contributor Author

Got all the tests passing - any other thoughts, @mattwynne or @brasmusson? What was the problem with the formatter for the summary numbers?

@danascheider danascheider removed the WIP label May 15, 2016
@brasmusson
Copy link
Contributor

An reasonable output from the progress formatter in case of one scenario that passed, one scenario that passed after one retry, one scenario that passed after two retries, and one scenario that still failed after two retries could be:

..R.RR.RRF
<exception stacktraces>
4 Scenarios (3 Passed, 1 Failed) - 2 Scenarios needed retires to pass

A problem with the implementation is that the summary is provided by the Console module, it is used both by the pretty formatter and the progress formatter (and peoples custom formatter), and the progress formatter is on the way to be fully based on events (#977) using the Summary class from the Core , whereas the pretty formatter is still using the legacy formatter API. To implement what is needed to produce a summary as the one above which works for all the APIs that formatters uses seems to be - how should I put it - not trivial.

@mattwynne
Copy link
Member

To implement what is needed to produce a summary as the one above which works for all the APIs that formatters uses seems to be - how should I put it - not trivial.

Classic Swedish understatement @brasmusson!

Actually I don't think it will be that hard, but equally I think it's an enhancement. With what @danascheider's already done, the thing is usable and useful. We can improve on the reporting in another iteration IMO.

Thoughts?

@@ -32,6 +32,70 @@
create_step_definition { string }
end

Given /^a scenario "([^\"]*)" that fails once, then passes$/ do |name|
Copy link
Member

Choose a reason for hiding this comment

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

Do you think maybe these should go into a retry_steps.rb? They're quite specific...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@mattwynne
Copy link
Member

There's lot of commits here. Probably best to squash when this gets merged? Unless you want to rebase @danascheider?

@danascheider
Copy link
Contributor Author

Sure, they can be squashed.

@mattwynne mattwynne merged commit 5cae2b2 into cucumber:master May 17, 2016
mattwynne added a commit that referenced this pull request May 17, 2016
@brasmusson brasmusson mentioned this pull request May 22, 2016
3 tasks
@danascheider danascheider mentioned this pull request May 26, 2016
private

def retry_required?(test_case, event)
event.test_case == test_case && event.result.failed? && test_case_counts[test_case] < configuration.retry_attempts
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not work, since the test_case you pass on is never the same that are in the after_test_case event. Filters like activate_steps call Case#with_steps which creates a new test case object.

Copy link
Member

Choose a reason for hiding this comment

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

I've resolved this with cucumber/cucumber-ruby-core#111 which makes equality for Test::Case objects work as you would expect it to.

richarda pushed a commit to richarda/cucumber that referenced this pull request Jul 1, 2016
…umber#920)

* Add feature file from PR 895 to start work on retry functionality

* Initial spec for --retry option

* Add another test for --retry flag, make new tests pass

* Squash some commits

Redo the commit I just reverted but with the file I intended to include the first time

* Rebase onto master

* Allow for --retry option in configuration

Add retry_attempts method to configuration base class

Add Retry formatter and specs for same

Remove files attempting to implement --retry with a formatter - bad idea

Add wip tag to prevent --retry features from killing the build

Actually run Travis build against active branch

Fix tiny grammatical error. Closes cucumber#914.

* Update scenarios to look like @mattwynne's suggestion

* Initial specs for retry filter - they test if it works at all, basically

Change Retry filter to have attribute :configuration and first pass at setting up a listener

Reorganize spec file

Finish adding tests for re-running flaky test cases - all but one pass

Fix spec that said to test what happens when a test case passes but actually didn't make sure it did pass

* Add consistently failing scenario to test cases

Define steps for the retry feature

* Correct # of retries

* Refactor test case

* Make method private

* Extract retry_required? method

* Move steps for retry filter into other file

* Correct block style
richarda pushed a commit to richarda/cucumber that referenced this pull request Jul 1, 2016
@mattwynne mattwynne mentioned this pull request Jul 2, 2016
2 tasks
brasmusson added a commit that referenced this pull request Jul 3, 2016
@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
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