From 0903496f58ede8c4cde47c1fc627f391cf64114c Mon Sep 17 00:00:00 2001 From: Robrecht Vanhuysse Date: Wed, 18 Dec 2024 15:43:00 +0100 Subject: [PATCH 1/5] Add bootstrap for well-known node for testing --- .../eu/xenit/apix/bootstrap/Bootstrap.java | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 apix-integrationtests/alfresco/src/main/java/eu/xenit/apix/bootstrap/Bootstrap.java diff --git a/apix-integrationtests/alfresco/src/main/java/eu/xenit/apix/bootstrap/Bootstrap.java b/apix-integrationtests/alfresco/src/main/java/eu/xenit/apix/bootstrap/Bootstrap.java new file mode 100644 index 00000000..4194e508 --- /dev/null +++ b/apix-integrationtests/alfresco/src/main/java/eu/xenit/apix/bootstrap/Bootstrap.java @@ -0,0 +1,65 @@ +package eu.xenit.apix.bootstrap; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import org.alfresco.model.ContentModel; +import org.alfresco.repo.nodelocator.CompanyHomeNodeLocator; +import org.alfresco.repo.nodelocator.NodeLocatorService; +import org.alfresco.repo.security.authentication.AuthenticationUtil; +import org.alfresco.repo.transaction.RetryingTransactionHelper; +import org.alfresco.service.cmr.repository.NodeRef; +import org.alfresco.service.cmr.repository.NodeService; +import org.alfresco.service.namespace.NamespaceService; +import org.alfresco.service.namespace.QName; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class Bootstrap implements InitializingBean { + + public static final String WELL_KNOWN_TESTNODE_NAME = "well-known-testnode"; + + private RetryingTransactionHelper transactionHelper; + private NodeLocatorService nodeLocator; + private NodeService nodeService; + + @Autowired + public Bootstrap( + RetryingTransactionHelper retryingTransactionHelper, + NodeLocatorService nodeLocatorService, + NodeService nodeService + ) { + this.transactionHelper = retryingTransactionHelper; + this.nodeLocator = nodeLocatorService; + this.nodeService = nodeService; + } + + @Override + public void afterPropertiesSet() throws Exception { + AuthenticationUtil.runAsSystem( + () -> transactionHelper.doInTransaction( + () -> { + NodeRef companyHome = nodeLocator.getNode(CompanyHomeNodeLocator.NAME, null, null); + NodeRef wellKnownTestNode = nodeService.getChildByName(companyHome, ContentModel.ASSOC_CONTAINS, WELL_KNOWN_TESTNODE_NAME); + if (wellKnownTestNode == null) { + Map folderProperties = new HashMap<>(); + folderProperties.put(ContentModel.PROP_NAME, WELL_KNOWN_TESTNODE_NAME); + folderProperties.put(ContentModel.PROP_NODE_UUID, WELL_KNOWN_TESTNODE_NAME); + nodeService.createNode( + companyHome, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, WELL_KNOWN_TESTNODE_NAME), + ContentModel.TYPE_FOLDER, + folderProperties + ); + } + return null; + }, + false, + true + ) + ); + } +} From 4980bf284f3cd8497199bab421cf01083a6366df Mon Sep 17 00:00:00 2001 From: Robrecht Vanhuysse Date: Wed, 18 Dec 2024 15:43:32 +0100 Subject: [PATCH 2/5] Update docker gradle plugins --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 0099b440..f1b4ae2f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,8 +4,8 @@ plugins { id 'eu.xenit.de' version '3.1.0' apply false id 'eu.xenit.amp' version '1.1.0' apply false id 'eu.xenit.alfresco' version '1.1.0' apply false - id 'eu.xenit.docker-alfresco' version '5.3.1' apply false - id 'eu.xenit.docker-compose' version '5.3.1' apply false + id 'eu.xenit.docker-alfresco' version '5.5.0' apply false + id 'eu.xenit.docker-compose' version '5.5.0' apply false id 'eu.xenit.alfresco-remote-testrunner' version '2.0.1' apply false } From a41b570535cb8eeeb17107ac60aacf31aa026da8 Mon Sep 17 00:00:00 2001 From: Robrecht Vanhuysse Date: Wed, 18 Dec 2024 15:45:44 +0100 Subject: [PATCH 3/5] Add OrderOfTheBee support tools for debugging --- apix-docker/build.gradle | 1 + build.gradle | 1 + 2 files changed, 2 insertions(+) diff --git a/apix-docker/build.gradle b/apix-docker/build.gradle index 79c91f88..c5b9b06a 100644 --- a/apix-docker/build.gradle +++ b/apix-docker/build.gradle @@ -18,6 +18,7 @@ subprojects { alfrescoSM "com.gradecak.alfresco-mvc:alfresco-mvc-aop:${mvc}" alfrescoSM files(jar) alfrescoAmp "eu.xenit:alfresco-dynamic-extensions-repo-${subproject_alfresco_version}:${de_version}@amp" + alfrescoAmp "org.orderofthebee.support-tools:support-tools-repo:${ootbee_version}:amp@amp" } dockerCompose { diff --git a/build.gradle b/build.gradle index f1b4ae2f..54b4388c 100644 --- a/build.gradle +++ b/build.gradle @@ -23,6 +23,7 @@ ext { jackson_version = '2.8.3' care4alfVersion = '2.3.0' http_version = '4.3.4' // Used by integration tests + ootbee_version = '1.2.2.0' // Used in docker image for testing } subprojects { From 2dc5070b8a2b37f14e798c9b5a1434876f8ff4a8 Mon Sep 17 00:00:00 2001 From: Robrecht Vanhuysse Date: Wed, 18 Dec 2024 15:46:49 +0100 Subject: [PATCH 4/5] Add default acs image to docker-compose to allow composeDown to run without saved DOCKER_IMAGE value --- apix-docker/70/docker-compose.yml | 2 +- apix-docker/71/docker-compose.yml | 2 +- apix-docker/72/docker-compose.yml | 2 +- apix-docker/73/docker-compose.yml | 2 +- apix-docker/74/docker-compose.yml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apix-docker/70/docker-compose.yml b/apix-docker/70/docker-compose.yml index af551880..60f4dc17 100644 --- a/apix-docker/70/docker-compose.yml +++ b/apix-docker/70/docker-compose.yml @@ -2,7 +2,7 @@ version: '2' services: alfresco-core: - image: ${DOCKER_IMAGE} + image: ${DOCKER_IMAGE:-private.docker.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:7.0} ports: - "${DOCKER_IP}:8080:8080" volumes: diff --git a/apix-docker/71/docker-compose.yml b/apix-docker/71/docker-compose.yml index af551880..f1f33720 100644 --- a/apix-docker/71/docker-compose.yml +++ b/apix-docker/71/docker-compose.yml @@ -2,7 +2,7 @@ version: '2' services: alfresco-core: - image: ${DOCKER_IMAGE} + image: ${DOCKER_IMAGE:-private.docker.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:7.1} ports: - "${DOCKER_IP}:8080:8080" volumes: diff --git a/apix-docker/72/docker-compose.yml b/apix-docker/72/docker-compose.yml index af551880..ba795747 100644 --- a/apix-docker/72/docker-compose.yml +++ b/apix-docker/72/docker-compose.yml @@ -2,7 +2,7 @@ version: '2' services: alfresco-core: - image: ${DOCKER_IMAGE} + image: ${DOCKER_IMAGE:-private.docker.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:7.2} ports: - "${DOCKER_IP}:8080:8080" volumes: diff --git a/apix-docker/73/docker-compose.yml b/apix-docker/73/docker-compose.yml index 1260a213..409e8d47 100644 --- a/apix-docker/73/docker-compose.yml +++ b/apix-docker/73/docker-compose.yml @@ -2,7 +2,7 @@ version: '2' services: alfresco-core: - image: ${DOCKER_IMAGE} + image: ${DOCKER_IMAGE:-private.docker.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:7.3} ports: - "${DOCKER_IP}:8080:8080" volumes: diff --git a/apix-docker/74/docker-compose.yml b/apix-docker/74/docker-compose.yml index 8e88c690..f2d5242c 100644 --- a/apix-docker/74/docker-compose.yml +++ b/apix-docker/74/docker-compose.yml @@ -2,7 +2,7 @@ version: '2' services: alfresco-core: - image: ${DOCKER_IMAGE} + image: ${DOCKER_IMAGE:-private.docker.xenit.eu/alfresco-enterprise/alfresco-repository-enterprise:7.4} ports: - "${DOCKER_IP}:8080:8080" volumes: From 9262989f49057813e5de04ecc7fdcb548aa708d7 Mon Sep 17 00:00:00 2001 From: Robrecht Vanhuysse Date: Wed, 18 Dec 2024 16:16:20 +0100 Subject: [PATCH 5/5] Only enable integrationtest bootstrap class locally through alf global property --- .../70/debug-extension.docker-compose.yml | 1 + .../71/debug-extension.docker-compose.yml | 1 + .../72/debug-extension.docker-compose.yml | 1 + .../73/debug-extension.docker-compose.yml | 1 + .../74/debug-extension.docker-compose.yml | 1 + .../eu/xenit/apix/bootstrap/Bootstrap.java | 58 +++++++++++-------- 6 files changed, 39 insertions(+), 24 deletions(-) diff --git a/apix-docker/70/debug-extension.docker-compose.yml b/apix-docker/70/debug-extension.docker-compose.yml index 63632e73..2460a823 100644 --- a/apix-docker/70/debug-extension.docker-compose.yml +++ b/apix-docker/70/debug-extension.docker-compose.yml @@ -6,6 +6,7 @@ services: environment: - DEBUG=true - SHARE_HOST=alfresco-share + - GLOBAL_eu.xenit.apix.integrationtest.bootstrap=true alfresco-share: image: hub.xenit.eu/public/alfresco-share-community:7.0.0 ports: diff --git a/apix-docker/71/debug-extension.docker-compose.yml b/apix-docker/71/debug-extension.docker-compose.yml index fd8a2fe3..75b4185c 100644 --- a/apix-docker/71/debug-extension.docker-compose.yml +++ b/apix-docker/71/debug-extension.docker-compose.yml @@ -6,6 +6,7 @@ services: environment: - DEBUG=true - SHARE_HOST=alfresco-share + - GLOBAL_eu.xenit.apix.integrationtest.bootstrap=true alfresco-share: image: hub.xenit.eu/public/alfresco-share-community:7.1 ports: diff --git a/apix-docker/72/debug-extension.docker-compose.yml b/apix-docker/72/debug-extension.docker-compose.yml index 3abe9e60..ba1c0702 100644 --- a/apix-docker/72/debug-extension.docker-compose.yml +++ b/apix-docker/72/debug-extension.docker-compose.yml @@ -6,6 +6,7 @@ services: environment: - DEBUG=true - SHARE_HOST=alfresco-share + - GLOBAL_eu.xenit.apix.integrationtest.bootstrap=true alfresco-share: image: hub.xenit.eu/public/alfresco-share-community:7.2 ports: diff --git a/apix-docker/73/debug-extension.docker-compose.yml b/apix-docker/73/debug-extension.docker-compose.yml index 72895807..afb0deb9 100644 --- a/apix-docker/73/debug-extension.docker-compose.yml +++ b/apix-docker/73/debug-extension.docker-compose.yml @@ -6,6 +6,7 @@ services: environment: - DEBUG=true - SHARE_HOST=alfresco-share + - GLOBAL_eu.xenit.apix.integrationtest.bootstrap=true alfresco-share: image: docker.io/xenit/alfresco-share-community:7.3 ports: diff --git a/apix-docker/74/debug-extension.docker-compose.yml b/apix-docker/74/debug-extension.docker-compose.yml index 825ba2ab..5e4964c7 100644 --- a/apix-docker/74/debug-extension.docker-compose.yml +++ b/apix-docker/74/debug-extension.docker-compose.yml @@ -6,6 +6,7 @@ services: environment: - DEBUG=true - SHARE_HOST=alfresco-share + - GLOBAL_eu.xenit.apix.integrationtest.bootstrap=true alfresco-share: image: docker.io/xenit/alfresco-share-community:7.4 ports: diff --git a/apix-integrationtests/alfresco/src/main/java/eu/xenit/apix/bootstrap/Bootstrap.java b/apix-integrationtests/alfresco/src/main/java/eu/xenit/apix/bootstrap/Bootstrap.java index 4194e508..5214e421 100644 --- a/apix-integrationtests/alfresco/src/main/java/eu/xenit/apix/bootstrap/Bootstrap.java +++ b/apix-integrationtests/alfresco/src/main/java/eu/xenit/apix/bootstrap/Bootstrap.java @@ -3,6 +3,7 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; +import java.util.Properties; import org.alfresco.model.ContentModel; import org.alfresco.repo.nodelocator.CompanyHomeNodeLocator; import org.alfresco.repo.nodelocator.NodeLocatorService; @@ -14,52 +15,61 @@ import org.alfresco.service.namespace.QName; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @Component public class Bootstrap implements InitializingBean { public static final String WELL_KNOWN_TESTNODE_NAME = "well-known-testnode"; + private static final String ENABLED_GLOBAL_PROPERTIES_KEY = "eu.xenit.apix.integrationtest.bootstrap.enabled"; private RetryingTransactionHelper transactionHelper; private NodeLocatorService nodeLocator; private NodeService nodeService; + private Properties globalProperties; @Autowired public Bootstrap( RetryingTransactionHelper retryingTransactionHelper, NodeLocatorService nodeLocatorService, - NodeService nodeService + NodeService nodeService, + @Qualifier("global-properties") Properties globalProperties ) { this.transactionHelper = retryingTransactionHelper; this.nodeLocator = nodeLocatorService; this.nodeService = nodeService; + this.globalProperties = globalProperties; } @Override public void afterPropertiesSet() throws Exception { - AuthenticationUtil.runAsSystem( - () -> transactionHelper.doInTransaction( - () -> { - NodeRef companyHome = nodeLocator.getNode(CompanyHomeNodeLocator.NAME, null, null); - NodeRef wellKnownTestNode = nodeService.getChildByName(companyHome, ContentModel.ASSOC_CONTAINS, WELL_KNOWN_TESTNODE_NAME); - if (wellKnownTestNode == null) { - Map folderProperties = new HashMap<>(); - folderProperties.put(ContentModel.PROP_NAME, WELL_KNOWN_TESTNODE_NAME); - folderProperties.put(ContentModel.PROP_NODE_UUID, WELL_KNOWN_TESTNODE_NAME); - nodeService.createNode( - companyHome, - ContentModel.ASSOC_CONTAINS, - QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, WELL_KNOWN_TESTNODE_NAME), - ContentModel.TYPE_FOLDER, - folderProperties - ); - } - return null; - }, - false, - true - ) - ); + if (Boolean.parseBoolean(globalProperties.getProperty(ENABLED_GLOBAL_PROPERTIES_KEY))) { + AuthenticationUtil.runAsSystem( + () -> transactionHelper.doInTransaction( + () -> { + NodeRef companyHome = nodeLocator.getNode(CompanyHomeNodeLocator.NAME, null, null); + NodeRef wellKnownTestNode = nodeService.getChildByName(companyHome, + ContentModel.ASSOC_CONTAINS, WELL_KNOWN_TESTNODE_NAME); + if (wellKnownTestNode == null) { + Map folderProperties = new HashMap<>(); + folderProperties.put(ContentModel.PROP_NAME, WELL_KNOWN_TESTNODE_NAME); + folderProperties.put(ContentModel.PROP_NODE_UUID, WELL_KNOWN_TESTNODE_NAME); + nodeService.createNode( + companyHome, + ContentModel.ASSOC_CONTAINS, + QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, + WELL_KNOWN_TESTNODE_NAME), + ContentModel.TYPE_FOLDER, + folderProperties + ); + } + return null; + }, + false, + true + ) + ); + } } }