Skip to content

Commit 643865c

Browse files
committed
Optimize Testcontainers config for VectorStores
* Unify image definition for vector stores in vector-store modules * Unify image definition for vector stores in spring-ai-testcontainers module Signed-off-by: Thomas Vitale <[email protected]>
1 parent eb2deba commit 643865c

File tree

42 files changed

+304
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+304
-59
lines changed

spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/chroma/ChromaContainerConnectionDetailsFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ChromaContainerConnectionDetailsFactoryTest {
4646

4747
@Container
4848
@ServiceConnection
49-
static ChromaDBContainer chroma = new ChromaDBContainer("ghcr.io/chroma-core/chroma:0.5.0");
49+
static ChromaDBContainer chroma = new ChromaDBContainer(ChromaImage.DEFAULT_IMAGE);
5050

5151
@Autowired
5252
private VectorStore vectorStore;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.ai.testcontainers.service.connection.chroma;
17+
18+
import org.testcontainers.utility.DockerImageName;
19+
20+
/**
21+
* @author Thomas Vitale
22+
*/
23+
public class ChromaImage {
24+
25+
public static final DockerImageName DEFAULT_IMAGE = DockerImageName.parse("ghcr.io/chroma-core/chroma:0.5.11");
26+
27+
}

spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/chroma/ChromaWithToken2ContainerConnectionDetailsFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ChromaWithToken2ContainerConnectionDetailsFactoryTest {
4646

4747
@Container
4848
@ServiceConnection
49-
static ChromaDBContainer chroma = new ChromaDBContainer("ghcr.io/chroma-core/chroma:0.4.24")
49+
static ChromaDBContainer chroma = new ChromaDBContainer(ChromaImage.DEFAULT_IMAGE)
5050
.withEnv("CHROMA_SERVER_AUTH_CREDENTIALS", "token")
5151
.withEnv("CHROMA_SERVER_AUTH_CREDENTIALS_PROVIDER",
5252
"chromadb.auth.token.TokenConfigServerAuthCredentialsProvider")

spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/chroma/ChromaWithTokenContainerConnectionDetailsFactoryTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ChromaWithTokenContainerConnectionDetailsFactoryTest {
4646

4747
@Container
4848
@ServiceConnection
49-
static ChromaDBContainer chroma = new ChromaDBContainer("ghcr.io/chroma-core/chroma:0.5.0")
49+
static ChromaDBContainer chroma = new ChromaDBContainer(ChromaImage.DEFAULT_IMAGE)
5050
.withEnv("CHROMA_SERVER_AUTHN_CREDENTIALS", "token")
5151
.withEnv("CHROMA_SERVER_AUTHN_PROVIDER", "chromadb.auth.token_authn.TokenAuthenticationServerProvider");
5252

spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/milvus/MilvusContainerConnectionDetailsFactoryTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
import org.springframework.ai.vectorstore.SearchRequest;
2525
import org.springframework.ai.vectorstore.VectorStore;
2626
import org.springframework.beans.factory.annotation.Autowired;
27-
import org.springframework.boot.autoconfigure.AutoConfigurations;
2827
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
29-
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
3028
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
3129
import org.springframework.context.annotation.Bean;
3230
import org.springframework.context.annotation.Configuration;
@@ -51,7 +49,7 @@ class MilvusContainerConnectionDetailsFactoryTest {
5149

5250
@Container
5351
@ServiceConnection
54-
static MilvusContainer milvusContainer = new MilvusContainer("milvusdb/milvus:v2.3.8");
52+
static MilvusContainer milvusContainer = new MilvusContainer(MilvusImage.DEFAULT_IMAGE);
5553

5654
List<Document> documents = List.of(
5755
new Document(ResourceUtils.getText("classpath:/test/data/spring.ai.txt"), Map.of("spring", "great")),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.ai.testcontainers.service.connection.milvus;
17+
18+
import org.testcontainers.utility.DockerImageName;
19+
20+
/**
21+
* @author Thomas Vitale
22+
*/
23+
public class MilvusImage {
24+
25+
public static final DockerImageName DEFAULT_IMAGE = DockerImageName.parse("milvusdb/milvus:v2.4.9");
26+
27+
}

spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/mongo/MongoDbAtlasLocalContainerConnectionDetailsFactoryTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ class MongoDbAtlasLocalContainerConnectionDetailsFactoryTest {
5252

5353
@Container
5454
@ServiceConnection
55-
private static MongoDBAtlasLocalContainer container = new MongoDBAtlasLocalContainer(
56-
"mongodb/mongodb-atlas-local:7.0.9");
55+
private static MongoDBAtlasLocalContainer container = new MongoDBAtlasLocalContainer(MongoDbImage.DEFAULT_IMAGE);
5756

5857
@Autowired
5958
private VectorStore vectorStore;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.ai.testcontainers.service.connection.mongo;
17+
18+
import org.testcontainers.utility.DockerImageName;
19+
20+
/**
21+
* @author Thomas Vitale
22+
*/
23+
public class MongoDbImage {
24+
25+
public static final DockerImageName DEFAULT_IMAGE = DockerImageName.parse("mongodb/mongodb-atlas-local:8.0.0");
26+
27+
}

spring-ai-spring-boot-testcontainers/src/test/java/org/springframework/ai/testcontainers/service/connection/ollama/OllamaContainerConnectionDetailsFactoryTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
/**
4343
* @author Eddú Meléndez
44+
* @author Thomas Vitale
4445
*/
4546
@SpringJUnitConfig
4647
@Disabled("requires more memory than is often available on dev machines")
@@ -55,7 +56,7 @@ class OllamaContainerConnectionDetailsFactoryTest {
5556

5657
@Container
5758
@ServiceConnection
58-
static OllamaContainer ollama = new OllamaContainer("ollama/ollama:0.3.9");
59+
static OllamaContainer ollama = new OllamaContainer(OllamaImage.DEFAULT_IMAGE);
5960

6061
@Autowired
6162
private OllamaEmbeddingModel embeddingModel;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.ai.testcontainers.service.connection.ollama;
17+
18+
import org.testcontainers.utility.DockerImageName;
19+
20+
/**
21+
* @author Thomas Vitale
22+
*/
23+
public class OllamaImage {
24+
25+
public static final DockerImageName DEFAULT_IMAGE = DockerImageName.parse("ollama/ollama:0.3.9");
26+
27+
}

0 commit comments

Comments
 (0)