From 531d8ce5ead889334e5dc58ad995cd630c2385cb Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 3 May 2019 10:13:08 +0100 Subject: [PATCH 1/8] Revert "Revert "Merge branch 'feature/SEARCH-1617_CMISScoring' into 'master'"" This reverts commit 13b7aa9ba6b106afb4e040c57372b5f0335f270d. --- e2e-test/pom.xml | 22 +- .../cmis/AbstractCmisE2ETest.java | 47 ++++- .../cmis/SolrSearchScoreQueryTests.java | 195 ++++++++++++++++++ .../src/test/resources/default.properties | 2 +- .../testdata/search-score-function.xml | 30 +++ 5 files changed, 286 insertions(+), 10 deletions(-) create mode 100644 e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java create mode 100644 e2e-test/src/test/resources/testdata/search-score-function.xml diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index f6f0c8256..4f3b3230f 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -12,8 +12,8 @@ Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share 6.0.0.3 - 6.0.0.0 - 2.0.1 + 6.0.0.1 + 2.0.9 2.6.0 src/test/resources/SearchSuite.xml @@ -54,12 +54,24 @@ restapi-test ${tas.rest.api.version} test + + + com.fasterxml.jackson.core + jackson-databind + + org.alfresco.tas cmis-test ${tas.cmis.api.version} test + + + com.fasterxml.jackson.core + jackson-databind + + org.alfresco @@ -73,6 +85,12 @@ ${rm.version} tests test + + + com.fasterxml.jackson.core + jackson-databind + + diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/AbstractCmisE2ETest.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/AbstractCmisE2ETest.java index f301a63ec..89c190bc3 100644 --- a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/AbstractCmisE2ETest.java +++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/AbstractCmisE2ETest.java @@ -1,13 +1,13 @@ package org.alfresco.test.search.functional.searchServices.cmis; -import org.alfresco.cmis.CmisProperties; -import org.alfresco.cmis.CmisWrapper; - import java.lang.reflect.Method; +import org.alfresco.cmis.CmisProperties; +import org.alfresco.cmis.CmisWrapper; import org.alfresco.test.search.functional.searchServices.search.AbstractSearchServicesE2ETest; -import org.alfresco.utility.LogFactory; +import org.alfresco.utility.Utility; import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; @@ -25,7 +25,7 @@ import org.testng.annotations.BeforeMethod; @Scope(value = "prototype") public abstract class AbstractCmisE2ETest extends AbstractSearchServicesE2ETest { - private static Logger LOG = LogFactory.getLogger(); + private static Logger LOGGER = LoggerFactory.getLogger(AbstractCmisE2ETest.class); @Autowired protected CmisWrapper cmisApi; @@ -38,17 +38,50 @@ public abstract class AbstractCmisE2ETest extends AbstractSearchServicesE2ETest @BeforeMethod(alwaysRun = true) public void showStartTestInfo(Method method) { - LOG.info(String.format("*** STARTING Test: [%s] ***", method.getName())); + LOGGER.info(String.format("*** STARTING Test: [%s] ***", method.getName())); } @AfterMethod(alwaysRun = true) public void showEndTestInfo(Method method) { - LOG.info(String.format("*** ENDING Test: [%s] ***", method.getName())); + LOGGER.info(String.format("*** ENDING Test: [%s] ***", method.getName())); } public Integer getSolrWaitTimeInSeconds() { return cmisProperties.envProperty().getSolrWaitTimeInSeconds(); } + + /** + * Repeat SOLR Query till results count returns expectedCountResults + * @param query CMIS Query to be executed + * @param expectedCountResults Number of results expected + * @return true when results count is equals to expectedCountResults + * @throws Exception + */ + protected boolean waitForIndexing(String query, long expectedCountResults) throws Exception + { + + for (int searchCount = 1; searchCount <= 3; searchCount++) + { + + try + { + cmisApi.withQuery(query).assertResultsCount().equals(expectedCountResults); + return true; + } + catch (AssertionError ae) + { + LOGGER.debug(ae.toString()); + } + + + Utility.waitToLoopTime(properties.getSolrWaitTimeInSeconds(), "Wait For Indexing"); + + } + + return false; + } + + } diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java new file mode 100644 index 000000000..11726579a --- /dev/null +++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java @@ -0,0 +1,195 @@ +package org.alfresco.test.search.functional.searchServices.cmis; + +import java.math.BigDecimal; + +import org.alfresco.utility.data.provider.XMLDataConfig; +import org.alfresco.utility.data.provider.XMLTestData; +import org.alfresco.utility.data.provider.XMLTestDataProvider; +import org.alfresco.utility.model.TestGroup; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.AfterClass; +import org.testng.annotations.Test; + +/** + * Testing SCORE function queries to solve issues related to + * https://issues.alfresco.com/jira/browse/ACE-2479 + * + * @author aborroy + * + */ +public class SolrSearchScoreQueryTests extends AbstractCmisE2ETest +{ + + private static Logger LOGGER = LoggerFactory.getLogger(SolrSearchScoreQueryTests.class); + private XMLTestData testData; + + @AfterClass(alwaysRun = true) + public void cleanupEnvironment() + { + if (testData != null) + { + testData.cleanup(dataContent); + } + else + { + LOGGER.warn("testData is inexplicably null - skipping clean up."); + } + } + + /* These tests does not require AbstractSearchServicesE2ETest common tests, + * as it's focused on testing scoring function features + * @see org.alfresco.test.search.functional.searchServices.search.AbstractSearchServicesE2ETest#searchServicesDataPreparation() + */ + @Override + public void searchServicesDataPreparation() throws Exception + { + } + + /* These tests does not require common data preparation from AbstractE2EFunctionalTest + * as it's including every test data required in search-score-funtion.xml + * @see org.alfresco.test.search.functional.AbstractE2EFunctionalTest#dataPreparation() + */ + @Override + public void dataPreparation() throws Exception + { + } + + @Test(dataProviderClass = XMLTestDataProvider.class, dataProvider = "getAllData") + @XMLDataConfig(file = "src/test/resources/testdata/search-score-function.xml") + public void prepareDataForScoreSearch(XMLTestData testData) throws Exception + { + this.testData = testData; + this.testData.createUsers(dataUser); + this.testData.createSitesStructure(dataSite, dataContent, dataUser); + cmisApi.authenticateUser(dataUser.getCurrentUser()); + + } + + /** + * Verify that results are ordered + * @throws Exception + */ + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") + public void scoreQueryOrdered() throws Exception + { + + String query = "SELECT cmis:objectId, SCORE() AS orderCriteria " + + "FROM cmis:document " + + "WHERE CONTAINS('Quidditch') " + + "ORDER BY orderCriteria"; + + if (waitForIndexing(query, 3)) + { + cmisApi + .withQuery(query) + .assertColumnIsOrdered().isOrderedAsc("orderCriteria"); + } + else + { + throw new AssertionError("Wait for indexing has failed!"); + } + + } + + /** + * Verify that results are inverse ordered + * @throws Exception + */ + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") + public void scoreQueryOrderedDesc() throws Exception + { + + String query = "SELECT cmis:objectId, SCORE() AS orderCriteria " + + "FROM cmis:document " + + "WHERE CONTAINS('Quidditch') " + + "ORDER BY orderCriteria DESC"; + + if (waitForIndexing(query, 3)) + { + cmisApi + .withQuery(query).assertColumnIsOrdered().isOrderedDesc("orderCriteria"); + } + else + { + throw new AssertionError("Wait for indexing has failed!"); + } + + } + + /** + * Verify that all SCORE results are between 0 and 1 + * @throws Exception + */ + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") + public void scoreQueryInRange() throws Exception + { + + String query = "SELECT cmis:objectId, SCORE() " + + "FROM cmis:document " + + "WHERE CONTAINS('Quidditch')"; + + if (waitForIndexing(query, 3)) + { + cmisApi + .withQuery(query) + .assertColumnValuesRange().isReturningValuesInRange("SEARCH_SCORE", BigDecimal.ZERO, BigDecimal.ONE); + } + else + { + throw new AssertionError("Wait for indexing has failed!"); + } + + } + + /** + * Verify that all SCORE results are between 0 and 1 + * @throws Exception + */ + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") + public void scoreQueryAliasInRange() throws Exception + { + + String query = "SELECT cmis:objectId, SCORE() AS orderCriteria " + + "FROM cmis:document " + + "WHERE CONTAINS('Quidditch')"; + + if (waitForIndexing(query, 3)) + { + cmisApi + .withQuery(query) + .assertColumnValuesRange().isReturningValuesInRange("orderCriteria", BigDecimal.ZERO, BigDecimal.ONE); + } + else + { + throw new AssertionError("Wait for indexing has failed!"); + } + + } + + /** + * Verify that SCORE is valid name for an alias + * Currently only supported with double quotes + * @throws Exception + */ + @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") + public void scoreQueryScoreAsAlias() throws Exception + { + + String query = "SELECT cmis:objectId, SCORE() AS \"score\" " + + "FROM cmis:document " + + "WHERE CONTAINS('Quidditch')"; + + if (waitForIndexing(query, 3)) + { + cmisApi + .withQuery(query).assertResultsCount().equals(3); + } + else + { + throw new AssertionError("Wait for indexing has failed!"); + } + + } + +} diff --git a/e2e-test/src/test/resources/default.properties b/e2e-test/src/test/resources/default.properties index 72d142995..f832c5e17 100644 --- a/e2e-test/src/test/resources/default.properties +++ b/e2e-test/src/test/resources/default.properties @@ -1,7 +1,7 @@ # Alfresco HTTP Server Settings alfresco.scheme=http alfresco.server=localhost -alfresco.port=8081 +alfresco.port=8080 # sync service related sync.scheme=http diff --git a/e2e-test/src/test/resources/testdata/search-score-function.xml b/e2e-test/src/test/resources/testdata/search-score-function.xml new file mode 100644 index 000000000..9c9fdc33d --- /dev/null +++ b/e2e-test/src/test/resources/testdata/search-score-function.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + Quidditch + + + Quidditch Quidditch + + + Quidditch Quidditch Quidditch + + + Some other words + + + + + + + + From 2cf0ed86da5d799a1cc3e5007c110485b87c1428 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 3 May 2019 10:13:17 +0100 Subject: [PATCH 2/8] Revert "Revert "Merge branch 'feature/SEARCH-1617_CMISScoring' into 'master'"" This reverts commit 5cedbf7f4c61c43c121ac23667edc082eb321d53. --- e2e-test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index 4f3b3230f..32b92c687 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -13,7 +13,7 @@ 6.0.0.3 6.0.0.1 - 2.0.9 + 2.0.10 2.6.0 src/test/resources/SearchSuite.xml From 244fa972e2db3dd644b52fdd57622fca56df25be Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 13 May 2019 16:17:17 +0200 Subject: [PATCH 3/8] [ SEARCH-1644 ] force e2e usage of jackson-databind 2.7.2 --- e2e-test/pom.xml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index f6f0c8256..b26020a3a 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -13,7 +13,7 @@ 6.0.0.3 6.0.0.0 - 2.0.1 + 2.0.9 2.6.0 src/test/resources/SearchSuite.xml @@ -54,12 +54,24 @@ restapi-test ${tas.rest.api.version} test + + + com.fasterxml.jackson.core + jackson-databind + + org.alfresco.tas cmis-test ${tas.cmis.api.version} test + + + com.fasterxml.jackson.core + jackson-databind + + org.alfresco @@ -67,12 +79,23 @@ ${rm.version} test + + com.fasterxml.jackson.core + jackson-databind + 2.7.2 + org.alfresco alfresco-rm-automation-community-rest-api ${rm.version} tests test + + + com.fasterxml.jackson.core + jackson-databind + + From 0a2874fb169c38d592ce5cdca41bba80357f823f Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 13 May 2019 16:58:41 +0200 Subject: [PATCH 4/8] [ SEARCH-1644 ] force e2e usage of jackson-databind 2.7.7 --- e2e-test/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index b26020a3a..7ad05dcd8 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -82,7 +82,7 @@ com.fasterxml.jackson.core jackson-databind - 2.7.2 + 2.7.7 org.alfresco From 2638be804530b3a4406d4143ddab2ef438e82449 Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 13 May 2019 17:41:33 +0200 Subject: [PATCH 5/8] [ SEARCH-1644 ] configurable version of jackson-databind --- e2e-test/pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index 7ad05dcd8..28b4f5168 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -22,6 +22,7 @@ ${java.version} ${java.version} 3.8.0 + 2.8.3 @@ -82,7 +83,7 @@ com.fasterxml.jackson.core jackson-databind - 2.7.7 + ${jackson.databind.version} org.alfresco From f8fc9c0f4976ea0062f99073dcfd0976cfc1336f Mon Sep 17 00:00:00 2001 From: agazzarini Date: Mon, 13 May 2019 17:47:15 +0200 Subject: [PATCH 6/8] [ SEARCH-1644 ] configurable version of jackson-databind + TAS utility dep --- e2e-test/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index 28b4f5168..c098d3411 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -13,7 +13,7 @@ 6.0.0.3 6.0.0.0 - 2.0.9 + 2.0.10 2.6.0 src/test/resources/SearchSuite.xml @@ -22,7 +22,7 @@ ${java.version} ${java.version} 3.8.0 - 2.8.3 + 2.7.7 From 5c92d34fe86713efc2ae3e5a19abbffddebe3969 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 17 May 2019 09:49:07 +0100 Subject: [PATCH 7/8] Updated to get score test working --- e2e-test/pom.xml | 2 +- e2e-test/src/test/resources/default.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e-test/pom.xml b/e2e-test/pom.xml index c098d3411..12f4bfbb7 100644 --- a/e2e-test/pom.xml +++ b/e2e-test/pom.xml @@ -12,7 +12,7 @@ Test Project to test Search Service and Analytics Features on a complete setup of Alfresco, Share 6.0.0.3 - 6.0.0.0 + 6.0.0.1 2.0.10 2.6.0 src/test/resources/SearchSuite.xml diff --git a/e2e-test/src/test/resources/default.properties b/e2e-test/src/test/resources/default.properties index f832c5e17..72d142995 100644 --- a/e2e-test/src/test/resources/default.properties +++ b/e2e-test/src/test/resources/default.properties @@ -1,7 +1,7 @@ # Alfresco HTTP Server Settings alfresco.scheme=http alfresco.server=localhost -alfresco.port=8080 +alfresco.port=8081 # sync service related sync.scheme=http From 40edc4782989c41d1e2c0c04a2c806b8d723042f Mon Sep 17 00:00:00 2001 From: Angel Borroy Date: Fri, 17 May 2019 13:50:52 +0200 Subject: [PATCH 8/8] Move scoring tests to ASS_14 --- .../searchServices/cmis/SolrSearchScoreQueryTests.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java index 11726579a..5df0abd22 100644 --- a/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java +++ b/e2e-test/src/test/java/org/alfresco/test/search/functional/searchServices/cmis/SolrSearchScoreQueryTests.java @@ -70,7 +70,7 @@ public class SolrSearchScoreQueryTests extends AbstractCmisE2ETest * Verify that results are ordered * @throws Exception */ - @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") + @Test(groups = { TestGroup.ASS_14, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") public void scoreQueryOrdered() throws Exception { @@ -96,7 +96,7 @@ public class SolrSearchScoreQueryTests extends AbstractCmisE2ETest * Verify that results are inverse ordered * @throws Exception */ - @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") + @Test(groups = { TestGroup.ASS_14, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") public void scoreQueryOrderedDesc() throws Exception { @@ -121,7 +121,7 @@ public class SolrSearchScoreQueryTests extends AbstractCmisE2ETest * Verify that all SCORE results are between 0 and 1 * @throws Exception */ - @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") + @Test(groups = { TestGroup.ASS_14, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") public void scoreQueryInRange() throws Exception { @@ -146,7 +146,7 @@ public class SolrSearchScoreQueryTests extends AbstractCmisE2ETest * Verify that all SCORE results are between 0 and 1 * @throws Exception */ - @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") + @Test(groups = { TestGroup.ASS_14, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") public void scoreQueryAliasInRange() throws Exception { @@ -172,7 +172,7 @@ public class SolrSearchScoreQueryTests extends AbstractCmisE2ETest * Currently only supported with double quotes * @throws Exception */ - @Test(groups = { TestGroup.CMIS, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") + @Test(groups = { TestGroup.ASS_14, TestGroup.QUERIES }, dependsOnMethods = "prepareDataForScoreSearch") public void scoreQueryScoreAsAlias() throws Exception {