...
TestServer and TestCluster are two frameworks we built to create Go unit tests for CockroachDB:, for tests that need a functional SQL layer and/or KV layer.
TestServer simulates a single CockroachDB node.
TestCluster simulates a multi-node CockroachDB cluster. Each node is simulated using one TestServer.
By default, TestServer uses in-RAM storage (not persisted) to make tests faster.
For integration tests, consider using roachtest instead. See: the pages Overview of all test frameworks and Roachtest vs TestServer for details.
For other unit tests that do not need a full SQL or KV layer, consider a more narrow unit test that only instantiates the components it cares about. This will make the test run faster.
Here are the main differences between a regular CockroachDB node (e.g. one started via cockroach start
) and one simulated via TestServer:
...
.StorageLayer()
always points to the storage layer inside TestServer..SystemLayer()
always points to the special system interface inside TestServer (previously known as “system tenant” in previous versions of CockroachDB).
Temporary API pitfall and misdesign
As of this writing, TestServerInterface
also contains the following:
...
language | go |
---|
...