ACCUMULO-4428 Stabilize the new GarbageCollectorIT Use the clusterControl on MAC to alter the state. Make the verification based on the filesystem instead of log messages from the GC.
Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/b0181fe5 Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/b0181fe5 Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/b0181fe5 Branch: refs/heads/1.8 Commit: b0181fe5e5858a9f93c69f8c54ff0b8102484de4 Parents: 9d4a46a Author: Josh Elser <els...@apache.org> Authored: Wed Aug 31 15:13:23 2016 -0400 Committer: Josh Elser <els...@apache.org> Committed: Fri Sep 2 16:08:54 2016 -0400 ---------------------------------------------------------------------- .../test/functional/GarbageCollectorIT.java | 36 ++++++++------------ 1 file changed, 14 insertions(+), 22 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/accumulo/blob/b0181fe5/test/src/test/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java ---------------------------------------------------------------------- diff --git a/test/src/test/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java b/test/src/test/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java index 94cd1fc..475529b 100644 --- a/test/src/test/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java +++ b/test/src/test/java/org/apache/accumulo/test/functional/GarbageCollectorIT.java @@ -100,9 +100,9 @@ public class GarbageCollectorIT extends ConfigurableMacIT { hadoopCoreSite.set("fs.file.impl", RawLocalFileSystem.class.getName()); } - private void killMacGc() throws ProcessNotFoundException, InterruptedException, KeeperException { + private void killMacGc() throws ProcessNotFoundException, InterruptedException, KeeperException, IOException { // kill gc started by MAC - getCluster().killProcess(ServerType.GARBAGE_COLLECTOR, getCluster().getProcesses().get(ServerType.GARBAGE_COLLECTOR).iterator().next()); + getCluster().getClusterControl().stop(ServerType.GARBAGE_COLLECTOR); // delete lock in zookeeper if there, this will allow next GC to start quickly String path = ZooUtil.getRoot(new ZooKeeperInstance(getCluster().getClientConfig())) + Constants.ZGC_LOCK; ZooReaderWriter zk = new ZooReaderWriter(cluster.getZooKeepers(), 30000, OUR_SECRET); @@ -115,10 +115,6 @@ public class GarbageCollectorIT extends ConfigurableMacIT { assertNull(getCluster().getProcesses().get(ServerType.GARBAGE_COLLECTOR)); } - private void killMacTServer() throws ProcessNotFoundException, InterruptedException, KeeperException { - getCluster().killProcess(ServerType.TABLET_SERVER, getCluster().getProcesses().get(ServerType.TABLET_SERVER).iterator().next()); - } - @Test public void gcTest() throws Exception { killMacGc(); @@ -169,29 +165,25 @@ public class GarbageCollectorIT extends ConfigurableMacIT { // Test WAL log has been created List<String> walsBefore = getWALsForTableId(tableId); Assert.assertEquals("Should be one WAL", 1, walsBefore.size()); - - // Flush and check for no WAL logs - c.tableOperations().flush("test_ingest", null, null, true); - List<String> walsAfter = getWALsForTableId(tableId); - Assert.assertEquals("Should be no WALs", 0, walsAfter.size()); + final File walToBeDeleted = new File(walsBefore.get(0).split("\\|")[0].replaceFirst("file:///", "")); // Validate WAL file still exists - String walFile = walsBefore.get(0).split("\\|")[0].replaceFirst("file:///", ""); - File wf = new File(walFile); - Assert.assertEquals("WAL file does not exist", true, wf.exists()); + Assert.assertEquals("WAL file does not exist", true, walToBeDeleted.exists()); - // Kill TServer and give it some time to die and master to rebalance - killMacTServer(); + // Kill TServers and give it some time to die + getCluster().getClusterControl().stop(ServerType.TABLET_SERVER); UtilWaitThread.sleep(5000); + // Restart them or the GC won't ever be able to run a cycle + getCluster().getClusterControl().start(ServerType.TABLET_SERVER); // Restart GC and let it run - Process gc = getCluster().exec(SimpleGarbageCollector.class); - UtilWaitThread.sleep(60000); + getCluster().getClusterControl().start(ServerType.GARBAGE_COLLECTOR); - // Then check the log for proper events - String output = FunctionalTestUtils.readAll(getCluster(), SimpleGarbageCollector.class, gc); - assertTrue("WAL GC should have started", output.contains("Beginning garbage collection of write-ahead logs")); - assertTrue("WAL was not removed even though tserver was down", output.contains("Removing WAL for offline server")); + log.info("Waiting for garbage collector to delete the WAL {}", walToBeDeleted); + while (walToBeDeleted.exists()) { + // Wait for the file to be deleted + Thread.sleep(2000); + } } @Test