You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2019/11/28 10:00:21 UTC

[GitHub] [hbase-connectors] iadamcsik-cldr commented on a change in pull request #47: HBASE-23295 HBaseContext should use most recent delegation token

iadamcsik-cldr commented on a change in pull request #47: HBASE-23295 HBaseContext should use most recent delegation token
URL: https://github.com/apache/hbase-connectors/pull/47#discussion_r351687174
 
 

 ##########
 File path: spark/hbase-spark/src/test/java/org/apache/hadoop/hbase/spark/TestJavaHBaseContext.java
 ##########
 @@ -70,68 +72,70 @@
   public static final HBaseClassTestRule TIMEOUT =
       HBaseClassTestRule.forClass(TestJavaHBaseContext.class);
 
-  private transient JavaSparkContext jsc;
-  HBaseTestingUtility htu;
-  protected static final Logger LOG = LoggerFactory.getLogger(TestJavaHBaseContext.class);
-
-
+  private static transient JavaSparkContext JSC;
+  private static HBaseTestingUtility HTU;
+  private static JavaHBaseContext HBASE_CONTEXT;
+  private static final Logger LOG = LoggerFactory.getLogger(TestJavaHBaseContext.class);
 
   byte[] tableName = Bytes.toBytes("t1");
   byte[] columnFamily = Bytes.toBytes("c");
   byte[] columnFamily1 = Bytes.toBytes("d");
   String columnFamilyStr = Bytes.toString(columnFamily);
   String columnFamilyStr1 = Bytes.toString(columnFamily1);
 
-
-  @Before
-  public void setUp() {
-    jsc = new JavaSparkContext("local", "JavaHBaseContextSuite");
-
+  @BeforeClass
+  public static void setUpBeforeClass() throws Exception {
     File tempDir = Files.createTempDir();
     tempDir.deleteOnExit();
 
-    htu = new HBaseTestingUtility();
-    try {
-      LOG.info("cleaning up test dir");
+    JSC = new JavaSparkContext("local", "JavaHBaseContextSuite");
+    HTU = new HBaseTestingUtility();
+    Configuration conf = HTU.getConfiguration();
 
-      htu.cleanupTestDir();
+    HBASE_CONTEXT = new JavaHBaseContext(JSC, conf);
 
-      LOG.info("starting minicluster");
+    LOG.info("cleaning up test dir");
 
-      htu.startMiniZKCluster();
-      htu.startMiniHBaseCluster(1, 1);
+    HTU.cleanupTestDir();
 
-      LOG.info(" - minicluster started");
+    LOG.info("starting minicluster");
 
-      try {
-        htu.deleteTable(TableName.valueOf(tableName));
-      } catch (Exception e) {
-        LOG.info(" - no table " + Bytes.toString(tableName) + " found");
-      }
+    HTU.startMiniZKCluster();
+    HTU.startMiniHBaseCluster(1, 1);
 
-      LOG.info(" - creating table " + Bytes.toString(tableName));
-      htu.createTable(TableName.valueOf(tableName),
-          new byte[][]{columnFamily, columnFamily1});
-      LOG.info(" - created table");
-    } catch (Exception e1) {
-      throw new RuntimeException(e1);
-    }
+    LOG.info(" - minicluster started");
   }
 
-  @After
-  public void tearDown() {
+  @AfterClass
+  public static void tearDownAfterClass() throws Exception {
+    LOG.info("shuting down minicluster");
+    HTU.shutdownMiniHBaseCluster();
+    HTU.shutdownMiniZKCluster();
+    LOG.info(" - minicluster shut down");
+    HTU.cleanupTestDir();
+
+    JSC.stop();
+    JSC = null;
+  }
+
+  @Before
+  public void setUp() throws Exception {
+
     try {
-      htu.deleteTable(TableName.valueOf(tableName));
-      LOG.info("shuting down minicluster");
-      htu.shutdownMiniHBaseCluster();
-      htu.shutdownMiniZKCluster();
-      LOG.info(" - minicluster shut down");
-      htu.cleanupTestDir();
+      HTU.deleteTable(TableName.valueOf(tableName));
     } catch (Exception e) {
-      throw new RuntimeException(e);
+      LOG.info(" - no table " + Bytes.toString(tableName) + " found");
 
 Review comment:
   These code parts should not have changed, looks like the cherry pick applied more than I asked for, let me revert these parts as well.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services