// Waits for a worker heartbeat to master to be processed private void waitForHeartbeat() throws InterruptedException { Assert.assertTrue( HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5, TimeUnit.SECONDS)); HeartbeatScheduler.schedule(HeartbeatContext.WORKER_BLOCK_SYNC); // Wait for the next heartbeat to be ready to guarantee that the previous heartbeat has finished Assert.assertTrue( HeartbeatScheduler.await(HeartbeatContext.WORKER_BLOCK_SYNC, 5, TimeUnit.SECONDS)); }
@Test public void ttlExpiredCreateFileTest() throws Exception { mFsMaster.createDirectory(new AlluxioURI("/testFolder"), CreateDirectoryOptions.defaults()); long ttl = 1; CreateFileOptions options = CreateFileOptions.defaults().setTtl(ttl); long fileId = mFsMaster.createFile(new AlluxioURI("/testFolder/testFile1"), options); FileInfo folderInfo = mFsMaster.getFileInfo(mFsMaster.getFileId(new AlluxioURI("/testFolder/testFile1"))); Assert.assertEquals(fileId, folderInfo.getFileId()); Assert.assertEquals(ttl, folderInfo.getTtl()); // Sleep for the ttl expiration. CommonUtils.sleepMs(2 * TTL_CHECKER_INTERVAL_MS); Assert.assertTrue( HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 10, TimeUnit.SECONDS)); HeartbeatScheduler.schedule(HeartbeatContext.MASTER_TTL_CHECK); Assert.assertTrue( HeartbeatScheduler.await(HeartbeatContext.MASTER_TTL_CHECK, 10, TimeUnit.SECONDS)); mThrown.expect(FileDoesNotExistException.class); mFsMaster.getFileInfo(fileId); }