You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2018/02/21 23:26:24 UTC
[bookkeeper] branch master updated: Fix GSSAPIBookKeeperTest
This is an automated email from the ASF dual-hosted git repository.
sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new f76041b Fix GSSAPIBookKeeperTest
f76041b is described below
commit f76041b9c81c3856843ce04b09ed39c14fe8c274
Author: Sijie Guo <si...@apache.org>
AuthorDate: Wed Feb 21 15:26:16 2018 -0800
Fix GSSAPIBookKeeperTest
Descriptions of the changes in this PR:
*Problem*
in GSSAPIBookKeeperTest, `InetAddress.getLocalHost().getHostName()` was used for adding principle to kdc keytab. However in the tests, it uses advertisedAddress (introduced by #1097).
So it causes authentication failed because server can't be found.
*Solution*
Change to use `Bookie. getBookieAddress(..)` to get the real hostname used by bookie for adding keytab entries.
Author: Sijie Guo <si...@apache.org>
Reviewers: Charan Reddy Guttapalem <re...@gmail.com>, Enrico Olivelli <eo...@gmail.com>
This closes #1191 from sijie/fix_gssapibookkeeper_test
---
.../org/apache/bookkeeper/sasl/GSSAPIBookKeeperTest.java | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/sasl/GSSAPIBookKeeperTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/sasl/GSSAPIBookKeeperTest.java
index 3bfa829..db39ae7 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/sasl/GSSAPIBookKeeperTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/sasl/GSSAPIBookKeeperTest.java
@@ -28,13 +28,13 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
-import java.net.InetAddress;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.Properties;
import java.util.concurrent.atomic.AtomicLong;
import javax.security.auth.login.Configuration;
+import org.apache.bookkeeper.bookie.Bookie;
import org.apache.bookkeeper.client.BKException;
import org.apache.bookkeeper.client.BKException.BKUnauthorizedAccessException;
import org.apache.bookkeeper.client.BookKeeper;
@@ -82,7 +82,9 @@ public class GSSAPIBookKeeperTest extends BookKeeperClusterTestCase {
kdc = new MiniKdc(conf, kdcDir.getRoot());
kdc.start();
- String localhostName = InetAddress.getLocalHost().getHostName();
+ ServerConfiguration bookieConf = newServerConfiguration();
+ bookieConf.setUseHostNameAsBookieID(true);
+ String localhostName = Bookie.getBookieAddress(bookieConf).getHostName();
String principalServerNoRealm = "bookkeeper/" + localhostName;
String principalServer = "bookkeeper/" + localhostName + "@" + kdc.getRealm();
@@ -172,12 +174,12 @@ public class GSSAPIBookKeeperTest extends BookKeeperClusterTestCase {
/**
* check if the entry exists. Restart the bookie to allow access
*/
- private int entryCount(long ledgerId, ServerConfiguration bookieConf,
- ClientConfiguration clientConf) throws Exception {
+ private int entryCount(long ledgerId, ClientConfiguration clientConf)
+ throws Exception {
LOG.info("Counting entries in {}", ledgerId);
for (ServerConfiguration conf : bsConfs) {
- bookieConf.setUseHostNameAsBookieID(true);
- bookieConf.setBookieAuthProviderFactoryClass(
+ conf.setUseHostNameAsBookieID(true);
+ conf.setBookieAuthProviderFactoryClass(
SASLBookieAuthProviderFactory.class.getName());
}
clientConf.setClientAuthProviderFactoryClass(
@@ -222,7 +224,7 @@ public class GSSAPIBookKeeperTest extends BookKeeperClusterTestCase {
connectAndWriteToBookie(clientConf, ledgerId); // should succeed
assertFalse(ledgerId.get() == -1);
- assertEquals("Should have entry", 1, entryCount(ledgerId.get(), bookieConf, clientConf));
+ assertEquals("Should have entry", 1, entryCount(ledgerId.get(), clientConf));
}
@Test
--
To stop receiving notification emails like this one, please contact
sijie@apache.org.