mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-05-12 17:04:48 +00:00
ACS-6151 - divided tests for each image
This commit is contained in:
parent
6b4e3e1cd6
commit
f5ce966dc2
@ -0,0 +1,10 @@
|
|||||||
|
package org.alfresco.transform.aio;
|
||||||
|
|
||||||
|
import org.alfresco.transform.base.LivenessReadinessProbeTest;
|
||||||
|
|
||||||
|
public class AIOLivenessReadinessProbeTest extends LivenessReadinessProbeTest {
|
||||||
|
@Override
|
||||||
|
protected LivenessReadinessProbeTest.ImagesForTests getImageForTest() {
|
||||||
|
return new ImagesForTests("ats-aio", "alfresco-transform-core-aio", "text/plain", "text/plain", "original.txt");
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package org.alfresco.transform.base;
|
package org.alfresco.transform.base;
|
||||||
|
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.provider.MethodSource;
|
|
||||||
|
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
@ -12,7 +11,6 @@ import org.testcontainers.containers.wait.strategy.Wait;
|
|||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@ -22,17 +20,16 @@ import static org.springframework.http.HttpStatus.TOO_MANY_REQUESTS;
|
|||||||
|
|
||||||
import org.springframework.web.reactive.function.client.WebClient;
|
import org.springframework.web.reactive.function.client.WebClient;
|
||||||
|
|
||||||
public class LivenessReadinessProbeTest
|
public abstract class LivenessReadinessProbeTest
|
||||||
{
|
{
|
||||||
protected String url;
|
@Test
|
||||||
|
public void readinessShouldReturnAn429ErrorAfterReachingMaxTransforms() throws URISyntaxException {
|
||||||
|
final ImagesForTests testData = getImageForTest();
|
||||||
|
|
||||||
@ParameterizedTest
|
|
||||||
@MethodSource ("containers")
|
|
||||||
public void readinessShouldReturnAn429ErrorAfterReachingMaxTransforms(final ImagesForTests testData) throws URISyntaxException {
|
|
||||||
try (final var env = createEnv(testData.image))
|
try (final var env = createEnv(testData.image))
|
||||||
{
|
{
|
||||||
env.start();
|
env.start();
|
||||||
url = "http://localhost:" + env.getFirstMappedPort();
|
var url = "http://localhost:" + env.getFirstMappedPort();
|
||||||
|
|
||||||
int max_transforms = 11;
|
int max_transforms = 11;
|
||||||
for (int i = 0; i<max_transforms; i++) {
|
for (int i = 0; i<max_transforms; i++) {
|
||||||
@ -46,6 +43,8 @@ public class LivenessReadinessProbeTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected abstract ImagesForTests getImageForTest();
|
||||||
|
|
||||||
private GenericContainer<?> createEnv(String image) throws URISyntaxException
|
private GenericContainer<?> createEnv(String image) throws URISyntaxException
|
||||||
{
|
{
|
||||||
System.out.println(image);
|
System.out.println(image);
|
||||||
@ -58,19 +57,7 @@ public class LivenessReadinessProbeTest
|
|||||||
.waitingFor(Wait.forListeningPort());
|
.waitingFor(Wait.forListeningPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<ImagesForTests> containers()
|
protected static class ImagesForTests
|
||||||
{
|
|
||||||
final var allContainers = List.of(
|
|
||||||
new ImagesForTests("imagemagick", "alfresco-imagemagick", "image/jpeg", "image/png", "test.jpeg"),
|
|
||||||
new ImagesForTests("ats-aio", "alfresco-transform-core-aio", "text/plain", "text/plain", "original.txt"),
|
|
||||||
new ImagesForTests("libreoffice", "alfresco-libreoffice", "text/plain", "application/pdf", "original.txt"),
|
|
||||||
new ImagesForTests("misc", "alfresco-transform-misc", "text/plain", "text/plain", "original.txt"),
|
|
||||||
new ImagesForTests("pdf-renderer", "alfresco-pdf-renderer", "application/pdf", "image/png", "test.pdf"),
|
|
||||||
new ImagesForTests("tika", "alfresco-tika", "text/plain", "text/plain", "original.txt"));
|
|
||||||
|
|
||||||
return allContainers;
|
|
||||||
}
|
|
||||||
private static class ImagesForTests
|
|
||||||
{
|
{
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String image;
|
private final String image;
|
||||||
@ -79,7 +66,7 @@ public class LivenessReadinessProbeTest
|
|||||||
private final String targetMimetype;
|
private final String targetMimetype;
|
||||||
private final String filename;
|
private final String filename;
|
||||||
|
|
||||||
private ImagesForTests(String name, String image, String sourceMimetype, String targetMimetype, String filename)
|
public ImagesForTests(String name, String image, String sourceMimetype, String targetMimetype, String filename)
|
||||||
{
|
{
|
||||||
this.name = Objects.requireNonNull(name);
|
this.name = Objects.requireNonNull(name);
|
||||||
this.image = Objects.requireNonNull(image);
|
this.image = Objects.requireNonNull(image);
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package org.alfresco.transform.imagemagick;
|
||||||
|
|
||||||
|
import org.alfresco.transform.base.LivenessReadinessProbeTest;
|
||||||
|
|
||||||
|
public class ImageMagickLivenessReadinessProbeTest extends LivenessReadinessProbeTest {
|
||||||
|
@Override
|
||||||
|
protected ImagesForTests getImageForTest() {
|
||||||
|
return new ImagesForTests("imagemagick", "alfresco-imagemagick", "image/jpeg", "image/png", "test.jpeg");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package org.alfresco.transform.libreoffice;
|
||||||
|
|
||||||
|
import org.alfresco.transform.base.LivenessReadinessProbeTest;
|
||||||
|
|
||||||
|
public class LibreOfficeLivenessReadinessProbeTest extends LivenessReadinessProbeTest {
|
||||||
|
@Override
|
||||||
|
protected ImagesForTests getImageForTest() {
|
||||||
|
return new ImagesForTests("tika", "alfresco-tika", "text/plain", "text/plain", "original.txt");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package org.alfresco.transform.misc;
|
||||||
|
|
||||||
|
import org.alfresco.transform.base.LivenessReadinessProbeTest;
|
||||||
|
|
||||||
|
public class MiscLivenessReadinessProbeTest extends LivenessReadinessProbeTest {
|
||||||
|
@Override
|
||||||
|
protected ImagesForTests getImageForTest() {
|
||||||
|
return new ImagesForTests("misc", "alfresco-transform-misc", "text/plain", "text/plain", "original.txt");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package org.alfresco.transform.pdfrenderer;
|
||||||
|
|
||||||
|
import org.alfresco.transform.base.LivenessReadinessProbeTest;
|
||||||
|
|
||||||
|
public class PdfRendererLivenessReadinessProbeTest extends LivenessReadinessProbeTest {
|
||||||
|
@Override
|
||||||
|
protected ImagesForTests getImageForTest() {
|
||||||
|
return new ImagesForTests("pdf-renderer", "alfresco-pdf-renderer", "application/pdf", "image/png", "test.pdf");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package org.alfresco.transform.tika;
|
||||||
|
|
||||||
|
import org.alfresco.transform.base.LivenessReadinessProbeTest;
|
||||||
|
|
||||||
|
|
||||||
|
public class TikaLivenessReadinessProbeTest extends LivenessReadinessProbeTest {
|
||||||
|
@Override
|
||||||
|
protected ImagesForTests getImageForTest() {
|
||||||
|
return new ImagesForTests("libreoffice", "alfresco-libreoffice", "text/plain", "application/pdf", "original.txt");
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user