This guide covers how to run tests for OCache, including unit tests, integration tests, and end-to-end tests.
# Run all unit tests
make test
# Run tests with race detector
make test-race
# Run integration tests
make test-integration
# Run all tests (unit + integration + e2e)
make test-allFast, isolated tests for individual components:
make test # Run all unit tests (server + client)
make test-server # Server tests only
make test-client # Client tests only
make test-race # Run with race detector
make test-coverage # Generate coverage reportComprehensive storage layer tests:
make test-integration # All integration tests (~5 minutes)
make test-integration-short # Short mode (~30 seconds)
make test-integration-race # With race detector
make test-integration-coverage # With coverage reportSpecialized integration test suites:
make test-integration-objects # Small, medium, and large objects integration tests
make test-integration-compaction # Compaction behavior
make test-integration-workflow # Cross-component workflowsFull system tests using the actual gRPC API:
make test-e2e # Shell-based E2E testsYou can run specific tests or test patterns using the TEST or TESTRUN variables:
Run a specific test by its exact name:
# Run a specific test function
make test TEST=TestCacheService_PutObjectAndGet
# Run a specific test in server
make test-server TEST=TestStorage
# Run a specific integration test
make test-integration TEST=TestIntegration_CompactionRun all tests matching a pattern:
# Run all tests with "CacheService" in the name
make test TESTRUN=CacheService
# Run all storage-related tests
make test-server TESTRUN=Storage
# Run all compaction tests
make test-integration TESTRUN=CompactionThe TEST and TESTRUN variables work with all test targets:
# Override the default filter for specialized targets
make test-integration-small TEST=TestSmallObjects_Basic
make test-integration-medium TESTRUN=Concurrent
# Run specific tests with race detector
make test-race TEST=TestCacheService
make test-integration-race TESTRUN=Segment
# Generate coverage for specific tests
make test-coverage TEST=TestStorageocache/
├── server/
│ └── *_test.go # Server unit tests
├── client/
│ └── *_test.go # Client unit tests
├── tests/
│ ├── integration/ # Integration test suite
│ │ └── *_test.go
│ └── e2e/ # End-to-end test scripts
│ └── *.sh
- Unit Tests: Test individual functions and components in isolation
- Integration Tests: Test the storage layer directly without gRPC
- E2E Tests: Test the complete system through its public APIs
For CI environments, use these targets:
# Run all checks (formatting, vetting, tests)
make check
# Lint without modifying files
make lint-ci
# Run full test suite
make test-all-
RocksDB not found: Install dependencies first
make install-deps make install-rocksdb
-
Tests timeout: Increase timeout for slower systems
# Edit Makefile to increase timeout values # Default is 60s for unit tests, 300s for integration
-
Race detector slowdown: Race detection significantly slows tests
# Use regular tests for quick feedback make test # Use race detector before committing make test-race
Run tests with verbose output:
# Verbose output is already enabled by default in Makefile
make test-server
# For even more detail, run go test directly
cd server && go test -v -run TestCacheService ./...- Run tests before committing: Use
make testfor quick validation - Check race conditions: Run
make test-racebefore PRs - Verify integration: Run
make test-integration-shortfor storage changes - Use specific tests during development: Use TEST/TESTRUN for faster feedback
- Clean test artifacts: Use
make cleanto remove test files
Generate and view test coverage:
# Generate HTML coverage report
make test-coverage
# View the report
open coverage.html
# Generate integration test coverage
make test-integration-coverage
open coverage-integration.htmlCoverage reports show which code paths are tested and help identify gaps in test coverage.