-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(boot): make sure sandbox directories are removed after tests #5720
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
Conversation
|
-1 We have been intentionally cleaning sandbox directory before the tests start and keep the files created by tests around. That way, when a test fails, it's easy to inspect what happened in the test by looking at the files inside sandbox. Quoting from our best practices at https://loopback.io/doc/en/lb4/Testing-your-application.html#clean-the-database-before-each-test:
With 5720 landed, how do you @raymondfeng envision to debug failed CLI tests? Are we going to have to run the tests from the debugger and setup a breakpoint before the files are deleted, so that we can inspect them? I find that rather annoying. |
Yes, that's the way to do it. @raymondfeng let's revert the change. As long as the sandbox directories are in |
|
I have a different view here. IMO, tests should clean up themselves so that no side effects are left on the system, such as files, env vars, or network ports. We also have to acknowledge that Sure, it would be easier to leave the sandbox files on the disk to troubleshoot these particular test failures. But we can also argue if we should also leave the server open without calling IMO, troubleshooting test failures is not different from debugging code issues. I'm not saying that we have to use debugger all the time. Please note that mocha allows you to skip hooks with |
Sure, I agree that in general, tests should not leave up mess on the system. However, in this particular case, I feel the developer experience is important than theoretical purity. What practical difficulties have you encountered with the original solution where we keep sandbox files around? I believe the problem with parallel mocha has been solved by making sandbox directories unique. What else is there to solve?
Good point. I believe this has been solved by your recent PR where you modified sandbox to use unique directory names. Am I mistaken? IMO, this pull request should not have been landed because we have clearly not reached consensus yet. I opened #5738 to revert the changes in this pull request so that we can discuss the problems you are trying to solve and find a better solution, one that we will all agree with. Few ideas to consider:
|
|
Two more comments:
|
I think we need to establish a protocol here. The pull requests are taking too long to land and it's not practical to get everybody to review each PR. IMO, it has always possible and encouraged to add more feedbacks even after a PR is landed. We can then decide if we should have follow-up PRs to address such comments or revert the original PR if it's severely flawed. Reverting a PR should be the last resort. It's natural to arrive an elegant solution over iterations. BTW, reverting a PR makes it difficult to fix/improve the original PR. |
When I was trying to troubleshoot test failures, I found there were many left-over subdirectories under
Not really. We reuse the sandbox path for all tests inside the same file. Let's assume
+1 to be consistent.
Do we want to honor this env var in |
|
@bajtos Let's make the discussion more concrete with the following example test file (which is typical in our test suite):
At step 1, Now you have the sandbox files created by My introduction of When you run the tests multiple times without |
That's true. I often re-run the failing test in isolation via There is one thing I find confusing here - I thought
I agree with you this is a problem. I am thinking about two ways how to improve the situation, they are not mutually exclusive:
Thoughts? @hacksparrow you were in favor of reverting this PR, do you have any suggestions how to address the practical problems described by @raymondfeng while keeping troubleshooting easy? |
|
Extracted from #5011. It cleans up the tests to avoid conflicting sandbox paths for parallel testing.
Checklist
👉 Read and sign the CLA (Contributor License Agreement) 👈
npm testpasses on your machinepackages/cliwere updatedexamples/*were updated👉 Check out how to submit a PR 👈