Skip to content

Commit 21b9deb

Browse files
committed
Update tests README with Model Runner Testcontainers information
1 parent ad49f8c commit 21b9deb

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

tests/README.md

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ go test -v ./integration -run TestSimple
1515
# Run a specific integration test
1616
go test -v ./integration -run TestGenAIAppIntegration
1717

18+
# Test Model Runner connectivity
19+
go test -v ./integration -run TestModelRunnerIntegration
20+
1821
# Run extended performance tests
1922
go test -v ./integration -run TestExtendedPerformance
2023

@@ -27,6 +30,7 @@ go test -v ./integration
2730
- **TestSimple**: Basic test to verify compilation and environment setup
2831
- **TestBasicTestcontainer**: Validates the Testcontainers environment setup
2932
- **TestGenAIAppIntegration**: Tests various API endpoints with different prompt types
33+
- **TestModelRunnerIntegration**: Tests connectivity to Docker Model Runner using Testcontainers
3034
- **TestLLMResponseQuality**: Validates the quality of LLM responses
3135
- **TestLLMPerformance**: Measures performance metrics of the LLM service
3236
- **TestMultiTurnConversation**: Tests context maintenance in conversations
@@ -47,6 +51,7 @@ go test -v ./integration
4751
- `extended_test.go`: Extended performance tests
4852
- `basic_testcontainer_test.go`: Basic test for Testcontainers functionality
4953
- `simple_test.go`: Minimal test to verify package compilation
54+
- `model_runner_test.go`: Test for Docker Model Runner connectivity using Testcontainers
5055

5156
## Running Tests
5257

@@ -68,6 +73,16 @@ go test -v ./integration -run TestGenAIAppIntegration
6873
go test -v ./integration -run TestChatQuality
6974
```
7075

76+
### Model Runner Tests
77+
78+
Tests connectivity to the Docker Model Runner:
79+
80+
```bash
81+
# Enable Docker Model Runner in Docker Desktop first
82+
# Make sure to check "Enable host-side TCP support"
83+
go test -v ./integration -run TestModelRunnerIntegration
84+
```
85+
7186
### Performance Tests
7287

7388
Measures response times and performance characteristics:
@@ -93,14 +108,39 @@ Skip long-running tests:
93108
go test -v ./integration -short
94109
```
95110

111+
## Using Testcontainers for Model Runner
112+
113+
The `TestModelRunnerIntegration` test demonstrates how to use Testcontainers to connect to the Docker Model Runner:
114+
115+
1. Creates a socat container that forwards traffic to model-runner.docker.internal
116+
2. Dynamically assigns ports to avoid conflicts
117+
3. Tests connectivity to the Model Runner API
118+
4. Logs available models and API endpoints
119+
5. Optionally attempts to create a model
120+
6. Provides the dynamically assigned URL for the application to use
121+
122+
This approach eliminates the need for hardcoded port values and provides a more reliable testing environment.
123+
96124
## Prerequisites
97125

98126
- Go 1.19 or higher
99127
- Docker (for Testcontainers functionality)
128+
- Docker Desktop with Model Runner enabled (for Model Runner tests)
100129
- Running GenAI application at http://localhost:8080 (for API tests)
101130

102-
## Notes
131+
## Testcontainers vs Docker Compose
132+
133+
This test suite demonstrates two approaches for managing dependencies:
134+
135+
1. **Docker Compose**: Used in the main branch for starting the application and its dependencies
136+
2. **Testcontainers**: Used in this branch for programmatically managing dependencies
137+
138+
Benefits of the Testcontainers approach:
139+
140+
- Dynamic port allocation to avoid conflicts
141+
- Programmatic creation and cleanup of containers
142+
- Simplified connection management
143+
- Same approach can be used for both development and testing
144+
- Eliminates the need for multiple compose files
103145

104-
- The tests expect your application to be running at http://localhost:8080
105-
- The Testcontainers functionality is currently simplified, but the structure is in place for full container-based testing
106-
- You can customize test duration and parameters in the respective test files
146+
See `TESTCONTAINERS_USAGE.md` in the project root for more details on the Testcontainers approach.

0 commit comments

Comments
 (0)