-
Notifications
You must be signed in to change notification settings - Fork 0
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
Batches not optimized after using KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE #24
Comments
If you provide a list of test files to For instance, when you provide a full path for the test files instead of a relative path. New paths have to be recorded for the first time (which means a lot of small batches). You can run a few CI builds, and once the new paths are recorded, they should be grouped in smaller batches in future CI builds. If the problem persists, please share the name of the branch you are testing it and share the link to CI builds in the user dashboard with a support: |
Hi @ArturT. Thanks for the response. I did some more investigation and found some interesting results. First, I did notice that our use of |
It could happen when you did not record all test files with absolute file paths. You could be running only a subset of the test suite for 2 weeks. For example, you generate a small list of test files ( Not all work done by developers over 2 weeks touched the whole code base, so not all test files with absolute paths have been recorded yet. As a result of that, your CI build would be unbalanced because you often provide a new unknown absolute file path to
Great. I guess you were running all test files on a I recommend using relative paths always. |
Let me give you some more details about our history as some of what you're saying doesn't make sense to me. We were originally using the KNAPSACK_PRO_TEST_FILE_PATTERN option which I believe ends up using relative file paths and when KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE became available, we switched to it using jest --listTests which generates absolute file paths. I would expect the first couple of runs with this new method to not be balanced since the file paths look new, but I don't understand why it never balanced itself over the hundreds of builds over the next 2 weeks unless there is a bug in Knapsack Pro that does not handle being sent absolute file names. Is there a separate process for "recording" or does that automatically happen as a given test file is executed? |
That's correct. The
Ok. So you were still running all test files. I incorrectly assumed you needed
Good point. Maybe the absolute paths were not sent to API.
"recording" is a mental shortcut for tests' execution time being saved to API. This happens after all tests are executed on the CI node. All ever-recorded tests can be seen in the I managed to reproduce the bug. When you started a new CI build you provided absolute test file paths to initialize a new Queue on the API side. API does not know the absolute paths' execution time, which caused unbalanced tests. We would have to convert absolute paths to relative paths as done here but on @knapsack-pro/core level where is |
We do not allow saving absolute test file paths to API because this could lead to problems when tests are executed on different machines. For example, you could have a path like Also, if you would like to reproduce something locally and run tests on your local machine, than the absolute test file path will be different than on CI. That is why it's safe always to use relative paths to your project directory. |
Thanks for the explanation @ArturT. We're now transforming the file paths from |
Great. I added this issue to our backlog. EDITED: Docs have been updated for |
storyHere is an idea on what we could do to make We already say in docs that you should use only relative paths for test files defined with If someone provides absolute paths in the file defined with The project path can be determined with const projectPath = process.cwd(); We already do removing of project path prefix from test files executed by Jest in |
We've noticed a slowdown in our Jest tests after upgrading to
@knapsack-pro/jest
v5.4.1 and using theKNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE
option. What we're seeing is that the execution behavior of batches is very different and not optimized, leading to our Jest steps taking about 9 minutes (up from about 6 minutes). I've tried downgrading just the@knapsack-pro/core
library from v4.0.0 to both v3.3.1 and v3.3.0, but did not see any change in behavior. However, reverting back from usingKNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE
toKNAPSACK_PRO_TEST_FILE_PATTERN
is what resolves the problem.Here's a comparison of the two:
KNAPSACK_PRO_TEST_FILE_PATTERN
With this approach, you can see that the batches start with the slowest ones and get faster, leading to better durations when parallelized.
KNAPSACK_PRO_TEST_FILE_LIST_SOURCE_FILE
With this approach, you can see that the batches are not organized and as a result lead to many more batches being executed and durations taking much longer.
I tried to look through the changes, but didn't find an explanation for why the batching behavior would be different between the two approaches so I'm creating this issue in the hopes that the context you have can provide an answer.
The text was updated successfully, but these errors were encountered: