only create used and unused segments once to make the test faster #15533
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is trying to make test run faster. When run on our own machine, the test runtime can just from
3.583 s
to2.939 s
after applying the change.Description
In this pull request, we try to only create the task, used segments and unused segments once. In the original setup method, it creates a task and create the used segments and unused segments before every test runs.
However, the first test
testRetrieveUsedSegmentsAction
only tries to assert the retrieved used segments are the same as the original created used segments. The second testtestRetrieveUnusedSegmentsAction
tries to assert the retrieved unused segments are the same as the original created unused segments. We do not need create the used and unused segments every time. Thus, we can just create them only once before all tests run. Another way can be create the used segments for the first test only and create the unused segments for the second test only.Besides, when we inspect the code inside,
action.perform
will just make a copy of used / unused segments and it does not modify the existing fields in this test class.Release note
Key changed/added classes in this PR
RetrieveSegmentsActionsTest
is changed to make it run faster.This PR has: