sketch out test cases
This commit is contained in:
parent
3fafd51314
commit
7067cf4491
|
@ -56,7 +56,9 @@ stateDiagram-v2
|
||||||
state FAILED
|
state FAILED
|
||||||
state COMPLETED
|
state COMPLETED
|
||||||
direction LR
|
direction LR
|
||||||
[*] --> READY : on create - normal or step
|
[*] --> READY : on create - normal
|
||||||
|
[*] --> GATED : on create - gated
|
||||||
|
GATED --> READY : on create - gated
|
||||||
READY --> QUEUED : placed on kafka (maint.)
|
READY --> QUEUED : placed on kafka (maint.)
|
||||||
|
|
||||||
%% worker processing states
|
%% worker processing states
|
||||||
|
|
|
@ -17,6 +17,12 @@
|
||||||
<name>HAPI FHIR JPA Server - Batch2 specification tests</name>
|
<name>HAPI FHIR JPA Server - Batch2 specification tests</name>
|
||||||
<description>Batch2 is a framework for managing and executing long running "batch" jobs</description>
|
<description>Batch2 is a framework for managing and executing long running "batch" jobs</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<maven.compiler.release>17</maven.compiler.release>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ca.uhn.hapi.fhir</groupId>
|
<groupId>ca.uhn.hapi.fhir</groupId>
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
package ca.uhn.hapi.fhir.batch2.test;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
|
import org.junit.jupiter.params.provider.ValueSource;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
|
public interface IJobMaintenenaceActions extends IWorkChunkCommon, WorkChunkTestConstants {
|
||||||
|
|
||||||
|
// fixme step 1 is special - only 1 chunk.
|
||||||
|
// fixme cover step 1 to step 2 and step 2->3
|
||||||
|
@ParameterizedTest
|
||||||
|
@ValueSource(strings={
|
||||||
|
"""
|
||||||
|
1|COMPLETE
|
||||||
|
2|GATED
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
1|COMPLETE
|
||||||
|
2|QUEUED
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
1|COMPLETE
|
||||||
|
2|COMPLETE
|
||||||
|
2|ERRORED
|
||||||
|
2|IN_PROGRESS
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
1|COMPLETE
|
||||||
|
2|READY
|
||||||
|
2|QUEUED
|
||||||
|
2|COMPLETE
|
||||||
|
2|ERRORED
|
||||||
|
2|FAILED
|
||||||
|
2|IN_PROGRESS
|
||||||
|
3|GATED
|
||||||
|
3|GATED
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
1|COMPLETE
|
||||||
|
2|READY
|
||||||
|
2|QUEUED
|
||||||
|
2|COMPLETE
|
||||||
|
2|ERRORED
|
||||||
|
2|FAILED
|
||||||
|
2|IN_PROGRESS
|
||||||
|
3|QUEUED # a lie
|
||||||
|
3|GATED
|
||||||
|
"""
|
||||||
|
|
||||||
|
}
|
||||||
|
)
|
||||||
|
default void testGatedStep2NotReady_notAdvance(String theChunkState) {
|
||||||
|
// given
|
||||||
|
// need job instance definition
|
||||||
|
// step 1
|
||||||
|
// step 2
|
||||||
|
// step 3
|
||||||
|
// IN STEP 2
|
||||||
|
|
||||||
|
// chunks
|
||||||
|
setupChunksInStates(theChunkState);
|
||||||
|
// when
|
||||||
|
// run job maintenance
|
||||||
|
|
||||||
|
// then
|
||||||
|
// step not changed.
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@ValueSource(strings={
|
||||||
|
"""
|
||||||
|
# new code only
|
||||||
|
1|COMPLETE
|
||||||
|
2|COMPLETE
|
||||||
|
2|COMPLETE
|
||||||
|
3|GATED|READY
|
||||||
|
3|GATED|READY
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
# OLD code only
|
||||||
|
1|COMPLETE
|
||||||
|
2|COMPLETE
|
||||||
|
2|COMPLETE
|
||||||
|
3|QUEUED|READY
|
||||||
|
3|QUEUED|READY
|
||||||
|
""",
|
||||||
|
"""
|
||||||
|
# mixed code only
|
||||||
|
1|COMPLETE
|
||||||
|
2|COMPLETE
|
||||||
|
2|COMPLETE
|
||||||
|
3|GATED|READY
|
||||||
|
3|QUEUED|READY
|
||||||
|
"""
|
||||||
|
|
||||||
|
})
|
||||||
|
default void testGatedStep2ReadyToAdvance_advanceToStep3(String theTestStates) {
|
||||||
|
// given
|
||||||
|
|
||||||
|
// when
|
||||||
|
// then
|
||||||
|
fail();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setupChunksInStates(String theChunkState);
|
||||||
|
|
||||||
|
}
|
|
@ -32,6 +32,10 @@ public interface IWorkChunkStorageTests extends IWorkChunkCommon, WorkChunkTestC
|
||||||
assertNull(chunk.getData());
|
assertNull(chunk.getData());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fixme add test - testWorkChunkCreate_inReady
|
||||||
|
|
||||||
|
// fixme add test - testNonGatedWorkChunkInReady_IsQueuedDuringMaintentaince
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
default void testStoreAndFetchWorkChunk_WithData() {
|
default void testStoreAndFetchWorkChunk_WithData() {
|
||||||
JobInstance instance = createInstance();
|
JobInstance instance = createInstance();
|
||||||
|
@ -39,6 +43,7 @@ public interface IWorkChunkStorageTests extends IWorkChunkCommon, WorkChunkTestC
|
||||||
|
|
||||||
String id = storeWorkChunk(JOB_DEFINITION_ID, TARGET_STEP_ID, instanceId, 0, CHUNK_DATA);
|
String id = storeWorkChunk(JOB_DEFINITION_ID, TARGET_STEP_ID, instanceId, 0, CHUNK_DATA);
|
||||||
assertNotNull(id);
|
assertNotNull(id);
|
||||||
|
// fixme drop this verify against READY state.
|
||||||
runMaintenancePass();
|
runMaintenancePass();
|
||||||
runInTransaction(() -> assertEquals(WorkChunkStatusEnum.QUEUED, freshFetchWorkChunk(id).getStatus()));
|
runInTransaction(() -> assertEquals(WorkChunkStatusEnum.QUEUED, freshFetchWorkChunk(id).getStatus()));
|
||||||
|
|
||||||
|
|
|
@ -391,6 +391,10 @@ public class JobInstanceProcessor {
|
||||||
readyChunksForNextStep.size());
|
readyChunksForNextStep.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// fixme create a new persistence transition for state advance
|
||||||
|
// fixme update stepId to next step AND update all chunks in this step to READY (from GATED or QUEUED ;-P)
|
||||||
|
// fixme so we can queue them safely.
|
||||||
|
|
||||||
// update the job step so the workers will process them.
|
// update the job step so the workers will process them.
|
||||||
// if it's the last (gated) step, there will be no change - but we should
|
// if it's the last (gated) step, there will be no change - but we should
|
||||||
// queue up the chunks anyways
|
// queue up the chunks anyways
|
||||||
|
|
Loading…
Reference in New Issue