Exemple #1
0
        public void TestNrOfJobsWithin()
        {
            Dictionary <string, int> result = DAO.NrOfJobsWithin(new DateTime(2012, 2, 1, 0, 0, 0), new DateTime(2012, 10, 10, 0, 0, 0));

            if (result.ContainsKey("Submitted"))
            {
                int nrOfSubmittedJobs = result["Submitted"];
                Assert.IsTrue(nrOfSubmittedJobs == 3);
            }

            if (result.ContainsKey("Running"))
            {
                int nrOfRunningJobs = result["Running"];
                Assert.IsTrue(nrOfRunningJobs == 2);
            }

            if (result.ContainsKey("Terminated"))
            {
                int nrOfTerminatedJobs = result["Terminated"];
                Assert.IsTrue(nrOfTerminatedJobs == 1);
            }

            if (result.ContainsKey("Failed"))
            {
                int nrOfFailedJobs = result["Failed"];
                Assert.IsTrue(nrOfFailedJobs == 1);
            }

            if (result.ContainsKey("Cancelled"))
            {
                int nrOfCancelledJobs = result["Cancelled"];
                Assert.IsTrue(nrOfCancelledJobs == 1);
            }
        }
Exemple #2
0
        public void TestNrOfJobsWithin()
        {
            //return the number of jobs within a given period grouped by their status (queued,running,ended, error). Here the activity log can be useful.
            var result = DAO.NrOfJobsWithin(DateTime.Today.AddDays(-2), DateTime.Today);

            //As there is only five different states
            Assert.IsFalse(result.Count() > 5);
            int submittedCount = 0;
            int cancelledCount = 0;

            foreach (Entry ent in result)
            {
                if (ent.State.Equals("Submitted"))
                {
                    submittedCount = ent.Count;
                }
                if (ent.State.Equals("Cancelled"))
                {
                    cancelledCount = ent.Count;
                }
            }
            DAO.AddEntry(DateTime.Today, "Submitted", "morten", 1);
            var result2 = DAO.NrOfJobsWithin(DateTime.Today.AddDays(-2), DateTime.Today);

            //As there is only five different states
            Assert.IsFalse(result2.Count() > 5);
            foreach (Entry ent in result2)
            {
                // assert that submitted count has increased by one
                if (ent.State.Equals("Submitted"))
                {
                    Assert.IsTrue(ent.Count - submittedCount == 1);
                }
                // assert that cancelledCount hasn't changed
                if (ent.State.Equals("Cancelled"))
                {
                    Assert.IsFalse(ent.Count - cancelledCount == 1);
                }
            }
        }