From ea77b92826a1a4b9687c97cb4fea3b369c0d3fa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Wed, 28 Feb 2024 12:05:13 -0600 Subject: [PATCH 01/10] Generate test application with pgvector when compose and spring-ai pgvector are selected --- .../SimpleDockerServiceResolver.java | 8 ++++ ...gVectorProjectGenerationConfiguration.java | 46 ++++++++++++++++++ .../main/resources/META-INF/spring.factories | 1 + ...orProjectGenerationConfigurationTests.java | 48 +++++++++++++++++++ .../src/test/resources/compose/pgvector.yaml | 9 ++++ 5 files changed, 112 insertions(+) create mode 100644 start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java create mode 100644 start-site/src/test/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfigurationTests.java create mode 100644 start-site/src/test/resources/compose/pgvector.yaml diff --git a/start-site/src/main/java/io/spring/start/site/container/SimpleDockerServiceResolver.java b/start-site/src/main/java/io/spring/start/site/container/SimpleDockerServiceResolver.java index bb5ec99a7c5..f9f757da829 100644 --- a/start-site/src/main/java/io/spring/start/site/container/SimpleDockerServiceResolver.java +++ b/start-site/src/main/java/io/spring/start/site/container/SimpleDockerServiceResolver.java @@ -42,6 +42,7 @@ public SimpleDockerServiceResolver() { this.dockerServices.put("mysql", mysql()); this.dockerServices.put("oracleFree", oracleFree()); this.dockerServices.put("oracleXe", oracleXe()); + this.dockerServices.put("pgvector", pgvector()); this.dockerServices.put("postgres", postgres()); this.dockerServices.put("pulsar", pulsar()); this.dockerServices.put("rabbit", rabbit()); @@ -105,6 +106,13 @@ private static DockerService oracleXe() { .build(); } + private static DockerService pgvector() { + return DockerService.withImageAndTag("pgvector/pgvector:pg16") + .website("https://hub.docker.com/r/pgvector/pgvector") + .ports(5432) + .build(); + } + private static DockerService postgres() { return DockerService.withImageAndTag("postgres") .website("https://hub.docker.com/_/postgres") diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java new file mode 100644 index 00000000000..fcc0f2deec2 --- /dev/null +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.spring.start.site.extension.dependency.postgresql; + +import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; +import io.spring.start.site.container.ComposeFileCustomizer; +import io.spring.start.site.container.DockerServiceResolver; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Configuration for generation of projects that depend on PgVector. + * + * @author Eddú Meléndez + */ +@Configuration(proxyBeanMethods = false) +@ConditionalOnRequestedDependency("spring-ai-vectordb-pgvector") +class PgVectorProjectGenerationConfiguration { + + @Bean + @ConditionalOnRequestedDependency("docker-compose") + ComposeFileCustomizer pgvectorComposeFileCustomizer(DockerServiceResolver serviceResolver) { + return (composeFile) -> serviceResolver.doWith("pgvector", + (service) -> composeFile.services() + .add("pgvector", + service.andThen((builder) -> builder.environment("POSTGRES_USER", "myuser") + .environment("POSTGRES_DB", "mydatabase") + .environment("POSTGRES_PASSWORD", "secret")))); + } + +} diff --git a/start-site/src/main/resources/META-INF/spring.factories b/start-site/src/main/resources/META-INF/spring.factories index 0a290ecb124..773cd6538a2 100644 --- a/start-site/src/main/resources/META-INF/spring.factories +++ b/start-site/src/main/resources/META-INF/spring.factories @@ -18,6 +18,7 @@ io.spring.start.site.extension.dependency.mysql.MysqlProjectGenerationConfigurat io.spring.start.site.extension.dependency.observability.ObservabilityProjectGenerationConfiguration,\ io.spring.start.site.extension.dependency.oracle.OracleProjectGenerationConfiguration,\ io.spring.start.site.extension.dependency.picocli.PicocliProjectGenerationConfiguration,\ +io.spring.start.site.extension.dependency.postgresql.PgVectorProjectGenerationConfiguration,\ io.spring.start.site.extension.dependency.postgresql.PostgresqlProjectGenerationConfiguration,\ io.spring.start.site.extension.dependency.redis.RedisProjectGenerationConfiguration,\ io.spring.start.site.extension.dependency.solace.SolaceProjectGenerationConfiguration,\ diff --git a/start-site/src/test/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfigurationTests.java b/start-site/src/test/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfigurationTests.java new file mode 100644 index 00000000000..24a596c62e5 --- /dev/null +++ b/start-site/src/test/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfigurationTests.java @@ -0,0 +1,48 @@ +/* + * Copyright 2012-2024 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.spring.start.site.extension.dependency.postgresql; + +import io.spring.initializr.generator.test.project.ProjectStructure; +import io.spring.initializr.web.project.ProjectRequest; +import io.spring.start.site.extension.AbstractExtensionTests; +import org.junit.jupiter.api.Test; + +import org.springframework.core.io.ClassPathResource; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link PgVectorProjectGenerationConfiguration}. + * + * @author Eddú Meléndez + */ +class PgVectorProjectGenerationConfigurationTests extends AbstractExtensionTests { + + @Test + void doesNothingWithoutDockerCompose() { + ProjectRequest request = createProjectRequest("web", "spring-ai-vectordb-pgvector"); + ProjectStructure structure = generateProject(request); + assertThat(structure.getProjectDirectory().resolve("compose.yaml")).doesNotExist(); + } + + @Test + void createsPostgresService() { + ProjectRequest request = createProjectRequest("docker-compose", "spring-ai-vectordb-pgvector"); + assertThat(composeFile(request)).hasSameContentAs(new ClassPathResource("compose/pgvector.yaml")); + } + +} diff --git a/start-site/src/test/resources/compose/pgvector.yaml b/start-site/src/test/resources/compose/pgvector.yaml new file mode 100644 index 00000000000..e57422abae1 --- /dev/null +++ b/start-site/src/test/resources/compose/pgvector.yaml @@ -0,0 +1,9 @@ +services: + pgvector: + image: 'pgvector/pgvector:pg16' + environment: + - 'POSTGRES_DB=mydatabase' + - 'POSTGRES_PASSWORD=secret' + - 'POSTGRES_USER=myuser' + ports: + - '5432' From 20f89e536d74257082b6cc83e3706a8e0ea1c0b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Wed, 28 Feb 2024 15:40:14 -0600 Subject: [PATCH 02/10] Support Testcontainers --- .../PgVectorProjectGenerationConfiguration.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java index fcc0f2deec2..417faacdf71 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java @@ -19,6 +19,8 @@ import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; import io.spring.start.site.container.ComposeFileCustomizer; import io.spring.start.site.container.DockerServiceResolver; +import io.spring.start.site.container.ServiceConnections; +import io.spring.start.site.container.ServiceConnectionsCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -32,6 +34,16 @@ @ConditionalOnRequestedDependency("spring-ai-vectordb-pgvector") class PgVectorProjectGenerationConfiguration { + private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.containers.PostgreSQLContainer"; + + @Bean + @ConditionalOnRequestedDependency("testcontainers") + ServiceConnectionsCustomizer postgresqlServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) { + return (serviceConnections) -> serviceResolver + .doWith("pgvector", (service) -> serviceConnections.addServiceConnection( + ServiceConnections.ServiceConnection.ofContainer("pgvector", service, TESTCONTAINERS_CLASS_NAME))); + } + @Bean @ConditionalOnRequestedDependency("docker-compose") ComposeFileCustomizer pgvectorComposeFileCustomizer(DockerServiceResolver serviceResolver) { From 652e4b65524f93a0722fe8a2dde85775e8627c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Wed, 28 Feb 2024 16:03:52 -0600 Subject: [PATCH 03/10] Rename bean --- .../postgresql/PgVectorProjectGenerationConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java index 417faacdf71..e23078fd71c 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java @@ -38,7 +38,7 @@ class PgVectorProjectGenerationConfiguration { @Bean @ConditionalOnRequestedDependency("testcontainers") - ServiceConnectionsCustomizer postgresqlServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) { + ServiceConnectionsCustomizer pgvectorServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) { return (serviceConnections) -> serviceResolver .doWith("pgvector", (service) -> serviceConnections.addServiceConnection( ServiceConnections.ServiceConnection.ofContainer("pgvector", service, TESTCONTAINERS_CLASS_NAME))); From bc1e96d6529aac543f755841af40328401256601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 29 Feb 2024 10:11:53 -0600 Subject: [PATCH 04/10] Add label to pgvector --- .../postgresql/PgVectorProjectGenerationConfiguration.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java index e23078fd71c..295066a2a85 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java @@ -52,7 +52,8 @@ ComposeFileCustomizer pgvectorComposeFileCustomizer(DockerServiceResolver servic .add("pgvector", service.andThen((builder) -> builder.environment("POSTGRES_USER", "myuser") .environment("POSTGRES_DB", "mydatabase") - .environment("POSTGRES_PASSWORD", "secret")))); + .environment("POSTGRES_PASSWORD", "secret") + .label("org.springframework.boot.service-connection", "postgres")))); } } From 68bc6d64b14b8e871de4fc62dc4bd0519859df96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 29 Feb 2024 10:13:12 -0600 Subject: [PATCH 05/10] Add conditional on platform for testcontainers --- .../PgVectorProjectGenerationConfiguration.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java index 295066a2a85..57d56d36dd1 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java @@ -16,10 +16,11 @@ package io.spring.start.site.extension.dependency.postgresql; +import io.spring.initializr.generator.condition.ConditionalOnPlatformVersion; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; import io.spring.start.site.container.ComposeFileCustomizer; import io.spring.start.site.container.DockerServiceResolver; -import io.spring.start.site.container.ServiceConnections; +import io.spring.start.site.container.ServiceConnections.ServiceConnection; import io.spring.start.site.container.ServiceConnectionsCustomizer; import org.springframework.context.annotation.Bean; @@ -37,11 +38,12 @@ class PgVectorProjectGenerationConfiguration { private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.containers.PostgreSQLContainer"; @Bean + @ConditionalOnPlatformVersion("3.3.0-M3") @ConditionalOnRequestedDependency("testcontainers") ServiceConnectionsCustomizer pgvectorServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) { return (serviceConnections) -> serviceResolver - .doWith("pgvector", (service) -> serviceConnections.addServiceConnection( - ServiceConnections.ServiceConnection.ofContainer("pgvector", service, TESTCONTAINERS_CLASS_NAME))); + .doWith("pgvector", (service) -> serviceConnections.addServiceConnection( + ServiceConnection.ofContainer("pgvector", service, TESTCONTAINERS_CLASS_NAME))); } @Bean From e6a04c3d6c16674552d195bc9cfab4cb15609b83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 29 Feb 2024 11:53:55 -0600 Subject: [PATCH 06/10] Match Testcontainers version --- ...gVectorProjectGenerationConfiguration.java | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java index 57d56d36dd1..e6553b34eaf 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java @@ -16,8 +16,12 @@ package io.spring.start.site.extension.dependency.postgresql; -import io.spring.initializr.generator.condition.ConditionalOnPlatformVersion; import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; +import io.spring.initializr.generator.project.ProjectDescription; +import io.spring.initializr.generator.version.Version; +import io.spring.initializr.generator.version.VersionParser; +import io.spring.initializr.generator.version.VersionRange; +import io.spring.initializr.versionresolver.MavenVersionResolver; import io.spring.start.site.container.ComposeFileCustomizer; import io.spring.start.site.container.DockerServiceResolver; import io.spring.start.site.container.ServiceConnections.ServiceConnection; @@ -26,6 +30,8 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import java.util.Map; + /** * Configuration for generation of projects that depend on PgVector. * @@ -37,13 +43,31 @@ class PgVectorProjectGenerationConfiguration { private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.containers.PostgreSQLContainer"; + private static final VersionRange TESTCONTAINERS_1_9_7_OR_LATER = VersionParser.DEFAULT.parseRange("1.19.7"); + + private final MavenVersionResolver versionResolver; + + private final ProjectDescription description; + + public PgVectorProjectGenerationConfiguration(MavenVersionResolver versionResolver, + ProjectDescription description) { + this.versionResolver = versionResolver; + this.description = description; + } + @Bean - @ConditionalOnPlatformVersion("3.3.0-M3") @ConditionalOnRequestedDependency("testcontainers") ServiceConnectionsCustomizer pgvectorServiceConnectionsCustomizer(DockerServiceResolver serviceResolver) { - return (serviceConnections) -> serviceResolver - .doWith("pgvector", (service) -> serviceConnections.addServiceConnection( + Map resolve = this.versionResolver.resolveDependencies("org.springframework.boot", + "spring-boot-dependencies", this.description.getPlatformVersion().toString()); + String testcontainersVersion = resolve.get("org.testcontainers:testcontainers"); + + return (serviceConnections) -> { + if (TESTCONTAINERS_1_9_7_OR_LATER.match(Version.parse(testcontainersVersion))) { + serviceResolver.doWith("pgvector", (service) -> serviceConnections.addServiceConnection( ServiceConnection.ofContainer("pgvector", service, TESTCONTAINERS_CLASS_NAME))); + } + }; } @Bean From 7f8a3eee816fa347398f300b3a2f6ad43c4c8547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 29 Feb 2024 12:00:43 -0600 Subject: [PATCH 07/10] Rename constant --- .../postgresql/PgVectorProjectGenerationConfiguration.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java index e6553b34eaf..f036527ccac 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java @@ -43,7 +43,7 @@ class PgVectorProjectGenerationConfiguration { private static final String TESTCONTAINERS_CLASS_NAME = "org.testcontainers.containers.PostgreSQLContainer"; - private static final VersionRange TESTCONTAINERS_1_9_7_OR_LATER = VersionParser.DEFAULT.parseRange("1.19.7"); + private static final VersionRange TESTCONTAINERS_1_19_7_OR_LATER = VersionParser.DEFAULT.parseRange("1.19.7"); private final MavenVersionResolver versionResolver; @@ -63,7 +63,7 @@ ServiceConnectionsCustomizer pgvectorServiceConnectionsCustomizer(DockerServiceR String testcontainersVersion = resolve.get("org.testcontainers:testcontainers"); return (serviceConnections) -> { - if (TESTCONTAINERS_1_9_7_OR_LATER.match(Version.parse(testcontainersVersion))) { + if (TESTCONTAINERS_1_19_7_OR_LATER.match(Version.parse(testcontainersVersion))) { serviceResolver.doWith("pgvector", (service) -> serviceConnections.addServiceConnection( ServiceConnection.ofContainer("pgvector", service, TESTCONTAINERS_CLASS_NAME))); } From 171c2bde0c4dab3e2268c85f04d1b7c42e1a5782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 29 Feb 2024 12:09:21 -0600 Subject: [PATCH 08/10] Fix checkstyle --- .../postgresql/PgVectorProjectGenerationConfiguration.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java index f036527ccac..765c130f5b5 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/postgresql/PgVectorProjectGenerationConfiguration.java @@ -16,6 +16,8 @@ package io.spring.start.site.extension.dependency.postgresql; +import java.util.Map; + import io.spring.initializr.generator.condition.ConditionalOnRequestedDependency; import io.spring.initializr.generator.project.ProjectDescription; import io.spring.initializr.generator.version.Version; @@ -30,8 +32,6 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import java.util.Map; - /** * Configuration for generation of projects that depend on PgVector. * @@ -49,8 +49,7 @@ class PgVectorProjectGenerationConfiguration { private final ProjectDescription description; - public PgVectorProjectGenerationConfiguration(MavenVersionResolver versionResolver, - ProjectDescription description) { + PgVectorProjectGenerationConfiguration(MavenVersionResolver versionResolver, ProjectDescription description) { this.versionResolver = versionResolver; this.description = description; } From 1a93d01b8ae10599ecc57f91568a15b70538b446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Thu, 29 Feb 2024 20:29:21 -0600 Subject: [PATCH 09/10] Fix compose file --- start-site/src/test/resources/compose/pgvector.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/start-site/src/test/resources/compose/pgvector.yaml b/start-site/src/test/resources/compose/pgvector.yaml index e57422abae1..36565c03d6c 100644 --- a/start-site/src/test/resources/compose/pgvector.yaml +++ b/start-site/src/test/resources/compose/pgvector.yaml @@ -5,5 +5,7 @@ services: - 'POSTGRES_DB=mydatabase' - 'POSTGRES_PASSWORD=secret' - 'POSTGRES_USER=myuser' + labels: + - "org.springframework.boot.service-connection=postgres" ports: - '5432' From 7dfda0fb26c51b108b31b0115c3c859bd584e8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edd=C3=BA=20Mel=C3=A9ndez?= Date: Wed, 20 Mar 2024 19:02:01 -0600 Subject: [PATCH 10/10] Add Testcontainers postgresql module when spring-ai-vectordb-pgvector is selected --- .../TestcontainersModuleRegistry.java | 2 +- ...inersProjectGenerationConfigurationTests.java | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersModuleRegistry.java b/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersModuleRegistry.java index fc15fc822b2..61ee1705d5d 100644 --- a/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersModuleRegistry.java +++ b/start-site/src/main/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersModuleRegistry.java @@ -88,7 +88,7 @@ static Iterable create(Version platformVersion) { builders.add(onDependencies("oracle").customizeBuild(addModule("oracle-xe")) .customizeHelpDocument(addReferenceLink("Oracle-XE Module", "databases/oraclexe/"))); } - builders.add(onDependencies("postgresql").customizeBuild(addModule("postgresql")) + builders.add(onDependencies("postgresql", "spring-ai-vectordb-pgvector").customizeBuild(addModule("postgresql")) .customizeHelpDocument(addReferenceLink("Postgres Module", "databases/postgres/"))); builders.add(onDependencies("pulsar", "pulsar-reactive").customizeBuild(addModule("pulsar")) .customizeHelpDocument(addReferenceLink("Pulsar Module", "pulsar/"))); diff --git a/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java b/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java index 815071fca46..42be1e38629 100644 --- a/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java +++ b/start-site/src/test/java/io/spring/start/site/extension/dependency/testcontainers/TestcontainersProjectGenerationConfigurationTests.java @@ -85,13 +85,15 @@ static Stream supportedEntriesBuild() { Arguments.arguments("data-couchbase-reactive", "couchbase"), Arguments.arguments("data-elasticsearch", "elasticsearch"), Arguments.arguments("data-mongodb", "mongodb"), Arguments.arguments("data-mongodb-reactive", "mongodb"), - Arguments.arguments("data-neo4j", "neo4j"), Arguments.arguments("spring-ai-vectordb-neo4j", "neo4j"), - Arguments.arguments("data-r2dbc", "r2dbc"), Arguments.arguments("db2", "db2"), - Arguments.arguments("kafka", "kafka"), Arguments.arguments("kafka-streams", "kafka"), - Arguments.arguments("mariadb", "mariadb"), Arguments.arguments("mysql", "mysql"), - Arguments.arguments("postgresql", "postgresql"), Arguments.arguments("oracle", "oracle-xe"), - Arguments.arguments("pulsar", "pulsar"), Arguments.arguments("pulsar-reactive", "pulsar"), - Arguments.arguments("solace", "solace"), Arguments.arguments("sqlserver", "mssqlserver")); + Arguments.arguments("data-neo4j", "neo4j"), Arguments.arguments("data-r2dbc", "r2dbc"), + Arguments.arguments("db2", "db2"), Arguments.arguments("kafka", "kafka"), + Arguments.arguments("kafka-streams", "kafka"), Arguments.arguments("mariadb", "mariadb"), + Arguments.arguments("mysql", "mysql"), Arguments.arguments("postgresql", "postgresql"), + Arguments.arguments("oracle", "oracle-xe"), Arguments.arguments("pulsar", "pulsar"), + Arguments.arguments("pulsar-reactive", "pulsar"), Arguments.arguments("solace", "solace"), + Arguments.arguments("spring-ai-vectordb-neo4j", "neo4j"), + Arguments.arguments("spring-ai-vectordb-pgvector", "postgresql"), + Arguments.arguments("sqlserver", "mssqlserver")); } static Stream supportedTestcontainersActiveMQEntriesBuild() {