Exemplo n.º 1
0
  @Test
  public void noCompression_FileSet_StopRestart_WithLongWait_4B() throws Exception {
    String testId = "test4B";
    initRFA(rfa1, testId2FileName(testId));
    initTRBP(
        rfa1,
        tbrp1,
        randomOutputDir + testId + "-%d{" + DATE_PATTERN_WITH_SECONDS + "}",
        currentTime);

    addExpectedFileName_ByDate(randomOutputDir, testId, getDateOfCurrentPeriodsStart(), false);

    incCurrentTime(1100);
    tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);

    for (int i = 0; i <= 2; i++) {
      rfa1.doAppend("Hello---" + i);
      addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
      incCurrentTime(500);
      tbrp1.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);
    }

    rfa1.stop();

    // change the timestamp of the currently actively file
    File activeFile = new File(rfa1.getFile());
    activeFile.setLastModified(currentTime);

    incCurrentTime(2000);

    initRFA(rfa2, randomOutputDir + "test4B.log");
    initTRBP(
        rfa2,
        tbrp2,
        randomOutputDir + testId + "-%d{" + DATE_PATTERN_WITH_SECONDS + "}",
        currentTime);

    for (int i = 0; i <= 2; i++) {
      rfa2.doAppend("World---" + i);
      addExpectedFileNamedIfItsTime_ByDate(randomOutputDir, testId, false);
      incCurrentTime(100);
      tbrp2.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);
    }

    massageExpectedFilesToCorresponToCurrentTarget("test4B.log");

    int i = 0;
    for (String fn : expectedFilenameList) {
      assertTrue(
          Compare.compare(
              fn, CoreTestConstants.TEST_SRC_PREFIX + "witness/rolling/tbr-test4B." + i++));
    }
  }
Exemplo n.º 2
0
  void doRestart(String testId, String patternPart, boolean fileOptionIsSet, int waitDuration) {
    // change the timestamp of the currently actively file
    File activeFile = new File(rfa1.getFile());
    activeFile.setLastModified(currentTime);

    incCurrentTime(waitDuration);

    String filePatternStr =
        randomOutputDir + patternPart + "-%d{" + DATE_PATTERN_WITH_SECONDS + "}";

    String fileName = fileOptionIsSet ? testId2FileName(testId) : null;
    initRFA(rfa2, fileName);
    initTRBP(rfa2, tbrp2, filePatternStr, currentTime);
    for (int i = 0; i < 3; i++) {
      rfa2.doAppend("World---" + i);
      addExpectedFileNamedIfItsTime_ByDate(filePatternStr);
      incCurrentTime(100);
      tbrp2.timeBasedFileNamingAndTriggeringPolicy.setCurrentTime(currentTime);
    }
    rfa2.stop();
  }