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

dgriffon pushed a commit to branch check-fix-on-logs
in repository https://gitbox.apache.org/repos/asf/unomi.git

commit 152c4a333e304cd076f7a46254c2fd161d67f90b
Author: david.griffon <[email protected]>
AuthorDate: Mon Dec 11 09:22:47 2023 +0100

    UNOMI-810 : migration - add refresh after ES request
---
 .github/workflows/unomi-ci-build-tests.yml                   |  7 +++++--
 .../org/apache/unomi/shell/migration/utils/HttpUtils.java    | 12 +++++++++++-
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/.github/workflows/unomi-ci-build-tests.yml 
b/.github/workflows/unomi-ci-build-tests.yml
index 4ee27ca0e..80b97ef68 100644
--- a/.github/workflows/unomi-ci-build-tests.yml
+++ b/.github/workflows/unomi-ci-build-tests.yml
@@ -42,7 +42,7 @@ jobs:
           java-version: ${{ matrix.java }}
           cache: maven
       - name: Integration tests
-        run: mvn -ntp clean install -Pintegration-tests
+        run: mvn -ntp clean install -Pintegration-tests 
-Dit.test=org.apache.unomi.itests.migration.Migrate16xTo220IT
       - name: Archive code coverage logs
         uses: actions/upload-artifact@v3
         if: false # UNOMI-746 Reactivate if necessary
@@ -54,7 +54,10 @@ jobs:
         if: failure()
         with:
           name: unomi-log-jdk${{ matrix.java }}-${{ github.run_number }}
-          path: itests/target/exam/**/data/log
+          path: |
+            itests/target/exam/**/data/log
+            itests/target/elasticsearch0/data
+            itests/target/elasticsearch0/logs
       - name: Publish Test Report
         uses: mikepenz/action-junit-report@v3
         if: failure()
diff --git 
a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/utils/HttpUtils.java
 
b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/utils/HttpUtils.java
index ec7a8a6dc..517681f98 100644
--- 
a/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/utils/HttpUtils.java
+++ 
b/tools/shell-commands/src/main/java/org/apache/unomi/shell/migration/utils/HttpUtils.java
@@ -44,7 +44,6 @@ import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.security.cert.X509Certificate;
-import java.util.Arrays;
 import java.util.Map;
 
 /**
@@ -182,6 +181,17 @@ public class HttpUtils {
         String stringResponse = EntityUtils.toString(entity);
         EntityUtils.consumeQuietly(entity);
 
+        // Refresh ES after execution
+        String refrehUrl = httpRequestBase.getURI().getScheme() + "://" +  
httpRequestBase.getURI().getScheme() + ":" + httpRequestBase.getURI().getPort() 
+ "/_refresh";
+        HttpGet refresh = new HttpGet(refrehUrl);
+        refresh.addHeader("accept", "application/json");
+        CloseableHttpResponse refreshResponse = httpClient.execute(refresh);
+        final int refreshStatusCode = 
refreshResponse.getStatusLine().getStatusCode();
+        HttpEntity refreshEntity = refreshResponse.getEntity();
+        if (refreshStatusCode >= 400) {
+            throw new HttpRequestException("Couldn't execute " + refrehUrl + " 
response: " + ((refreshEntity != null) ? EntityUtils.toString(refreshEntity) : 
"n/a"), refreshStatusCode);
+        }
+
         return stringResponse;
     }
 }

Reply via email to