Embedded CockroachDB for unit tests

Is there a way of having a disposable in-memory version of Cockroach that we’d only use for unit tests? Presently, it looks like the docker method is advised, however I’d like to avoid this as it complicates things.

Thanks

@mark_balmer, I’m not sure if it would work for your case, but there’s a cockroach demo command that starts up a temporary, in-memory cluster with immediate access to a sql shell. In 19.2 (docs linked above), there’s even a --nodes flag that lets you make it multi-node, though that hasn’t yet made it into an official beta release, so you’d have to build off master to get that today.

Otherwise, if you’re using cockroach start, you can pass --store=type=mem,size=<maximum bytes or percentage of available memory> to make a node in-memory only. I don’t know how much this option has been vetted, however. It’s definitely not intended for anything but testing scenarios.

Hope that helps.

Best,
Jesse

If you are using a go client you can use testserver: