Exemplo n.º 1
0
        public virtual void TestJobsQueryState()
        {
            WebResource r = Resource();
            // we only create 3 jobs and it cycles through states so we should have 3 unique states
            IDictionary <JobId, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job> jobsMap = appContext
                                                                                      .GetAllJobs();
            string queryState = "BOGUS";
            JobId  jid        = null;

            foreach (KeyValuePair <JobId, Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job> entry in
                     jobsMap)
            {
                jid        = entry.Value.GetID();
                queryState = entry.Value.GetState().ToString();
                break;
            }
            ClientResponse response = r.Path("ws").Path("v1").Path("history").Path("mapreduce"
                                                                                   ).Path("jobs").QueryParam("state", queryState).Accept(MediaType.ApplicationJson)
                                      .Get <ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            JSONObject jobs = json.GetJSONObject("jobs");
            JSONArray  arr  = jobs.GetJSONArray("job");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, arr.Length());
            JSONObject info = arr.GetJSONObject(0);

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = appContext.GetPartialJob(jid);
            VerifyJobsUtils.VerifyHsJobPartial(info, job);
        }
Exemplo n.º 2
0
        public virtual void TestJobsQueryUser()
        {
            WebResource    r        = Resource();
            ClientResponse response = r.Path("ws").Path("v1").Path("history").Path("mapreduce"
                                                                                   ).Path("jobs").QueryParam("user", "mock").Accept(MediaType.ApplicationJson).Get <
                ClientResponse>();

            NUnit.Framework.Assert.AreEqual(MediaType.ApplicationJsonType, response.GetType()
                                            );
            JSONObject json = response.GetEntity <JSONObject>();

            System.Console.Out.WriteLine(json.ToString());
            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 1, json.Length());
            JSONObject jobs = json.GetJSONObject("jobs");
            JSONArray  arr  = jobs.GetJSONArray("job");

            NUnit.Framework.Assert.AreEqual("incorrect number of elements", 3, arr.Length());
            // just verify one of them.
            JSONObject info = arr.GetJSONObject(0);

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = appContext.GetPartialJob(MRApps.
                                                                                      ToJobID(info.GetString("id")));
            VerifyJobsUtils.VerifyHsJobPartial(info, job);
        }