Add MongoDB Atlas support for TestContainers and Docker Compose

Implement service connection support for MongoDB Atlas using both
TestContainers and Docker Compose. This change enables easier
integration testing and local development with MongoDB Atlas.

- Leverage TestContainers 1.20.2 which introduces MongoDBAtlasLocalContainer
- Add TestContainers support using MongoDBAtlasLocalContainer
- Implement Docker Compose configuration for MongoDB Atlas
- Create connection details factories for both TestContainers and Docker Compose
- Update dependency management for MongoDB Atlas integration
- Add integration tests for both TestContainers and Docker Compose setups
- Update documentation to include MongoDB Atlas support
This commit is contained in:
Eddú Meléndez
2024-09-30 20:29:20 -06:00
committed by Mark Pollack
parent e58341a447
commit e1d9bfc616
11 changed files with 311 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package org.springframework.ai.docker.compose.service.connection.mongo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.mongo.MongoConnectionDetails;
import org.springframework.boot.docker.compose.service.connection.test.AbstractDockerComposeIntegrationTests;
import org.testcontainers.utility.DockerImageName;
import static org.assertj.core.api.Assertions.assertThat;
class MongoDbAtlasLocalDockerComposeConnectionDetailsFactoryTests extends AbstractDockerComposeIntegrationTests {
protected MongoDbAtlasLocalDockerComposeConnectionDetailsFactoryTests() {
super("mongo-compose.yaml", DockerImageName.parse("mongodb/mongodb-atlas-local"));
}
@Test
void runCreatesConnectionDetails() {
MongoConnectionDetails connectionDetails = run(MongoConnectionDetails.class);
assertThat(connectionDetails.getConnectionString()).isNotNull();
}
}

View File

@@ -0,0 +1,5 @@
services:
mongo:
image: '{imageName}'
ports:
- '27017'