[ https://issues.apache.org/jira/browse/HBASE-4448?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13109103#comment-13109103 ]
Doug Meil commented on HBASE-4448: ---------------------------------- As Jesse said, we have to reuse JVMs for this to work. Rather than doing this... {code} @BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL.startMiniCluster(1); {code} ... you would do something like this... {code} @BeforeClass public static void setUpBeforeClass() throws Exception { TEST_UTIL = HBaseTestingUtilityFactory.get().getMiniCluster(1); {code} ... and it would already be started. And rather than calling an explicit shutdown on the HBaseTestingUtility instance, you'd call a "return" on the factory... {code} HBaseTestingUtilityFactory.get().returnMiniCluster(instance); {code} ... where it would also blow away and tables that have been created so it's clean for the next person that uses it. > HBaseTestingUtilityFactory - pattern for re-using HBaseTestingUtility > instances across unit tests > ------------------------------------------------------------------------------------------------- > > Key: HBASE-4448 > URL: https://issues.apache.org/jira/browse/HBASE-4448 > Project: HBase > Issue Type: Improvement > Reporter: Doug Meil > Assignee: Doug Meil > Priority: Minor > Attachments: HBaseTestingUtilityFactory.java > > > Setting up and tearing down HBaseTestingUtility instances in unit tests is > very expensive. On my MacBook it takes about 10 seconds to set up a > MiniCluster, and 7 seconds to tear it down. When multiplied by the number of > test classes that use this facility, that's a lot of time in the build. > This factory assumes that the JVM is being re-used across test classes in the > build, otherwise this pattern won't work. > I don't think this is appropriate for every use, but I think it can be > applicable in a great many cases - especially where developers just want a > simple MiniCluster with 1 slave. -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira