You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@unomi.apache.org by jk...@apache.org on 2022/07/27 20:23:05 UTC

[unomi] branch migrationTests updated: UNOMI-632: migrate remaining indices that need a reindexation by generify the segment migration script to handle others indices in the same scenario

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

jkevan pushed a commit to branch migrationTests
in repository https://gitbox.apache.org/repos/asf/unomi.git


The following commit(s) were added to refs/heads/migrationTests by this push:
     new 8f3f15494 UNOMI-632: migrate remaining indices that need a reindexation by generify the segment migration script to handle others indices in the same scenario
8f3f15494 is described below

commit 8f3f15494f8d54215ce077dc247993fbdcda5cb3
Author: Kevan <ke...@jahia.com>
AuthorDate: Wed Jul 27 22:22:52 2022 +0200

    UNOMI-632: migrate remaining indices that need a reindexation by generify the segment migration script to handle others indices in the same scenario
---
 .../test/java/org/apache/unomi/itests/AllITs.java  | 33 +---------------------
 .../test/java/org/apache/unomi/itests/BaseIT.java  |  4 +++
 .../unomi/itests/migration/Migrate16xTo200IT.java  |  6 +++-
 ...roovy => migrate-2.0.0-01-globalReindex.groovy} | 11 ++++++--
 .../migrate-2.0.0-01-segmentReindex.groovy         | 26 -----------------
 5 files changed, 18 insertions(+), 62 deletions(-)

diff --git a/itests/src/test/java/org/apache/unomi/itests/AllITs.java b/itests/src/test/java/org/apache/unomi/itests/AllITs.java
index 1db16621a..481c21e68 100644
--- a/itests/src/test/java/org/apache/unomi/itests/AllITs.java
+++ b/itests/src/test/java/org/apache/unomi/itests/AllITs.java
@@ -31,38 +31,7 @@ import org.junit.runners.Suite.SuiteClasses;
 @RunWith(Suite.class)
 @SuiteClasses({
         Migrate16xTo200IT.class,
-        BasicIT.class,
-        ConditionEvaluatorIT.class,
-        ConditionESQueryBuilderIT.class,
-        SegmentIT.class,
-        ProfileServiceIT.class,
-        ProfileImportBasicIT.class,
-        ProfileImportSurfersIT.class,
-        ProfileImportRankingIT.class,
-        ProfileImportActorsIT.class,
-        ProfileExportIT.class,
-        ProfileMergeIT.class,
-        EventServiceIT.class,
-        PropertiesUpdateActionIT.class,
-        CopyPropertiesActionIT.class,
-        IncrementPropertyIT.class,
-        InputValidationIT.class,
-        ModifyConsentIT.class,
-        PatchIT.class,
-        ContextServletIT.class,
-        SecurityIT.class,
-        RuleServiceIT.class,
-        PrivacyServiceIT.class,
-        GroovyActionsServiceIT.class,
-        GraphQLEventIT.class,
-        GraphQLListIT.class,
-        GraphQLProfileIT.class,
-        GraphQLProfilePropertiesIT.class,
-        GraphQLSegmentIT.class,
-        GraphQLWebSocketIT.class,
-        JSONSchemaIT.class,
-        GraphQLProfileAliasesIT.class,
-        SendEventActionIT.class
+        BasicIT.class
 })
 public class AllITs {
 }
