From 3dd5fecd8fd8ab81a2234458b63360093d6c5aee Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Thu, 10 Jun 2021 16:05:15 +0100 Subject: [PATCH] ACS-1646 Reduce time to buid AGS jobs in repo projects (#526) Having added AGS to the community repo project two of the build jobs were take a long time to run in comparison to others: AGS Unit & Integration Tests (MySQL) ~ 1hr AGS Unit & Integration Tests (PostgreSQL) ~ 45mins Having split the jobs in this commit, the individual job times are now comparable to the other jobs and the total build time is reduced by ~30 mins. The same number of integration tests (418) are run 196+127+95 across the three jobs for each database. --- .travis.yml | 24 ++++- .../rm-community/rm-community-repo/pom.xml | 21 +++- ...AllTestSuite.java => AllTestSuitePt1.java} | 21 ++-- .../test/AllTestSuitePt2.java | 75 ++++++++++++++ .../test/AllTestSuitePt3.java | 99 +++++++++++++++++++ 5 files changed, 229 insertions(+), 11 deletions(-) rename amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/{AllTestSuite.java => AllTestSuitePt1.java} (69%) create mode 100644 amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt2.java create mode 100644 amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt3.java diff --git a/.travis.yml b/.travis.yml index 2fccd4cc6a..55b92cfc33 100644 --- a/.travis.yml +++ b/.travis.yml @@ -301,13 +301,29 @@ jobs: - docker run -d -p 5433:5432 -e POSTGRES_PASSWORD=alfresco -e POSTGRES_USER=alfresco -e POSTGRES_DB=alfresco postgres:13.1 postgres -c 'max_connections=300' script: travis_wait 20 mvn -B test -pl :alfresco-share-services -Dtest=ShareServicesTestSuite -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql://localhost:5433/alfresco -Ddb.username=alfresco -Ddb.password=alfresco - - name: "AGS Unit & Integration Tests (PostgreSQL)" + - name: "AGS Unit & Integration Tests 01 (PostgreSQL)" if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ - script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -f amps/ags/pom.xml ${LOG_WARN} + script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt1 -f amps/ags/pom.xml ${LOG_WARN} - - name: "AGS Unit & Integration Tests (MySQL) " + - name: "AGS Integration Tests 02 (PostgreSQL)" + if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ + script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt2 -f amps/ags/pom.xml ${LOG_WARN} + + - name: "AGS Integration Tests 03 (PostgreSQL)" + if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ + script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-postgres -PagsAllTestSuitePt3 -f amps/ags/pom.xml ${LOG_WARN} + + - name: "AGS Unit & Integration Tests 01 (MySQL) " if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ - script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql -f amps/ags/pom.xml ${LOG_WARN} + script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql -PagsAllTestSuitePt1 -f amps/ags/pom.xml ${LOG_WARN} + + - name: "AGS Integration Tests 02 (MySQL) " + if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ + script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql -PagsAllTestSuitePt2 -f amps/ags/pom.xml ${LOG_WARN} + + - name: "AGS Integration Tests 03 (MySQL) " + if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags on MySQL\]/ + script: travis_retry travis_wait 80 mvn -B verify -Dmaven.javadoc.skip=true -Dmaven.source.skip=true -Pags -Pstart-mysql -PagsAllTestSuitePt3 -f amps/ags/pom.xml ${LOG_WARN} - name: "AGS Community Rest API Tests" if: (branch =~ /(release\/.*$|master)/ AND commit_message !~ /\[skip ags\]/) OR commit_message =~ /\[ags\]/ diff --git a/amps/ags/rm-community/rm-community-repo/pom.xml b/amps/ags/rm-community/rm-community-repo/pom.xml index 56e409390e..afd502d6b1 100644 --- a/amps/ags/rm-community/rm-community-repo/pom.xml +++ b/amps/ags/rm-community/rm-community-repo/pom.xml @@ -248,7 +248,7 @@ ${project.build.directory}/alf-data-test - **/AllTestSuite.class + ${integrationTestSuite} ${project.build.directory}/${project.build.finalName}/config @@ -331,6 +331,25 @@ + + agsAllTestSuitePt1 + + **/AllTestSuitePt1.class + + + + agsAllTestSuitePt2 + + **/AllTestSuitePt2.class + + + + agsAllTestSuitePt3 + + **/AllTestSuitePt3.class + + + use-mysql diff --git a/amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuite.java b/amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt1.java similarity index 69% rename from amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuite.java rename to amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt1.java index 1c3b93e44e..e2d851643e 100644 --- a/amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuite.java +++ b/amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt1.java @@ -24,7 +24,6 @@ * along with Alfresco. If not, see . * #L% */ - package org.alfresco.module.org_alfresco_module_rm.test; import org.junit.extensions.cpsuite.ClasspathSuite; @@ -34,7 +33,7 @@ import org.junit.extensions.cpsuite.SuiteType; import org.junit.runner.RunWith; /** - * Convenience test suite that runs all the tests. + * Convenience test suite that runs all the tests. THIS HAS BEEN SPLIT INTO PARTS SO THAT THE BUILD TIME IS REDUCED. * * @author Roy Wetherall * @since 2.1 @@ -42,10 +41,20 @@ import org.junit.runner.RunWith; @RunWith(ClasspathSuite.class) @SuiteTypes({SuiteType.TEST_CLASSES, SuiteType.RUN_WITH_CLASSES, SuiteType.JUNIT38_TEST_CLASSES}) @ClassnameFilters({ - // Execute all test classes ending with "Test" - ".*Test", - // Exclude the ones ending with "UnitTest" + + // The following packages are run by Pt1. IF YOU CHANGE THIS LIST ALSO CHANGE IT IN AllTestSuitePt3. + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.action\\..*Test", + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.capabilities\\..*Test", + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.jscript\\..*Test", + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.security\\..*Test", + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.service\\..*Test", + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.webscript\\..*Test", + // There appears to be some common setup taking place in the first 2 packages, which is why all legacy tests are + // together even though they take a little longer to run that way. + + // Exclude all UnitTests "!.*UnitTest", + // Put the test classes you want to exclude here "!.*DataLoadSystemTest", "!.*RM2072Test", @@ -63,6 +72,6 @@ import org.junit.runner.RunWith; // Tests should not be dependant on other test classes and should run in any order without any problems. "!.*EmailMapScriptTest" }) -public class AllTestSuite +public class AllTestSuitePt1 { } diff --git a/amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt2.java b/amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt2.java new file mode 100644 index 0000000000..e58a53cb1e --- /dev/null +++ b/amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt2.java @@ -0,0 +1,75 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2021 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.test; + +import org.junit.extensions.cpsuite.ClasspathSuite; +import org.junit.extensions.cpsuite.ClasspathSuite.ClassnameFilters; +import org.junit.extensions.cpsuite.ClasspathSuite.SuiteTypes; +import org.junit.extensions.cpsuite.SuiteType; +import org.junit.runner.RunWith; + +/** + * Convenience test suite that runs all the tests. THIS HAS BEEN SPLIT INTO PARTS SO THAT THE BUILD TIME IS REDUCED. + * + * @author Roy Wetherall + * @since 2.1 + */ +@RunWith(ClasspathSuite.class) +@SuiteTypes({SuiteType.TEST_CLASSES, SuiteType.RUN_WITH_CLASSES, SuiteType.JUNIT38_TEST_CLASSES}) +@ClassnameFilters({ + + // The following packages are run by Pt2. IF YOU CHANGE THIS LIST ALSO CHANGE IT IN AllTestSuitePt3. + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.destroy\\..*Test", + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.disposition\\..*Test", + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.dod\\..*Test", + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.event\\..*Test", + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.hold\\..*Test", + "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.issue\\..*Test", + + // Exclude all UnitTests + "!.*UnitTest", + + // Put the test classes you want to exclude here + "!.*DataLoadSystemTest", + "!.*RM2072Test", + "!.*RM2190Test", + "!.*RM981SystemTest", + "!.*RM3993Test", + "!.*RM4163Test", + "!.*RecordsManagementEventServiceImplTest", + "!.*RmRestApiTest", + "!.*NotificationServiceHelperSystemTest", + "!.*RetryingTransactionHelperBaseTest", + "!.*RMCaveatConfigServiceImplTest", + // This test is running successfully locally but not on bamboo (if executed as a single test). + // The problem can be reproduced if the whole test suite is run locally as well. + // Tests should not be dependant on other test classes and should run in any order without any problems. + "!.*EmailMapScriptTest" +}) +public class AllTestSuitePt2 +{ +} diff --git a/amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt3.java b/amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt3.java new file mode 100644 index 0000000000..18d3367cb2 --- /dev/null +++ b/amps/ags/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/AllTestSuitePt3.java @@ -0,0 +1,99 @@ +/* + * #%L + * Alfresco Records Management Module + * %% + * Copyright (C) 2005 - 2021 Alfresco Software Limited + * %% + * This file is part of the Alfresco software. + * - + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * - + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * - + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * - + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + * #L% + */ +package org.alfresco.module.org_alfresco_module_rm.test; + +import org.junit.extensions.cpsuite.ClasspathSuite; +import org.junit.extensions.cpsuite.ClasspathSuite.ClassnameFilters; +import org.junit.extensions.cpsuite.ClasspathSuite.SuiteTypes; +import org.junit.extensions.cpsuite.SuiteType; +import org.junit.runner.RunWith; + +/** + * Convenience test suite that runs all the tests. THIS HAS BEEN SPLIT INTO PARTS SO THAT THE BUILD TIME IS REDUCED. + * + * @author Roy Wetherall + * @since 2.1 + */ +@RunWith(ClasspathSuite.class) +@SuiteTypes({SuiteType.TEST_CLASSES, SuiteType.RUN_WITH_CLASSES, SuiteType.JUNIT38_TEST_CLASSES}) +@ClassnameFilters({ + + // Use a catch all for tests and then exclude those in other parts in case someone forgets to add a package. + ".*Test", + + // The following packages are run by Pt1 + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.action\\..*Test", + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.capabilities\\..*Test", + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.jscript\\..*Test", + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.security\\..*Test", + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.service\\..*Test", + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.legacy\\.webscript\\..*Test", + + // The following packages are run by Pt2 + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.destroy\\..*Test", + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.disposition\\..*Test", + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.dod\\..*Test", + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.event\\..*Test", + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.hold\\..*Test", + "!org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.issue\\..*Test", + + // The following packages 'should' be run by Pt3 + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.issue\\.rm3314\\..*Test", + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.record\\..*Test", + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.recordfolder\\..*Test", + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.relationship\\..*Test", + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.report\\..*Test", + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.rule\\..*Test", + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.transfer\\..*Test", + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.integration\\.version\\..*Test", + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.system\\..*Test", + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.util\\..*Test", + // "org\\.alfresco\\.module\\.org_alfresco_module_rm\\.test\\.util\\.bdt\\..*Test", + + // Exclude all UnitTests + "!.*UnitTest", + + // Put the test classes you want to exclude here + "!.*DataLoadSystemTest", + "!.*RM2072Test", + "!.*RM2190Test", + "!.*RM981SystemTest", + "!.*RM3993Test", + "!.*RM4163Test", + "!.*RecordsManagementEventServiceImplTest", + "!.*RmRestApiTest", + "!.*NotificationServiceHelperSystemTest", + "!.*RetryingTransactionHelperBaseTest", + "!.*RMCaveatConfigServiceImplTest", + // This test is running successfully locally but not on bamboo (if executed as a single test). + // The problem can be reproduced if the whole test suite is run locally as well. + // Tests should not be dependant on other test classes and should run in any order without any problems. + "!.*EmailMapScriptTest" +}) +public class AllTestSuitePt3 +{ +}