This is an automated email from the ASF dual-hosted git repository.

wenjin272 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/flink-agents.git


The following commit(s) were added to refs/heads/main by this push:
     new 750ceee4 [ci][integrations] Enable Elasticsearch vector-store tests 
(#1011)
750ceee4 is described below

commit 750ceee4c3a06cfce37afd95a0063ea569c648d3
Author: kaiwangleo <[email protected]>
AuthorDate: Fri Aug 14 20:00:07 2026 +0800

    [ci][integrations] Enable Elasticsearch vector-store tests (#1011)
    
    Co-authored-by: Leo Wang <[email protected]>
---
 .github/workflows/ci.yml                           | 27 ++++++++++++++++++++++
 .../ElasticsearchVectorStoreTest.java              | 20 ++++++++++++----
 2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1bfdbae0..e5ee9a85 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -245,6 +245,33 @@ jobs:
           LOG_LEVEL: INFO
         run: tools/ut.sh -j -e -f ${{ matrix.flink-version }}
 
+  elasticsearch_tests:
+    name: Elasticsearch vector-store tests
+    runs-on: ubuntu-latest
+    timeout-minutes: 25
+    steps:
+      - uses: actions/checkout@v4
+      - name: Install Java
+        uses: actions/setup-java@v4
+        with:
+          java-version: '17'
+          distribution: 'temurin'
+      - name: Install flink-agents Java
+        run: bash tools/build.sh -j
+      - name: Start Elasticsearch
+        run: |
+          docker compose -f tools/docker/elasticsearch/docker-compose.yml down 
-v
+          docker compose -f tools/docker/elasticsearch/docker-compose.yml up -d
+          timeout 180 bash -c 'until curl -fsS 
http://localhost:9200/_cluster/health; do sleep 5; done'
+      - name: Run Elasticsearch tests
+        env:
+          ES_HOST: http://localhost:9200
+        run: |
+          mvn -B --no-transfer-progress -pl 
integrations/vector-stores/elasticsearch -am -Dspotless.skip=true 
-Drat.skip=true -Dtest=ElasticsearchVectorStoreTest 
-Dsurefire.failIfNoSpecifiedTests=false test
+      - name: Stop Elasticsearch
+        if: always()
+        run: docker compose -f tools/docker/elasticsearch/docker-compose.yml 
down -v
+
   cross_language_tests:
     name: cross-language [${{ matrix.os }}] [python-${{ 
matrix.python-version}}] [java-${{ matrix.java-version}}]
     runs-on: ${{ matrix.os }}
diff --git 
a/integrations/vector-stores/elasticsearch/src/test/java/org/apache/flink/agents/integrations/vectorstores/elasticsearch/ElasticsearchVectorStoreTest.java
 
b/integrations/vector-stores/elasticsearch/src/test/java/org/apache/flink/agents/integrations/vectorstores/elasticsearch/ElasticsearchVectorStoreTest.java
index 2b281483..9c04b0c1 100644
--- 
a/integrations/vector-stores/elasticsearch/src/test/java/org/apache/flink/agents/integrations/vectorstores/elasticsearch/ElasticsearchVectorStoreTest.java
+++ 
b/integrations/vector-stores/elasticsearch/src/test/java/org/apache/flink/agents/integrations/vectorstores/elasticsearch/ElasticsearchVectorStoreTest.java
@@ -27,10 +27,11 @@ import 
org.apache.flink.agents.api.vectorstores.BaseVectorStore;
 import 
org.apache.flink.agents.api.vectorstores.CollectionManageableVectorStore;
 import org.apache.flink.agents.api.vectorstores.Document;
 import org.apache.flink.agents.api.vectorstores.VectorStoreQuery;
+import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
 import org.mockito.Mockito;
 
 import java.util.ArrayList;
@@ -48,7 +49,7 @@ import java.util.Map;
  * <p>For {@link ElasticsearchVectorStore} doesn't support security check yet, 
when start the
  * container, should add "-e xpack.security.enabled=false" option.
  */
-@Disabled("Should setup Elasticsearch server.")
+@EnabledIfEnvironmentVariable(named = "ES_HOST", matches = ".+")
 public class ElasticsearchVectorStoreTest {
     public static BaseVectorStore store;
 
@@ -64,11 +65,12 @@ public class ElasticsearchVectorStoreTest {
     }
 
     @BeforeAll
-    public static void initialize() {
+    public static void initialize() throws Exception {
+        String esHost = System.getenv().getOrDefault("ES_HOST", 
"http://localhost:9200";);
         final ResourceDescriptor.Builder builder =
                 
ResourceDescriptor.Builder.newBuilder(ElasticsearchVectorStore.class.getName())
                         .addInitialArgument("embedding_model", 
"embeddingModel")
-                        .addInitialArgument("host", "localhost:9200")
+                        .addInitialArgument("host", esHost)
                         .addInitialArgument("dims", 5)
                         .addInitialArgument("username", "elastic")
                         .addInitialArgument("password", 
System.getenv("ES_PASSWORD"));
@@ -76,6 +78,14 @@ public class ElasticsearchVectorStoreTest {
                 new ElasticsearchVectorStore(
                         builder.build(),
                         
ResourceContext.fromGetResource(ElasticsearchVectorStoreTest::getResource));
+        store.open();
+    }
+
+    @AfterAll
+    public static void cleanup() throws Exception {
+        if (store != null) {
+            store.close();
+        }
     }
 
     @Test
@@ -121,6 +131,7 @@ public class ElasticsearchVectorStoreTest {
 
         // test get all documents
         List<Document> all = store.get(null, name, null, null, 
Collections.emptyMap());
+        all.forEach(document -> document.setScore(null));
         Assertions.assertEquals(documents, all);
 
         // test get specific document
@@ -138,6 +149,7 @@ public class ElasticsearchVectorStoreTest {
         store.delete(Collections.singletonList("doc1"), name, null, 
Collections.emptyMap());
         Thread.sleep(1000);
         List<Document> remain = store.get(null, name, null, null, 
Collections.emptyMap());
+        remain.forEach(document -> document.setScore(null));
         Assertions.assertEquals(1, remain.size());
         Assertions.assertEquals(documents.get(1), remain.get(0));
 

Reply via email to