예제 #1
0
        public virtual void VerifyTaskAttemptGeneric(TaskAttempt ta, TaskType ttype, string
                                                     id, string state, string type, string rack, string nodeHttpAddress, string diagnostics
                                                     , string assignedContainerId, long startTime, long finishTime, long elapsedTime,
                                                     float progress)
        {
            TaskAttemptId attid     = ta.GetID();
            string        attemptId = MRApps.ToString(attid);

            WebServicesTestUtils.CheckStringMatch("id", attemptId, id);
            WebServicesTestUtils.CheckStringMatch("type", ttype.ToString(), type);
            WebServicesTestUtils.CheckStringMatch("state", ta.GetState().ToString(), state);
            WebServicesTestUtils.CheckStringMatch("rack", ta.GetNodeRackName(), rack);
            WebServicesTestUtils.CheckStringMatch("nodeHttpAddress", ta.GetNodeHttpAddress(),
                                                  nodeHttpAddress);
            string         expectDiag      = string.Empty;
            IList <string> diagnosticsList = ta.GetDiagnostics();

            if (diagnosticsList != null && !diagnostics.IsEmpty())
            {
                StringBuilder b = new StringBuilder();
                foreach (string diag in diagnosticsList)
                {
                    b.Append(diag);
                }
                expectDiag = b.ToString();
            }
            WebServicesTestUtils.CheckStringMatch("diagnostics", expectDiag, diagnostics);
            WebServicesTestUtils.CheckStringMatch("assignedContainerId", ConverterUtils.ToString
                                                      (ta.GetAssignedContainerID()), assignedContainerId);
            NUnit.Framework.Assert.AreEqual("startTime wrong", ta.GetLaunchTime(), startTime);
            NUnit.Framework.Assert.AreEqual("finishTime wrong", ta.GetFinishTime(), finishTime
                                            );
            NUnit.Framework.Assert.AreEqual("elapsedTime wrong", finishTime - startTime, elapsedTime
                                            );
            NUnit.Framework.Assert.AreEqual("progress wrong", ta.GetProgress() * 100, progress
                                            , 1e-3f);
        }