Search in sources :

Example 1 with HelixAccountServiceConfig

use of com.github.ambry.config.HelixAccountServiceConfig in project ambry by linkedin.

the class BackupFileManagerTest method testDisableBackupDir.

/**
 * Test disable backup. Every method from {@link BackupFileManager} should return null or have no effect.
 * @throws IOException if I/O error occurs
 */
@Test
public void testDisableBackupDir() throws IOException {
    helixConfigProps.remove(HelixAccountServiceConfig.BACKUP_DIRECTORY_KEY);
    VerifiableProperties vHelixConfigProps = new VerifiableProperties(helixConfigProps);
    HelixAccountServiceConfig config = new HelixAccountServiceConfig(vHelixConfigProps);
    BackupFileManager backup = new BackupFileManager(accountServiceMetrics, config.backupDir, config.maxBackupFileCount);
    // getLatestAccounts should return null
    assertNull("Disabled backup shouldn't have any state", backup.getLatestAccounts(0));
    // persistAccountMap should not create any backup
    Stat stat = new Stat();
    stat.setVersion(1);
    stat.setMtime(System.currentTimeMillis());
    backup.persistAccountMap(Collections.emptyList(), stat.getVersion(), stat.getMtime() / 1000);
    assertTrue("Disabled backup shouldn't add any backup", backup.isEmpty());
}
Also used : Stat(org.apache.zookeeper.data.Stat) VerifiableProperties(com.github.ambry.config.VerifiableProperties) HelixAccountServiceConfig(com.github.ambry.config.HelixAccountServiceConfig) Test(org.junit.Test)

Aggregations

HelixAccountServiceConfig (com.github.ambry.config.HelixAccountServiceConfig)1 VerifiableProperties (com.github.ambry.config.VerifiableProperties)1 Stat (org.apache.zookeeper.data.Stat)1 Test (org.junit.Test)1