コード例 #1
0
        public virtual void TestJobsQueryStartTimeNegative()
        {
            WebResource    r        = Resource();
            ClientResponse response = r.Path("ws").Path("v1").Path("history").Path("mapreduce"
                                                                                   ).Path("jobs").QueryParam("startedTimeBegin", (-1000).ToString()).Accept(MediaType
                                                                                                                                                            .ApplicationJson).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(ClientResponse.Status.BadRequest, response.GetClientResponseStatus
                                                ());
            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject msg       = response.GetEntity <JSONObject>();
            JSONObject exception = msg.GetJSONObject("RemoteException");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 3, exception.Length
                                                ());
            string message   = exception.GetString("message");
            string type      = exception.GetString("exception");
            string classname = exception.GetString("javaClassName");

            WebServicesTestUtils.CheckStringMatch("exception message", "java.lang.Exception: startedTimeBegin must be greater than 0"
                                                  , message);
            WebServicesTestUtils.CheckStringMatch("exception type", "BadRequestException", type
                                                  );
            WebServicesTestUtils.CheckStringMatch("exception classname", "org.apache.hadoop.yarn.webapp.BadRequestException"
                                                  , classname);
        }
コード例 #2
0
        // acls not being checked since
        // we are using mock job instead of CompletedJob
        public static void VerifyHsJobGeneric(Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job
                                              job, string id, string user, string name, string state, string queue, long startTime
                                              , long finishTime, int mapsTotal, int mapsCompleted, int reducesTotal, int reducesCompleted
                                              )
        {
            JobReport report = job.GetReport();

            WebServicesTestUtils.CheckStringMatch("id", MRApps.ToString(job.GetID()), id);
            WebServicesTestUtils.CheckStringMatch("user", job.GetUserName().ToString(), user);
            WebServicesTestUtils.CheckStringMatch("name", job.GetName(), name);
            WebServicesTestUtils.CheckStringMatch("state", job.GetState().ToString(), state);
            WebServicesTestUtils.CheckStringMatch("queue", job.GetQueueName(), queue);
            NUnit.Framework.Assert.AreEqual("startTime incorrect", report.GetStartTime(), startTime
                                            );
            NUnit.Framework.Assert.AreEqual("finishTime incorrect", report.GetFinishTime(), finishTime
                                            );
            NUnit.Framework.Assert.AreEqual("mapsTotal incorrect", job.GetTotalMaps(), mapsTotal
                                            );
            NUnit.Framework.Assert.AreEqual("mapsCompleted incorrect", job.GetCompletedMaps()
                                            , mapsCompleted);
            NUnit.Framework.Assert.AreEqual("reducesTotal incorrect", job.GetTotalReduces(),
                                            reducesTotal);
            NUnit.Framework.Assert.AreEqual("reducesCompleted incorrect", job.GetCompletedReduces
                                                (), reducesCompleted);
        }
コード例 #3
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        public virtual void VerifyHsJobTaskAttemptCounters(JSONObject info, TaskAttempt att
                                                           )
        {
            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 2, info.Length());
            WebServicesTestUtils.CheckStringMatch("id", MRApps.ToString(att.GetID()), info.GetString
                                                      ("id"));
            // just do simple verification of fields - not data is correct
            // in the fields
            JSONArray counterGroups = info.GetJSONArray("taskAttemptCounterGroup");

            for (int i = 0; i < counterGroups.Length(); i++)
            {
                JSONObject counterGroup = counterGroups.GetJSONObject(i);
                string     name         = counterGroup.GetString("counterGroupName");
                NUnit.Framework.Assert.IsTrue("name not set", (name != null && !name.IsEmpty()));
                JSONArray counters = counterGroup.GetJSONArray("counter");
                for (int j = 0; j < counters.Length(); j++)
                {
                    JSONObject counter     = counters.GetJSONObject(j);
                    string     counterName = counter.GetString("name");
                    NUnit.Framework.Assert.IsTrue("name not set", (counterName != null && !counterName
                                                                   .IsEmpty()));
                    long value = counter.GetLong("value");
                    NUnit.Framework.Assert.IsTrue("value  >= 0", value >= 0);
                }
            }
        }
コード例 #4
0
        public virtual void TestSingleNodeQueryStateLost()
        {
            WebResource r   = Resource();
            MockNM      nm1 = rm.RegisterNode("h1:1234", 5120);
            MockNM      nm2 = rm.RegisterNode("h2:1234", 5120);

            rm.SendNodeStarted(nm1);
            rm.SendNodeStarted(nm2);
            rm.NMwaitForState(nm1.GetNodeId(), NodeState.Running);
            rm.NMwaitForState(nm2.GetNodeId(), NodeState.Running);
            rm.SendNodeLost(nm1);
            rm.SendNodeLost(nm2);
            ClientResponse response = r.Path("ws").Path("v1").Path("cluster").Path("nodes").Path
                                          ("h2:1234").Accept(MediaType.ApplicationJson).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();
            JSONObject info = json.GetJSONObject("node");
            string     id   = info.Get("id").ToString();

            NUnit.Framework.Assert.AreEqual("Incorrect Node Information.", "h2:1234", id);
            RMNode rmNode = rm.GetRMContext().GetInactiveRMNodes()["h2"];

            WebServicesTestUtils.CheckStringMatch("nodeHTTPAddress", string.Empty, info.GetString
                                                      ("nodeHTTPAddress"));
            WebServicesTestUtils.CheckStringMatch("state", rmNode.GetState().ToString(), info
                                                  .GetString("state"));
        }
