From 6b1b5340e309b92a3e84cdfadcf4d6bd210a92b9 Mon Sep 17 00:00:00 2001 From: cezary-witkowski Date: Fri, 13 Dec 2024 12:52:35 +0100 Subject: [PATCH] [ACS-9069] Minor tweaks --- .../ElasticsearchInitialReindexingTests.java | 2 +- .../ElasticsearchReindexingTests.java | 22 ++++++++++++++----- .../tas/AlfrescoStackInitializer.java | 4 ++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsearch/initialReindex/ElasticsearchInitialReindexingTests.java b/tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsearch/initialReindex/ElasticsearchInitialReindexingTests.java index 435ad8a50c..f7ea0fb49d 100644 --- a/tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsearch/initialReindex/ElasticsearchInitialReindexingTests.java +++ b/tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsearch/initialReindex/ElasticsearchInitialReindexingTests.java @@ -1,7 +1,7 @@ package org.alfresco.elasticsearch.initialReindex; import static org.alfresco.elasticsearch.SearchQueryService.req; -import static org.alfresco.tas.AlfrescoStackInitializer.*; +import static org.alfresco.tas.AlfrescoStackInitializer.reindex; import static org.alfresco.utility.model.FileType.TEXT_PLAIN; import java.util.Map; diff --git a/tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsearch/reindexing/ElasticsearchReindexingTests.java b/tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsearch/reindexing/ElasticsearchReindexingTests.java index 6981c2f190..0e16d2efae 100644 --- a/tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsearch/reindexing/ElasticsearchReindexingTests.java +++ b/tests/tas-elasticsearch/src/test/java/org/alfresco/elasticsearch/reindexing/ElasticsearchReindexingTests.java @@ -45,7 +45,7 @@ */ @ContextConfiguration(locations = "classpath:alfresco-elasticsearch-context.xml", initializers = AlfrescoStackInitializer.class) -@SuppressWarnings("PMD.JUnit4TestShouldUseTestAnnotation") // these are testng tests +@SuppressWarnings({"PMD.JUnit4TestShouldUseTestAnnotation", "PMD.JUnitTestsShouldIncludeAssert"}) // these are testng tests public class ElasticsearchReindexingTests extends AbstractTestNGSpringContextTests { @Autowired @@ -97,7 +97,8 @@ public void testReindexerFixesBrokenIndex() // WHEN // Run reindexer (leaving ALFRESCO_REINDEX_TO_TIME as default). - reindex(Map.of("ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime)); + reindex(Map.of("ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate")); // THEN // Check document indexed. @@ -116,7 +117,8 @@ public void testRecreateIndex() // WHEN // Run reindexer (with default dates to reindex everything). - reindex(Map.of("ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime)); + reindex(Map.of("ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate")); // THEN // Check document indexed. @@ -139,6 +141,7 @@ public void testRecreateIndexWithMetadataAndContent() // WHEN // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default reindex(Map.of("ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "true", "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "true", "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "false")); @@ -161,6 +164,7 @@ public void testRecreateIndexWithMetadataAndNoContent() // WHEN // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default reindex(Map.of("ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "true", "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "false", "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "false")); @@ -184,6 +188,7 @@ public void testRecreateIndexWithNoMetadataAndContent() // WHEN // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default reindex(Map.of("ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "false", "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "true", "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "false")); @@ -207,6 +212,7 @@ public void testRecreateIndexWithMetadataAndNoContentAndPath() // WHEN // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default reindex(Map.of("ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "true", "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "false", "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true")); @@ -230,6 +236,7 @@ public void testRecreateIndexWithMetadataAndContentAndPath() // WHEN // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default reindex(Map.of("ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "true", "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "true", "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true")); @@ -251,6 +258,7 @@ public void testRecreateIndexWithNoMetadataAndPath() // WHEN // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default reindex(Map.of("ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "false", "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "false", "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true")); @@ -274,8 +282,9 @@ public void testPathReindex() // WHEN // Run reindexer with path indexing enabled (and with default dates to reindex everything). - reindex(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", - "true", "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime)); + reindex(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true", + "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate")); // THEN // Check path indexed. @@ -300,7 +309,8 @@ public void testPathReindexQueryWithNamespaces() // WHEN // Run reindexer with path indexing enabled (and with default dates to reindex everything). reindex(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true", - "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime)); + "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate")); // THEN // Check path indexed. diff --git a/tests/testcontainers-env/src/main/java/org/alfresco/tas/AlfrescoStackInitializer.java b/tests/testcontainers-env/src/main/java/org/alfresco/tas/AlfrescoStackInitializer.java index 0c70990540..f77887535d 100644 --- a/tests/testcontainers-env/src/main/java/org/alfresco/tas/AlfrescoStackInitializer.java +++ b/tests/testcontainers-env/src/main/java/org/alfresco/tas/AlfrescoStackInitializer.java @@ -149,7 +149,8 @@ public void configureSecuritySettings(GenericContainer searchEngineContainer) */ public static void reindexEverything() { - reindex(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true")); // Ensure path reindexing is enabled. + reindex(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true", // Ensure path reindexing is enabled. + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate")); } /** @@ -183,7 +184,6 @@ public static Map getReindexEnvBasic() "SPRING_DATASOURCE_USERNAME", databaseType.getUsername(), "SPRING_DATASOURCE_PASSWORD", databaseType.getPassword(), "ELASTICSEARCH_INDEX_NAME", CUSTOM_ALFRESCO_INDEX, - "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", "SPRING_ACTIVEMQ_BROKER-URL", "nio://activemq:61616", "JAVA_TOOL_OPTIONS", "-Xmx1g", "ALFRESCO_ACCEPTEDCONTENTMEDIATYPESCACHE_BASEURL", "http://transform-core-aio:8090/transform/config"));