in server/src/testFixtures/java/org/apache/cassandra/sidecar/snapshots/AbstractSnapshotPathBuilderTest.java [70:169]
protected void setup() throws IOException
{
CassandraInputValidator validator = new CassandraInputValidator();
InstancesMetadata mockInstancesMetadata = mock(InstancesMetadata.class);
InstanceMetadata mockInstanceMeta = mock(InstanceMetadata.class);
InstanceMetadata mockInvalidDataDirInstanceMeta = mock(InstanceMetadata.class);
InstanceMetadata mockEmptyDataDirInstanceMeta = mock(InstanceMetadata.class);
when(mockInstancesMetadata.instanceFromHost("localhost")).thenReturn(mockInstanceMeta);
when(mockInstanceMeta.dataDirs()).thenReturn(Arrays.asList(dataDir0.getAbsolutePath(),
dataDir1.getAbsolutePath()));
when(mockInstancesMetadata.instanceFromHost("invalidDataDirInstance")).thenReturn(mockInvalidDataDirInstanceMeta);
String invalidDirPath = dataDir0.getParentFile().getAbsolutePath() + "/invalid-data-dir";
when(mockInvalidDataDirInstanceMeta.dataDirs()).thenReturn(Collections.singletonList(invalidDirPath));
when(mockInstancesMetadata.instanceFromHost("emptyDataDirInstance")).thenReturn(mockEmptyDataDirInstanceMeta);
when(mockEmptyDataDirInstanceMeta.dataDirs()).thenReturn(Collections.emptyList());
// Create some files and directories
new File(dataDir0, "not_a_keyspace_dir").createNewFile();
new File(dataDir0, "ks1/table1/snapshots/backup.2022-03-17-04-PDT/not_a_file.db").mkdirs();
new File(dataDir0, "ks1/not_a_table_dir").createNewFile();
new File(dataDir0, "ks1/table1/snapshots/not_a_snapshot_dir").createNewFile();
new File(dataDir0, "data/ks2/table2/snapshots/ea823202-a62c-4603-bb6a-4e15d79091cd").mkdirs();
new File(dataDir1, "ks3/table3/snapshots/snapshot1").mkdirs();
// table was dropped and recreated. The table gets a new uuid
new File(dataDir1, "data/ks4/table4-a6442310a57611ec8b980b0b2009844e" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u").mkdirs();
new File(dataDir1, "data/ks4/table4-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u").mkdirs();
// this is a different table with the same "table4" prefix
new File(dataDir1, "data/ks4/table4abc-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u").mkdirs();
// table && table-<TABLE_UUID>
new File(dataDir0, "ks1/a_table/snapshots/a_snapshot/").mkdirs();
new File(dataDir0, "ks1/a_table-a72c8740a57611ec935db766a70c44a1/snapshots/a_snapshot/").mkdirs();
// create some files inside snapshot backup.2022-03-17-04-PDT
new File(dataDir0, "ks1/table1/snapshots/backup.2022-03-17-04-PDT/data.db").createNewFile();
new File(dataDir0, "ks1/table1/snapshots/backup.2022-03-17-04-PDT/index.db").createNewFile();
new File(dataDir0, "ks1/table1/snapshots/backup.2022-03-17-04-PDT/nb-203-big-TOC.txt").createNewFile();
// create some files inside snapshot ea823202-a62c-4603-bb6a-4e15d79091cd
new File(dataDir0, "data/ks2/table2/snapshots/ea823202-a62c-4603-bb6a-4e15d79091cd/data.db")
.createNewFile();
new File(dataDir0, "data/ks2/table2/snapshots/ea823202-a62c-4603-bb6a-4e15d79091cd/index.db")
.createNewFile();
new File(dataDir0, "data/ks2/table2/snapshots/ea823202-a62c-4603-bb6a-4e15d79091cd/nb-203-big-TOC.txt")
.createNewFile();
// create some files inside snapshot snapshot1 in dataDir1
new File(dataDir1, "ks3/table3/snapshots/snapshot1/data.db").createNewFile();
new File(dataDir1, "ks3/table3/snapshots/snapshot1/index.db").createNewFile();
new File(dataDir1, "ks3/table3/snapshots/snapshot1/nb-203-big-TOC.txt").createNewFile();
// create some files inside snapshot this_is_a_valid_snapshot_name_i_❤_u in dataDir1
new File(dataDir1, "data/ks4/table4-a6442310a57611ec8b980b0b2009844e" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u/data.db").createNewFile();
new File(dataDir1, "data/ks4/table4-a6442310a57611ec8b980b0b2009844e" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u/index.db").createNewFile();
new File(dataDir1, "data/ks4/table4-a6442310a57611ec8b980b0b2009844e" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u/nb-203-big-TOC.txt").createNewFile();
new File(dataDir1, "data/ks4/table4-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u/data.db").createNewFile();
new File(dataDir1, "data/ks4/table4-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u/index.db").createNewFile();
new File(dataDir1, "data/ks4/table4-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u/nb-203-big-TOC.txt").createNewFile();
new File(dataDir1, "data/ks4/table4abc-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u/data.db").createNewFile();
new File(dataDir1, "data/ks4/table4abc-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u/index.db").createNewFile();
new File(dataDir1, "data/ks4/table4abc-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/this_is_a_valid_snapshot_name_i_❤_u/nb-203-big-TOC.txt").createNewFile();
new File(dataDir0, "ks1/a_table/snapshots/a_snapshot/data.db").createNewFile();
new File(dataDir0, "ks1/a_table/snapshots/a_snapshot/index.db").createNewFile();
new File(dataDir0, "ks1/a_table/snapshots/a_snapshot/nb-203-big-TOC.txt").createNewFile();
new File(dataDir0, "ks1/a_table-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/a_snapshot/data.db").createNewFile();
new File(dataDir0, "ks1/a_table-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/a_snapshot/index.db").createNewFile();
new File(dataDir0, "ks1/a_table-a72c8740a57611ec935db766a70c44a1" +
"/snapshots/a_snapshot/nb-203-big-TOC.txt").createNewFile();
vertx = Vertx.vertx();
ServiceConfiguration serviceConfiguration = new ServiceConfigurationImpl();
executorPools = new ExecutorPools(vertx, serviceConfiguration);
instance = initialize(vertx, serviceConfiguration, mockInstancesMetadata, validator, executorPools);
}