예제 #1
0
        internal static void SetDatabaseDefaults()
        {
            // Reset Status count
            TestDBContext testDB = new TestDBContext();
            foreach (Test test in testDB.Tests)
                test.Status = null;

            // Reset Browser count
            foreach (Node node in testDB.Nodes)
                node.Browser = 5;

            testDB.SaveChanges();
            testDB.Database.Connection.Close();
        }
예제 #2
0
        private void SetRunnerToAvailable()
        {
            // Have to re-initilize. If it's been grabbed by several instances they'll all have a different count (Browser).
            TestDB = new TestDBContext();
            Runner = TestDB.Nodes.Find(Runner.ID);
            Test = TestDB.Tests.Find(Test.ID);
            Test.Status = null;

            switch (Test.Type)
            {
                case "iOS":
                    Runner.iOS = true;
                    break;
                case "Android":
                    Runner.Android = true;
                    break;
                case "Browser":
                    Runner.Browser++;
                    break;
                case "Desktop":
                    Runner.Desktop = true;
                    break;
            }
            TestDB.SaveChanges();
        }
예제 #3
0
        private void CheckSchedules()
        {
            TimeSpan LastScheduleCheckTime = DateTime.Now.TimeOfDay;
            TimeSpan LastPendingCheckTime = DateTime.Now.TimeOfDay.Subtract(TimeSpan.FromMinutes(9));

            while (!Scheduler.CancellationPending)
            {
                Thread.Sleep(60000);

                TestDBContext TestDB = new TestDBContext();
                TimeSpan CurrentTime = DateTime.Now.TimeOfDay;

                var Query =
                    from schedule in TestDB.Schedules
                    from test in TestDB.Tests
                    where schedule.IsScheduled &&
                    schedule.Time >= LastScheduleCheckTime &&
                    schedule.Time <= CurrentTime &&
                    schedule.TestID == test.ID &&
                    test.Status == null
                    select new { schedule, test };

                string CurrentDay = DateTime.Now.DayOfWeek.ToString();

                foreach (var items in Query)
                {
                    foreach (PropertyInfo property in items.schedule.GetType().GetProperties())
                    {
                        if (property.Name == CurrentDay && Convert.ToBoolean(property.GetValue(items.schedule)))
                        {
                            items.test.Status = TestRunner.Pending;
                            TestDB.SaveChanges();
                            TestRunner.CreateTestThread(items.schedule.TestID);
                            break;
                        }
                    }
                }

                LastScheduleCheckTime = CurrentTime;

                if (LastScheduleCheckTime - LastPendingCheckTime >= TimeSpan.FromMinutes(10))
                {
                    TestRunner.CheckPendingTests();
                    LastPendingCheckTime = DateTime.Now.TimeOfDay;
                }
            }
        }