in server/src/testFixtures/java/org/apache/cassandra/sidecar/snapshots/AbstractSnapshotPathBuilderTest.java [181:237]
protected abstract SnapshotPathBuilder initialize(Vertx vertx,
ServiceConfiguration serviceConfiguration,
InstancesMetadata instancesMetadata,
CassandraInputValidator validator,
ExecutorPools executorPools);
@Test
void succeedsWhenSnapshotExists()
{
succeedsWhenPathExists(instance.streamSnapshotFiles(Collections.singletonList(dataDir0.getAbsolutePath() + "/ks1/table1"),
"backup.2022-03-17-04-PDT", false), snapshotFiles -> {
assertThat(snapshotFiles).isNotEmpty();
List<SnapshotPathBuilder.SnapshotFile> expectedSnapshotFiles = new ArrayList<>();
Path basePath = Paths.get(dataDir0.getAbsolutePath() + "/ks1/table1/snapshots/backup.2022-03-17-04-PDT/");
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("data.db"), 0, 0, null));
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("index.db"), 0, 0, null));
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("nb-203-big-TOC.txt"), 0, 0, null));
assertThat(snapshotFiles).containsExactlyInAnyOrderElementsOf(expectedSnapshotFiles);
});
succeedsWhenPathExists(instance.streamSnapshotFiles(Collections.singletonList(dataDir0.getAbsolutePath() + "/data/ks2/table2"),
"ea823202-a62c-4603-bb6a-4e15d79091cd", false), snapshotFiles -> {
assertThat(snapshotFiles).isNotEmpty();
List<SnapshotPathBuilder.SnapshotFile> expectedSnapshotFiles = new ArrayList<>();
Path basePath = Paths.get(dataDir0.getAbsolutePath() + "/data/ks2/table2/snapshots/ea823202-a62c-4603-bb6a-4e15d79091cd/");
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("data.db"), 0, 0, null));
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("index.db"), 0, 0, null));
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("nb-203-big-TOC.txt"), 0, 0, null));
assertThat(snapshotFiles).containsExactlyInAnyOrderElementsOf(expectedSnapshotFiles);
});
succeedsWhenPathExists(instance.streamSnapshotFiles(Collections.singletonList(dataDir1.getAbsolutePath() + "/ks3/table3"),
"snapshot1", false), snapshotFiles -> {
assertThat(snapshotFiles).isNotEmpty();
List<SnapshotPathBuilder.SnapshotFile> expectedSnapshotFiles = new ArrayList<>();
Path basePath = Paths.get(dataDir1.getAbsolutePath() + "/ks3/table3/snapshots/snapshot1");
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("data.db"), 0, 0, null));
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("index.db"), 0, 0, null));
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("nb-203-big-TOC.txt"), 0, 0, null));
assertThat(snapshotFiles).containsExactlyInAnyOrderElementsOf(expectedSnapshotFiles);
});
// table table4 shares the prefix with table table4abc
succeedsWhenPathExists(instance.streamSnapshotFiles(Collections.singletonList(dataDir1.getAbsolutePath() +
"/data/ks4/table4abc-a72c8740a57611ec935db766a70c44a1"),
"this_is_a_valid_snapshot_name_i_❤_u", false), snapshotFiles -> {
assertThat(snapshotFiles).isNotEmpty();
List<SnapshotPathBuilder.SnapshotFile> expectedSnapshotFiles = new ArrayList<>();
Path basePath = Paths.get(dataDir1.getAbsolutePath() +
"/data/ks4/table4abc-a72c8740a57611ec935db766a70c44a1/snapshots/this_is_a_valid_snapshot_name_i_❤_u");
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("data.db"), 0, 0, "a72c8740a57611ec935db766a70c44a1"));
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("index.db"), 0, 0, "a72c8740a57611ec935db766a70c44a1"));
expectedSnapshotFiles.add(new SnapshotPathBuilder.SnapshotFile(basePath.resolve("nb-203-big-TOC.txt"), 0, 0, "a72c8740a57611ec935db766a70c44a1"));
assertThat(snapshotFiles).containsExactlyInAnyOrderElementsOf(expectedSnapshotFiles);
});
}