Test Your Application

Warning:
Cockroach Labs will stop providing Assistance Support for this version on November 18, 2022. Prior to that date, upgrade to a more recent version to continue receiving support. For more details, see the Release Support Policy.

This page documents best practices for unit testing applications built on CockroachDB.

If you are deploying a self-hosted cluster, see the Production Checklist for information about preparing your cluster for production.

Use a local, single-node cluster with in-memory storage

The cockroach start-single-node command starts a single-node, insecure cluster with in-memory storage:

icon/buttons/copy
cockroach start-single-node --insecure --store=type=mem,size=0.25 --advertise-addr=localhost

Using in-memory storage improves the speed of the cluster for local testing purposes.

Log test output to a file

By default, cockroach start-single-node logs cluster activity to a file with the default logging configuration. When you specify the --store=type=mem flag, the command prints cluster activity directly to the console instead.

To customize logging behavior for local clusters, use the --log flag:

icon/buttons/copy
cockroach start-single-node --insecure --store=type=mem,size=0.25 --advertise-addr=localhost --log="{file-defaults: {dir: /path/to/logs}, sinks: {stderr: {filter: NONE}}}"

The log flag has two suboptions:

  • file-defaults, which specifies the path of the file in which to log events (/path/to/logs).
  • sinks, which provides a secondary destination to which to log events (stderr).

For more information about logging, see Configure logs.

Use a local file server for bulk operations

To test bulk operations like IMPORT, BACKUP, or RESTORE, we recommend using a local file server.

For more details, see Use a Local File Server for Bulk Operations.

See also


Yes No

Yes No