def test_parse_backup_index(self):
    file_content = 'content of the test file'
    self.storage.storage_driver.upload_blob_from_string('node1/backup1/data/ks1/sstable1.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup1/data/ks1/sstable2.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup1/meta/tokenmap.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup1/meta/manifest.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup1/meta/schema.cql', file_content)
    self.storage.storage_driver.upload_blob_from_string('node2/backup1/data/ks1/sstable1.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node2/backup1/data/ks1/sstable2.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node2/backup1/meta/tokenmap.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node2/backup1/meta/manifest.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node2/backup1/meta/schema.cql', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup2/data/ks1/sstable1.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup2/data/ks1/sstable2.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup2/meta/tokenmap.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup2/meta/manifest.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup2/meta/schema.cql', file_content)
    build_indices(self.config, False)
    path = 'index/backup_index'
    backup_index = self.storage.storage_driver.list_objects(path)
    blobs_by_backup = self.storage.group_backup_index_by_backup_and_node(backup_index)
    self.assertTrue(('backup1' in blobs_by_backup))
    self.assertTrue(('backup2' in blobs_by_backup))
    self.assertTrue(('node1' in blobs_by_backup['backup1']))
    self.assertTrue(('node2' in blobs_by_backup['backup1']))
    self.assertTrue(('node1' in blobs_by_backup['backup2']))
    self.assertFalse(('node2' in blobs_by_backup['backup2']))
def test_parse_backup_index(self):
    file_content = 'content of the test file'
    self.storage.storage_driver.upload_blob_from_string('node1/backup1/data/ks1/sstable1.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup1/data/ks1/sstable2.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup1/meta/tokenmap.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup1/meta/manifest.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup1/meta/schema.cql', file_content)
    self.storage.storage_driver.upload_blob_from_string('node2/backup1/data/ks1/sstable1.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node2/backup1/data/ks1/sstable2.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node2/backup1/meta/tokenmap.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node2/backup1/meta/manifest.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node2/backup1/meta/schema.cql', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup2/data/ks1/sstable1.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup2/data/ks1/sstable2.db', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup2/meta/tokenmap.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup2/meta/manifest.json', file_content)
    self.storage.storage_driver.upload_blob_from_string('node1/backup2/meta/schema.cql', file_content)
    build_indices(self.config, False)
    path = 'index/backup_index'
    backup_index = self.storage.storage_driver.list_objects(path)
    blobs_by_backup = self.storage.group_backup_index_by_backup_and_node(backup_index)
    self.assertTrue(('backup1' in blobs_by_backup))
    self.assertTrue(('backup2' in blobs_by_backup))
    self.assertTrue(('node1' in blobs_by_backup['backup1']))
    self.assertTrue(('node2' in blobs_by_backup['backup1']))
    self.assertTrue(('node1' in blobs_by_backup['backup2']))
    self.assertFalse(('node2' in blobs_by_backup['backup2']))