Skip to content

Commit

Permalink
HSEARCH-2613 Fix test logic for job restarting using HQL
Browse files Browse the repository at this point in the history
  • Loading branch information
mincong-h authored and Sanne committed Oct 25, 2017
1 parent 7380a58 commit c8a3771
Showing 1 changed file with 14 additions and 5 deletions.
Expand Up @@ -153,7 +153,7 @@ public void testJob_usingCriteria() throws InterruptedException, IOException, Pa
}

@Test
public void testJob_usingHQL() throws InterruptedException, IOException, ParseException {
public void testJob_usingHQL() throws Exception {
assertEquals( 0, messageManager.findMessagesFor( SDF.parse( "31/08/2016" ) ).size() );
assertEquals( 0, messageManager.findMessagesFor( SDF.parse( "01/09/2016" ) ).size() );

Expand All @@ -164,15 +164,24 @@ public void testJob_usingHQL() throws InterruptedException, IOException, ParseEx
MassIndexingJob.NAME,
MassIndexingJob.parameters()
.forEntity( Message.class )
.restrictedBy( "select m from Message m where day( m.date ) = 31" )
.restrictedBy( "select m from Message m where day( m.date ) = 1" )
.build()
);
JobExecution jobExec1 = BatchRuntime.getJobOperator().getJobExecution( execId1 );
jobExec1 = JobTestUtil.waitForTermination( jobOperator, jobExec1, JOB_TIMEOUT_MS );
JobInterruptorUtil.disable();

assertEquals( BatchStatus.COMPLETED, jobExec1.getBatchStatus() );
assertEquals( DB_DAY1_ROWS, messageManager.findMessagesFor( SDF.parse( "31/08/2016" ) ).size() );
assertEquals( 0, messageManager.findMessagesFor( SDF.parse( "01/09/2016" ) ).size() );
assertEquals( BatchStatus.FAILED, jobExec1.getBatchStatus() );

// Restart the job.
long execId2 = jobOperator.restart( execId1, null );
JobExecution jobExec2 = jobOperator.getJobExecution( execId2 );
JobTestUtil.waitForTermination( jobOperator, jobExec2, JOB_TIMEOUT_MS );

// FIXME The job should finish correctly
assertEquals( BatchStatus.COMPLETED, jobExec2.getBatchStatus() );
assertEquals( 0, messageManager.findMessagesFor( SDF.parse( "31/08/2016" ) ).size() );
assertEquals( DB_DAY2_ROWS, messageManager.findMessagesFor( SDF.parse( "01/09/2016" ) ).size() );
}

}

0 comments on commit c8a3771

Please sign in to comment.