public void executeAll()
        {
            Owner ow = new Owner("Nicolai");
            Scheduler sh = new Scheduler();

            for(int i = 0; i < 30; i++)
            {
                sh.addJob(new Job(1, 200+i, ow, s => "Hello world"));
            }

            for(int i = 0; i < 30; i++)
            {
                sh.addJob(new Job(1, 600+i, ow, s => "Hello world"));
            }

            for (int i = 0; i < 30; i++)
            {
                sh.addJob(new Job(1, 2001 + i, ow, s => "Hello world"));
            }

            sh.executeAll();

            // Sleeps for a second to make sure that all Jobs gets done
            System.Threading.Thread.Sleep(3000);

            Assert.AreEqual(0, sh.JobQueue.Count);

            Assert.AreEqual(0, sh.shortRunningJobs);
            Assert.AreEqual(0, sh.longRunningJobs);
            Assert.AreEqual(0, sh.veryLongRunningJobs);
        }
示例#2
0
        /// <summary>
        /// Creates a new job and adds it to the database. After adding to the database, it assigns a ID to itself.
        /// </summary>
        /// <param name="CPUNum"></param>
        /// <param name="runtime"></param>
        /// <param name="owner"></param>
        /// <param name="p"></param>
        public Job(int CPUNum, int runtime, Owner owner, Func<string, string> p)
        {
            id = 0;
            NumberOfCPU = CPUNum;
            ExpRuntime = runtime;
            Owner = owner;

            this.p = p;

            State = JobState.WAITING;

            this.id = DatabaseManager.addJob(this);

            if(runtime >= 100 && runtime <= 500)
            {
                this.type = JobType.SHORT;
            }
            else if (runtime >= 600 && runtime <= 2000)
            {
                this.type = JobType.LONG;
            }
            else if (runtime >= 2100 && runtime <= 5000)
            {
                this.type = JobType.VERY_LONG;
            }
        }
示例#3
0
 private void okay_Click(object sender, EventArgs e)
 {
     Owner owner = new Owner(owner_text.Text);
     int cpu = int.Parse(cpu_combobox.SelectedItem.ToString());
     int runtime = int.Parse(runtime_text.Text);
     Job job = new Job(cpu, runtime, owner, f => "Hello");
     JobSubmittedClick(job);
     this.Hide();
     clearFields();
 }
        public void addJob()
        {
            Owner ow = new Owner("Nicolai");
            Job job = new Job(1, 30000, ow, s => "Hello world");
            Scheduler sh = new Scheduler();

            sh.addJob(job);

            Assert.AreEqual(1, sh.JobQueue.Count);
        }
        public void removeJob_removeFromRunningList()
        {
            Owner ow = new Owner("Nicolai");
            Job job = new Job(1, 30000, ow, s => "Hello world");
            Scheduler sh = new Scheduler();

            sh.RunningJobs.Add(job);
            sh.removeJob(job);

            //Assert.AreEqual(0, sh.RunningJobs.Count);
        }
示例#6
0
        public void Equals_HashCode_wrongDifferentMinutes()
        {
            Owner o = new Owner("Nicolai");
            Job j1 = new Job(1, 1, o, s => "Bring it!");
            Job j2 = new Job(1, 2, o, s => "Bring it!");

            bool result = j1.Equals(j2);
            int h1 = j1.GetHashCode();
            int h2 = j2.GetHashCode();

            Assert.AreNotEqual(h1, h2);
            Assert.AreEqual(false, result);
        }
示例#7
0
        public void Equals_HashCode_right()
        {
            Owner o = new Owner("Nicolai");
            Job j1 = new Job(1, 1, o, s => "Bring it!");
            Job j2 = new Job(1, 1, o, s => "Bring it!");

            bool result = j1.Equals(j2);
            int h1 = j1.GetHashCode();
            int h2 = j2.GetHashCode();

            Assert.AreEqual(true, result);
            Assert.AreEqual(h1, h2);
        }
示例#8
0
        public void checkOwnerInfo()
        {
            BenchmarkDBEntities dbContent = new BenchmarkDBEntities();

            Owner ow = new Owner("testOwner");
            int owId = ow.id;

            var result = from user in dbContent.DB_userSet
                         where user.userId == owId
                         select user;

            DB_userSet resultUser = result.First();
            Assert.AreEqual(resultUser.name, "testOwner");
        }
示例#9
0
        public void Equals_HashCode_typesDifferentState()
        {
            Owner o = new Owner("Nicolai");
            Job j1 = new Job(1, 1, o, s => "Bring it!");
            Job j2 = new Job(1, 1, o, s => "Brought it!");

            j1.State = JobState.Cancelled;

            bool result = j1.Equals(j2);
            int h1 = j1.GetHashCode();
            int h2 = j2.GetHashCode();

            Assert.AreNotEqual(h1, h2);
            Assert.AreEqual(false, result);
        }
        public void popJob_popVeryLongJob()
        {
            Owner ow = new Owner("Nicolai");
            Job j1 = new Job(1, 30000, ow, s => "Hello world");
            Job j2 = new Job(1, 30002, ow, s => "Hello world");
            Job j3 = new Job(1, 3000000, ow, s => "Hello world");

            Scheduler sh = new Scheduler();

            sh.addJob(j3);
            sh.addJob(j1);
            sh.addJob(j2);

            Assert.AreEqual(j3, sh.PopJob());
        }
示例#11
0
        public void checkJobInfo()
        {
            using (var dbContent = new BenchmarkDBEntities())
            {

                Owner ow = new Owner("TestAnders");
                int owId = ow.id;

                Job testJob = new Job(1, 10, ow, s => "Hello world");
                int jobId = testJob.id;

                var result = from job in dbContent.DB_JobSet
                             where job.jobId == jobId
                             select job;

                DB_JobSet resultJob = result.First();

                Assert.AreEqual("WAITING", resultJob.status);
                Assert.AreEqual(resultJob.user_userId, owId);
                Assert.AreEqual(resultJob.jobId, jobId);
            }
        }
示例#12
0
        public void Equals_withWrongObject()
        {
            Owner o = new Owner("Nicolai");
            Job j1 = new Job(1, 1, o, s => "Bring it!");

            bool result = j1.Equals(o);

            Assert.AreEqual(false, result);
        }
示例#13
0
        public void Equals_withNull()
        {
            Owner o = new Owner("Nicolai");
            Job j1 = new Job(1, 1, o, s => "Bring it!");
            Job j2 = null;

            bool result = j1.Equals(j2);

            Assert.AreEqual(false, result);
        }