Skip to content
New issue

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

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

Already on GitHub? # to your account

[Kaizen] Unflake RegularSynchSpec #1045

Merged
merged 1 commit into from
Jul 9, 2021

Conversation

dzajkowski
Copy link
Contributor

the reason for the flakiness is a race condition between scalamock and akka testkit. by guaranteeing that actors will be shutdown when scalamock is closing down its stubs the possibility for the race is removed.

@@ -474,7 +476,7 @@ class RegularSyncSpec
peersClient.setAutoPilot(new PeersClientAutoPilot)
override lazy val branchResolution: BranchResolution = stub[BranchResolution]
(blockchainReader.getBestBlockNumber _).when().returns(0)
(branchResolution.resolveBranch _).when(*).returns(NewBetterBranch(Nil)).repeat(10)
(branchResolution.resolveBranch _).when(*).returns(NewBetterBranch(Nil)).atLeastOnce()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

not convinced if this is required but the repeat(10) seems arbitrary.

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, atLeastOnce or anyNumberOf Times seems more appropriate. I just always wonder why does a method needs to be called so many times. Is it a recursive one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the logic in RegularSync will run a retry on failure. the failure is the missing node (vide a bit lower) which should result in some logic and a retry. the 10 used to be 1 a long time ago.

Copy link
Contributor

@AnastasiiaL AnastasiiaL left a comment

Choose a reason for hiding this comment

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

I wanna know the steps you took to arrive at this solution 🧐😄

@@ -86,6 +86,8 @@ class RegularSyncSpec
def sync[T <: Fixture](test: => T): Future[Assertion] =
Future {
test
// this makes sure that actors are all done after the test (believe me, afterEach does not work with mocks)
TestKit.shutdownActorSystem(testSystem)
Copy link
Contributor

Choose a reason for hiding this comment

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

This 'fixture' pretty weird... are there any other tests with this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's custom to this test, haven't seen it any other place.

@dzajkowski dzajkowski force-pushed the kaizen/unflake-regular-synch-spec branch from 8107cc6 to 5539597 Compare July 9, 2021 13:15
@dzajkowski dzajkowski merged commit 7456a31 into develop Jul 9, 2021
@dzajkowski dzajkowski deleted the kaizen/unflake-regular-synch-spec branch July 9, 2021 14:18
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants