Ejemplo n.º 1
0
        public static void LoadTest(string ipString, int testRange)
        {
            Configuration conf = new Configuration();

            conf.Set(DefaultImpersonationProvider.GetTestProvider().GetProxySuperuserGroupConfKey
                         (RealUserName), StringUtils.Join(",", Arrays.AsList(GroupNames)));
            conf.Set(DefaultImpersonationProvider.GetTestProvider().GetProxySuperuserIpConfKey
                         (RealUserName), ipString);
            ProxyUsers.RefreshSuperUserGroupsConfiguration(conf);
            // First try proxying a group that's allowed
            UserGroupInformation realUserUgi = UserGroupInformation.CreateRemoteUser(RealUserName
                                                                                     );
            UserGroupInformation proxyUserUgi = UserGroupInformation.CreateProxyUserForTesting
                                                    (ProxyUserName, realUserUgi, GroupNames);
            long         startTime = Runtime.NanoTime();
            SecureRandom sr        = new SecureRandom();

            for (int i = 1; i < 1000000; i++)
            {
                try
                {
                    ProxyUsers.Authorize(proxyUserUgi, "1.2.3." + sr.Next(testRange));
                }
                catch (AuthorizationException)
                {
                }
            }
            long stopTime    = Runtime.NanoTime();
            long elapsedTime = stopTime - startTime;

            System.Console.Out.WriteLine(elapsedTime / 1000000 + " ms");
        }
Ejemplo n.º 2
0
 // Expected
 private void AssertAuthorized(UserGroupInformation proxyUgi, string host)
 {
     try
     {
         ProxyUsers.Authorize(proxyUgi, host);
     }
     catch (AuthorizationException)
     {
         NUnit.Framework.Assert.Fail("Did not allow authorization of " + proxyUgi + " from "
                                     + host);
     }
 }