Unit tests for Milvus CLI internal modules and classes.
These tests directly test Python classes like:
ConnectionClient- Connection managementCollectionClient- Collection operationsDatabaseClient- Database operationsIndexClient- Index operations- etc.
- Python >= 3.8.5
- Running Milvus instance
- pymilvus >= 2.5.0
Create a test.env file in this directory or set environment variables:
# Required
MILVUS_TEST_URI=http://10.102.9.174:19530
# Optional
MILVUS_TEST_TOKEN=your_token_here
MILVUS_TEST_TLS_MODE=0
MILVUS_TEST_CERT_PATH=/path/to/cert
MILVUS_TEST_COLLECTION_PREFIX=test_collectionDefault values (if not set):
MILVUS_TEST_URI:http://127.0.0.1:19530MILVUS_TEST_TOKEN:NoneMILVUS_TEST_TLS_MODE:0MILVUS_TEST_CERT_PATH:NoneMILVUS_TEST_COLLECTION_PREFIX:test_collection
# From project root
python -m unittest discover milvus_cli/test
# Or from this directory
python -m unittest discover .python -m unittest milvus_cli.test.test_connection_client
python -m unittest milvus_cli.test.test_collection_clientpython -m unittest milvus_cli.test.test_connection_client.TestConnectionClientpython -m unittest milvus_cli.test.test_connection_client.TestConnectionClient.test_show_connectionpython -m unittest discover milvus_cli/test -vtest_config.py- Test configuration managementtest_connection_client.py- Connection teststest_collection_client.py- Collection teststest_database_client.py- Database teststest_index_client.py- Index teststest_partition_client.py- Partition teststest_data_client.py- Data import/export teststest_user_client.py- User management teststest_role_client.py- Role management teststest_alias_client.py- Alias teststest_cli_client.py- CLI client tests
| Aspect | Unit Tests (milvus_cli/test/) |
Integration Tests (tests/) |
|---|---|---|
| Framework | unittest | pytest |
| Target | Python classes/modules | CLI commands |
| Speed | Faster | Slower |
| Scope | Internal API | User interface |
| Run command | python -m unittest discover |
pytest tests/ or python run_tests.py |
If tests fail with connection errors:
- Ensure Milvus is running at the configured URI
- Check
test.envor environment variables - Verify network connectivity
If you get import errors:
# Install the package in development mode
pip install -e .If configuration is not being picked up:
- Check that
test.envexists in this directory - Or set environment variables directly
- Run
test_config.pyto verify configuration:python milvus_cli/test/test_config.py