コード例 #5
0
        public virtual void TestJobsQueryFinishTimeEndInvalidformat()
        {
            WebResource    r        = Resource();
            ClientResponse response = r.Path("ws").Path("v1").Path("history").Path("mapreduce"
                                                                                   ).Path("jobs").QueryParam("finishedTimeEnd", "efsd").Accept(MediaType.ApplicationJson
                                                                                                                                               ).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(ClientResponse.Status.BadRequest, response.GetClientResponseStatus
                                                ());
            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject msg       = response.GetEntity <JSONObject>();
            JSONObject exception = msg.GetJSONObject("RemoteException");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 3, exception.Length
                                                ());
            string message   = exception.GetString("message");
            string type      = exception.GetString("exception");
            string classname = exception.GetString("javaClassName");

            WebServicesTestUtils.CheckStringMatch("exception message", "java.lang.Exception: Invalid number format: For input string: \"efsd\""
                                                  , message);
            WebServicesTestUtils.CheckStringMatch("exception type", "BadRequestException", type
                                                  );
            WebServicesTestUtils.CheckStringMatch("exception classname", "org.apache.hadoop.yarn.webapp.BadRequestException"
                                                  , classname);
        }
コード例 #6
0
 public virtual void VerifyHsTaskCountersXML(NodeList nodes, TaskAttempt att)
 {
     for (int i = 0; i < nodes.GetLength(); i++)
     {
         Element element = (Element)nodes.Item(i);
         WebServicesTestUtils.CheckStringMatch("id", MRApps.ToString(att.GetID()), WebServicesTestUtils
                                               .GetXmlString(element, "id"));
         // just do simple verification of fields - not data is correct
         // in the fields
         NodeList groups = element.GetElementsByTagName("taskAttemptCounterGroup");
         for (int j = 0; j < groups.GetLength(); j++)
         {
             Element counters = (Element)groups.Item(j);
             NUnit.Framework.Assert.IsNotNull("should have counters in the web service info",
                                              counters);
             string name = WebServicesTestUtils.GetXmlString(counters, "counterGroupName");
             NUnit.Framework.Assert.IsTrue("name not set", (name != null && !name.IsEmpty()));
             NodeList counterArr = counters.GetElementsByTagName("counter");
             for (int z = 0; z < counterArr.GetLength(); z++)
             {
                 Element counter     = (Element)counterArr.Item(z);
                 string  counterName = WebServicesTestUtils.GetXmlString(counter, "name");
                 NUnit.Framework.Assert.IsTrue("counter name not set", (counterName != null && !counterName
                                                                        .IsEmpty()));
                 long value = WebServicesTestUtils.GetXmlLong(counter, "value");
                 NUnit.Framework.Assert.IsTrue("value not >= 0", value >= 0);
             }
         }
     }
 }
コード例 #7
0
 /// <exception cref="System.Exception"/>
 public virtual void VerifyClusterSchedulerXML(NodeList nodes)
 {
     for (int i = 0; i < nodes.GetLength(); i++)
     {
         Element element = (Element)nodes.Item(i);
         VerifyClusterSchedulerGeneric(WebServicesTestUtils.GetXmlAttrString(element, "xsi:type"
                                                                             ), WebServicesTestUtils.GetXmlFloat(element, "usedCapacity"), WebServicesTestUtils
                                       .GetXmlFloat(element, "capacity"), WebServicesTestUtils.GetXmlFloat(element, "maxCapacity"
                                                                                                           ), WebServicesTestUtils.GetXmlString(element, "queueName"));
         NodeList children = element.GetChildNodes();
         for (int j = 0; j < children.GetLength(); j++)
         {
             Element qElem = (Element)children.Item(j);
             if (qElem.GetTagName().Equals("queues"))
             {
                 NodeList qListInfos = qElem.GetChildNodes();
                 for (int k = 0; k < qListInfos.GetLength(); k++)
                 {
                     Element qElem2 = (Element)qListInfos.Item(k);
                     string  qName2 = WebServicesTestUtils.GetXmlString(qElem2, "queueName");
                     string  q2     = CapacitySchedulerConfiguration.Root + "." + qName2;
                     VerifySubQueueXML(qElem2, q2, 100, 100);
                 }
             }
         }
     }
 }
コード例 #8
0
        public virtual void TestJobsQueryStateInvalid()
        {
            WebResource    r        = Resource();
            ClientResponse response = r.Path("ws").Path("v1").Path("history").Path("mapreduce"
                                                                                   ).Path("jobs").QueryParam("state", "InvalidState").Accept(MediaType.ApplicationJson
                                                                                                                                             ).Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(ClientResponse.Status.BadRequest, response.GetClientResponseStatus
                                                ());
            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject msg       = response.GetEntity <JSONObject>();
            JSONObject exception = msg.GetJSONObject("RemoteException");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 3, exception.Length
                                                ());
            string message   = exception.GetString("message");
            string type      = exception.GetString("exception");
            string classname = exception.GetString("javaClassName");

            WebServicesTestUtils.CheckStringContains("exception message", "org.apache.hadoop.mapreduce.v2.api.records.JobState.InvalidState"
                                                     , message);
            WebServicesTestUtils.CheckStringMatch("exception type", "IllegalArgumentException"
                                                  , type);
            WebServicesTestUtils.CheckStringMatch("exception classname", "java.lang.IllegalArgumentException"
                                                  , classname);
        }
コード例 #9
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        public virtual void VerifySchedulerFifoXML(string xml)
        {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.NewInstance();
            DocumentBuilder        db  = dbf.NewDocumentBuilder();
            InputSource            @is = new InputSource();

            @is.SetCharacterStream(new StringReader(xml));
            Document dom        = db.Parse(@is);
            NodeList nodesSched = dom.GetElementsByTagName("scheduler");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodesSched.GetLength
                                                ());
            NodeList nodes = dom.GetElementsByTagName("schedulerInfo");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.GetLength
                                                ());
            for (int i = 0; i < nodes.GetLength(); i++)
            {
                Element element = (Element)nodes.Item(i);
                VerifyClusterSchedulerFifoGeneric(WebServicesTestUtils.GetXmlAttrString(element,
                                                                                        "xsi:type"), WebServicesTestUtils.GetXmlString(element, "qstate"), WebServicesTestUtils
                                                  .GetXmlFloat(element, "capacity"), WebServicesTestUtils.GetXmlFloat(element, "usedCapacity"
                                                                                                                      ), WebServicesTestUtils.GetXmlInt(element, "minQueueMemoryCapacity"), WebServicesTestUtils
                                                  .GetXmlInt(element, "maxQueueMemoryCapacity"), WebServicesTestUtils.GetXmlInt(element
                                                                                                                                , "numNodes"), WebServicesTestUtils.GetXmlInt(element, "usedNodeCapacity"), WebServicesTestUtils
                                                  .GetXmlInt(element, "availNodeCapacity"), WebServicesTestUtils.GetXmlInt(element
                                                                                                                           , "totalNodeCapacity"), WebServicesTestUtils.GetXmlInt(element, "numContainers")
                                                  );
            }
        }
コード例 #10
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        public virtual void VerifyClusterMetricsXML(string xml)
        {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.NewInstance();
            DocumentBuilder        db  = dbf.NewDocumentBuilder();
            InputSource            @is = new InputSource();

            @is.SetCharacterStream(new StringReader(xml));
            Document dom   = db.Parse(@is);
            NodeList nodes = dom.GetElementsByTagName("clusterMetrics");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.GetLength
                                                ());
            for (int i = 0; i < nodes.GetLength(); i++)
            {
                Element element = (Element)nodes.Item(i);
                VerifyClusterMetrics(WebServicesTestUtils.GetXmlInt(element, "appsSubmitted"), WebServicesTestUtils
                                     .GetXmlInt(element, "appsCompleted"), WebServicesTestUtils.GetXmlInt(element, "reservedMB"
                                                                                                          ), WebServicesTestUtils.GetXmlInt(element, "availableMB"), WebServicesTestUtils.
                                     GetXmlInt(element, "allocatedMB"), WebServicesTestUtils.GetXmlInt(element, "reservedVirtualCores"
                                                                                                       ), WebServicesTestUtils.GetXmlInt(element, "availableVirtualCores"), WebServicesTestUtils
                                     .GetXmlInt(element, "allocatedVirtualCores"), WebServicesTestUtils.GetXmlInt(element
                                                                                                                  , "totalVirtualCores"), WebServicesTestUtils.GetXmlInt(element, "containersAllocated"
                                                                                                                                                                         ), WebServicesTestUtils.GetXmlInt(element, "totalMB"), WebServicesTestUtils.GetXmlInt
                                         (element, "totalNodes"), WebServicesTestUtils.GetXmlInt(element, "lostNodes"), WebServicesTestUtils
                                     .GetXmlInt(element, "unhealthyNodes"), WebServicesTestUtils.GetXmlInt(element, "decommissionedNodes"
                                                                                                           ), WebServicesTestUtils.GetXmlInt(element, "rebootedNodes"), WebServicesTestUtils
                                     .GetXmlInt(element, "activeNodes"));
            }
        }
