-
Notifications
You must be signed in to change notification settings - Fork 75
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
Conversation
@@ -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() |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
8107cc6
to
5539597
Compare
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.