mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-08-14 17:58:27 +00:00
Reset probe in testing
This commit is contained in:
@@ -249,7 +249,7 @@ public abstract class ProbeTestTransform
|
|||||||
{
|
{
|
||||||
throw new TransformException(TOO_MANY_REQUESTS,
|
throw new TransformException(TOO_MANY_REQUESTS,
|
||||||
getMessagePrefix(isLiveProbe) + "Transformer requested to die. A transform took " +
|
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)
|
if (maxTransformCount > 0 && transformCount.get() > maxTransformCount)
|
||||||
|
@@ -242,7 +242,7 @@ public class ProbeTransform
|
|||||||
{
|
{
|
||||||
throw new TransformException(TOO_MANY_REQUESTS,
|
throw new TransformException(TOO_MANY_REQUESTS,
|
||||||
getMessagePrefix(isLiveProbe) + "Transformer requested to die. A transform took " +
|
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)
|
if (maxTransformCount > 0 && transformCount.get() > maxTransformCount)
|
||||||
@@ -302,8 +302,7 @@ public class ProbeTransform
|
|||||||
true)) || transCount > AVERAGE_OVER_TRANSFORMS)
|
true)) || transCount > AVERAGE_OVER_TRANSFORMS)
|
||||||
{
|
{
|
||||||
nextTransformTime = System.currentTimeMillis() + livenessTransformPeriod;
|
nextTransformTime = System.currentTimeMillis() + livenessTransformPeriod;
|
||||||
logger.trace("{} - {}ms+{}%={}ms", message, normalTime, livenessPercent,
|
logger.trace("{} - {}ms+{}%={}ms", message, normalTime, livenessPercent, maxTime);
|
||||||
maxTime);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!isLiveProbe && !readySent.getAndSet(true))
|
else if (!isLiveProbe && !readySent.getAndSet(true))
|
||||||
@@ -356,4 +355,10 @@ public class ProbeTransform
|
|||||||
{
|
{
|
||||||
return normalTime;
|
return normalTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetForTesting()
|
||||||
|
{
|
||||||
|
die.set(false);
|
||||||
|
transformCount.set(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -129,6 +129,7 @@ public class TransformControllerTest
|
|||||||
public File tempDir;
|
public File tempDir;
|
||||||
@MockBean
|
@MockBean
|
||||||
protected AlfrescoSharedFileStoreClient fakeSfsClient;
|
protected AlfrescoSharedFileStoreClient fakeSfsClient;
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void fakeSfsClient()
|
public void fakeSfsClient()
|
||||||
{
|
{
|
||||||
@@ -229,6 +230,7 @@ public class TransformControllerTest
|
|||||||
@Test
|
@Test
|
||||||
public void testReadyEndpointReturnsSuccessful() throws Exception
|
public void testReadyEndpointReturnsSuccessful() throws Exception
|
||||||
{
|
{
|
||||||
|
transformController.probeTransform.resetForTesting();
|
||||||
mockMvc.perform(MockMvcRequestBuilders.get(ENDPOINT_READY))
|
mockMvc.perform(MockMvcRequestBuilders.get(ENDPOINT_READY))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString("Success - ")));
|
.andExpect(content().string(containsString("Success - ")));
|
||||||
@@ -237,6 +239,7 @@ public class TransformControllerTest
|
|||||||
@Test
|
@Test
|
||||||
public void testLiveEndpointReturnsSuccessful() throws Exception
|
public void testLiveEndpointReturnsSuccessful() throws Exception
|
||||||
{
|
{
|
||||||
|
transformController.probeTransform.resetForTesting();
|
||||||
mockMvc.perform(MockMvcRequestBuilders.get(ENDPOINT_LIVE))
|
mockMvc.perform(MockMvcRequestBuilders.get(ENDPOINT_LIVE))
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string(containsString("Success - ")));
|
.andExpect(content().string(containsString("Success - ")));
|
||||||
|
Reference in New Issue
Block a user