コード例 #11
0
 public virtual void VerifyClusterGeneric(long clusterid, long startedon, string state
                                          , string haState, string haZooKeeperConnectionState, string hadoopVersionBuiltOn
                                          , string hadoopBuildVersion, string hadoopVersion, string resourceManagerVersionBuiltOn
                                          , string resourceManagerBuildVersion, string resourceManagerVersion)
 {
     NUnit.Framework.Assert.AreEqual("clusterId doesn't match: ", ResourceManager.GetClusterTimeStamp
                                         (), clusterid);
     NUnit.Framework.Assert.AreEqual("startedOn doesn't match: ", ResourceManager.GetClusterTimeStamp
                                         (), startedon);
     NUnit.Framework.Assert.IsTrue("stated doesn't match: " + state, state.Matches(Service.STATE
                                                                                   .Inited.ToString()));
     NUnit.Framework.Assert.IsTrue("HA state doesn't match: " + haState, haState.Matches
                                       ("INITIALIZING"));
     WebServicesTestUtils.CheckStringMatch("hadoopVersionBuiltOn", VersionInfo.GetDate
                                               (), hadoopVersionBuiltOn);
     WebServicesTestUtils.CheckStringEqual("hadoopBuildVersion", VersionInfo.GetBuildVersion
                                               (), hadoopBuildVersion);
     WebServicesTestUtils.CheckStringMatch("hadoopVersion", VersionInfo.GetVersion(),
                                           hadoopVersion);
     WebServicesTestUtils.CheckStringMatch("resourceManagerVersionBuiltOn", YarnVersionInfo
                                           .GetDate(), resourceManagerVersionBuiltOn);
     WebServicesTestUtils.CheckStringEqual("resourceManagerBuildVersion", YarnVersionInfo
                                           .GetBuildVersion(), resourceManagerBuildVersion);
     WebServicesTestUtils.CheckStringMatch("resourceManagerVersion", YarnVersionInfo.GetVersion
                                               (), resourceManagerVersion);
 }
コード例 #12
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        public virtual void VerifyClusterInfoXML(string xml)
        {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.NewInstance();
            DocumentBuilder        db  = dbf.NewDocumentBuilder();
            InputSource            @is = new InputSource();

            @is.SetCharacterStream(new StringReader(xml));
            Document dom   = db.Parse(@is);
            NodeList nodes = dom.GetElementsByTagName("clusterInfo");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.GetLength
                                                ());
            for (int i = 0; i < nodes.GetLength(); i++)
            {
                Element element = (Element)nodes.Item(i);
                VerifyClusterGeneric(WebServicesTestUtils.GetXmlLong(element, "id"), WebServicesTestUtils
                                     .GetXmlLong(element, "startedOn"), WebServicesTestUtils.GetXmlString(element, "state"
                                                                                                          ), WebServicesTestUtils.GetXmlString(element, "haState"), WebServicesTestUtils.GetXmlString
                                         (element, "haZooKeeperConnectionState"), WebServicesTestUtils.GetXmlString(element
                                                                                                                    , "hadoopVersionBuiltOn"), WebServicesTestUtils.GetXmlString(element, "hadoopBuildVersion"
                                                                                                                                                                                 ), WebServicesTestUtils.GetXmlString(element, "hadoopVersion"), WebServicesTestUtils
                                     .GetXmlString(element, "resourceManagerVersionBuiltOn"), WebServicesTestUtils.GetXmlString
                                         (element, "resourceManagerBuildVersion"), WebServicesTestUtils.GetXmlString(element
                                                                                                                     , "resourceManagerVersion"));
            }
        }
コード例 #13
0
 public virtual void VerifyHsJobConfXML(NodeList nodes, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job
                                        job)
 {
     NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.GetLength
                                         ());
     for (int i = 0; i < nodes.GetLength(); i++)
     {
         Element element = (Element)nodes.Item(i);
         WebServicesTestUtils.CheckStringMatch("path", job.GetConfFile().ToString(), WebServicesTestUtils
                                               .GetXmlString(element, "path"));
         // just do simple verification of fields - not data is correct
         // in the fields
         NodeList properties = element.GetElementsByTagName("property");
         for (int j = 0; j < properties.GetLength(); j++)
         {
             Element property = (Element)properties.Item(j);
             NUnit.Framework.Assert.IsNotNull("should have counters in the web service info",
                                              property);
             string name  = WebServicesTestUtils.GetXmlString(property, "name");
             string value = WebServicesTestUtils.GetXmlString(property, "value");
             NUnit.Framework.Assert.IsTrue("name not set", (name != null && !name.IsEmpty()));
             NUnit.Framework.Assert.IsTrue("name not set", (value != null && !value.IsEmpty())
                                           );
         }
     }
 }
コード例 #14
0
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 /// <exception cref="System.Exception"/>
 public virtual void VerifyNodeAppInfoGeneric(Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application
                                              app, string id, string state, string user)
 {
     WebServicesTestUtils.CheckStringMatch("id", app.GetAppId().ToString(), id);
     WebServicesTestUtils.CheckStringMatch("state", app.GetApplicationState().ToString
                                               (), state);
     WebServicesTestUtils.CheckStringMatch("user", app.GetUser().ToString(), user);
 }
