Source:
<code>public void deleteStoreFilesTest() throws Exception { <START> assumeTrue(isLogSegmented); <END> store.shutdown(); File storeDir = StoreTestUtils.createTempDirectory("store-" + storeId); File reserveDir = StoreTestUtils.createTempDirectory("reserve-pool"); DiskSpaceAllocator diskAllocator = new DiskSpaceAllocator(true, reserveDir, 0, new StorageManagerMetrics(new MetricRegistry())); StoreConfig config = new StoreConfig(new VerifiableProperties(properties)); MetricRegistry registry = new MetricRegistry(); StoreMetrics metrics = new StoreMetrics(registry); BlobStore testStore = new BlobStore(getMockReplicaId(storeDir.getAbsolutePath()), config, scheduler, storeStatsScheduler, diskIOScheduler, diskAllocator, metrics, metrics, STORE_KEY_FACTORY, recovery, hardDelete, null, time); testStore.start(); diskAllocator.initializePool(Collections.singletonList(testStore.getDiskSpaceRequirements())); assertTrue("Store directory doesn't exist", storeDir.exists()); try { testStore.deleteStoreFiles(); } catch (IllegalStateException e) { } File invalidDir = new File(storeDir, "invalidDir"); assertTrue("Couldn't create dir within store dir", invalidDir.mkdir()); assertTrue("Could not make unreadable", invalidDir.setReadable(false)); testStore.shutdown(); try { testStore.deleteStoreFiles(); fail("should fail because one invalid dir is unreadable"); } catch (Exception e) { } assertTrue("store directory should exist because deletion failed", storeDir.exists()); assertTrue("Could not make readable", invalidDir.setReadable(true)); File tempFile = File.createTempFile("sample-swap", LogSegmentNameHelper.SUFFIX + BlobStoreCompactor.TEMP_LOG_SEGMENT_NAME_SUFFIX, storeDir); assertEquals("Swap reserve dir should be empty initially", 0, diskAllocator.getSwapReserveFileMap().getFileSizeSet().size()); testStore.deleteStoreFiles(); assertFalse("swap segment still exists", tempFile.exists()); assertEquals("Swap reserve dir should have one swap segment", 1, diskAllocator.getSwapReserveFileMap().getFileSizeSet().size()); assertFalse("store directory shouldn't exist", storeDir.exists()); reloadStore(); }</code><technical_language>this code tested segmented logs? put test of swap segments if (isLogSegmented)</technical_language>

Target:
public void deleteStoreFilesTest() throws Exception { store.shutdown(); File storeDir = StoreTestUtils.createTempDirectory("store-" + storeId); File reserveDir = StoreTestUtils.createTempDirectory("reserve-pool"); DiskSpaceAllocator diskAllocator = new DiskSpaceAllocator(true, reserveDir, 0, new StorageManagerMetrics(new MetricRegistry())); StoreConfig config = new StoreConfig(new VerifiableProperties(properties)); MetricRegistry registry = new MetricRegistry(); StoreMetrics metrics = new StoreMetrics(registry); BlobStore testStore = new BlobStore(getMockReplicaId(storeDir.getAbsolutePath()), config, scheduler, storeStatsScheduler, diskIOScheduler, diskAllocator, metrics, metrics, STORE_KEY_FACTORY, recovery, hardDelete, null, time); testStore.start(); DiskSpaceRequirements diskSpaceRequirements = testStore.getDiskSpaceRequirements(); diskAllocator.initializePool(diskSpaceRequirements == null ? Collections.emptyList() : Collections.singletonList(testStore.getDiskSpaceRequirements())); assertTrue("Store directory doesn't exist", storeDir.exists()); try { testStore.deleteStoreFiles(); } catch (IllegalStateException e) { } File invalidDir = new File(storeDir, "invalidDir"); assertTrue("Couldn't create dir within store dir", invalidDir.mkdir()); assertTrue("Could not make unreadable", invalidDir.setReadable(false)); testStore.shutdown(); try { testStore.deleteStoreFiles(); fail("should fail because one invalid dir is unreadable"); } catch (Exception e) { } assertTrue("store directory should exist because deletion failed", storeDir.exists()); assertTrue("Could not make readable", invalidDir.setReadable(true)); File tempFile = File.createTempFile("sample-swap", LogSegmentNameHelper.SUFFIX + BlobStoreCompactor.TEMP_LOG_SEGMENT_NAME_SUFFIX, storeDir); assertEquals("Swap reserve dir should be empty initially", 0, diskAllocator.getSwapReserveFileMap().getFileSizeSet().size()); testStore.deleteStoreFiles(); assertFalse("swap segment still exists", tempFile.exists()); assertEquals("Swap reserve dir should have one swap segment", 1, diskAllocator.getSwapReserveFileMap().getFileSizeSet().size()); assertFalse("store directory shouldn't exist", storeDir.exists()); reloadStore(); }