From 116458ab0494dc938488a6ccde11a4a7b69bf9dd Mon Sep 17 00:00:00 2001 From: Duo Zhang Date: Tue, 16 Aug 2022 21:43:03 +0800 Subject: [PATCH] HBASE-27279 Addendum fix TestSaslTlsIPCRejectPlainText --- .../security/AbstractTestTlsRejectPlainText.java | 2 +- .../security/TestNettyTlsIPCRejectPlainText.java | 2 ++ .../hbase/security/TestSaslTlsIPCRejectPlainText.java | 11 ++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/AbstractTestTlsRejectPlainText.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/AbstractTestTlsRejectPlainText.java index 9e69e92f165..9586fde5f2f 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/AbstractTestTlsRejectPlainText.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/AbstractTestTlsRejectPlainText.java @@ -59,7 +59,7 @@ import org.apache.hadoop.hbase.shaded.ipc.protobuf.generated.TestRpcServiceProto public abstract class AbstractTestTlsRejectPlainText { - protected static final HBaseCommonTestingUtil UTIL = new HBaseCommonTestingUtil(); + protected static HBaseCommonTestingUtil UTIL; protected static File DIR; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestNettyTlsIPCRejectPlainText.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestNettyTlsIPCRejectPlainText.java index d9a14131c30..378101f76f3 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestNettyTlsIPCRejectPlainText.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestNettyTlsIPCRejectPlainText.java @@ -19,6 +19,7 @@ package org.apache.hadoop.hbase.security; import java.io.IOException; import org.apache.hadoop.hbase.HBaseClassTestRule; +import org.apache.hadoop.hbase.HBaseCommonTestingUtil; import org.apache.hadoop.hbase.ipc.TestProtobufRpcServiceImpl; import org.apache.hadoop.hbase.testclassification.MediumTests; import org.apache.hadoop.hbase.testclassification.RPCTests; @@ -41,6 +42,7 @@ public class TestNettyTlsIPCRejectPlainText extends AbstractTestTlsRejectPlainTe @BeforeClass public static void setUpBeforeClass() throws IOException { + UTIL = new HBaseCommonTestingUtil(); initialize(); } diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestSaslTlsIPCRejectPlainText.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestSaslTlsIPCRejectPlainText.java index 8c0d45921b7..a6984fcdf3a 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestSaslTlsIPCRejectPlainText.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/security/TestSaslTlsIPCRejectPlainText.java @@ -46,9 +46,7 @@ public class TestSaslTlsIPCRejectPlainText extends AbstractTestTlsRejectPlainTex public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestSaslTlsIPCRejectPlainText.class); - private static final HBaseTestingUtil UTIL = new HBaseTestingUtil(); - - private static final File KEYTAB_FILE = new File(UTIL.getDataTestDir("keytab").toUri().getPath()); + private static File KEYTAB_FILE; private static MiniKdc KDC; private static String HOST = "localhost"; @@ -57,13 +55,16 @@ public class TestSaslTlsIPCRejectPlainText extends AbstractTestTlsRejectPlainTex @BeforeClass public static void setUpBeforeClass() throws Exception { + HBaseTestingUtil util = new HBaseTestingUtil(); + UTIL = util; initialize(); - KDC = UTIL.setupMiniKdc(KEYTAB_FILE); + KEYTAB_FILE = new File(util.getDataTestDir("keytab").toUri().getPath()); + KDC = util.setupMiniKdc(KEYTAB_FILE); PRINCIPAL = "hbase/" + HOST; KDC.createPrincipal(KEYTAB_FILE, PRINCIPAL); HBaseKerberosUtils.setPrincipalForTesting(PRINCIPAL + "@" + KDC.getRealm()); UGI = loginKerberosPrincipal(KEYTAB_FILE.getCanonicalPath(), PRINCIPAL); - setSecuredConfiguration(UTIL.getConfiguration()); + setSecuredConfiguration(util.getConfiguration()); SecurityInfo securityInfoMock = Mockito.mock(SecurityInfo.class); Mockito.when(securityInfoMock.getServerPrincipal()) .thenReturn(HBaseKerberosUtils.KRB_PRINCIPAL);