From fbedf89377e540fb10239a880fc2e01ef7021b93 Mon Sep 17 00:00:00 2001 From: Daniel Templeton Date: Thu, 16 Aug 2018 13:43:49 -0700 Subject: [PATCH] HDFS-13746. Still occasional "Should be different group" failure in TestRefreshUserMappings#testGroupMappingRefresh (Contributed by Siyao Meng via Daniel Templeton) Change-Id: I9fad1537ace38367a463d9fe67aaa28d3178fc69 (cherry picked from commit 8512e1a91be3e340d919c7cdc9c09dfb762a6a4e) --- .../security/TestRefreshUserMappings.java | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestRefreshUserMappings.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestRefreshUserMappings.java index 0e7dfc32611..2d7410a405c 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestRefreshUserMappings.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/security/TestRefreshUserMappings.java @@ -34,7 +34,6 @@ import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLDecoder; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.apache.hadoop.conf.Configuration; @@ -46,6 +45,8 @@ import org.apache.hadoop.security.authorize.AuthorizationException; import org.apache.hadoop.security.authorize.DefaultImpersonationProvider; import org.apache.hadoop.security.authorize.ProxyUsers; import org.apache.hadoop.test.GenericTestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.slf4j.event.Level; import org.junit.After; import org.junit.Before; @@ -53,6 +54,8 @@ import org.junit.Test; public class TestRefreshUserMappings { + private static final Logger LOG = LoggerFactory.getLogger( + TestRefreshUserMappings.class); private MiniDFSCluster cluster; Configuration config; private static final long groupRefreshTimeoutSec = 1; @@ -119,42 +122,42 @@ public class TestRefreshUserMappings { Groups groups = Groups.getUserToGroupsMappingService(config); String user = UserGroupInformation.getCurrentUser().getUserName(); - System.out.println("First attempt:"); + LOG.debug("First attempt:"); List g1 = groups.getGroups(user); - String [] str_groups = new String [g1.size()]; - g1.toArray(str_groups); - System.out.println(Arrays.toString(str_groups)); - - System.out.println("Second attempt, should be the same:"); + LOG.debug(g1.toString()); + + LOG.debug("Second attempt, should be the same:"); List g2 = groups.getGroups(user); - g2.toArray(str_groups); - System.out.println(Arrays.toString(str_groups)); + LOG.debug(g2.toString()); for(int i=0; i g3 = groups.getGroups(user); - g3.toArray(str_groups); - System.out.println(Arrays.toString(str_groups)); + LOG.debug(g3.toString()); for(int i=0; i g4 = groups.getGroups(user); - g4.toArray(str_groups); - System.out.println(Arrays.toString(str_groups)); - for(int i=0; i { + List g4; + try { + g4 = groups.getGroups(user); + } catch (IOException e) { + return false; + } + LOG.debug(g4.toString()); + // if g4 is the same as g3, wait and retry + return !g3.equals(g4); + }, 50, Math.toIntExact(groupRefreshTimeoutSec * 1000 * 30)); } - + @Test public void testRefreshSuperUserGroupsConfiguration() throws Exception { final String SUPER_USER = "super_user";