This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push: new ea3c6a8eb44 CAMEL-22012 Add a test-infra for camel-weaviate (#17847) ea3c6a8eb44 is described below commit ea3c6a8eb443527be6c4c3a397e04f440b9c319e Author: Tom Cunningham <tcunn...@redhat.com> AuthorDate: Thu Apr 24 08:41:09 2025 -0400 CAMEL-22012 Add a test-infra for camel-weaviate (#17847) * CAMEL-22012 Add a test-infra for camel-weaviate * Add camel-test-infra-weaviate to test-infra pom.xml --- components/camel-ai/camel-weaviate/pom.xml | 9 ++ .../component/weaviate/WeaviateTestSupport.java | 40 ++++++ .../component/weaviate/it/WeaviateContainerIT.java | 152 +++++++++++++++++++++ test-infra/camel-test-infra-weaviate/pom.xml | 59 ++++++++ .../infra/weaviate/common/WeaviateProperties.java | 29 ++++ .../weaviate/services/WeaviateInfraService.java | 31 +++++ .../WeaviateLocalContainerInfraService.java | 112 +++++++++++++++ .../services/WeaviateRemoteInfraService.java | 52 +++++++ .../src/main/resources/META-INF/MANIFEST.MF | 0 .../infra/weaviate/services/container.properties | 17 +++ .../infra/weaviate/services/WeaviateService.java | 26 ++++ .../weaviate/services/WeaviateServiceFactory.java | 71 ++++++++++ test-infra/pom.xml | 1 + 13 files changed, 599 insertions(+) diff --git a/components/camel-ai/camel-weaviate/pom.xml b/components/camel-ai/camel-weaviate/pom.xml index ed145e4e1f4..509706091a7 100644 --- a/components/camel-ai/camel-weaviate/pom.xml +++ b/components/camel-ai/camel-weaviate/pom.xml @@ -60,6 +60,15 @@ <version>${weaviate-client-version}</version> </dependency> + <!-- test infra --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-infra-weaviate</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <!-- test dependencies --> <dependency> <groupId>org.apache.camel</groupId> diff --git a/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateTestSupport.java b/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateTestSupport.java new file mode 100644 index 00000000000..a9fefd01c29 --- /dev/null +++ b/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/WeaviateTestSupport.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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 org.apache.camel.component.weaviate; + +import org.apache.camel.CamelContext; +import org.apache.camel.test.infra.weaviate.services.WeaviateService; +import org.apache.camel.test.infra.weaviate.services.WeaviateServiceFactory; +import org.apache.camel.test.junit5.CamelTestSupport; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.extension.RegisterExtension; + +@TestInstance(TestInstance.Lifecycle.PER_CLASS) +public class WeaviateTestSupport extends CamelTestSupport { + @RegisterExtension + static WeaviateService WEAVIATE = WeaviateServiceFactory.createSingletonService(); + + @Override + protected CamelContext createCamelContext() throws Exception { + CamelContext context = super.createCamelContext(); + + WeaviateVectorDbComponent component = context.getComponent("weaviate", WeaviateVectorDbComponent.class); + component.getConfiguration().setHost(WEAVIATE.getWeaviateHost() + ":" + WEAVIATE.getWeaviatePort()); + + return context; + } +} diff --git a/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/it/WeaviateContainerIT.java b/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/it/WeaviateContainerIT.java new file mode 100644 index 00000000000..500031e078a --- /dev/null +++ b/components/camel-ai/camel-weaviate/src/test/java/org/apache/camel/component/weaviate/it/WeaviateContainerIT.java @@ -0,0 +1,152 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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 org.apache.camel.component.weaviate.it; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import io.weaviate.client.base.Result; +import io.weaviate.client.v1.data.model.WeaviateObject; +import org.apache.camel.Exchange; +import org.apache.camel.component.weaviate.WeaviateTestSupport; +import org.apache.camel.component.weaviate.WeaviateVectorDb; +import org.apache.camel.component.weaviate.WeaviateVectorDbAction; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.condition.DisabledIfSystemProperties; +import org.junit.jupiter.api.condition.DisabledIfSystemProperty; + +import static org.assertj.core.api.Assertions.assertThat; + +// This Integration test is meant to be run over the local container set up +// by camel-test-infra-weaviate - if we want to run the integration tests against +// a weaviate server, we should not run it. If weaviate.apikey is specified, +// skip this IT +@DisabledIfSystemProperties({ + @DisabledIfSystemProperty(named = "weaviate.apikey", matches = ".*", disabledReason = "weaviate API Key provided"), +}) +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public class WeaviateContainerIT extends WeaviateTestSupport { + private static final String COLLECTION = "WeaviateComponentITCollection"; + private static String CREATEID = null; + + @Test + @Order(1) + public void createCollection() { + + Exchange result = fluentTemplate + .to("weaviate:test-collection") + .withHeader(WeaviateVectorDb.Headers.ACTION, WeaviateVectorDbAction.CREATE_COLLECTION) + .withHeader(WeaviateVectorDb.Headers.COLLECTION_NAME, COLLECTION) + .request(Exchange.class); + + assertThat(result).isNotNull(); + Result<Boolean> res = (Result<Boolean>) result.getIn().getBody(); + assertThat(!res.hasErrors()); + assertThat(res.getResult() == true); + assertThat(result.getException()).isNull(); + } + + @Test + @Order(2) + public void create() { + + List<Float> elements = Arrays.asList(1.0f, 2.0f, 3.0f); + + HashMap<String, String> map = new HashMap<String, String>(); + map.put("sky", "blue"); + map.put("age", "34"); + + Exchange result = fluentTemplate + .to("weaviate:test-collection") + .withHeader(WeaviateVectorDb.Headers.ACTION, WeaviateVectorDbAction.CREATE) + .withBody(elements) + .withHeader(WeaviateVectorDb.Headers.COLLECTION_NAME, COLLECTION) + .withHeader(WeaviateVectorDb.Headers.PROPERTIES, map) + .request(Exchange.class); + + assertThat(result).isNotNull(); + + Result<WeaviateObject> res = (Result<WeaviateObject>) result.getIn().getBody(); + CREATEID = res.getResult().getId(); + + assertThat(!res.hasErrors()); + assertThat(res != null); + } + + @Test + @Order(8) + public void queryByVector() { + + List<Float> elements = Arrays.asList(1.0f, 2.0f, 3.2f); + + HashMap<String, String> map = new HashMap<String, String>(); + map.put("sky", "blue"); + + Exchange result = fluentTemplate + .to("weaviate:test-collection") + .withHeader(WeaviateVectorDb.Headers.ACTION, WeaviateVectorDbAction.QUERY) + .withBody( + elements) + .withHeader(WeaviateVectorDb.Headers.COLLECTION_NAME, COLLECTION) + .withHeader(WeaviateVectorDb.Headers.QUERY_TOP_K, 20) + .withHeader(WeaviateVectorDb.Headers.FIELDS, map) + .request(Exchange.class); + + assertThat(result).isNotNull(); + List<Float> vector = (List<Float>) result.getIn().getBody(); + assertThat(vector.get(0) == 1.0f); + assertThat(vector.get(1) == 2.0f); + assertThat(vector.get(2) == 3.0f); + } + + @Test + @Order(9) + public void deleteById() { + + Exchange result = fluentTemplate + .to("weaviate:test-collection") + .withHeader(WeaviateVectorDb.Headers.ACTION, WeaviateVectorDbAction.DELETE_BY_ID) + .withHeader(WeaviateVectorDb.Headers.COLLECTION_NAME, COLLECTION) + .withHeader(WeaviateVectorDb.Headers.INDEX_ID, CREATEID) + .request(Exchange.class); + + assertThat(result).isNotNull(); + Result<Boolean> res = (Result<Boolean>) result.getIn().getBody(); + + assertThat(!res.hasErrors()); + assertThat(res.getResult() == true); + assertThat(result.getException()).isNull(); + } + + @Test + @Order(10) + public void deleteCollection() { + Exchange result = fluentTemplate + .to("weaviate:test-collection") + .withHeader(WeaviateVectorDb.Headers.ACTION, WeaviateVectorDbAction.DELETE_COLLECTION) + .withHeader(WeaviateVectorDb.Headers.COLLECTION_NAME, COLLECTION) + .request(Exchange.class); + + assertThat(result).isNotNull(); + Result<Boolean> res = (Result<Boolean>) result.getIn().getBody(); + assertThat(!res.hasErrors()); + assertThat(res.getResult() == true); + assertThat(result.getException()).isNull(); + } + +} diff --git a/test-infra/camel-test-infra-weaviate/pom.xml b/test-infra/camel-test-infra-weaviate/pom.xml new file mode 100644 index 00000000000..43d5ef37757 --- /dev/null +++ b/test-infra/camel-test-infra-weaviate/pom.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You 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 + + http://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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>camel-test-infra-parent</artifactId> + <groupId>org.apache.camel</groupId> + <relativePath>../camel-test-infra-parent/pom.xml</relativePath> + <version>4.12.0-SNAPSHOT</version> + </parent> + + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-test-infra-weaviate</artifactId> + <name>Camel :: Test Infra :: Weaviate</name> + + <properties> + <assembly.skipAssembly>false</assembly.skipAssembly> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-infra-common</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + </dependency> + + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>testcontainers</artifactId> + <version>${testcontainers-version}</version> + </dependency> + + <dependency> + <groupId>org.testcontainers</groupId> + <artifactId>weaviate</artifactId> + <version>${testcontainers-version}</version> + </dependency> + </dependencies> + + +</project> diff --git a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/common/WeaviateProperties.java b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/common/WeaviateProperties.java new file mode 100644 index 00000000000..8e7e81c2374 --- /dev/null +++ b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/common/WeaviateProperties.java @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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 org.apache.camel.test.infra.weaviate.common; + +public final class WeaviateProperties { + public static final String WEAVIATE_ENDPOINT_URL = "weaviate.endpoint.url"; + public static final String WEAVIATE_ENDPOINT_HOST = "weaviate.endpoint.host"; + public static final String WEAVIATE_ENDPOINT_PORT = "weaviate.endpoint.port"; + public static final String WEAVIATE_CONTAINER = "weaviate.container"; + + private WeaviateProperties() { + + } +} diff --git a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateInfraService.java b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateInfraService.java new file mode 100644 index 00000000000..c7ab38adf5e --- /dev/null +++ b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateInfraService.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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 org.apache.camel.test.infra.weaviate.services; + +import org.apache.camel.test.infra.common.services.InfrastructureService; + +/** + * Test infra service for Weaviate + */ +public interface WeaviateInfraService extends InfrastructureService { + + String getWeaviateEndpointUrl(); + + String getWeaviateHost(); + + int getWeaviatePort(); +} diff --git a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateLocalContainerInfraService.java b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateLocalContainerInfraService.java new file mode 100644 index 00000000000..8ba7b46515f --- /dev/null +++ b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateLocalContainerInfraService.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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 org.apache.camel.test.infra.weaviate.services; + +import java.net.MalformedURLException; +import java.net.URL; +import java.time.Duration; + +import org.apache.camel.spi.annotations.InfraService; +import org.apache.camel.test.infra.common.LocalPropertyResolver; +import org.apache.camel.test.infra.common.services.ContainerService; +import org.apache.camel.test.infra.weaviate.common.WeaviateProperties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testcontainers.utility.DockerImageName; +import org.testcontainers.weaviate.WeaviateContainer; + +@InfraService(service = WeaviateInfraService.class, + description = "Weaviate Vector Database", + serviceAlias = { "weaviate" }) +public class WeaviateLocalContainerInfraService implements WeaviateInfraService, ContainerService<WeaviateContainer> { + + private static final Logger LOG = LoggerFactory.getLogger(WeaviateLocalContainerInfraService.class); + + private final WeaviateContainer container; + + public WeaviateLocalContainerInfraService() { + this(LocalPropertyResolver.getProperty(WeaviateLocalContainerInfraService.class, + WeaviateProperties.WEAVIATE_CONTAINER)); + } + + public WeaviateLocalContainerInfraService(String imageName) { + container = initContainer(imageName); + } + + public WeaviateLocalContainerInfraService(WeaviateContainer container) { + this.container = container; + } + + protected WeaviateContainer initContainer(String imageName) { + return new WeaviateContainer(DockerImageName.parse(imageName).asCompatibleSubstituteFor("semitechnologies/weaviate")) + .withStartupTimeout(Duration.ofMinutes(3L)); + } + + @Override + public void registerProperties() { + System.setProperty(WeaviateProperties.WEAVIATE_ENDPOINT_URL, getWeaviateEndpointUrl()); + System.setProperty(WeaviateProperties.WEAVIATE_ENDPOINT_HOST, getWeaviateHost()); + System.setProperty(WeaviateProperties.WEAVIATE_ENDPOINT_PORT, String.valueOf(getWeaviatePort())); + } + + @Override + public void initialize() { + LOG.info("Trying to start the Weaviate container"); + container.start(); + + registerProperties(); + LOG.info("Weaviate instance running at {}", getWeaviateEndpointUrl()); + } + + @Override + public void shutdown() { + LOG.info("Stopping the Weaviate container"); + container.stop(); + } + + @Override + public WeaviateContainer getContainer() { + return container; + } + + @Override + public String getWeaviateEndpointUrl() { + return container.getHttpHostAddress(); + } + + @Override + public String getWeaviateHost() { + URL url = null; + try { + url = new URL("http://" + container.getHttpHostAddress()); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + return url.getHost(); + } + + @Override + public int getWeaviatePort() { + URL url = null; + try { + url = new URL("http://" + container.getHttpHostAddress()); + } catch (MalformedURLException e) { + throw new RuntimeException(e); + } + return url.getPort(); + } +} diff --git a/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateRemoteInfraService.java b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateRemoteInfraService.java new file mode 100644 index 00000000000..8a7a8157e6f --- /dev/null +++ b/test-infra/camel-test-infra-weaviate/src/main/java/org/apache/camel/test/infra/weaviate/services/WeaviateRemoteInfraService.java @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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 org.apache.camel.test.infra.weaviate.services; + +import org.apache.camel.test.infra.weaviate.common.WeaviateProperties; + +public class WeaviateRemoteInfraService implements WeaviateInfraService { + + @Override + public void registerProperties() { + // NO-OP + } + + @Override + public void initialize() { + registerProperties(); + } + + @Override + public void shutdown() { + // NO-OP + } + + @Override + public String getWeaviateEndpointUrl() { + return System.getProperty(WeaviateProperties.WEAVIATE_ENDPOINT_URL); + } + + @Override + public String getWeaviateHost() { + return System.getProperty(WeaviateProperties.WEAVIATE_ENDPOINT_HOST); + } + + @Override + public int getWeaviatePort() { + return Integer.parseInt(System.getProperty(WeaviateProperties.WEAVIATE_ENDPOINT_PORT)); + } +} diff --git a/test-infra/camel-test-infra-weaviate/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-weaviate/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test-infra/camel-test-infra-weaviate/src/main/resources/org/apache/camel/test/infra/weaviate/services/container.properties b/test-infra/camel-test-infra-weaviate/src/main/resources/org/apache/camel/test/infra/weaviate/services/container.properties new file mode 100644 index 00000000000..02600e13bc0 --- /dev/null +++ b/test-infra/camel-test-infra-weaviate/src/main/resources/org/apache/camel/test/infra/weaviate/services/container.properties @@ -0,0 +1,17 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You 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 +## +## http://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. +## --------------------------------------------------------------------------- +weaviate.container=cr.weaviate.io/semitechnologies/weaviate:1.25.5 diff --git a/test-infra/camel-test-infra-weaviate/src/test/java/org/apache/camel/test/infra/weaviate/services/WeaviateService.java b/test-infra/camel-test-infra-weaviate/src/test/java/org/apache/camel/test/infra/weaviate/services/WeaviateService.java new file mode 100644 index 00000000000..02155fc60cb --- /dev/null +++ b/test-infra/camel-test-infra-weaviate/src/test/java/org/apache/camel/test/infra/weaviate/services/WeaviateService.java @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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 org.apache.camel.test.infra.weaviate.services; + +import org.apache.camel.test.infra.common.services.ContainerTestService; +import org.apache.camel.test.infra.common.services.TestService; + +/** + * Test infra service for Weaviate + */ +public interface WeaviateService extends TestService, WeaviateInfraService, ContainerTestService { +} diff --git a/test-infra/camel-test-infra-weaviate/src/test/java/org/apache/camel/test/infra/weaviate/services/WeaviateServiceFactory.java b/test-infra/camel-test-infra-weaviate/src/test/java/org/apache/camel/test/infra/weaviate/services/WeaviateServiceFactory.java new file mode 100644 index 00000000000..fcc6e8b376c --- /dev/null +++ b/test-infra/camel-test-infra-weaviate/src/test/java/org/apache/camel/test/infra/weaviate/services/WeaviateServiceFactory.java @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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 + * + * http://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 org.apache.camel.test.infra.weaviate.services; + +import org.apache.camel.test.infra.common.services.SimpleTestServiceBuilder; +import org.apache.camel.test.infra.common.services.SingletonService; + +public final class WeaviateServiceFactory { + private WeaviateServiceFactory() { + + } + + public static class SingletonWeaviateService extends SingletonService<WeaviateService> implements WeaviateService { + + public SingletonWeaviateService(WeaviateService service, String name) { + super(service, name); + } + + @Override + public String getWeaviateEndpointUrl() { + return getService().getWeaviateEndpointUrl(); + } + + @Override + public String getWeaviateHost() { + return getService().getWeaviateHost(); + } + + @Override + public int getWeaviatePort() { + return getService().getWeaviatePort(); + } + } + + public static SimpleTestServiceBuilder<WeaviateService> builder() { + return new SimpleTestServiceBuilder<>("weaviate"); + } + + public static WeaviateService createService() { + return builder() + .addLocalMapping(WeaviateLocalContainerService::new) + .addRemoteMapping(WeaviateRemoteService::new) + .build(); + } + + public static WeaviateService createSingletonService() { + return builder() + .addLocalMapping(() -> new SingletonWeaviateService(new WeaviateLocalContainerService(), "weaviate")) + .build(); + } + + public static class WeaviateLocalContainerService extends WeaviateLocalContainerInfraService implements WeaviateService { + } + + public static class WeaviateRemoteService extends WeaviateRemoteInfraService implements WeaviateService { + } +} diff --git a/test-infra/pom.xml b/test-infra/pom.xml index 0cbf3308f30..d62315a9e97 100644 --- a/test-infra/pom.xml +++ b/test-infra/pom.xml @@ -90,6 +90,7 @@ <module>camel-test-infra-tensorflow-serving</module> <module>camel-test-infra-triton</module> <module>camel-test-infra-neo4j</module> + <module>camel-test-infra-weaviate</module> <module>camel-test-infra-all</module> </modules>