コード例 #15
0
 private void VerifyStateInvalidException(string message, string type, string classname
                                          )
 {
     WebServicesTestUtils.CheckStringContains("exception message", "org.apache.hadoop.yarn.server.nodemanager.containermanager.application.ApplicationState.FOO_STATE"
                                              , message);
     WebServicesTestUtils.CheckStringMatch("exception type", "IllegalArgumentException"
                                           , type);
     WebServicesTestUtils.CheckStringMatch("exception classname", "java.lang.IllegalArgumentException"
                                           , classname);
 }
コード例 #16
0
 public virtual void VerifyAMSingleTaskXML(Element element, Task task)
 {
     VerifyTaskGeneric(task, WebServicesTestUtils.GetXmlString(element, "id"), WebServicesTestUtils
                       .GetXmlString(element, "state"), WebServicesTestUtils.GetXmlString(element, "type"
                                                                                          ), WebServicesTestUtils.GetXmlString(element, "successfulAttempt"), WebServicesTestUtils
                       .GetXmlLong(element, "startTime"), WebServicesTestUtils.GetXmlLong(element, "finishTime"
                                                                                          ), WebServicesTestUtils.GetXmlLong(element, "elapsedTime"), WebServicesTestUtils
                       .GetXmlFloat(element, "progress"), WebServicesTestUtils.GetXmlString(element, "status"
                                                                                            ));
 }
コード例 #17
0
 public virtual void VerifyHsInfoGeneric(string hadoopVersionBuiltOn, string hadoopBuildVersion
                                         , string hadoopVersion, long startedon)
 {
     WebServicesTestUtils.CheckStringMatch("hadoopVersionBuiltOn", VersionInfo.GetDate
                                               (), hadoopVersionBuiltOn);
     WebServicesTestUtils.CheckStringEqual("hadoopBuildVersion", VersionInfo.GetBuildVersion
                                               (), hadoopBuildVersion);
     WebServicesTestUtils.CheckStringMatch("hadoopVersion", VersionInfo.GetVersion(),
                                           hadoopVersion);
     NUnit.Framework.Assert.AreEqual("startedOn doesn't match: ", JobHistoryServer.historyServerTimeStamp
                                     , startedon);
 }
コード例 #18
0
 public virtual void VerifyAMInfoGeneric(AppContext ctx, string id, string user, string
                                         name, long startedOn, long elapsedTime)
 {
     WebServicesTestUtils.CheckStringMatch("id", ctx.GetApplicationID().ToString(), id
                                           );
     WebServicesTestUtils.CheckStringMatch("user", ctx.GetUser().ToString(), user);
     WebServicesTestUtils.CheckStringMatch("name", ctx.GetApplicationName(), name);
     NUnit.Framework.Assert.AreEqual("startedOn incorrect", ctx.GetStartTime(), startedOn
                                     );
     NUnit.Framework.Assert.IsTrue("elapsedTime not greater then 0", (elapsedTime > 0)
                                   );
 }
コード例 #19
0
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 /// <exception cref="System.Exception"/>
 public virtual void VerifyContainersInfoXML(NodeList nodes, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container
                                             cont)
 {
     for (int i = 0; i < nodes.GetLength(); i++)
     {
         Element element = (Element)nodes.Item(i);
         VerifyNodeContainerInfoGeneric(cont, WebServicesTestUtils.GetXmlString(element, "id"
                                                                                ), WebServicesTestUtils.GetXmlString(element, "state"), WebServicesTestUtils.GetXmlString
                                            (element, "user"), WebServicesTestUtils.GetXmlInt(element, "exitCode"), WebServicesTestUtils
                                        .GetXmlString(element, "diagnostics"), WebServicesTestUtils.GetXmlString(element
                                                                                                                 , "nodeId"), WebServicesTestUtils.GetXmlInt(element, "totalMemoryNeededMB"), WebServicesTestUtils
                                        .GetXmlInt(element, "totalVCoresNeeded"), WebServicesTestUtils.GetXmlString(element
                                                                                                                    , "containerLogsLink"));
     }
 }
コード例 #20
0
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 /// <exception cref="System.Exception"/>
 public virtual void VerifyNodesXML(NodeList nodes, MockNM nm)
 {
     for (int i = 0; i < nodes.GetLength(); i++)
     {
         Element element = (Element)nodes.Item(i);
         VerifyNodeInfoGeneric(nm, WebServicesTestUtils.GetXmlString(element, "state"), WebServicesTestUtils
                               .GetXmlString(element, "rack"), WebServicesTestUtils.GetXmlString(element, "id")
                               , WebServicesTestUtils.GetXmlString(element, "nodeHostName"), WebServicesTestUtils
                               .GetXmlString(element, "nodeHTTPAddress"), WebServicesTestUtils.GetXmlLong(element
                                                                                                          , "lastHealthUpdate"), WebServicesTestUtils.GetXmlString(element, "healthReport"
                                                                                                                                                                   ), WebServicesTestUtils.GetXmlInt(element, "numContainers"), WebServicesTestUtils
                               .GetXmlLong(element, "usedMemoryMB"), WebServicesTestUtils.GetXmlLong(element, "availMemoryMB"
                                                                                                     ), WebServicesTestUtils.GetXmlLong(element, "usedVirtualCores"), WebServicesTestUtils
                               .GetXmlLong(element, "availableVirtualCores"), WebServicesTestUtils.GetXmlString
                                   (element, "version"));
     }
 }
