<div dir="ltr"><div>(tl;dr is at the bottom)<br></div><div><br>Some <b>background</b>: our (auth-server) remote tests have always run in such a way that each file full of remote tests starts up several child processes to run an auth-server and other server helper stubs. The tests in the file would make requests against this new flock of children, and then shut them down, before moving on to the next test file.<br><br></div><div>Some of the <b>problems </b>we would encounter because of this setup, by my own rating of importance:<br><br></div><div>- Since the tests took a long time to run (around 4 minutes), I'd find myself trying as much as possible to not run them. Our CI would run them, so they weren't ever forgotten, but a developer being passively discouraged to run tests is not a great situation.<br><br></div><div>- We would get sporadic test failures and time outs due to child process startup woes, and not being able to reflect exceptions in the child processes back to the test runner. It's like screaming children in the line at Disney.<br><br></div><div>- Quite often, the child processes wouldn't be killed when the parent test runner process quit, and then we'd have odd errors when consecutive runs tried to start up processes to listen on an already used port. It's a hard knock life, indeed.<br><br></div><div>- Running the tests was slow, even on CI, so waiting for the green checkmarks meant you needed to go do something else and remember to come back and merge later. (Unfortunately, a lot of the time is spent in `npm install`, so it still takes longer than I'd like.)<br><br></div><div>- Even though we hoped different processes would isolate the tests, we polluted the process `ENV` to customize the children, which had an affect of causing test order to affect whether tests passed in some cases.<br></div><div><br></div><div><b>Pull Request <a href="https://github.com/mozilla/fxa-auth-server/pull/1760">#1760</a></b> is shutting down the orphanage. It includes some adjustments to the `TestServer` type used in our remote tests. It no longer spawns a bunch of children, but instead just starts up all the servers in the same process. This fixes (or greatly reduces) each of the problems listed above. <b>We now have the full `npm test` run executing in under 1 minute!</b> And there are no more dangling orphans left behind at fire stations.<br><br></div><div>Fun little bonus, this even discovered a couple of exceptions that were just silently ignored, due to how Hapi reports them and how we ignored that log output. Thankfully, mostly harmless.<br></div><div><br></div><b>tl;dr</b> - Running the auth-server tests now starts all needed servers in the same process, improving correctness, reducing coupling between tests, and improving test run speed by around 4x!<br></div>