diff --git a/engines/aio/pom.xml b/engines/aio/pom.xml
index f30fd1a9e..7920964f6 100644
--- a/engines/aio/pom.xml
+++ b/engines/aio/pom.xml
@@ -132,6 +132,11 @@
com.google.guava
guava
+
+ org.testcontainers
+ testcontainers
+ test
+
diff --git a/engines/aio/src/test/java/org/alfresco/transform/aio/AIOLivenessReadinessProbeIT.java b/engines/aio/src/test/java/org/alfresco/transform/aio/AIOLivenessReadinessProbeIT.java
new file mode 100644
index 000000000..5f18b3081
--- /dev/null
+++ b/engines/aio/src/test/java/org/alfresco/transform/aio/AIOLivenessReadinessProbeIT.java
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * Alfresco Transform Core
+ * %%
+ * Copyright (C) 2005 - 2023 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.transform.aio;
+
+import org.alfresco.transform.base.LivenessReadinessProbeTest;
+
+public class AIOLivenessReadinessProbeIT extends LivenessReadinessProbeTest {
+ @Override
+ protected LivenessReadinessProbeTest.ImagesForTests getImageForTest() {
+ return new ImagesForTests("alfresco-transform-core-aio", "text/plain", "text/plain", "original.txt");
+ }
+}
diff --git a/engines/base/pom.xml b/engines/base/pom.xml
index 326bbbf38..4634ab283 100644
--- a/engines/base/pom.xml
+++ b/engines/base/pom.xml
@@ -97,6 +97,11 @@
4.2.0
test
+
+ org.testcontainers
+ testcontainers
+ test
+
diff --git a/engines/base/src/test/java/org/alfresco/transform/base/LivenessReadinessProbeTest.java b/engines/base/src/test/java/org/alfresco/transform/base/LivenessReadinessProbeTest.java
new file mode 100644
index 000000000..b1bde0d1e
--- /dev/null
+++ b/engines/base/src/test/java/org/alfresco/transform/base/LivenessReadinessProbeTest.java
@@ -0,0 +1,122 @@
+package org.alfresco.transform.base;
+
+import org.junit.jupiter.api.Test;
+
+import org.springframework.core.io.ClassPathResource;
+
+import org.springframework.http.client.MultipartBodyBuilder;
+import org.springframework.test.web.reactive.server.WebTestClient;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+import java.net.URISyntaxException;
+
+import java.util.Objects;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import static org.springframework.http.HttpStatus.OK;
+import static org.springframework.http.HttpStatus.TOO_MANY_REQUESTS;
+
+import org.springframework.web.reactive.function.client.WebClient;
+
+public abstract class LivenessReadinessProbeTest
+{
+ protected final Integer MAX_TRANSFORMS = 10;
+
+ @Test
+ public void readinessShouldReturnAn429ErrorAfterReachingMaxTransforms() throws URISyntaxException
+ {
+ final ImagesForTests testData = getImageForTest();
+
+ try (final var env = createEnv(testData.image))
+ {
+ env.start();
+ var url = "http://localhost:" + env.getFirstMappedPort();
+
+ /*
+ Asserts that /ready probe hasn't died before sending a transformation request.
+ Each /ready request creates a valid transformation and increases the counter of
+ used transformations, hence the need to divide MAX_TRANSFORMS
+ */
+ for (int i = 0; i createEnv(String image) throws URISyntaxException
+ {
+ System.out.println(image);
+ final GenericContainer> transformCore = new GenericContainer<>("alfresco/"+image+":latest");
+
+ return transformCore.withEnv("livenessTransformEnabled", "true")
+ .withEnv("maxTransforms", MAX_TRANSFORMS.toString())
+ .withNetworkAliases(image)
+ .withExposedPorts(8090)
+ .waitingFor(Wait.forListeningPort());
+ }
+
+ protected static class ImagesForTests
+ {
+ private final String image;
+ private final String sourceMimetype;
+ private final String targetMimetype;
+ private final String filename;
+
+ public ImagesForTests(String image, String sourceMimetype, String targetMimetype, String filename)
+ {
+ this.image = Objects.requireNonNull(image);
+ this.sourceMimetype = Objects.requireNonNull(sourceMimetype);
+ this.targetMimetype = Objects.requireNonNull(targetMimetype);
+ this.filename = Objects.requireNonNull(filename);
+ }
+ }
+
+ private void sendTransformRequest(String url, String sourceMimetype, String targetMimetype, String filename)
+ {
+ var builder = createRequestBuilder(sourceMimetype, targetMimetype, filename);
+ WebClient client = WebClient.create();
+ WebClient.ResponseSpec responseSpec = client.post()
+ .uri(url + "/test")
+ .bodyValue(builder.build())
+ .retrieve();
+
+ System.out.println(responseSpec.toBodilessEntity().block());
+ assertEquals(OK, responseSpec.toBodilessEntity().block().getStatusCode());
+ }
+
+ private MultipartBodyBuilder createRequestBuilder(String sourceMimetype, String targetMimetype, String filename)
+ {
+ MultipartBodyBuilder builder = new MultipartBodyBuilder();
+ builder.part("_sourceMimetype", sourceMimetype);
+ builder.part("_targetMimetype", targetMimetype);
+ builder.part("file", new ClassPathResource(filename));
+
+ return builder;
+ }
+
+ private static void assertProbeDied(String url)
+ {
+ WebTestClient client = WebTestClient.bindToServer().baseUrl(url+"/ready").build();
+ client.get()
+ .exchange()
+ .expectStatus().isEqualTo(TOO_MANY_REQUESTS);
+ }
+
+ private static void assertProbeIsOk(String url)
+ {
+ WebTestClient client = WebTestClient.bindToServer().baseUrl(url+"/ready").build();
+ client.get()
+ .exchange()
+ .expectStatus().isEqualTo(OK);
+ }
+}
\ No newline at end of file
diff --git a/engines/imagemagick/pom.xml b/engines/imagemagick/pom.xml
index 4fd1af94d..533cffffa 100644
--- a/engines/imagemagick/pom.xml
+++ b/engines/imagemagick/pom.xml
@@ -53,6 +53,11 @@
org.apache.commons
commons-lang3
+
+ org.testcontainers
+ testcontainers
+ test
+
diff --git a/engines/imagemagick/src/test/java/org/alfresco/transform/imagemagick/ImageMagickLivenessReadinessProbeIT.java b/engines/imagemagick/src/test/java/org/alfresco/transform/imagemagick/ImageMagickLivenessReadinessProbeIT.java
new file mode 100644
index 000000000..e0a8b0f5a
--- /dev/null
+++ b/engines/imagemagick/src/test/java/org/alfresco/transform/imagemagick/ImageMagickLivenessReadinessProbeIT.java
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * Alfresco Transform Core
+ * %%
+ * Copyright (C) 2005 - 2023 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.transform.imagemagick;
+
+import org.alfresco.transform.base.LivenessReadinessProbeTest;
+
+public class ImageMagickLivenessReadinessProbeIT extends LivenessReadinessProbeTest {
+ @Override
+ protected ImagesForTests getImageForTest() {
+ return new ImagesForTests("alfresco-imagemagick", "image/jpeg", "image/png", "quick.jpg");
+ }
+}
diff --git a/engines/libreoffice/pom.xml b/engines/libreoffice/pom.xml
index ac457f13f..58cf1a398 100644
--- a/engines/libreoffice/pom.xml
+++ b/engines/libreoffice/pom.xml
@@ -57,6 +57,11 @@
org.apache.pdfbox
pdfbox
+
+ org.testcontainers
+ testcontainers
+ test
+
diff --git a/engines/libreoffice/src/test/java/org/alfresco/transform/libreoffice/LibreOfficeLivenessReadinessProbeIT.java b/engines/libreoffice/src/test/java/org/alfresco/transform/libreoffice/LibreOfficeLivenessReadinessProbeIT.java
new file mode 100644
index 000000000..1fe37792c
--- /dev/null
+++ b/engines/libreoffice/src/test/java/org/alfresco/transform/libreoffice/LibreOfficeLivenessReadinessProbeIT.java
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * Alfresco Transform Core
+ * %%
+ * Copyright (C) 2005 - 2023 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.transform.libreoffice;
+
+import org.alfresco.transform.base.LivenessReadinessProbeTest;
+
+public class LibreOfficeLivenessReadinessProbeIT extends LivenessReadinessProbeTest {
+ @Override
+ protected ImagesForTests getImageForTest() {
+ return new ImagesForTests("alfresco-libreoffice", "text/plain", "application/pdf", "original.txt");
+ }
+}
diff --git a/engines/misc/pom.xml b/engines/misc/pom.xml
index 9f2d0539e..1490fbfa6 100644
--- a/engines/misc/pom.xml
+++ b/engines/misc/pom.xml
@@ -101,6 +101,11 @@
org.dom4j
dom4j
+
+ org.testcontainers
+ testcontainers
+ test
+
diff --git a/engines/misc/src/test/java/org/alfresco/transform/misc/MiscLivenessReadinessProbeIT.java b/engines/misc/src/test/java/org/alfresco/transform/misc/MiscLivenessReadinessProbeIT.java
new file mode 100644
index 000000000..1d772a37f
--- /dev/null
+++ b/engines/misc/src/test/java/org/alfresco/transform/misc/MiscLivenessReadinessProbeIT.java
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * Alfresco Transform Core
+ * %%
+ * Copyright (C) 2005 - 2023 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.transform.misc;
+
+import org.alfresco.transform.base.LivenessReadinessProbeTest;
+
+public class MiscLivenessReadinessProbeIT extends LivenessReadinessProbeTest {
+ @Override
+ protected ImagesForTests getImageForTest() {
+ return new ImagesForTests("alfresco-transform-misc", "text/plain", "text/plain", "original.txt");
+ }
+}
diff --git a/engines/pdfrenderer/pom.xml b/engines/pdfrenderer/pom.xml
index 0a7f360c3..1f54ca74c 100644
--- a/engines/pdfrenderer/pom.xml
+++ b/engines/pdfrenderer/pom.xml
@@ -49,6 +49,11 @@
org.dom4j
dom4j
+
+ org.testcontainers
+ testcontainers
+ test
+
diff --git a/engines/pdfrenderer/src/test/java/org/alfresco/transform/pdfrenderer/PdfRendererLivenessReadinessProbeIT.java b/engines/pdfrenderer/src/test/java/org/alfresco/transform/pdfrenderer/PdfRendererLivenessReadinessProbeIT.java
new file mode 100644
index 000000000..5a16b4556
--- /dev/null
+++ b/engines/pdfrenderer/src/test/java/org/alfresco/transform/pdfrenderer/PdfRendererLivenessReadinessProbeIT.java
@@ -0,0 +1,37 @@
+/*
+ * #%L
+ * Alfresco Transform Core
+ * %%
+ * Copyright (C) 2005 - 2023 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.transform.pdfrenderer;
+
+import org.alfresco.transform.base.LivenessReadinessProbeTest;
+
+public class PdfRendererLivenessReadinessProbeIT extends LivenessReadinessProbeTest {
+ @Override
+ protected ImagesForTests getImageForTest() {
+ return new ImagesForTests("alfresco-pdf-renderer", "application/pdf", "image/png", "quick.pdf");
+ }
+}
diff --git a/engines/tika/pom.xml b/engines/tika/pom.xml
index 2c234acca..c627e3296 100644
--- a/engines/tika/pom.xml
+++ b/engines/tika/pom.xml
@@ -145,6 +145,11 @@
mockito-junit-jupiter
test
+
+ org.testcontainers
+ testcontainers
+ test
+
diff --git a/engines/tika/src/test/java/org/alfresco/transform/tika/TikaLivenessReadinessProbeIT.java b/engines/tika/src/test/java/org/alfresco/transform/tika/TikaLivenessReadinessProbeIT.java
new file mode 100644
index 000000000..dddb9e1e0
--- /dev/null
+++ b/engines/tika/src/test/java/org/alfresco/transform/tika/TikaLivenessReadinessProbeIT.java
@@ -0,0 +1,38 @@
+/*
+ * #%L
+ * Alfresco Transform Core
+ * %%
+ * Copyright (C) 2005 - 2023 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.transform.tika;
+
+import org.alfresco.transform.base.LivenessReadinessProbeTest;
+
+
+public class TikaLivenessReadinessProbeIT extends LivenessReadinessProbeTest {
+ @Override
+ protected ImagesForTests getImageForTest() {
+ return new ImagesForTests("alfresco-tika", "text/plain", "text/plain", "original.txt");
+ }
+}
diff --git a/pom.xml b/pom.xml
index 1c4e39983..0d1c61427 100644
--- a/pom.xml
+++ b/pom.xml
@@ -184,7 +184,11 @@
snakeyaml
${dependency.snakeyaml.version}
-
+
+ org.testcontainers
+ testcontainers
+ 1.19.1
+
@@ -197,7 +201,6 @@
activemq-client-jakarta
5.18.3
-