コード例 #21
0
        public virtual void TestInvalidUri2()
        {
            WebResource r           = Resource();
            string      responseStr = string.Empty;

            try
            {
                responseStr = r.Accept(MediaType.ApplicationJson).Get <string>();
                NUnit.Framework.Assert.Fail("should have thrown exception on invalid uri");
            }
            catch (UniformInterfaceException ue)
            {
                ClientResponse response = ue.GetResponse();
                NUnit.Framework.Assert.AreEqual(ClientResponse.Status.NotFound, response.GetClientResponseStatus
                                                    ());
                WebServicesTestUtils.CheckStringMatch("error string exists and shouldn't", string.Empty
                                                      , responseStr);
            }
        }
コード例 #22
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        private void TestTaskAttemptIdErrorGeneric(string attid, string error)
        {
            WebResource r = Resource();
            IDictionary <JobId, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job> jobsMap = appContext
                                                                                      .GetAllJobs();

            foreach (JobId id in jobsMap.Keys)
            {
                string jobId = MRApps.ToString(id);
                foreach (Task task in jobsMap[id].GetTasks().Values)
                {
                    string tid = MRApps.ToString(task.GetID());
                    try
                    {
                        r.Path("ws").Path("v1").Path("history").Path("mapreduce").Path("jobs").Path(jobId
                                                                                                    ).Path("tasks").Path(tid).Path("attempts").Path(attid).Accept(MediaType.ApplicationJson
                                                                                                                                                                  ).Get <JSONObject>();
                        NUnit.Framework.Assert.Fail("should have thrown exception on invalid uri");
                    }
                    catch (UniformInterfaceException ue)
                    {
                        ClientResponse response = ue.GetResponse();
                        NUnit.Framework.Assert.AreEqual(ClientResponse.Status.NotFound, response.GetClientResponseStatus
                                                            ());
                        NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                                        );
                        JSONObject msg       = response.GetEntity <JSONObject>();
                        JSONObject exception = msg.GetJSONObject("RemoteException");
                        NUnit.Framework.Assert.AreEqual("incorrect number of elements", 3, exception.Length
                                                            ());
                        string message   = exception.GetString("message");
                        string type      = exception.GetString("exception");
                        string classname = exception.GetString("javaClassName");
                        WebServicesTestUtils.CheckStringMatch("exception message", error, message);
                        WebServicesTestUtils.CheckStringMatch("exception type", "NotFoundException", type
                                                              );
                        WebServicesTestUtils.CheckStringMatch("exception classname", "org.apache.hadoop.yarn.webapp.NotFoundException"
                                                              , classname);
                    }
                }
            }
        }
コード例 #23
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        public virtual void VerifyHsJobConf(JSONObject info, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job
                                            job)
        {
            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 2, info.Length());
            WebServicesTestUtils.CheckStringMatch("path", job.GetConfFile().ToString(), info.
                                                  GetString("path"));
            // just do simple verification of fields - not data is correct
            // in the fields
            JSONArray properties = info.GetJSONArray("property");

            for (int i = 0; i < properties.Length(); i++)
            {
                JSONObject prop  = properties.GetJSONObject(i);
                string     name  = prop.GetString("name");
                string     value = prop.GetString("value");
                NUnit.Framework.Assert.IsTrue("name not set", (name != null && !name.IsEmpty()));
                NUnit.Framework.Assert.IsTrue("value not set", (value != null && !value.IsEmpty()
                                                                ));
            }
        }
コード例 #24
0
 public virtual void VerifyHsTaskAttemptXML(Element element, TaskAttempt att, TaskType
                                            ttype)
 {
     VerifyTaskAttemptGeneric(att, ttype, WebServicesTestUtils.GetXmlString(element, "id"
                                                                            ), WebServicesTestUtils.GetXmlString(element, "state"), WebServicesTestUtils.GetXmlString
                                  (element, "type"), WebServicesTestUtils.GetXmlString(element, "rack"), WebServicesTestUtils
                              .GetXmlString(element, "nodeHttpAddress"), WebServicesTestUtils.GetXmlString(element
                                                                                                           , "diagnostics"), WebServicesTestUtils.GetXmlString(element, "assignedContainerId"
                                                                                                                                                               ), WebServicesTestUtils.GetXmlLong(element, "startTime"), WebServicesTestUtils.GetXmlLong
                                  (element, "finishTime"), WebServicesTestUtils.GetXmlLong(element, "elapsedTime")
                              , WebServicesTestUtils.GetXmlFloat(element, "progress"));
     if (ttype == TaskType.Reduce)
     {
         VerifyReduceTaskAttemptGeneric(att, WebServicesTestUtils.GetXmlLong(element, "shuffleFinishTime"
                                                                             ), WebServicesTestUtils.GetXmlLong(element, "mergeFinishTime"), WebServicesTestUtils
                                        .GetXmlLong(element, "elapsedShuffleTime"), WebServicesTestUtils.GetXmlLong(element
                                                                                                                    , "elapsedMergeTime"), WebServicesTestUtils.GetXmlLong(element, "elapsedReduceTime"
                                                                                                                                                                           ));
     }
 }