diff --git a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
index 799334e41..dc103951d 100644
--- a/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/BaseIT.java
@@ -163,6 +163,10 @@ public abstract class BaseIT extends KarafTestSupport {
 
     @Before
     public void waitForStartup() throws InterruptedException {
+        // disable retry
+        retry = new KarafTestSupport.Retry(false);
+
+        // Start Unomi if not already done
         if (!unomiStarted) {
             executeCommand("unomi:start");
             unomiStarted = true;
diff --git a/itests/src/test/java/org/apache/unomi/itests/migration/Migrate16xTo200IT.java b/itests/src/test/java/org/apache/unomi/itests/migration/Migrate16xTo200IT.java
index 12adf1438..1372ba2d7 100644
--- a/itests/src/test/java/org/apache/unomi/itests/migration/Migrate16xTo200IT.java
+++ b/itests/src/test/java/org/apache/unomi/itests/migration/Migrate16xTo200IT.java
@@ -84,11 +84,15 @@ public class Migrate16xTo200IT extends BaseIT {
         Assert.assertTrue(HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/context-scope/_mapping", null).contains("\"match\":\"*\",\"match_mapping_type\":\"string\",\"mapping\":{\"analyzer\":\"folding\""));
         Assert.assertTrue(HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/context-segment/_mapping", null).contains("\"condition\":{\"type\":\"object\",\"enabled\":false}"));
         Assert.assertTrue(HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/context-scoring/_mapping", null).contains("\"condition\":{\"type\":\"object\",\"enabled\":false}"));
+        Assert.assertTrue(HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/context-campaign/_mapping", null).contains("\"entryCondition\":{\"type\":\"object\",\"enabled\":false}"));
+        Assert.assertTrue(HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/context-conditiontype/_mapping", null).contains("\"parentCondition\":{\"type\":\"object\",\"enabled\":false}"));
+        Assert.assertTrue(HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/context-goal/_mapping", null).contains("\"startEvent\":{\"type\":\"object\",\"enabled\":false}"));
+        Assert.assertTrue(HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/context-patch/_mapping", null).contains("\"data\":{\"type\":\"object\",\"enabled\":false}"));
+        Assert.assertTrue(HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/context-rule/_mapping", null).contains("\"condition\":{\"type\":\"object\",\"enabled\":false}"));
         Assert.assertTrue(HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/context-profile/_mapping", null).contains("\"interests\":{\"type\":\"nested\""));
         for (String eventIndex : MigrationUtils.getIndexesPrefixedBy(httpClient, "http://localhost:9400", "context-event-")) {
             Assert.assertTrue(HttpUtils.executeGetRequest(httpClient, "http://localhost:9400/" + eventIndex + "/_mapping", null).contains("\"flattenedProperties\":{\"type\":\"flattened\"}"));
         }
-        // TODO check for campaign, conditionType, goal, patch, rule
     }
 
     /**
diff --git a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-02-scoringPlanReindex.groovy b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-01-globalReindex.groovy
similarity index 64%
rename from tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-02-scoringPlanReindex.groovy
rename to tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-01-globalReindex.groovy
index b475fde56..24603d75e 100644
--- a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-02-scoringPlanReindex.groovy
+++ b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-01-globalReindex.groovy
@@ -21,6 +21,11 @@ String esAddress = migrationConfig.getString("esAddress", session)
 String indexPrefix = migrationConfig.getString("indexPrefix", session)
 
 String baseSettings = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.0.0/base_index_mapping.json")
-String mapping = MigrationUtils.extractMappingFromBundles(bundleContext, "scoring.json")
-String newIndexSettings = MigrationUtils.buildIndexCreationRequest(httpClient, esAddress, baseSettings, indexPrefix + "-scoring", mapping)
-MigrationUtils.reIndex(httpClient, bundleContext, esAddress, indexPrefix + "-scoring", newIndexSettings, null)
+String[] indicesToReindex = ["segment", "scoring", "campaign", "conditionType", "goal", "patch", "rule"];
+indicesToReindex.each { indexToReindex ->
+    String mappingFileName = "${indexToReindex}.json"
+    String realIndexName = "${indexPrefix}-${indexToReindex.toLowerCase()}"
+    String mapping = MigrationUtils.extractMappingFromBundles(bundleContext, mappingFileName)
+    String newIndexSettings = MigrationUtils.buildIndexCreationRequest(httpClient, esAddress, baseSettings, realIndexName, mapping)
+    MigrationUtils.reIndex(httpClient, bundleContext, esAddress, realIndexName, newIndexSettings, null)
+}
diff --git a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-01-segmentReindex.groovy b/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-01-segmentReindex.groovy
deleted file mode 100644
index 0cfdbc8e8..000000000
--- a/tools/shell-commands/src/main/resources/META-INF/cxs/migration/migrate-2.0.0-01-segmentReindex.groovy
+++ /dev/null
@@ -1,26 +0,0 @@
-import org.apache.unomi.shell.migration.utils.MigrationUtils
-
-/*
- * 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.
- */
-
-String esAddress = migrationConfig.getString("esAddress", session)
-String indexPrefix = migrationConfig.getString("indexPrefix", session)
-
-String baseSettings = MigrationUtils.resourceAsString(bundleContext, "requestBody/2.0.0/base_index_mapping.json")
-String mapping = MigrationUtils.extractMappingFromBundles(bundleContext, "segment.json")
-String newIndexSettings = MigrationUtils.buildIndexCreationRequest(httpClient, esAddress, baseSettings, indexPrefix + "-segment", mapping)
-MigrationUtils.reIndex(httpClient, bundleContext, esAddress, indexPrefix + "-segment", newIndexSettings, null)