integration
Last updated
Last updated
Last updated: 2025-04-24 01:05:27.879745 File source:
This directory contains the test suite for the DMS. The tests in this directory verify the functionality of the DMS by creating a network of nodes and testing their interactions. These tests ensure that the core features of the DMS are working correctly in a multi-node environment.
Before running the tests, ensure you have the following prerequisites installed:
GlusterFS
Docker
The DMS binary built and available in the test directory (optional for make rule usage)
Ensure GlusterFS is installed and pull the container.
Using Make:
Using Go:
To run a specific test:
Available test suites:
BasicTests
: Tests basic node communication
DeploymentTests
: Tests deployment functionality
DeploymentWithVolumesTests
: Tests deployment with storage volumes
StorageTests
: Tests storage functionality
The test suite is organized as follows:
integration_test.go
: Entry point for all tests
suite_test.go
: Defines the test suite structure and common functionality
client_test.go
: Client implementation for interacting with DMS nodes
basic_test.go
: Basic communication tests
deployment_test.go
: Tests for deployment functionality
glusterfs_test.go
: GlusterFS setup for storage tests
storage_test.go
: Tests for storage functionality
volume_test.go
: Tests for volume management
utils_test.go
: Utility functions for tests
testdata/
: Test deployment ensembles
TestSuite: The main test suite that sets up a network of nodes
Client: A wrapper around the DMS CLI for testing
prefixWriter: Used to prefix node logs with node identifiers
Tests should be run in parallel to speed up the test suite.
To add a test for a new feature in parallel, here's the suggested workflow:
Create a new test file in the test/integration
directory.
Define a runner function that takes a *TestSuite
parameter:
Add your test to the TestIntegration
function in integration_test.go
:
Each test suite must use unique port ranges to avoid conflicts:
Allocate unique restPortIndex
and p2pPortIndex
for each test suite
Increment by at least 3 (for a 3-node test) from the previous test suite's ports
Document the port ranges used in comments to avoid future conflicts
Tests should properly clean up resources:
Use t.Cleanup()
for Docker containers and other external resources
Ensure all nodes are properly shut down in the TearDownSuite
method
Verify resource allocation and deallocation in deployment tests
Store test ensembles in testdata/ensembles/
Use descriptive names for test files
When using dynamic hostnames, use the replaceHostnameInFile
utility
Use suite.Require()
instead of package-level assertions to ensure proper test failure tracking
Add descriptive failure messages to assertions
Use suite.T().Logf()
for detailed logging during test execution
Each test suite should be completely independent
Do not share state between test suites
Use unique node directories and configurations
Use suite.Require().Eventually()
for operations that may take time to complete
Set appropriate timeouts based on operation complexity
Include descriptive timeout messages