News for hackers. Stuff that matters.
Re:Our Rails test suite runs in 1 minute on Buildkite by reillyse on Tuesday January 18, 2022 @02:39PM (#29984596)
"We never run all of our application’s tests in local development. It’s not a good use of time and will never be as fast as running them on CI. "

Actually I've just released something for that. It's a way of running from your local environment extremely quickly (spoiler alert we use non-local servers).

You can check it out at https://brisktest.com/ we have a demo running Jest at the moment but I'm recording a rails demo right now.

Re:Our Rails test suite runs in 1 minute on Buildkite by moltar on Wednesday January 19, 2022 @10:02AM (#29994429)
How do I sign up?
Re:Our Rails test suite runs in 1 minute on Buildkite by renewiltord on Tuesday January 18, 2022 @02:17PM (#29984261)
Nice simple article describing a technique to parallelize tests and a quick fix to an issue blocking it.

It is interesting to observe the time that things take in various environments. I worked in ad tech previously with lots of offline big-data jobs. Test completion took a few minutes even fully parallelized. Now I work in HFT and our test suite completes on an M1 Max in 21 s and it's got higher coverage.

The situations aren't really comparable. But it's interesting to see the different baselines.

Re:Our Rails test suite runs in 1 minute on Buildkite by rubyist5eva on Tuesday January 18, 2022 @03:54PM (#29985623)
Our Rails test suite runs in about 20 minutes (mostly integration tests) but parallelized on CircleCI with 3 workers it's down to ~6. If I run our entire suite locally on my 8-core macbook I get about 3 minutes but I can't do much with my laptop during that time because my system is monopolized, a colleague of mine runs it on a threadripper and it's sub-2 minutes. So running on Circle is well worth it, I can go top off my coffee, make a snack, answer emails, etc...
Re:Our Rails test suite runs in 1 minute on Buildkite by blue_box on Tuesday January 18, 2022 @01:16PM (#29983304)
Would be nice if they shared how many tests they have :)
Re:Our Rails test suite runs in 1 minute on Buildkite by byroot on Tuesday January 18, 2022 @01:41PM (#29983729)
In the grand scheme of things it doesn't matter that much.

Once you starts parallelizing, CI time is: setup_time + (test_run_time / workers), so assuming money isn't a problem you can add more workers as you keep adding more tests.

What really matter is how fast you can setup your test workers and how slow individual tests are.

Re:Our Rails test suite runs in 1 minute on Buildkite by Ataraxic on Tuesday January 18, 2022 @02:13PM (#29984207)
I think your last statement captures something that not often emphasized, which is that startup time of workers and app are variable costs which scale with the amount of parallelization and so if you have a very large test suite there may be a limit where setup eats up so much time that parallelizing more is going to be pretty "wasteful" and I guess that's where the money comes in.

Secondly if you're actually trying to startup 100+ test workers per build and so on there's going to be some time distribution for how long it takes for each worker to startup and that adds a bit more time for all workers to complete. This distribution probably isn't _that_ wide timewise but if you really start to push your test suite runtime down it may pop up. If you're running things in docker sometimes a node doesn't have the image in it's docker cache...

Unsure if CI services like buildkite have really made this that much faster but it seems like they are using a single box with 64 cores.

Re:Our Rails test suite runs in 1 minute on Buildkite by byroot on Tuesday January 18, 2022 @02:44PM (#29984645)
> Unsure if CI services like buildkite have really made this that much faster

Buildkite doesn't directly help with it, but since you bring your own hardware and that it's highly customizable, it does allow you to invest in improving setup time quite dramatically. It's a great product.

Re:Our Rails test suite runs in 1 minute on Buildkite by pmontra on Tuesday January 18, 2022 @01:32PM (#29983586)
Indeed. The only hint is "Our whole test suite locally takes around 12 minutes running serially on a MacBook Pro" so it should be a real world case. They used 64 cores on Buildkite.
[dead]
Re:Our Rails test suite runs in 1 minute on Buildkite by exdsq on Tuesday January 18, 2022 @01:36PM (#29983652)
If you're not programming in Rust and Julia, are you really programming? /s
Re:Our Rails test suite runs in 1 minute on Buildkite by bnt on Tuesday January 18, 2022 @01:42PM (#29983746)
I thought HN crowd was more into Nim or Zig?
Re:Our Rails test suite runs in 1 minute on Buildkite by ksec on Tuesday January 18, 2022 @02:40PM (#29984609)
Hell No. Zig is still a relatively new. But if you search Rust on HN, you still see it wins by a very wide margin.
Re:Our Rails test suite runs in 1 minute on Buildkite by devoutsalsa on Tuesday January 18, 2022 @01:53PM (#29983915)
Nah, it's all about MUMPS.
Re:Our Rails test suite runs in 1 minute on Buildkite by aaronbrethorst on Tuesday January 18, 2022 @02:17PM (#29984277)
I hear Verona is beautiful this time of year.
Re:Our Rails test suite runs in 1 minute on Buildkite by bnt on Tuesday January 18, 2022 @02:21PM (#29984329)
Canada is indeed beautiful
Re:Our Rails test suite runs in 1 minute on Buildkite by aaronbrethorst on Tuesday January 18, 2022 @03:09PM (#29984997)
(Epic Systems is probably the biggest user of MUMPS in the world, and is headquartered in Verona, Wisconsin.)
Re:Our Rails test suite runs in 1 minute on Buildkite by exdsq on Tuesday January 18, 2022 @05:31PM (#29987032)
Nim is 14 years old, why don’t you just recommend FORTRAN you graybeard?
Re:Our Rails test suite runs in 1 minute on Buildkite by inetknght on Tuesday January 18, 2022 @01:37PM (#29983671)
One minute? That's terrible. What kinds of tests and how many are you running?

> We never run all of our application’s tests in local development. It’s not a good use of time and will never be as fast as running them on CI.

WTF this is bad practice. Developers should always get in the habit of running tests locally first. No test should require running in the cloud. And, even more, it's actually rare that CI is more performant than your developers' machines. You should invest in your developers.

> Our whole test suite locally takes around 12 minutes running serially on a MacBook Pro.

That's really really really awful. Most projects' tests, even when they're poorly written, still run in 3 or 4 minutes. My own tests run on the order of single-digit seconds.

> We haven’t put much effort here because it’s not something our engineers ever run.

Well of course not. They can't iterate fast if they're slowed down by tests. That's why tests have to be fast!

> This gave us some speed gains, but we wanted it really fast. Our infrastructure team set us up with some 64 core machines

Holy schnapple if I had 64 core machines, a complete test suite would finish on the order of tens of milliseconds!

I'm glad ya'll have gotten your tests down from 12 minutes to 1 minutes. There's a ton more improving you can do though.

Re:Our Rails test suite runs in 1 minute on Buildkite by quesera on Tuesday January 18, 2022 @01:49PM (#29983853)
> Most projects' tests, even when they're poorly written, still run in 3 or 4 minutes. My own tests run on the order of single-digit seconds.

That is an absurd statement to make without context.

I work on a large project with a few thousand very well-written tests, which run in 24 minutes serially on a recent-era laptop, or under a minute in well-parallelized CI environment.

Re:Our Rails test suite runs in 1 minute on Buildkite by hdjjhhvvhga on Tuesday January 18, 2022 @01:40PM (#29983722)
How can you tell that if you don't know the complexity of their projects?
Re:Our Rails test suite runs in 1 minute on Buildkite by pskinner on Tuesday January 18, 2022 @02:01PM (#29984040)
This is because RoR projects do not do unit testing, they do integration testing with a real DB.

This approach is terrible and causes the poor performance.

There are whole sets of testing "tools" for RoR projects that promote this mechanism of testing - if you're testing an API you need to use an external tool to properly hit that API.

If you're writing unit tests, write unit tests with mocked dependencies.

Re:Our Rails test suite runs in 1 minute on Buildkite by ch4s3 on Tuesday January 18, 2022 @02:14PM (#29984210)
> This is because RoR projects do not do unit testing, they do integration testing with a real DB.

Lots of RoR projects do unit testing without the DB involved, I did it for ~10years and you can write small unit tests until your eyes bleed, but eventually you'll want to test the controllers.

> There are whole sets of testing "tools" for RoR projects that promote this mechanism of testing - if you're testing an API you need to use an external tool to properly hit that API.

You can just use the built in minitest tools and some fixtures to hit the API, and even back it with sqlite so it's fast and light. Most people don't because thing like Rspec, FaktoryBot, and Cuprite are convenient and nice to work with if a bit slow.

>If you're writing unit tests, write unit tests with mocked dependencies.

There were like 3 talks at Rails Conf about this, people do it all the time in Rails land.

Re:Our Rails test suite runs in 1 minute on Buildkite by pmontra on Tuesday January 18, 2022 @02:10PM (#29984166)
It's hard to really test business logic without hitting the database or other components, no matter the language and the framework. You really have to trust your mocks and sometimes you discover only in production that one of them didn't do what it should do. It happened to me.

The teams I work with tend to write unit tests to demonstrate that a class or module or whatever work, then integration tests to demonstrate that that part of the application works from the frontend code down to the database.

Re:Our Rails test suite runs in 1 minute on Buildkite by quesera on Tuesday January 18, 2022 @02:12PM (#29984182)
> This is because RoR projects do not do unit testing, they do integration testing with a real DB.

This is not correct.

Rails projects use unit testing, integration testing, and functional testing, as appropriate for the case.

Re:Our Rails test suite runs in 1 minute on Buildkite by realusername on Tuesday January 18, 2022 @02:18PM (#29984284)
If you write all yours tests without spinning up once a database, I'm not vouching for the effectiveness of said tests...

Especially that we're talking about a web framework, the db is a core part of your stack.

Yes there's going to be strictly unit tests but then at some point there are also queries and models.

Re:Our Rails test suite runs in 1 minute on Buildkite by syspec on Tuesday January 18, 2022 @09:45PM (#29989285)
Oh the number of times I've run my tests for springboot in which passed, only to fail because of a subtle db issue when hitting the real DB

I'll take hitting real "_test" db anyday

Re:Our Rails test suite runs in 1 minute on Buildkite by touisteur on Tuesday January 18, 2022 @03:47PM (#29985535)
Might be a place to bypass fsync/fdatasync via LD_PRELOAD using libeatmydata, it will save hours of CI time without switching DAO or DB configuration.