Example #1
0
        /// <summary>
        /// Constructor
        /// Creates subscriptions to the BenchmarkSystem EventHandlers
        /// </summary>
        /// <param name="benchmark">The Benchmark containing this Logger</param>
        /// <param name="dao">The DAO used to save log information.</param>
        public Logger(BenchmarkSystem benchmark, ITM_DAO dao)
        {
            Contract.Requires(benchmark != null);
            Contract.Requires(dao != null);

            _tmDAO = dao;

            benchmark.JobSubmitted += OnJobSubmitted;
            benchmark.JobCancelled += OnJobCancelled;
            benchmark.JobRunning += OnJobRunning;
            benchmark.JobTerminated += OnJobTerminated;
            benchmark.JobFailed += OnJobFailed;
            benchmark.JobDone += OnJobDone;
        }
        public ArtificialClient()
        {
            _benchmark = new BenchmarkSystem();
            _users = new List<User>();
            _jobs = new Queue<Job>((int)JOBS_AT_START);
            _jobsAdded = 0;
            _jobsDone = 0;
            _random = new Random();

            _benchmark.JobCancelled += KeepBenchmarkLoaded;
            _benchmark.JobDone += KeepBenchmarkLoaded;
            _benchmark.JobFailed += KeepBenchmarkLoaded;
            _benchmark.JobTerminated += KeepBenchmarkLoaded;
        }
 public void LoadBenchmarkSystem()
 {
     _b = new BenchmarkSystem();
 }
Example #4
0
        public void Test_GetJobsFromUserInPeriodOrdered()
        {
            BenchmarkSystem b = new BenchmarkSystem();
            DateTime startTime = new DateTime(2020, 1, 1);
            DateTime endTime = new DateTime(2020, 12, 31);
            User user = new User("Test User", "A secret password");

            _tmDAO.AddUser(user);
            int jobQuantity = 30;
            Job job = null;
            for (int index = 1; index <= jobQuantity; index++)
            {
                DateTime t1 = new DateTime(2020, 3, index);

                job = new Job(user, 100, 5, s => 38);
                _tmDAO.AddJob(job);
                _tmDAO.AddLog(job, t1);
                if (index % 2 == 0)
                {
                    job.Process(new String[] { "test" });
                    _tmDAO.AddLog(job, t1.AddHours(1));
                }
            }
            List<Job> jobsRequested = new List<Job>(_tmDAO.GetJobsFromUserInPeriodOrdered(user.UserId, startTime, endTime));

            for (int i = 0; i < jobsRequested.Count - 1; i++)
            {
                if (jobsRequested[i].CompareTo(jobsRequested[i + 1]) == 1)
                {
                    Assert.Fail("The order is no correct. JobId: " + jobsRequested[i] + " was larger than JobId: " + jobsRequested[i + 1]);
                }
            }

            Assert.AreEqual(jobQuantity, jobsRequested.Count);
        }
Example #5
0
 /// <summary>
 /// The constructor
 /// </summary>
 public ConsoleUI()
 {
     _benchmark = new BenchmarkSystem();
     Launch();
 }