private synchronized void populate(long newEndTime) {
   long timeNow = System.currentTimeMillis();
   startTime = endTime >= timeNow ? endTime : timeNow;
   endTime = newEndTime;
   SKLogger.d(
       this,
       "populating test queue from: "
           + TimeUtils.logString(startTime)
           + " to "
           + TimeUtils.logString(endTime));
   for (TestGroup tg : tc.config.backgroundTestGroups) {
     for (Long t : tg.getTimesInInterval(startTime, endTime)) {
       SKLogger.d(this, "Add test group id " + tg.id + " at time: " + TimeUtils.logString(t));
       addEntry(t, tg);
     }
   }
   SKLogger.d(this, "queue populated with: " + entries.size());
 }
 private void extendSize() {
   long minSize = TimeUtils.daysToMillis(SKConstants.TEST_QUEUE_NORMAL_SIZE_IN_DAYS);
   long currentSize = endTime - System.currentTimeMillis();
   if (currentSize < minSize) {
     SKLogger.d(this, "extending queue");
     long maxSize = TimeUtils.daysToMillis(SKConstants.TEST_QUEUE_MAX_SIZE_IN_DAYS);
     long newEndSize = System.currentTimeMillis() + maxSize;
     populate(newEndSize);
   } else {
     SKLogger.d(this, "no need to extend queue, endTime: " + TimeUtils.logString(endTime));
   }
 }
 public void addEntry(long time, TestGroup tg) {
   entries.add(new QueueEntry(time, tg.id, tc.config.backgroundTestGroups.indexOf(tg)));
   SKLogger.d(this, "scheduling test group at: " + TimeUtils.logString(time));
 }