Jackie-Jiang commented on a change in pull request #3475: Enhance controller 
periodic task and scheduler
URL: https://github.com/apache/incubator-pinot/pull/3475#discussion_r233678751
 
 

 ##########
 File path: 
pinot-core/src/test/java/com/linkedin/pinot/core/periodictask/PeriodicTaskSchedulerTest.java
 ##########
 @@ -16,171 +16,70 @@
 package com.linkedin.pinot.core.periodictask;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-import org.testng.Assert;
 import org.testng.annotations.Test;
 
+import static org.testng.Assert.*;
 
-public class PeriodicTaskSchedulerTest {
-
-  @Test
-  public void testSchedulerWithOneTask() throws InterruptedException {
-    AtomicInteger count = new AtomicInteger(0);
-    PeriodicTaskScheduler periodicTaskScheduler = new PeriodicTaskScheduler();
-    long runFrequencyInSeconds = 1L;
-    long initialDelayInSeconds = 1L;
-    long totalRunTimeInMilliseconds = 3_500L;
-
-    List<PeriodicTask> periodicTasks = new ArrayList<>();
-    PeriodicTask task = new BasePeriodicTask("Task", runFrequencyInSeconds, 
initialDelayInSeconds) {
-      @Override
-      public void init() {
-        count.set(0);
-      }
-
-      @Override
-      public void run() {
-        // Execute task.
-        count.incrementAndGet();
-      }
-    };
-    periodicTasks.add(task);
-
-    long start = System.currentTimeMillis();
-    periodicTaskScheduler.start(periodicTasks);
-    Thread.sleep(totalRunTimeInMilliseconds);
 
-    periodicTaskScheduler.stop();
-
-    Assert.assertTrue(count.get() > 0);
-    Assert.assertEquals(count.get(), (totalRunTimeInMilliseconds / 
(runFrequencyInSeconds * 1000)));
-    Assert.assertTrue(totalRunTimeInMilliseconds <= 
(System.currentTimeMillis() - start));
-  }
+public class PeriodicTaskSchedulerTest {
 
   @Test
-  public void testSchedulerWithTwoStaggeredTasks() throws InterruptedException 
{
-    AtomicInteger count = new AtomicInteger(0);
-    PeriodicTaskScheduler periodicTaskScheduler = new PeriodicTaskScheduler();
-    long runFrequencyInSeconds = 2L;
-    long totalRunTimeInMilliseconds = 1_500L;
-
-    List<PeriodicTask> periodicTasks = new ArrayList<>();
-    PeriodicTask task1 = new BasePeriodicTask("Task1", runFrequencyInSeconds, 
0L) {
-      @Override
-      public void init() {
-      }
-
-      @Override
-      public void run() {
-        // Execute task.
-        count.incrementAndGet();
-      }
-    };
-    periodicTasks.add(task1);
+  public void testTaskWithInvalidInterval() throws Exception {
+    AtomicBoolean initCalled = new AtomicBoolean();
+    AtomicBoolean runCalled = new AtomicBoolean();
 
-    // Stagger 2 tasks by delaying the 2nd task half of the frequency.
-    PeriodicTask task2 = new BasePeriodicTask("Task2", runFrequencyInSeconds, 
runFrequencyInSeconds / 2) {
+    List<PeriodicTask> periodicTasks = Collections.singletonList(new 
BasePeriodicTask("TestTask", 0L, 0L) {
 
 Review comment:
   Done

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to