Why this change is needed:
PR #2366 introduces critical workspace isolation functionality to resolve
multi-instance concurrency issues, but lacks comprehensive automated tests
to validate the implementation. Without proper test coverage, we cannot
ensure the feature works correctly across all scenarios mentioned in the PR.
What this test suite covers:
1. Pipeline Status Isolation: Verifies different workspaces maintain
independent pipeline status without interference
2. Lock Mechanism: Validates the new keyed lock system works correctly
- Different workspaces can acquire locks in parallel
- Same workspace locks serialize properly
- No deadlocks occur
3. Backward Compatibility: Ensures legacy code without workspace parameters
continues to work using default workspace
4. Multi-Workspace Concurrency: Confirms multiple LightRAG instances with
different workspaces can run concurrently without data interference
Testing approach:
- All tests are automated and deterministic
- Uses timing assertions to verify parallel vs serial lock behavior
- Validates data isolation through direct namespace data inspection
- Comprehensive error handling and detailed test output
Test results:
All 9 test cases passed successfully, confirming the workspace isolation
feature is working correctly across all key scenarios.
Impact:
Provides confidence that PR #2366's workspace isolation feature is
production-ready and won't introduce regressions.
(cherry picked from commit
|
||
|---|---|---|
| .. | ||
| e2e_real_service | ||
| gpt5_nano_compatibility | ||
| conftest.py | ||
| e2e_multi_tenant_state.py | ||
| README.md | ||
| test_aquery_data_endpoint.py | ||
| test_backward_compatibility.py | ||
| test_curl_aquery_data.sh | ||
| test_document_routes_tenant_scoped.py | ||
| test_graph_storage.py | ||
| test_idempotency.py | ||
| test_lightrag_ollama_chat.py | ||
| test_multi_tenant_backends.py | ||
| test_multitenant_e2e.py | ||
| test_overlap_validation.py | ||
| test_postgres_retry_integration.py | ||
| test_tenant_api_routes.py | ||
| test_tenant_models.py | ||
| test_tenant_security.py | ||
| test_tenant_storage_phase3.py | ||
| test_workspace_isolation.py | ||
| test_write_json_optimization.py | ||
LightRAG Test Suite Index
This directory contains organized test suites for LightRAG.
Test Suites
📁 gpt5_nano_compatibility/
Comprehensive test suite for gpt-5-nano model compatibility and configuration validation.
Contents:
test_gpt5_nano_compatibility.py- Primary compatibility test suite (5 tests)test_env_config.py- .env configuration validation (6 tests)test_direct_gpt5nano.py- Direct API testingtest_gpt5_reasoning.py- Reasoning token overhead analysisREADME.md- Complete documentation
Run:
cd gpt5_nano_compatibility
python test_gpt5_nano_compatibility.py # Primary test suite
python test_env_config.py # Configuration tests
Status: ✅ All tests passing
What's Tested
OpenAI Integration
- ✅ API connectivity with gpt-5-nano
- ✅ Parameter normalization (max_tokens → max_completion_tokens)
- ✅ Temperature parameter handling
- ✅ Token budget adjustments for reasoning overhead
- ✅ Backward compatibility with other models
Configuration
- ✅ .env file loading
- ✅ Configuration parser respects environment variables
- ✅ Model selection from configuration
Models
- ✅ gpt-5-nano (primary, cost-optimized)
- ✅ text-embedding-3-small (embeddings)
- ✅ gpt-4o-mini (backward compatibility)
Functionality
- ✅ Embeddings generation
- ✅ Entity extraction
- ✅ LLM completion
- ✅ Full RAG pipeline integration
Quick Start
-
Setup environment:
cp .env.example .env # Edit .env with your OpenAI API keys -
Run primary test suite:
cd tests/gpt5_nano_compatibility python test_gpt5_nano_compatibility.py -
Expected output:
✅ Parameter Normalization: PASSED ✅ Configuration Loading: PASSED ✅ Embeddings: PASSED ✅ Simple Completion: PASSED ✅ Entity Extraction: PASSED 🎉 ALL TESTS PASSED
Key Implementation Details
Parameter Normalization
The main gpt-5-nano compatibility fix is in /lightrag/llm/openai.py:
def _normalize_openai_kwargs_for_model(model: str, kwargs: dict[str, Any]) -> None:
"""Handle model-specific parameter constraints"""
if model.startswith("gpt-5"):
# Convert max_tokens → max_completion_tokens
if "max_tokens" in kwargs:
max_tokens = kwargs.pop("max_tokens")
kwargs["max_completion_tokens"] = int(max(max_tokens * 2.5, 300))
# Remove unsupported parameters
kwargs.pop("temperature", None)
Why 2.5x Multiplier?
gpt-5-nano uses internal reasoning that consumes tokens. Testing showed:
- Original token budget often leaves empty responses
- 2.5x multiplication provides adequate margin
- 300 token minimum ensures consistency
Related Documentation
/docs/GPT5_NANO_COMPATIBILITY.md- Comprehensive user guide/docs/GPT5_NANO_COMPATIBILITY_IMPLEMENTATION.md- Technical implementation detailsgpt5_nano_compatibility/README.md- Detailed test documentation
Test Statistics
- Total Tests: 11
- Passing: 11 ✅
- Failing: 0 ✅
- Coverage: OpenAI integration, configuration, embeddings, LLM, RAG pipeline
Maintenance
When modifying LightRAG's OpenAI integration:
- Run tests to ensure compatibility
- Pay special attention to parameter handling
- Test with both gpt-5-nano and gpt-4o-mini
- Update documentation if behavior changes
Last Updated: 2024 Status: Production Ready ✅ Test Coverage: OpenAI API Integration (100%)