Example #1
0
        public virtual void TestGetClusterNodeLabelsWithLocalAccess()
        {
            YarnClient client = Org.Mockito.Mockito.Mock <YarnClient>();

            Org.Mockito.Mockito.When(client.GetClusterNodeLabels()).ThenReturn(ImmutableSet.Of
                                                                                   ("remote1", "remote2"));
            ClusterCLI cli = new ClusterCLI();

            cli.SetClient(client);
            cli.SetSysOutPrintStream(sysOut);
            cli.SetSysErrPrintStream(sysErr);
            ClusterCLI.localNodeLabelsManager = Org.Mockito.Mockito.Mock <CommonNodeLabelsManager
                                                                          >();
            Org.Mockito.Mockito.When(ClusterCLI.localNodeLabelsManager.GetClusterNodeLabels()
                                     ).ThenReturn(ImmutableSet.Of("local1", "local2"));
            int rc = cli.Run(new string[] { ClusterCLI.Cmd, "-" + ClusterCLI.ListLabelsCmd, "-"
                                            + ClusterCLI.DirectlyAccessNodeLabelStore });

            NUnit.Framework.Assert.AreEqual(0, rc);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PrintWriter           pw   = new PrintWriter(baos);

            // it should return local* instead of remote*
            pw.Write("Node Labels: local1,local2");
            pw.Close();
            Org.Mockito.Mockito.Verify(sysOut).WriteLine(baos.ToString("UTF-8"));
        }
Example #2
0
        public virtual void TestGetEmptyClusterNodeLabels()
        {
            YarnClient client = Org.Mockito.Mockito.Mock <YarnClient>();

            Org.Mockito.Mockito.When(client.GetClusterNodeLabels()).ThenReturn(new HashSet <string
                                                                                            >());
            ClusterCLI cli = new ClusterCLI();

            cli.SetClient(client);
            cli.SetSysOutPrintStream(sysOut);
            cli.SetSysErrPrintStream(sysErr);
            int rc = cli.Run(new string[] { ClusterCLI.Cmd, "-" + ClusterCLI.ListLabelsCmd });

            NUnit.Framework.Assert.AreEqual(0, rc);
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            PrintWriter           pw   = new PrintWriter(baos);

            pw.Write("Node Labels: ");
            pw.Close();
            Org.Mockito.Mockito.Verify(sysOut).WriteLine(baos.ToString("UTF-8"));
        }
Example #3
0
 /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/>
 /// <exception cref="System.IO.IOException"/>
 public override ICollection <string> GetClusterNodeLabels()
 {
     return(client.GetClusterNodeLabels());
 }