コード例 #25
0
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 /// <exception cref="System.Exception"/>
 public virtual void VerifyNodesXML(NodeList nodes)
 {
     for (int i = 0; i < nodes.GetLength(); i++)
     {
         Element element = (Element)nodes.Item(i);
         VerifyNodeInfoGeneric(WebServicesTestUtils.GetXmlString(element, "id"), WebServicesTestUtils
                               .GetXmlString(element, "healthReport"), WebServicesTestUtils.GetXmlLong(element,
                                                                                                       "totalVmemAllocatedContainersMB"), WebServicesTestUtils.GetXmlLong(element, "totalPmemAllocatedContainersMB"
                                                                                                                                                                          ), WebServicesTestUtils.GetXmlLong(element, "totalVCoresAllocatedContainers"), WebServicesTestUtils
                               .GetXmlBoolean(element, "vmemCheckEnabled"), WebServicesTestUtils.GetXmlBoolean(
                                   element, "pmemCheckEnabled"), WebServicesTestUtils.GetXmlLong(element, "lastNodeUpdateTime"
                                                                                                 ), WebServicesTestUtils.GetXmlBoolean(element, "nodeHealthy"), WebServicesTestUtils
                               .GetXmlString(element, "nodeHostName"), WebServicesTestUtils.GetXmlString(element
                                                                                                         , "hadoopVersionBuiltOn"), WebServicesTestUtils.GetXmlString(element, "hadoopBuildVersion"
                                                                                                                                                                      ), WebServicesTestUtils.GetXmlString(element, "hadoopVersion"), WebServicesTestUtils
                               .GetXmlString(element, "nodeManagerVersionBuiltOn"), WebServicesTestUtils.GetXmlString
                                   (element, "nodeManagerBuildVersion"), WebServicesTestUtils.GetXmlString(element,
                                                                                                           "nodeManagerVersion"));
     }
 }
コード例 #26
0
        public virtual void TestInvalidAccept()
        {
            WebResource r           = Resource();
            string      responseStr = string.Empty;

            try
            {
                responseStr = r.Path("ws").Path("v1").Path("applicationhistory").QueryParam("user.name"
                                                                                            , Users[round]).Accept(MediaType.TextPlain).Get <string>();
                NUnit.Framework.Assert.Fail("should have thrown exception on invalid uri");
            }
            catch (UniformInterfaceException ue)
            {
                ClientResponse response = ue.GetResponse();
                NUnit.Framework.Assert.AreEqual(ClientResponse.Status.InternalServerError, response
                                                .GetClientResponseStatus());
                WebServicesTestUtils.CheckStringMatch("error string exists and shouldn't", string.Empty
                                                      , responseStr);
            }
        }
コード例 #27
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        public virtual void VerifyAMInfoXML(string xml, AppContext ctx)
        {
            DocumentBuilderFactory dbf = DocumentBuilderFactory.NewInstance();
            DocumentBuilder        db  = dbf.NewDocumentBuilder();
            InputSource            @is = new InputSource();

            @is.SetCharacterStream(new StringReader(xml));
            Document dom   = db.Parse(@is);
            NodeList nodes = dom.GetElementsByTagName("info");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, nodes.GetLength
                                                ());
            for (int i = 0; i < nodes.GetLength(); i++)
            {
                Element element = (Element)nodes.Item(i);
                VerifyAMInfoGeneric(ctx, WebServicesTestUtils.GetXmlString(element, "appId"), WebServicesTestUtils
                                    .GetXmlString(element, "user"), WebServicesTestUtils.GetXmlString(element, "name"
                                                                                                      ), WebServicesTestUtils.GetXmlLong(element, "startedOn"), WebServicesTestUtils.GetXmlLong
                                        (element, "elapsedTime"));
            }
        }
コード例 #28
0
 /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
 /// <exception cref="System.Exception"/>
 public virtual void VerifyNodeAppInfoXML(NodeList nodes, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application
                                          app, Dictionary <string, string> hash)
 {
     for (int i = 0; i < nodes.GetLength(); i++)
     {
         Element element = (Element)nodes.Item(i);
         VerifyNodeAppInfoGeneric(app, WebServicesTestUtils.GetXmlString(element, "id"), WebServicesTestUtils
                                  .GetXmlString(element, "state"), WebServicesTestUtils.GetXmlString(element, "user"
                                                                                                     ));
         NodeList ids = element.GetElementsByTagName("containerids");
         for (int j = 0; j < ids.GetLength(); j++)
         {
             Element line  = (Element)ids.Item(j);
             Node    first = line.GetFirstChild();
             string  val   = first.GetNodeValue();
             NUnit.Framework.Assert.AreEqual("extra containerid: " + val, val, Sharpen.Collections.Remove
                                                 (hash, val));
         }
         NUnit.Framework.Assert.IsTrue("missing containerids", hash.IsEmpty());
     }
 }
