Skip to content

Commit

Permalink
ACS-6151 - added requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
goleksyalfresco committed Nov 29, 2023
1 parent 51062f4 commit 85c838d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 6 deletions.
1 change: 0 additions & 1 deletion engines/base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>1.19.1</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@

public abstract class LivenessReadinessProbeTest
{
protected final Integer MAX_TRANSFORMS = 10;

@Test
public void readinessShouldReturnAn429ErrorAfterReachingMaxTransforms() throws URISyntaxException
{
Expand All @@ -32,8 +34,13 @@ public void readinessShouldReturnAn429ErrorAfterReachingMaxTransforms() throws U
env.start();
var url = "http://localhost:" + env.getFirstMappedPort();

int max_transforms = 11;
for (int i = 0; i<max_transforms; i++) {
/*
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<MAX_TRANSFORMS/2; i++) {
assertProbeIsOk(url);
sendTransformRequest(url, testData.sourceMimetype, testData.targetMimetype, testData.filename);
}

Expand All @@ -52,7 +59,7 @@ private GenericContainer<?> createEnv(String image) throws URISyntaxException
final GenericContainer<?> transformCore = new GenericContainer<>("alfresco/"+image+":latest");

return transformCore.withEnv("livenessTransformEnabled", "true")
.withEnv("maxTransforms", "10")
.withEnv("maxTransforms", MAX_TRANSFORMS.toString())
.withNetworkAliases(image)
.withExposedPorts(8090)
.waitingFor(Wait.forListeningPort());
Expand Down Expand Up @@ -104,4 +111,12 @@ private static void assertProbeDied(String url)
.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);
}
}
Binary file removed engines/base/src/test/resources/test.jpeg
Binary file not shown.
Binary file removed engines/base/src/test/resources/test.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
public class ImageMagickLivenessReadinessProbeTest extends LivenessReadinessProbeTest {
@Override
protected ImagesForTests getImageForTest() {
return new ImagesForTests("alfresco-imagemagick", "image/jpeg", "image/png", "test.jpeg");
return new ImagesForTests("alfresco-imagemagick", "image/jpeg", "image/png", "quick.jpg");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
public class PdfRendererLivenessReadinessProbeTest extends LivenessReadinessProbeTest {
@Override
protected ImagesForTests getImageForTest() {
return new ImagesForTests("alfresco-pdf-renderer", "application/pdf", "image/png", "test.pdf");
return new ImagesForTests("alfresco-pdf-renderer", "application/pdf", "image/png", "quick.pdf");
}
}

0 comments on commit 85c838d

Please sign in to comment.