1111import org .elasticsearch .client .Client ;
1212import org .elasticsearch .common .settings .Settings ;
1313import org .elasticsearch .common .util .concurrent .ThreadContext ;
14+ import org .elasticsearch .node .Node ;
1415import org .elasticsearch .persistent .PersistentTaskState ;
1516import org .elasticsearch .persistent .PersistentTasksCustomMetaData ;
1617import org .elasticsearch .search .aggregations .Aggregations ;
4748
4849public class RollupJobTaskTests extends ESTestCase {
4950
51+ private static final Settings SETTINGS = Settings .builder ()
52+ .put (Node .NODE_NAME_SETTING .getKey (), "test" )
53+ .build ();
5054 private static ThreadPool pool = new TestThreadPool ("test" );
5155
5256 @ AfterClass
@@ -62,7 +66,7 @@ public void testInitialStatusStopped() {
6266 RollupJobStatus status = new RollupJobStatus (IndexerState .STOPPED , Collections .singletonMap ("foo" , "bar" ), randomBoolean ());
6367 Client client = mock (Client .class );
6468 when (client .settings ()).thenReturn (Settings .EMPTY );
65- SchedulerEngine schedulerEngine = new SchedulerEngine (Clock .systemUTC ());
69+ SchedulerEngine schedulerEngine = new SchedulerEngine (SETTINGS , Clock .systemUTC ());
6670 RollupJobTask task = new RollupJobTask (1 , "type" , "action" , new TaskId ("node" , 123 ), job ,
6771 status , client , schedulerEngine , pool , Collections .emptyMap ());
6872 assertThat (((RollupJobStatus )task .getStatus ()).getIndexerState (), equalTo (IndexerState .STOPPED ));
@@ -75,7 +79,7 @@ public void testInitialStatusAborting() {
7579 RollupJobStatus status = new RollupJobStatus (IndexerState .ABORTING , Collections .singletonMap ("foo" , "bar" ), randomBoolean ());
7680 Client client = mock (Client .class );
7781 when (client .settings ()).thenReturn (Settings .EMPTY );
78- SchedulerEngine schedulerEngine = new SchedulerEngine (Clock .systemUTC ());
82+ SchedulerEngine schedulerEngine = new SchedulerEngine (SETTINGS , Clock .systemUTC ());
7983 RollupJobTask task = new RollupJobTask (1 , "type" , "action" , new TaskId ("node" , 123 ), job ,
8084 status , client , schedulerEngine , pool , Collections .emptyMap ());
8185 assertThat (((RollupJobStatus )task .getStatus ()).getIndexerState (), equalTo (IndexerState .STOPPED ));
@@ -88,7 +92,7 @@ public void testInitialStatusStopping() {
8892 RollupJobStatus status = new RollupJobStatus (IndexerState .STOPPING , Collections .singletonMap ("foo" , "bar" ), randomBoolean ());
8993 Client client = mock (Client .class );
9094 when (client .settings ()).thenReturn (Settings .EMPTY );
91- SchedulerEngine schedulerEngine = new SchedulerEngine (Clock .systemUTC ());
95+ SchedulerEngine schedulerEngine = new SchedulerEngine (SETTINGS , Clock .systemUTC ());
9296 RollupJobTask task = new RollupJobTask (1 , "type" , "action" , new TaskId ("node" , 123 ), job ,
9397 status , client , schedulerEngine , pool , Collections .emptyMap ());
9498 assertThat (((RollupJobStatus )task .getStatus ()).getIndexerState (), equalTo (IndexerState .STOPPED ));
@@ -101,7 +105,7 @@ public void testInitialStatusStarted() {
101105 RollupJobStatus status = new RollupJobStatus (IndexerState .STARTED , Collections .singletonMap ("foo" , "bar" ), randomBoolean ());
102106 Client client = mock (Client .class );
103107 when (client .settings ()).thenReturn (Settings .EMPTY );
104- SchedulerEngine schedulerEngine = new SchedulerEngine (Clock .systemUTC ());
108+ SchedulerEngine schedulerEngine = new SchedulerEngine (SETTINGS , Clock .systemUTC ());
105109 RollupJobTask task = new RollupJobTask (1 , "type" , "action" , new TaskId ("node" , 123 ), job ,
106110 status , client , schedulerEngine , pool , Collections .emptyMap ());
107111 assertThat (((RollupJobStatus )task .getStatus ()).getIndexerState (), equalTo (IndexerState .STARTED ));
@@ -114,7 +118,7 @@ public void testInitialStatusIndexingOldID() {
114118 RollupJobStatus status = new RollupJobStatus (IndexerState .INDEXING , Collections .singletonMap ("foo" , "bar" ), false );
115119 Client client = mock (Client .class );
116120 when (client .settings ()).thenReturn (Settings .EMPTY );
117- SchedulerEngine schedulerEngine = new SchedulerEngine (Clock .systemUTC ());
121+ SchedulerEngine schedulerEngine = new SchedulerEngine (SETTINGS , Clock .systemUTC ());
118122 RollupJobTask task = new RollupJobTask (1 , "type" , "action" , new TaskId ("node" , 123 ), job ,
119123 status , client , schedulerEngine , pool , Collections .emptyMap ());
120124 assertThat (((RollupJobStatus )task .getStatus ()).getIndexerState (), equalTo (IndexerState .STARTED ));
@@ -128,7 +132,7 @@ public void testInitialStatusIndexingNewID() {
128132 RollupJobStatus status = new RollupJobStatus (IndexerState .INDEXING , Collections .singletonMap ("foo" , "bar" ), true );
129133 Client client = mock (Client .class );
130134 when (client .settings ()).thenReturn (Settings .EMPTY );
131- SchedulerEngine schedulerEngine = new SchedulerEngine (Clock .systemUTC ());
135+ SchedulerEngine schedulerEngine = new SchedulerEngine (SETTINGS , Clock .systemUTC ());
132136 RollupJobTask task = new RollupJobTask (1 , "type" , "action" , new TaskId ("node" , 123 ), job ,
133137 status , client , schedulerEngine , pool , Collections .emptyMap ());
134138 assertThat (((RollupJobStatus )task .getStatus ()).getIndexerState (), equalTo (IndexerState .STARTED ));
@@ -141,7 +145,7 @@ public void testNoInitialStatus() {
141145 RollupJob job = new RollupJob (ConfigTestHelpers .randomRollupJobConfig (random ()), Collections .emptyMap ());
142146 Client client = mock (Client .class );
143147 when (client .settings ()).thenReturn (Settings .EMPTY );
144- SchedulerEngine schedulerEngine = new SchedulerEngine (Clock .systemUTC ());
148+ SchedulerEngine schedulerEngine = new SchedulerEngine (SETTINGS , Clock .systemUTC ());
145149 RollupJobTask task = new RollupJobTask (1 , "type" , "action" , new TaskId ("node" , 123 ), job ,
146150 null , client , schedulerEngine , pool , Collections .emptyMap ());
147151 assertThat (((RollupJobStatus )task .getStatus ()).getIndexerState (), equalTo (IndexerState .STOPPED ));
@@ -154,7 +158,7 @@ public void testStartWhenStarted() throws InterruptedException {
154158 RollupJobStatus status = new RollupJobStatus (IndexerState .STARTED , Collections .singletonMap ("foo" , "bar" ), randomBoolean ());
155159 Client client = mock (Client .class );
156160 when (client .settings ()).thenReturn (Settings .EMPTY );
157- SchedulerEngine schedulerEngine = new SchedulerEngine (Clock .systemUTC ());
161+ SchedulerEngine schedulerEngine = new SchedulerEngine (SETTINGS , Clock .systemUTC ());
158162 RollupJobTask task = new RollupJobTask (1 , "type" , "action" , new TaskId ("node" , 123 ), job ,
159163 status , client , schedulerEngine , pool , Collections .emptyMap ());
160164 assertThat (((RollupJobStatus )task .getStatus ()).getIndexerState (), equalTo (IndexerState .STARTED ));
@@ -641,7 +645,7 @@ public void testStopWhenStopped() throws InterruptedException {
641645 RollupJobStatus status = new RollupJobStatus (IndexerState .STOPPED , null , randomBoolean ());
642646 Client client = mock (Client .class );
643647 when (client .settings ()).thenReturn (Settings .EMPTY );
644- SchedulerEngine schedulerEngine = new SchedulerEngine (Clock .systemUTC ());
648+ SchedulerEngine schedulerEngine = new SchedulerEngine (SETTINGS , Clock .systemUTC ());
645649 RollupJobTask task = new RollupJobTask (1 , "type" , "action" , new TaskId ("node" , 123 ), job ,
646650 status , client , schedulerEngine , pool , Collections .emptyMap ());
647651 assertThat (((RollupJobStatus )task .getStatus ()).getIndexerState (), equalTo (IndexerState .STOPPED ));
@@ -748,7 +752,7 @@ public void testStopWhenAborting() throws InterruptedException {
748752 RollupJobStatus status = new RollupJobStatus (IndexerState .STOPPED , null , randomBoolean ());
749753 Client client = mock (Client .class );
750754 when (client .settings ()).thenReturn (Settings .EMPTY );
751- SchedulerEngine schedulerEngine = new SchedulerEngine (Clock .systemUTC ());
755+ SchedulerEngine schedulerEngine = new SchedulerEngine (SETTINGS , Clock .systemUTC ());
752756
753757 CountDownLatch latch = new CountDownLatch (2 );
754758
0 commit comments