コード例 #29
0
        public virtual void TestSingleContainerWrong()
        {
            WebResource r = Resource();

            Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application
                app = new MockApp(1);
            nmContext.GetApplications()[app.GetAppId()] = app;
            AddAppContainers(app);
            Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application
                app2 = new MockApp(2);
            nmContext.GetApplications()[app2.GetAppId()] = app2;
            AddAppContainers(app2);
            try
            {
                r.Path("ws").Path("v1").Path("node").Path("containers").Path("container_1234_0001_01_000005"
                                                                             ).Accept(MediaType.ApplicationJson).Get <JSONObject>();
                NUnit.Framework.Assert.Fail("should have thrown exception on invalid user query");
            }
            catch (UniformInterfaceException ue)
            {
                ClientResponse response = ue.GetResponse();
                NUnit.Framework.Assert.AreEqual(ClientResponse.Status.NotFound, response.GetClientResponseStatus
                                                    ());
                NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                                );
                JSONObject msg       = response.GetEntity <JSONObject>();
                JSONObject exception = msg.GetJSONObject("RemoteException");
                NUnit.Framework.Assert.AreEqual("incorrect number of elements", 3, exception.Length
                                                    ());
                string message   = exception.GetString("message");
                string type      = exception.GetString("exception");
                string classname = exception.GetString("javaClassName");
                WebServicesTestUtils.CheckStringMatch("exception message", "java.lang.Exception: container with id, container_1234_0001_01_000005, not found"
                                                      , message);
                WebServicesTestUtils.CheckStringMatch("exception type", "NotFoundException", type
                                                      );
                WebServicesTestUtils.CheckStringMatch("exception classname", "org.apache.hadoop.yarn.webapp.NotFoundException"
                                                      , classname);
            }
        }
コード例 #30
0
        /// <exception cref="Org.Codehaus.Jettison.Json.JSONException"/>
        /// <exception cref="System.Exception"/>
        public virtual void VerifyNodeInfoGeneric(MockNM nm, string state, string rack, string
                                                  id, string nodeHostName, string nodeHTTPAddress, long lastHealthUpdate, string
                                                  healthReport, int numContainers, long usedMemoryMB, long availMemoryMB, long usedVirtualCores
                                                  , long availVirtualCores, string version)
        {
            RMNode              node   = rm.GetRMContext().GetRMNodes()[nm.GetNodeId()];
            ResourceScheduler   sched  = rm.GetResourceScheduler();
            SchedulerNodeReport report = sched.GetNodeReport(nm.GetNodeId());

            WebServicesTestUtils.CheckStringMatch("state", node.GetState().ToString(), state);
            WebServicesTestUtils.CheckStringMatch("rack", node.GetRackName(), rack);
            WebServicesTestUtils.CheckStringMatch("id", nm.GetNodeId().ToString(), id);
            WebServicesTestUtils.CheckStringMatch("nodeHostName", nm.GetNodeId().GetHost(), nodeHostName
                                                  );
            WebServicesTestUtils.CheckStringMatch("healthReport", node.GetHealthReport().ToString
                                                      (), healthReport);
            string expectedHttpAddress = nm.GetNodeId().GetHost() + ":" + nm.GetHttpPort();

            WebServicesTestUtils.CheckStringMatch("nodeHTTPAddress", expectedHttpAddress, nodeHTTPAddress
                                                  );
            WebServicesTestUtils.CheckStringMatch("version", node.GetNodeManagerVersion(), version
                                                  );
            long expectedHealthUpdate = node.GetLastHealthReportTime();

            NUnit.Framework.Assert.AreEqual("lastHealthUpdate doesn't match, got: " + lastHealthUpdate
                                            + " expected: " + expectedHealthUpdate, expectedHealthUpdate, lastHealthUpdate);
            if (report != null)
            {
                NUnit.Framework.Assert.AreEqual("numContainers doesn't match: " + numContainers,
                                                report.GetNumContainers(), numContainers);
                NUnit.Framework.Assert.AreEqual("usedMemoryMB doesn't match: " + usedMemoryMB, report
                                                .GetUsedResource().GetMemory(), usedMemoryMB);
                NUnit.Framework.Assert.AreEqual("availMemoryMB doesn't match: " + availMemoryMB,
                                                report.GetAvailableResource().GetMemory(), availMemoryMB);
                NUnit.Framework.Assert.AreEqual("usedVirtualCores doesn't match: " + usedVirtualCores
                                                , report.GetUsedResource().GetVirtualCores(), usedVirtualCores);
                NUnit.Framework.Assert.AreEqual("availVirtualCores doesn't match: " + availVirtualCores
                                                , report.GetAvailableResource().GetVirtualCores(), availVirtualCores);
            }
        }