-
Notifications
You must be signed in to change notification settings - Fork 118
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
#707 Refactor Shard object by splitting it into smaller functions #799
Conversation
Codecov Report
@@ Coverage Diff @@
## master #799 +/- ##
============================================
+ Coverage 78.77% 78.81% +0.03%
+ Complexity 696 666 -30
============================================
Files 143 148 +5
Lines 2950 2959 +9
Branches 423 426 +3
============================================
+ Hits 2324 2332 +8
Misses 354 354
- Partials 272 273 +1 |
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 cannot find any reason to keep those logic wrapped in Shard
object, it breaks SRP. This file is rather big and a lot of functions here are not related to each other so can be keep separately. I see 4 main parts of this feature here that can be split into dedicated files.
- Function
shardCountByTime
and all related private functions - Function
createShardsByShardCount
and all related private functions - Function
createTestMethodDurationMap
which is shared part - Data classes, shouldn't hold any logic, they can be keep together if they are simple.
Also I was thinking about something like that but without magic numbers:
Additionally flank now is using ftl api to run shards, and this api has restriction on maximum test shards up to 50. So below code is not valid now:
|
|
FYI the API restriction is changing soon to 250. I don't want to hardcode the API restriction in Flank as Firebase can change this anytime. |
We have |
We'll likely have to revisit this design. 50 is currently the global limit for both physical and virtual devices. In the future 250 will be the limit for virtual devices. Physical devices will still be limited to 50.
That's a good point. Let's keep the hard coded values. Ideally FTL would expose an API for us to fetch the shard limits so we don't have to push a new Flank release every time. Probably the numbers change infrequently enough this won't be a big deal. If they did keep changing it then possibly https://firebase.google.com/docs/remote-config would be helpful. |
so what should be done here? remove this condition? |
I think we should update to respect the limit defined in AVAILABLE_SHARD_COUNT_RANGE, then in a future PR we'll have to solve for the 250 limit once FTL makes this change. |
…-object # Conflicts: # release_notes.md
so new condition will look |
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.
There is no good reason to wrap functions in object scope.
Kotlin thankfully has no java limitations so we are not forced to keep java rules.
Classes and objects are good for composing data, not functions.
test_runner/src/test/kotlin/ftl/shard/TestMethodDurationTest.kt
Outdated
Show resolved
Hide resolved
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 think there is still a lot of space for improvements. As refactors need more care than common tasks solving them in comment -> fix -> repeat
workflow doesn't make sense so I will leave it at current state. I wonder if other team members have any suggestions.
…-object # Conflicts: # release_notes.md
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.
#707 has main goals
- Split code into smaller chunks/pieces
- Simplify logic (for some time flank had new features 'attached' only which led to a bit tangled code)
I think with this PR (great job!) we managed to handle 1). IMO we should continue our effort with second part, maybe not within this issue but followup one.
Let me know know what think, and thanks!
# Conflicts: # release_notes.md
…-object # Conflicts: # release_notes.md # test_runner/src/main/kotlin/ftl/args/ArgsHelper.kt
…707-refactor-shard-object # Conflicts: # release_notes.md
2109a84
Agreed. We can consider converting the Flank refactor (#718) ticket into an Epic composed of multiple tickets. I'd like to get the remaining features/bug fixes out and then focus on the refactor. What do you think? |
Fixes #707 Refactor Shared object by splitting it into smaller functions
Checklist