diff --git a/.github/workflows/master_release.yml b/.github/workflows/master_release.yml index 730df44111..74ee74e965 100644 --- a/.github/workflows/master_release.yml +++ b/.github/workflows/master_release.yml @@ -22,8 +22,8 @@ env: GITHUB_ACTIONS_DEPLOY_TIMEOUT: 60 BASE_BUILD_NUMBER: 10000 # Release version has to start with real version (23.2.0-....) for the docker image to build successfully. - RELEASE_VERSION: 25.1.0-A.3 - DEVELOPMENT_VERSION: 25.1.0-A.4-SNAPSHOT + RELEASE_VERSION: 25.1.0-A.4 + DEVELOPMENT_VERSION: 25.1.0-A.5-SNAPSHOT jobs: run_ci: diff --git a/dev/dev-acs-amps-overlay/pom.xml b/dev/dev-acs-amps-overlay/pom.xml index e9f5ac97c2..da639f7895 100644 --- a/dev/dev-acs-amps-overlay/pom.xml +++ b/dev/dev-acs-amps-overlay/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-dev-tomcat-env - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/dev/dev-repo-amps-overlay/pom.xml b/dev/dev-repo-amps-overlay/pom.xml index 5f546753c6..d782d23d91 100644 --- a/dev/dev-repo-amps-overlay/pom.xml +++ b/dev/dev-repo-amps-overlay/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-dev-tomcat-env - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/dev/dev-share-amps-overlay/pom.xml b/dev/dev-share-amps-overlay/pom.xml index 547e18f36b..04b520e63e 100644 --- a/dev/dev-share-amps-overlay/pom.xml +++ b/dev/dev-share-amps-overlay/pom.xml @@ -8,7 +8,7 @@ org.alfresco alfresco-dev-tomcat-env - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/dev/dev-tomcat/pom.xml b/dev/dev-tomcat/pom.xml index b60135c584..50dd8696b9 100644 --- a/dev/dev-tomcat/pom.xml +++ b/dev/dev-tomcat/pom.xml @@ -9,7 +9,7 @@ org.alfresco alfresco-dev-tomcat-env - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/dev/pom.xml b/dev/pom.xml index 9ae77ef506..ffdf6a5605 100644 --- a/dev/pom.xml +++ b/dev/pom.xml @@ -9,7 +9,7 @@ org.alfresco acs-packaging - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/distribution-ags/pom.xml b/distribution-ags/pom.xml index 6f85670fde..789417ca3c 100644 --- a/distribution-ags/pom.xml +++ b/distribution-ags/pom.xml @@ -8,7 +8,7 @@ org.alfresco acs-packaging - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/distribution-share/pom.xml b/distribution-share/pom.xml index f61be3ef42..d6885538e4 100644 --- a/distribution-share/pom.xml +++ b/distribution-share/pom.xml @@ -7,7 +7,7 @@ org.alfresco acs-packaging - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/distribution/pom.xml b/distribution/pom.xml index a956f6cdcc..a59c64f511 100644 --- a/distribution/pom.xml +++ b/distribution/pom.xml @@ -8,7 +8,7 @@ org.alfresco acs-packaging - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/docker-alfresco/ags/pom.xml b/docker-alfresco/ags/pom.xml index 9b95097f4a..8cd95c7994 100644 --- a/docker-alfresco/ags/pom.xml +++ b/docker-alfresco/ags/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-services-docker - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT alfresco/alfresco-governance-repository-enterprise diff --git a/docker-alfresco/aws/pom.xml b/docker-alfresco/aws/pom.xml index 45f2041bd7..653dc45635 100644 --- a/docker-alfresco/aws/pom.xml +++ b/docker-alfresco/aws/pom.xml @@ -8,7 +8,7 @@ org.alfresco content-services-docker - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/docker-alfresco/pom.xml b/docker-alfresco/pom.xml index 2308b0cd1d..e8f8f9b553 100644 --- a/docker-alfresco/pom.xml +++ b/docker-alfresco/pom.xml @@ -8,7 +8,7 @@ org.alfresco acs-packaging - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/docker-share/ags/pom.xml b/docker-share/ags/pom.xml index 5b6858004a..144ca47150 100644 --- a/docker-share/ags/pom.xml +++ b/docker-share/ags/pom.xml @@ -8,7 +8,7 @@ org.alfresco share-docker - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/docker-share/aws/pom.xml b/docker-share/aws/pom.xml index 4f98f52f11..022eda3586 100644 --- a/docker-share/aws/pom.xml +++ b/docker-share/aws/pom.xml @@ -7,7 +7,7 @@ org.alfresco share-docker - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/docker-share/pom.xml b/docker-share/pom.xml index ac81c5efaa..d5479393ec 100644 --- a/docker-share/pom.xml +++ b/docker-share/pom.xml @@ -7,7 +7,7 @@ org.alfresco acs-packaging - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/pom.xml b/pom.xml index 6d378d5b16..e56ac1bd2e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,18 +4,18 @@ acs-packaging pom Alfresco Content Services Packaging - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT org.alfresco alfresco-enterprise-repo ../alfresco-enterprise-repo/pom.xml - 25.1.0.13 + 25.1.0.15 - 25.1.0.13 - 25.1.0.12 + 25.1.0.15 + 25.1.0.14 3.0.2 diff --git a/tests/pipeline-all-amps/pom.xml b/tests/pipeline-all-amps/pom.xml index d15d9fc49c..68daa71216 100644 --- a/tests/pipeline-all-amps/pom.xml +++ b/tests/pipeline-all-amps/pom.xml @@ -7,7 +7,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT ../pom.xml diff --git a/tests/pipeline-all-amps/repo/pom.xml b/tests/pipeline-all-amps/repo/pom.xml index 6d9aa00d12..8de9ce41d9 100644 --- a/tests/pipeline-all-amps/repo/pom.xml +++ b/tests/pipeline-all-amps/repo/pom.xml @@ -5,7 +5,7 @@ org.alfresco pipeline-all-amps - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT alfresco-pipeline-all-amps-repo diff --git a/tests/pipeline-all-amps/share/pom.xml b/tests/pipeline-all-amps/share/pom.xml index 8523e38c57..caa60d0894 100644 --- a/tests/pipeline-all-amps/share/pom.xml +++ b/tests/pipeline-all-amps/share/pom.xml @@ -5,7 +5,7 @@ org.alfresco pipeline-all-amps - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT alfresco-pipeline-all-amps-share diff --git a/tests/pom.xml b/tests/pom.xml index a971d37152..6cc0ac0d84 100644 --- a/tests/pom.xml +++ b/tests/pom.xml @@ -7,7 +7,7 @@ org.alfresco acs-packaging - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/tests/tas-all-amps/pom.xml b/tests/tas-all-amps/pom.xml index ea52faef10..4defc8ae65 100644 --- a/tests/tas-all-amps/pom.xml +++ b/tests/tas-all-amps/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/tests/tas-cmis/pom.xml b/tests/tas-cmis/pom.xml index c7d5b720a3..310e45554b 100644 --- a/tests/tas-cmis/pom.xml +++ b/tests/tas-cmis/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/tests/tas-distribution-zip/pom.xml b/tests/tas-distribution-zip/pom.xml index a47b674120..365b26d3e6 100644 --- a/tests/tas-distribution-zip/pom.xml +++ b/tests/tas-distribution-zip/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/tests/tas-elasticsearch/pom.xml b/tests/tas-elasticsearch/pom.xml index 9fa5cad2b1..b1ab839a55 100644 --- a/tests/tas-elasticsearch/pom.xml +++ b/tests/tas-elasticsearch/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT 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 a94760d7f5..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,9 +1,9 @@ package org.alfresco.elasticsearch.initialReindex; import static org.alfresco.elasticsearch.SearchQueryService.req; -import static org.alfresco.tas.AlfrescoStackInitializer.getImagesConfig; +import static org.alfresco.tas.AlfrescoStackInitializer.reindex; +import static org.alfresco.utility.model.FileType.TEXT_PLAIN; -import java.util.HashMap; import java.util.Map; import java.util.UUID; @@ -13,19 +13,15 @@ import org.alfresco.utility.data.DataContent; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.network.ServerHealth; import org.alfresco.utility.report.log.Step; -import org.apache.http.HttpHost; -import org.opensearch.client.RestClient; -import org.opensearch.client.RestHighLevelClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.startupcheck.IndefiniteWaitOneShotStartupCheckStrategy; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -37,10 +33,6 @@ public class ElasticsearchInitialReindexingTests extends AbstractTestNGSpringContextTests { - private static final Logger LOGGER = LoggerFactory.getLogger(ElasticsearchInitialReindexingTests.class); - - public static final String CUSTOM_ALFRESCO_INDEX = "custom-alfresco-index"; - @Autowired private ServerHealth serverHealth; @Autowired @@ -52,11 +44,8 @@ public class ElasticsearchInitialReindexingTests extends AbstractTestNGSpringCon @Autowired protected SearchQueryService searchQueryService; - private org.alfresco.utility.model.UserModel testUser; - - private org.alfresco.utility.model.SiteModel testSite; - - private RestHighLevelClient elasticClient; + private UserModel testUser; + private SiteModel testSite; /** * Create a user and a private site and wait for these to be indexed. @@ -72,13 +61,6 @@ public void dataPreparation() testUser = dataUser.createRandomTestUser(); testSite = dataSite.usingUser(testUser).createPrivateRandomSite(); createDocument(); - - Step.STEP("create ES client"); - elasticClient = new RestHighLevelClient( - RestClient.builder(new HttpHost(AlfrescoStackInitializer.searchEngineContainer.getContainerIpAddress(), - AlfrescoStackInitializer.searchEngineContainer.getFirstMappedPort(), - "http"))); - } /** @@ -96,36 +78,14 @@ public void testReindexerIndexesSystemDocuments() // WHEN // Run reindexer against the initial documents. reindex(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByIds", - "ELASTICSEARCH_INDEX_NAME", CUSTOM_ALFRESCO_INDEX, - "ALFRESCO_REINDEX_FROM_ID", "0", - "ALFRESCO_REINDEX_TO_ID", "1000")); + "ALFRESCO_REINDEX_FROM_ID", "0", + "ALFRESCO_REINDEX_TO_ID", "1000")); // THEN // Check system document is indexed. searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), "budget.xls"); } - /** - * Run the alfresco-elasticsearch-reindexing container. - * - * @param envParam Any environment variables to override from the defaults. - */ - private void reindex(Map envParam) - { - // Run the reindexing container. - Map env = AlfrescoStackInitializer.getReindexEnvBasic(); - env.putAll(envParam); - - try (GenericContainer reindexingComponent = new GenericContainer(getImagesConfig().getReIndexingImage()) - .withEnv(env) - .withNetwork(AlfrescoStackInitializer.network) - .withStartupCheckStrategy( - new IndefiniteWaitOneShotStartupCheckStrategy())) - { - reindexingComponent.start(); - } - } - /** * Create a document using in the test site using the test user. * @@ -136,7 +96,7 @@ private String createDocument() String documentName = "TestFile" + UUID.randomUUID() + ".txt"; dataContent.usingUser(testUser) .usingSite(testSite) - .createContent(new org.alfresco.utility.model.FileModel(documentName, org.alfresco.utility.model.FileType.TEXT_PLAIN, "content")); + .createContent(new FileModel(documentName, TEXT_PLAIN, "content")); return documentName; } } 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 75017d3984..4b32d969b4 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 @@ -1,7 +1,11 @@ package org.alfresco.elasticsearch.reindexing; import static org.alfresco.elasticsearch.SearchQueryService.req; -import static org.alfresco.tas.AlfrescoStackInitializer.getImagesConfig; +import static org.alfresco.tas.AlfrescoStackInitializer.CUSTOM_ALFRESCO_INDEX; +import static org.alfresco.tas.AlfrescoStackInitializer.liveIndexer; +import static org.alfresco.tas.AlfrescoStackInitializer.reindex; +import static org.alfresco.tas.AlfrescoStackInitializer.searchEngineContainer; +import static org.alfresco.utility.model.FileType.TEXT_PLAIN; import static org.alfresco.utility.report.log.Step.STEP; import static org.junit.Assert.fail; @@ -18,7 +22,10 @@ import org.alfresco.utility.data.DataContent; import org.alfresco.utility.data.DataSite; import org.alfresco.utility.data.DataUser; +import org.alfresco.utility.model.FileModel; +import org.alfresco.utility.model.SiteModel; import org.alfresco.utility.model.TestGroup; +import org.alfresco.utility.model.UserModel; import org.alfresco.utility.network.ServerHealth; import org.apache.http.HttpHost; import org.opensearch.client.RequestOptions; @@ -30,8 +37,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; -import org.testcontainers.containers.GenericContainer; -import org.testcontainers.containers.startupcheck.IndefiniteWaitOneShotStartupCheckStrategy; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -40,11 +45,9 @@ */ @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 { - public static final String CUSTOM_ALFRESCO_INDEX = "custom-alfresco-index"; - @Autowired private ServerHealth serverHealth; @Autowired @@ -56,15 +59,10 @@ public class ElasticsearchReindexingTests extends AbstractTestNGSpringContextTes @Autowired protected SearchQueryService searchQueryService; - private org.alfresco.utility.model.UserModel testUser; - - private org.alfresco.utility.model.SiteModel testSite; - + private UserModel testUser; + private SiteModel testSite; private RestHighLevelClient elasticClient; - /** - * Create a user and a private site and wait for these to be indexed. - */ @BeforeClass(alwaysRun = true) public void dataPreparation() { @@ -75,284 +73,286 @@ public void dataPreparation() testUser = dataUser.createRandomTestUser(); testSite = dataSite.usingUser(testUser).createPrivateRandomSite(); - createDocument(); + createDocumentWithRandomName(); STEP("create ES client"); elasticClient = new RestHighLevelClient( - RestClient.builder(new HttpHost(AlfrescoStackInitializer.searchEngineContainer.getContainerIpAddress(), - AlfrescoStackInitializer.searchEngineContainer.getFirstMappedPort(), + RestClient.builder(new HttpHost(searchEngineContainer.getContainerIpAddress(), + searchEngineContainer.getFirstMappedPort(), "http"))); - } @Test(groups = TestGroup.SEARCH) public void testReindexerFixesBrokenIndex() { // GIVEN - - // Delete all documents inside Elasticsearch. cleanUpIndex(); - //stop live indexing - AlfrescoStackInitializer.liveIndexer.stop(); - // Create document. - - String testStart = DateTimeFormatter.ofPattern("yyyyMMddHHmm").format(ZonedDateTime.now(Clock.systemUTC())); - String documentName = createDocument(); + liveIndexer.stop(); + String reindexerStartTime = getReindexerStartTimeNow(); + String documentName = createDocumentWithRandomName(); // Check document not indexed. // Nb. The cm:name:* term ensures that the query hits the index rather than the db. - SearchRequest query = req("cm:name:" + documentName + " AND cm:name:*"); searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser()); // WHEN // Run reindexer (leaving ALFRESCO_REINDEX_TO_TIME as default). - try(GenericContainer reindexingComponent = createReindexContainer(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", - "ELASTICSEARCH_INDEX_NAME", CUSTOM_ALFRESCO_INDEX, - "ALFRESCO_REINDEX_FROM_TIME", testStart))) { - //Reindex - reindexingComponent.start(); - - // THEN - // Check document indexed. - searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); - } + reindex(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", + "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime)); + + // THEN + // Check document indexed. + searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); + // TIDY - // Restart ElasticsearchConnector. cleanUpIndex(); - AlfrescoStackInitializer.liveIndexer.start(); - + liveIndexer.start(); } @Test(groups = TestGroup.SEARCH) public void testRecreateIndex() { // GIVEN - // Create document. - String documentName = createDocument(); - // Stop ElasticsearchConnector. - AlfrescoStackInitializer.liveIndexer.stop(); - // Delete index documents. + String documentName = createDocumentWithRandomName(); + liveIndexer.stop(); cleanUpIndex(); // WHEN // Run reindexer (with default dates to reindex everything). - try(GenericContainer reindexingComponent = createReindexContainer(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", - "ELASTICSEARCH_INDEX_NAME", CUSTOM_ALFRESCO_INDEX))) { - //Reindex - reindexingComponent.start(); - - // THEN - // Check document indexed. - // Nb. The cm:name:* term ensures that the query hits the index rather than the db. - SearchRequest query = req("cm:name:" + documentName + " AND cm:name:*"); - searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); - } + reindex(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate")); + + // THEN + // Check document indexed. + // Nb. The cm:name:* term ensures that the query hits the index rather than the db. + SearchRequest query = req("cm:name:" + documentName + " AND cm:name:*"); + searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); // TIDY // Restart ElasticsearchConnector. cleanUpIndex(); - AlfrescoStackInitializer.liveIndexer.start(); - + liveIndexer.start(); } - /** - * Common testing method for reindexing enabled and disabled features tests. - * @param metadataIndexingEnabled Reindexing metadata is enabled when true, disabled when false - * @param contentIndexingEnabled Reindexing content is enabled when true, disabled when false - * @param pathIndexingEnabled Reindexing path is enabled when true, disabled when false - * @param queryString Verification query string. It may include a mark that is replaced by the actual document name created. - * @param expectingDocNameAsResult Result from verification query string is the name of the document created when true, empty result when false. - */ - private void internalTestEnabledFeatures( - Boolean metadataIndexingEnabled, - Boolean contentIndexingEnabled, - Boolean pathIndexingEnabled, - String queryString, - Boolean expectingDocNameAsResult - ) + @Test(groups = TestGroup.SEARCH) + public void testRecreateIndexWithMetadataAndContent() { - // Initial timestamp for reindexing by date: this will save reindexing time for these tests - ZonedDateTime now = ZonedDateTime.now(Clock.systemUTC()); - // ACS-5044 Increased time to 20 minutes as 10 minutes proved insufficient to prevent intermittent failures - String testStart = DateTimeFormatter.ofPattern("yyyyMMddHHmm").format(now.minusMinutes(20)); - // GIVEN - // Stop ElasticsearchConnector - AlfrescoStackInitializer.liveIndexer.stop(); - // Create document - String documentName = createDocument(); - // Delete index documents + String reindexerStartTime = getReindexerStartTimeTwentyMinutesAgo(); + liveIndexer.stop(); + String documentName = createDocumentWithRandomName(); cleanUpIndex(); - // Restart ElasticsearchConnector to Index Content - AlfrescoStackInitializer.liveIndexer.start(); + // Reindexer requires lifeIndexer to index content. + liveIndexer.start(); // WHEN // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default - try(GenericContainer reindexingComponent = createReindexContainer(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", - "ELASTICSEARCH_INDEX_NAME", CUSTOM_ALFRESCO_INDEX, - "ALFRESCO_REINDEX_FROM_TIME", testStart, - "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", metadataIndexingEnabled.toString(), - "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", contentIndexingEnabled.toString(), - "ALFRESCO_REINDEX_PATHINDEXINGENABLED", pathIndexingEnabled.toString()))) { - //Reindex - reindexingComponent.start(); - - // THEN - SearchRequest query = req(queryString.replace("", documentName)); - - if (expectingDocNameAsResult) { - searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); - } else { - searchQueryService.expectNoResultsFromQuery(query, dataUser.getAdminUser()); - } - } - - } - - @Test(groups = TestGroup.SEARCH) - public void testRecreateIndexWithMetadataAndContent() - { - internalTestEnabledFeatures(true, true, false, - "cm:name:'' AND TEXT:'content'", true); + reindex(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", + "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "true", + "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "true", + "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "false")); + + // THEN + // Document is still indexed after reindexing. + SearchRequest query = req("cm:name:'" + documentName + "' AND TEXT:'content'"); + searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); } @Test(groups = TestGroup.SEARCH) public void testRecreateIndexWithMetadataAndNoContent() { - internalTestEnabledFeatures(true, false, false, - "cm:name:'' AND TEXT:'content'", false); + // GIVEN + String reindexerStartTime = getReindexerStartTimeTwentyMinutesAgo(); + liveIndexer.stop(); + String documentName = createDocumentWithRandomName(); + cleanUpIndex(); + + // WHEN + // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default + reindex(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", + "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "true", + "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "false", + "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "false")); + + // THEN + SearchRequest query = req("cm:name:'" + documentName + "' AND TEXT:'content'"); + searchQueryService.expectNoResultsFromQuery(query, dataUser.getAdminUser()); } @Test(groups = TestGroup.SEARCH) public void testRecreateIndexWithNoMetadataAndContent() { + // GIVEN + String reindexerStartTime = getReindexerStartTimeTwentyMinutesAgo(); + liveIndexer.stop(); + String documentName = createDocumentWithRandomName(); + cleanUpIndex(); + // Reindexer requires lifeIndexer to index content. + liveIndexer.start(); + + // WHEN + // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default + reindex(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", + "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "false", + "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "true", + "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "false")); + + // THEN // When not using metadata, document shouldn't be present in Elasticsearch index, // since metadata reindexing process is indexing also permissions - internalTestEnabledFeatures(false, true, false, - "cm:name:'' AND cm:name:*", false); + SearchRequest query = req("cm:name:'" + documentName + "' AND cm:name:*"); + searchQueryService.expectNoResultsFromQuery(query, dataUser.getAdminUser()); } @Test(groups = TestGroup.SEARCH) public void testRecreateIndexWithMetadataAndNoContentAndPath() { - internalTestEnabledFeatures(true, false, true, - "cm:name:'' AND PATH:'/app:company_home/st:sites/cm:" + testSite + "/cm:documentLibrary/cm:'", true); + // GIVEN + String reindexerStartTime = getReindexerStartTimeTwentyMinutesAgo(); + liveIndexer.stop(); + String documentName = createDocumentWithRandomName(); + cleanUpIndex(); + + // WHEN + // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default + reindex(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", + "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "true", + "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "false", + "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true")); + + // THEN + SearchRequest query = req("cm:name:'%s' AND PATH:'/app:company_home/st:sites/cm:%s/cm:documentLibrary/cm:%s'".formatted(documentName, testSite, documentName)); + searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); } @Test(groups = TestGroup.SEARCH) public void testRecreateIndexWithMetadataAndContentAndPath() { - internalTestEnabledFeatures(true, true, true, - "cm:name:'' AND TEXT:'content' " + - "AND PATH:'/app:company_home/st:sites/cm:" + testSite + "/cm:documentLibrary/cm:'", true); + // GIVEN + String reindexerStartTime = getReindexerStartTimeTwentyMinutesAgo(); + liveIndexer.stop(); + String documentName = createDocumentWithRandomName(); + cleanUpIndex(); + // Reindexer requires lifeIndexer to index content. + liveIndexer.start(); + + // WHEN + // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default + reindex(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", + "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "true", + "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "true", + "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true")); + + // THEN + SearchRequest query = req("cm:name:'%s' AND TEXT:'content' AND PATH:'/app:company_home/st:sites/cm:%s/cm:documentLibrary/cm:%s'".formatted(documentName, testSite, documentName)); + searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); } @Test(groups = TestGroup.SEARCH) public void testRecreateIndexWithNoMetadataAndPath() { + // GIVEN + String reindexerStartTime = getReindexerStartTimeTwentyMinutesAgo(); + liveIndexer.stop(); + String documentName = createDocumentWithRandomName(); + cleanUpIndex(); + + // WHEN + // Run reindexer leaving ALFRESCO_REINDEX_TO_TIME as default + reindex(Map.of("ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", + "ALFRESCO_REINDEX_FROM_TIME", reindexerStartTime, + "ALFRESCO_REINDEX_METADATAINDEXINGENABLED", "false", + "ALFRESCO_REINDEX_CONTENTINDEXINGENABLED", "false", + "ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true")); + + // THEN // When not using metadata, document shouldn't be present in Elasticsearch index, // since metadata reindexing process is indexing also permissions - internalTestEnabledFeatures(false, false, true, - "cm:name:'' AND cm:name:*", false); + SearchRequest query = req("cm:name:'" + documentName + "' AND cm:name:*"); + searchQueryService.expectNoResultsFromQuery(query, dataUser.getAdminUser()); } @Test (groups = TestGroup.SEARCH) public void testPathReindex() { // GIVEN - // Create document. - String documentName = createDocument(); - // Stop ElasticsearchConnector. - AlfrescoStackInitializer.liveIndexer.stop(); - // Delete index documents. + String documentName = createDocumentWithRandomName(); + liveIndexer.stop(); cleanUpIndex(); // WHEN // Run reindexer with path indexing enabled (and with default dates to reindex everything). - try(GenericContainer reindexingComponent = createReindexContainer(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true", - "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", - "ELASTICSEARCH_INDEX_NAME", CUSTOM_ALFRESCO_INDEX))) { - //Reindex - reindexingComponent.start(); - - // THEN - // Check path indexed. - // Nb. The cm:name:* term ensures that the query hits the index rather than the db. - SearchRequest query = req("PATH:\"//" + documentName + "\" AND cm:name:*"); - searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); - // Also check that the document can be obtained by a path query against the site. - query = req("PATH:\"//" + testSite.getTitle() + "/documentLibrary/*\" AND cm:name:" + documentName + " AND cm:name:*"); - searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); - } + reindex(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true", + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate")); + + // THEN + // Check path indexed. + // Nb. The cm:name:* term ensures that the query hits the index rather than the db. + SearchRequest query = req("PATH:\"//" + documentName + "\" AND cm:name:*"); + searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); + // Also check that the document can be obtained by a path query against the site. + query = req("PATH:\"//" + testSite.getTitle() + "/documentLibrary/*\" AND cm:name:" + documentName + " AND cm:name:*"); + searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); // TIDY - // Restart ElasticsearchConnector. - AlfrescoStackInitializer.liveIndexer.start(); + liveIndexer.start(); } @Test (groups = TestGroup.SEARCH) public void testPathReindexQueryWithNamespaces() { // GIVEN - // Create document. - String documentName = createDocument(); - // Stop ElasticsearchConnector. - AlfrescoStackInitializer.liveIndexer.stop(); - // Delete index documents. + String documentName = createDocumentWithRandomName(); + liveIndexer.stop(); cleanUpIndex(); // WHEN // Run reindexer with path indexing enabled (and with default dates to reindex everything). - try(GenericContainer reindexingComponent = createReindexContainer(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true", - "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate", - "ELASTICSEARCH_INDEX_NAME", CUSTOM_ALFRESCO_INDEX))) { - //Reindex - reindexingComponent.start(); - - // THEN - // Check path indexed. - // Nb. The cm:name:* term ensures that the query hits the index rather than the db. - SearchRequest query = req("PATH:\"//cm:" + documentName + "\" AND cm:name:*"); - searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); - // Also check that the document can be obtained by a path query against the site. - query = req("PATH:\"//cm:" + testSite.getTitle() + "/cm:documentLibrary/*\" AND cm:name:" + documentName + " AND cm:name:*"); - searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); - } + reindex(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true", + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate")); + + // THEN + // Check path indexed. + // Nb. The cm:name:* term ensures that the query hits the index rather than the db. + SearchRequest query = req("PATH:\"//cm:" + documentName + "\" AND cm:name:*"); + searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); + // Also check that the document can be obtained by a path query against the site. + query = req("PATH:\"//cm:" + testSite.getTitle() + "/cm:documentLibrary/*\" AND cm:name:" + documentName + " AND cm:name:*"); + searchQueryService.expectResultsFromQuery(query, dataUser.getAdminUser(), documentName); // TIDY - // Restart ElasticsearchConnector. - AlfrescoStackInitializer.liveIndexer.start(); + liveIndexer.start(); } - /** - * Run the alfresco-elasticsearch-reindexing container. - * - * @param envParam Any environment variables to override from the defaults. - * @return reindex container - */ - private GenericContainer createReindexContainer(Map envParam) + private String getReindexerStartTimeNow() { - // Run the reindexing container. - Map env = AlfrescoStackInitializer.getReindexEnvBasic(); - env.putAll(envParam); - - return new GenericContainer(getImagesConfig().getReIndexingImage()) - .withEnv(env) - .withNetwork(AlfrescoStackInitializer.network) - .withStartupCheckStrategy(new IndefiniteWaitOneShotStartupCheckStrategy()); + ZonedDateTime now = ZonedDateTime.now(Clock.systemUTC()); + return formatTimeForReindexer(now); } - /** - * Create a document using in the test site using the test user. - * - * @return The randomly generated name of the new document. - */ - private String createDocument() + private String getReindexerStartTimeTwentyMinutesAgo() + { + // Initial timestamp for reindexing by date: this will save reindexing time for these tests + ZonedDateTime now = ZonedDateTime.now(Clock.systemUTC()); + // ACS-5044 Increased time to 20 minutes as 10 minutes proved insufficient to prevent intermittent failures + return formatTimeForReindexer(now.minusMinutes(20)); + } + + private String formatTimeForReindexer(ZonedDateTime zonedDateTime) + { + return DateTimeFormatter.ofPattern("yyyyMMddHHmm").format(zonedDateTime); + } + + private String createDocumentWithRandomName() { String documentName = "TestFile" + UUID.randomUUID() + ".txt"; dataContent.usingUser(testUser) .usingSite(testSite) - .createContent(new org.alfresco.utility.model.FileModel(documentName, org.alfresco.utility.model.FileType.TEXT_PLAIN, "content")); + .createContent(new FileModel(documentName, TEXT_PLAIN, "content")); return documentName; } @@ -370,5 +370,4 @@ private void cleanUpIndex() fail("Failed to tidy index. " + e); } } - } diff --git a/tests/tas-email/pom.xml b/tests/tas-email/pom.xml index f061c4fa11..c213d35275 100644 --- a/tests/tas-email/pom.xml +++ b/tests/tas-email/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/tests/tas-integration/pom.xml b/tests/tas-integration/pom.xml index 951550b600..b7178d4222 100644 --- a/tests/tas-integration/pom.xml +++ b/tests/tas-integration/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/tests/tas-mtls/pom.xml b/tests/tas-mtls/pom.xml index 2e30b7361f..9e4e8c0774 100644 --- a/tests/tas-mtls/pom.xml +++ b/tests/tas-mtls/pom.xml @@ -8,7 +8,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/tests/tas-restapi/pom.xml b/tests/tas-restapi/pom.xml index 17d8dfe828..9975d72a22 100644 --- a/tests/tas-restapi/pom.xml +++ b/tests/tas-restapi/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/tests/tas-sync-service/pom.xml b/tests/tas-sync-service/pom.xml index 277d4cfb92..0510b298ec 100644 --- a/tests/tas-sync-service/pom.xml +++ b/tests/tas-sync-service/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/tests/tas-webdav/pom.xml b/tests/tas-webdav/pom.xml index 4f3939a55f..ae1c0a6360 100644 --- a/tests/tas-webdav/pom.xml +++ b/tests/tas-webdav/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT diff --git a/tests/testcontainers-env/pom.xml b/tests/testcontainers-env/pom.xml index 9a3dfecf78..d5d4646f2d 100644 --- a/tests/testcontainers-env/pom.xml +++ b/tests/testcontainers-env/pom.xml @@ -9,7 +9,7 @@ org.alfresco content-repository-tests - 25.1.0-A.4-SNAPSHOT + 25.1.0-A.5-SNAPSHOT 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 0e00d01dcd..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 @@ -148,11 +148,21 @@ public void configureSecuritySettings(GenericContainer searchEngineContainer) * Run the alfresco-elasticsearch-reindexing container with path reindexing enabled. */ public static void reindexEverything() + { + reindex(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true", // Ensure path reindexing is enabled. + "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate")); + } + + /** + * Run the alfresco-elasticsearch-reindexing container. + * + * @param envParam Any environment variables to override from the defaults. + */ + public static void reindex(Map envParam) { // Run the reindexing container. Map env = AlfrescoStackInitializer.getReindexEnvBasic(); - env.putAll(Map.of("ALFRESCO_REINDEX_PATHINDEXINGENABLED", "true", // Ensure path reindexing is enabled. - "ALFRESCO_REINDEX_JOB_NAME", "reindexByDate")); + env.putAll(envParam); try (GenericContainer reindexingComponent = new GenericContainer(getImagesConfig().getReIndexingImage()) .withEnv(env)