@Test
public void testBackupDatastore() throws Exception {

    MemberNode node = MemberNode.builder(memberNodes).akkaConfig("Member1")
            .moduleShardsConfig("module-shards-member1.conf").waitForShardLeader("cars", "people")
            .testName("testBackupDatastore").build();
    String fileName = "target/testBackupDatastore";
    new File(fileName).delete();
    ClusterAdminRpcService service = new ClusterAdminRpcService(node.configDataStore(), node.operDataStore(), null);
    RpcResult<BackupDatastoreOutput> rpcResult = service .backupDatastore(new BackupDatastoreInputBuilder()
            .setFilePath(fileName).build()).get(5, TimeUnit.SECONDS);
    verifySuccessfulRpcResult(rpcResult);
    try (FileInputStream fis = new FileInputStream(fileName)) {
        List<DatastoreSnapshot> snapshots = SerializationUtils.deserialize(fis);
        assertEquals("DatastoreSnapshot size", 2, snapshots.size());
        ImmutableMap<String, DatastoreSnapshot> map = ImmutableMap.of(snapshots.get(0).getType(), snapshots.get(0),
                snapshots.get(1).getType(), snapshots.get(1));
        verifyDatastoreSnapshot(node.configDataStore().getActorUtils().getDataStoreName(),
                map.get(node.configDataStore().getActorUtils().getDataStoreName()), "cars", "people");
    } finally {
        new File(fileName).delete();
    }
    // Test failure by killing a shard.
    node.configDataStore().getActorUtils().getShardManager().tell(node.datastoreContextBuilder()
            .shardInitializationTimeout(200, TimeUnit.MILLISECONDS).build(), ActorRef.noSender());
    ActorRef carsShardActor = node.configDataStore().getActorUtils().findLocalShard("cars").get();
    node.kit().watch(carsShardActor);
    carsShardActor.tell(PoisonPill.getInstance(), ActorRef.noSender());
    node.kit().expectTerminated(carsShardActor);
    rpcResult = service.backupDatastore(new BackupDatastoreInputBuilder().setFilePath(fileName).build())
            .get(5, TimeUnit.SECONDS);
    assertFalse("isSuccessful", rpcResult.isSuccessful());
    assertEquals("getErrors", 1, rpcResult.getErrors().size());
}