Skip to content

Commit ae71cf4

Browse files
committed
✨ Completed instructions for integration testing container
Created and tested instructions for creating an integration testing container that allows all the integration tests that run by default to pass. The container image has all the necessary sample files placed on disk and all the necessary sample files deployed to AEM. In theory, this would allow the integration tests to be run as part of a GitHub action if the test container image were available however because AEM is proprietary, an AEM image cannot be placed in a publicly accessible location.
1 parent f5caf46 commit ae71cf4

4 files changed

Lines changed: 47 additions & 4 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Creating `deploy_it_assets.jar`
2+
3+
Execute the following command from this directory to create the necessary `deploy_it_assets.jar` file in the ff_it_files directory:
4+
`jbang export fatjar --verbose --output ..\test_containers\ff_it_files\deploy_it_assets.jar .\deploy_it_assets.java`
5+
6+
# Developer Tips
7+
8+
When making changes to the script, it is helpful if you execute the following command to create a maven project under
9+
the current directory. You can them import that project in Eclipse and work with the code like normal Java code
10+
(taking advantage of Eclipse's incremental compilation, error messages, etc.).
11+
12+
`jbang export maven .\deploy_it_assets.java`
13+
14+
When you have completed your change, you can copy/paste the modified code back into the original deploy_it_assets.java and delete
15+
the maven project in Eclipse (checking the box to delete the files on disk).

rest-services/jbang_scripts/deploy_it_assets.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,15 @@
55
//DEPS org.slf4j:slf4j-simple:2.0.17
66
//JAVA 21+
77

8+
package com._4point.aem.fluentforms.deploy_it_assets;
9+
810
import picocli.CommandLine;
911
import picocli.CommandLine.Command;
1012
import picocli.CommandLine.Parameters;
1113

14+
import java.nio.file.Files;
1215
import java.nio.file.Path;
16+
import java.util.List;
1317
import java.util.concurrent.Callable;
1418

1519
import com._4point.aem.package_manager.FormsAndDocumentsClient;
@@ -24,7 +28,8 @@ class deploy_it_assets implements Callable<Integer> {
2428
private static final String AEM_SERVER_USER = "admin";
2529
private static final String AEM_SERVER_PASSWORD = "admin";
2630
private static final Path REST_SERVICES_PROJECT_DIR = Path.of("..");
27-
private static final Path SAMPLES_DIR = REST_SERVICES_PROJECT_DIR.resolve(Path.of("test_containers", "ff_it_files"));
31+
private static final List<Path> SAMPLES_DIRS_LIST = List.of(Path.of("/opt", "adobe", "ff_it_files"), REST_SERVICES_PROJECT_DIR.resolve(Path.of("test_containers", "ff_it_files")));
32+
private static final Path SAMPLES_DIR = findSamplesDir(SAMPLES_DIRS_LIST);
2833
private static final Path AF_TEST_FORMS_PATH = SAMPLES_DIR.resolve("sample00002test.zip");
2934
private static final Path OF_TEST_FORMS_PATH = SAMPLES_DIR.resolve("SampleForm.xdp");
3035

@@ -96,4 +101,15 @@ public Integer call() throws Exception { // your business logic goes here...
96101

97102
return 0;
98103
}
104+
105+
private static Path findSamplesDir(List<Path> samplesDirsList) {
106+
return samplesDirsList.stream()
107+
.filter(dir -> dir.toFile().isDirectory() && isSamplesDir(dir))
108+
.findFirst()
109+
.orElseThrow(() -> new IllegalStateException("Could not find a valid samples directory in: " + samplesDirsList));
110+
}
111+
112+
private static boolean isSamplesDir(Path dir) {
113+
return Files.exists(dir.resolve("sample00002test.zip")) && Files.exists(dir.resolve("SampleForm.xdp"));
114+
}
99115
}
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
In order to create an integration test container image, using the `ff_it_test` dockerfile, perform the following steps:
22

3-
1. Alter the first line of the `ff_it_test.dockerfile` file to use the desired AEM base container image.
4-
2. Run `docker buildx build --file ff_it_test.dockerfile -t aem_lts_it_tests:aem65lts_it_tests .` to create the integration test image.
3+
1. Create the `deploy_it_assets.jar` file in `ff_it_files` by following the "Creating deploy_it_assets.jar" instructions in `jbang_scripts\README.md`.
4+
(This step is required because the .jar is not stored in the GitHub repository but it is required in order for the dockerfile to run.)
5+
2. Alter the first line of the `ff_it_test.dockerfile` file to use the desired AEM base container image.
6+
3. Run `docker buildx build --file ff_it_test.dockerfile -t aem_lts_it_tests:aem65lts_it_tests .` to create the integration test image.
7+
8+
After performing these steps then the integration tests should run successfully after `TestUtils.java` is modified to set
9+
`AEM_TARGET_TYPE` to be `AemTargetType.TESTCONTAINERS`. If the name of the integration test container image is
10+
different than the one in the steps above, then `AEM_IMAGE_NAME` may also need to be modified.

rest-services/test_containers/ff_it_test.dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM aem_lts:aem65lts AS ff_it_test
1+
FROM aem:aem65lts AS ff_it_test
22

33
ENV container="aem-lts-quickstart,aem-author,ubuntu,java21"
44

@@ -9,6 +9,12 @@ RUN mkdir -p /opt/adobe/ff_it_files
99

1010
COPY ff_it_files/* /opt/adobe/ff_it_files
1111

12+
RUN /bin/bash -c "/opt/adobe/AEM*/runStart ; \
13+
jbang --java=21 /opt/adobe/aem_cntrl-0.0.1-SNAPSHOT.jar wflog --startup ; \
14+
jbang --java=21 /opt/adobe/ff_it_files/deploy_it_assets.jar ; \
15+
/opt/adobe/AEM*/runStop ; \
16+
jbang --java=21 /opt/adobe/aem_cntrl-0.0.1-SNAPSHOT.jar wflog --shutdown"
17+
1218
#NOTE: make sure to copy admin.password.file and license.properties files to the /opt/aem-config folder.
1319
# VOLUME ["/opt/aem-config/"]
1420
#VOLUME ["/opt/adobe/???/crx-quickstart/logs"]

0 commit comments

Comments
 (0)