예제 #1
0
  @Test
  public void testGenerateBackups() {
    PId pid = new PiId("0234567890123456789012345678901234567890", 1);

    // act
    SortedSet<String> backupIds = koalaGCPastImpl.generateBackupIds(16, NodeScope.GLOBAL, pid);

    String firstBackup = backupIds.first();
    assertTrue(firstBackup.endsWith("1"));
    for (String id : backupIds) {
      assertEquals(firstBackup.substring(1), id.substring(1));
    }
  }
예제 #2
0
  @Test
  public void testGetRegionalIds() {
    // setup
    KoalaIdFactory koalaIdFactory = new KoalaIdFactory(0, 0);
    koalaIdFactory.setKoalaPiEntityFactory(koalaPiEntityFactory);
    koalaGCPastImpl.setKoalaIdFactory(koalaIdFactory);
    PId testId = koalaGCPastImpl.getKoalaIdFactory().buildPId("R. Lopez");

    // act
    Set<String> ids = koalaGCPastImpl.generateBackupIds(4, NodeScope.REGION, testId);

    assertEquals(4, ids.size());
    assertSetEndsWithBackupIdentifier(ids);
    assertSetContains(ids, testId.getIdAsHex().substring(4, testId.getIdAsHex().length() - 1));
  }
예제 #3
0
  @Test
  public void testGetGlobalIds() {
    // setup
    KoalaIdFactory koalaIdFactory = new KoalaIdFactory(0, 0);
    koalaIdFactory.setKoalaPiEntityFactory(koalaPiEntityFactory);
    koalaGCPastImpl.setKoalaIdFactory(koalaIdFactory);
    PId testId = koalaGCPastImpl.getKoalaIdFactory().buildPId("R. Lopez");

    // act
    Set<String> globalIds = koalaGCPastImpl.generateBackupIds(4, NodeScope.GLOBAL, testId);

    // asssert
    assertEquals(4, globalIds.size());
    assertSetEndsWithBackupIdentifier(globalIds);
  }
예제 #4
0
  @Test
  public void testGetAvailabilityZoneIds() {
    // setup
    KoalaIdFactory koalaIdFactory = new KoalaIdFactory(0, 0);
    koalaIdFactory.setKoalaPiEntityFactory(koalaPiEntityFactory);
    koalaGCPastImpl.setKoalaIdFactory(koalaIdFactory);
    PId testId = koalaGCPastImpl.getKoalaIdFactory().buildPId("YEAHBOB");

    // act
    Set<String> ids = koalaGCPastImpl.generateBackupIds(4, NodeScope.AVAILABILITY_ZONE, testId);

    // assert
    assertEquals(4, ids.size());
    assertSetEndsWithBackupIdentifier(ids);
    assertSetContains(ids, testId.getIdAsHex().substring(5, testId.getIdAsHex().length() - 1));
  }
예제 #5
0
  @Test
  public void testGetGlobalBackupIDs() {
    // setup
    koalaGCPastImpl.setKoalaIdFactory(new KoalaIdFactory(0, 0));
    realTestId =
        (PId)
            koalaGCPastImpl
                .getKoalaIdFactory()
                .buildPIdFromHexString("1234567890123456789012345678901234567892");

    // act
    Set<String> ids = koalaGCPastImpl.generateBackupIds(4, NodeScope.GLOBAL, realTestId);

    // assert
    assertSetEndsWithBackupIdentifier(ids);
    assertSetContains(ids, "34567890123456789012345678901234560013");
  }