Reset probe in testing

This commit is contained in:
alandavis
2022-08-01 08:39:59 +01:00
parent 5883065d1b
commit 478c689902
3 changed files with 12 additions and 4 deletions

View File

@@ -249,7 +249,7 @@ public abstract class ProbeTestTransform
{
throw new TransformException(TOO_MANY_REQUESTS,
getMessagePrefix(isLiveProbe) + "Transformer requested to die. A transform took " +
"longer than " + (maxTransformTime * 1000) + " seconds");
"longer than " + (maxTransformTime / 1000) + " seconds");
}
if (maxTransformCount > 0 && transformCount.get() > maxTransformCount)

View File

@@ -242,7 +242,7 @@ public class ProbeTransform
{
throw new TransformException(TOO_MANY_REQUESTS,
getMessagePrefix(isLiveProbe) + "Transformer requested to die. A transform took " +
"longer than " + (maxTransformTime * 1000) + " seconds");
"longer than " + (maxTransformTime / 1000) + " seconds");
}
if (maxTransformCount > 0 && transformCount.get() > maxTransformCount)
@@ -302,8 +302,7 @@ public class ProbeTransform
true)) || transCount > AVERAGE_OVER_TRANSFORMS)
{
nextTransformTime = System.currentTimeMillis() + livenessTransformPeriod;
logger.trace("{} - {}ms+{}%={}ms", message, normalTime, livenessPercent,
maxTime);
logger.trace("{} - {}ms+{}%={}ms", message, normalTime, livenessPercent, maxTime);
}
}
else if (!isLiveProbe && !readySent.getAndSet(true))
@@ -356,4 +355,10 @@ public class ProbeTransform
{
return normalTime;
}
public void resetForTesting()
{
die.set(false);
transformCount.set(0);
}
}

View File

@@ -129,6 +129,7 @@ public class TransformControllerTest
public File tempDir;
@MockBean
protected AlfrescoSharedFileStoreClient fakeSfsClient;
@BeforeEach
public void fakeSfsClient()
{
@@ -229,6 +230,7 @@ public class TransformControllerTest
@Test
public void testReadyEndpointReturnsSuccessful() throws Exception
{
transformController.probeTransform.resetForTesting();
mockMvc.perform(MockMvcRequestBuilders.get(ENDPOINT_READY))
.andExpect(status().isOk())
.andExpect(content().string(containsString("Success - ")));
@@ -237,6 +239,7 @@ public class TransformControllerTest
@Test
public void testLiveEndpointReturnsSuccessful() throws Exception
{
transformController.probeTransform.resetForTesting();
mockMvc.perform(MockMvcRequestBuilders.get(ENDPOINT_LIVE))
.andExpect(status().isOk())
.andExpect(content().string(containsString("Success - ")));