Example #1
0
        public void PerformMaintenanceTestNothingToRemove()
        {
            Maintenance maintenance = new Maintenance();
            StorageMaintenanceParameters maintenanceParameters = new StorageMaintenanceParameters();

            PrepareComplexStorageForMaintenanceTests();

            maintenance.PerformMaintenance(m_managerStorage, maintenanceParameters);

            Assert.AreEqual(4, m_managerStorage.GetExecutors().Length);
            Assert.AreEqual(5, m_managerStorage.GetApplications().Length);
        }
Example #2
0
        public void PerformMaintenanceTestMultipleParameters()
        {
            Maintenance maintenance = new Maintenance();
            StorageMaintenanceParameters maintenanceParameters = new StorageMaintenanceParameters();

            maintenanceParameters.AddApplicationStateToRemove(ApplicationState.AwaitingManifest);
            maintenanceParameters.ExecutorPingTimeCutOff = new TimeSpan(20, 0, 0);

            PrepareComplexStorageForMaintenanceTests();

            maintenance.PerformMaintenance(m_managerStorage, maintenanceParameters);

            Assert.AreEqual(2, m_managerStorage.GetExecutors().Length);
            Assert.AreEqual(3, m_managerStorage.GetApplications().Length);
        }
Example #3
0
        public void PerformMaintenanceTestNullStorageMaintenanceParameters()
        {
            Maintenance maintenance = new Maintenance();
            StorageMaintenanceParameters maintenanceParameters = null;

            PrepareComplexStorageForMaintenanceTests();

            try
            {
                maintenance.PerformMaintenance(m_managerStorage, maintenanceParameters);
            }
            catch (NullReferenceException)
            {
                // expecting to get this
                return;
            }

            Assert.Fail("This should have thrown a NullReferenceException");
        }
Example #4
0
        public void RemoveExecutorsByPingTimeSpanTestNothingToRemove()
        {
            Maintenance maintenance = new Maintenance();

            Assert.AreEqual(0, m_managerStorage.GetExecutors().Length);

            maintenance.RemoveExecutors(m_managerStorage, new TimeSpan(1000));

            Assert.AreEqual(0, m_managerStorage.GetExecutors().Length);
        }
Example #5
0
        public void RemoveApplicationsByTimeCreatedTestRemoveNonExistingDates()
        {
            Maintenance maintenance = new Maintenance();
            DateTime timeCreated = DateTime.Now;

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated, false, "username1"));

            Assert.AreEqual(1, m_managerStorage.GetApplications().Length);

            maintenance.RemoveApplications(m_managerStorage, timeCreated.AddDays(-1));

            Assert.AreEqual(1, m_managerStorage.GetApplications().Length);
        }
Example #6
0
        public void RemoveApplicationsByTimeCreatedTestRemoveMultipleOldApplications()
        {
            Maintenance maintenance = new Maintenance();

            DateTime timeCreated = DateTime.Now;

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated.AddDays(-5), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, timeCreated.AddDays(-4), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Ready, timeCreated.AddDays(1), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated.AddDays(-3), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, timeCreated.AddDays(2), false, "username1"));

            Assert.AreEqual(5, m_managerStorage.GetApplications().Length);

            maintenance.RemoveApplications(m_managerStorage, timeCreated);

            Assert.AreEqual(2, m_managerStorage.GetApplications().Length);
        }
Example #7
0
        public void RemoveApplicationsByTimeCreatedTestNothingToRemove()
        {
            Maintenance maintenance = new Maintenance();

            Assert.AreEqual(0, m_managerStorage.GetApplications().Length);

            maintenance.RemoveApplications(m_managerStorage, DateTime.Now);

            Assert.AreEqual(0, m_managerStorage.GetApplications().Length);
        }
Example #8
0
        public void PerformMaintenanceTestRemoveApplicationByState()
        {
            Maintenance maintenance = new Maintenance();
            StorageMaintenanceParameters maintenanceParameters = new StorageMaintenanceParameters();

            maintenanceParameters.AddApplicationStateToRemove(ApplicationState.AwaitingManifest);
            maintenanceParameters.AddApplicationStateToRemove(ApplicationState.Ready);

            PrepareComplexStorageForMaintenanceTests();

            maintenance.PerformMaintenance(m_managerStorage, maintenanceParameters);

            Assert.AreEqual(4, m_managerStorage.GetExecutors().Length);
            Assert.AreEqual(2, m_managerStorage.GetApplications().Length);
        }
Example #9
0
        public void RemoveExecutorsByPingTimeTestRemoveMultipleOldApplications()
        {
            Maintenance maintenance = new Maintenance();

            DateTime pingTime = DateTime.Now;

            m_managerStorage.AddExecutor(new ExecutorStorageView(true, true, pingTime.AddDays(-1), "hostname", 1, "username", 1, 2, 3, 4));
            m_managerStorage.AddExecutor(new ExecutorStorageView(false, true, pingTime.AddDays(2), "hostname", 1, "username", 1, 2, 3, 4));
            m_managerStorage.AddExecutor(new ExecutorStorageView(true, false, pingTime.AddDays(1), "hostname", 1, "username", 1, 2, 3, 4));
            m_managerStorage.AddExecutor(new ExecutorStorageView(false, false, pingTime.AddDays(-2), "hostname", 1, "username", 1, 2, 3, 4));

            Assert.AreEqual(4, m_managerStorage.GetExecutors().Length);

            maintenance.RemoveExecutors(m_managerStorage, pingTime);

            Assert.AreEqual(2, m_managerStorage.GetExecutors().Length);
        }
Example #10
0
        public void RemoveApplicationsByApplicationStateTestNothingToRemove()
        {
            Maintenance maintenance = new Maintenance();

            Assert.AreEqual(0, m_managerStorage.GetApplications().Length);

            maintenance.RemoveApplications(m_managerStorage);

            Assert.AreEqual(0, m_managerStorage.GetApplications().Length);
        }
Example #11
0
        public void RemoveAllExecutorsTestRemovingMultiple()
        {
            Maintenance maintenance = new Maintenance();

            m_managerStorage.AddExecutor(new ExecutorStorageView(true, true, DateTime.Now, "hostname", 123, "username", 0, 0, 0, 0));
            m_managerStorage.AddExecutor(new ExecutorStorageView(true, false, DateTime.Now, "hostname", 4543, "username", 1, 2, 3, 4));
            m_managerStorage.AddExecutor(new ExecutorStorageView(false, true, DateTime.Now, "hostname", 1, "username", 0, 0, 7, 0));
            m_managerStorage.AddExecutor(new ExecutorStorageView(false, false, DateTime.Now, "hostname", 33, "username", 0, 4, 0, 0));

            Assert.AreEqual(4, m_managerStorage.GetExecutors().Length);

            maintenance.RemoveAllExecutors(m_managerStorage);

            Assert.AreEqual(0, m_managerStorage.GetExecutors().Length);
        }
Example #12
0
        public void RemoveAllExecutorsTestNothingToRemove()
        {
            Maintenance maintenance = new Maintenance();

            Assert.AreEqual(0, m_managerStorage.GetExecutors().Length);

            maintenance.RemoveAllExecutors(m_managerStorage);

            Assert.AreEqual(0, m_managerStorage.GetExecutors().Length);
        }
Example #13
0
        public void RemoveAllApplicationsTestRemovingMultiple()
        {
            Maintenance maintenance = new Maintenance();

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, DateTime.Now, false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, DateTime.Now, false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Ready, DateTime.Now, false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, DateTime.Now, false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, DateTime.Now, false, "username1"));

            Assert.AreEqual(5, m_managerStorage.GetApplications().Length);

            maintenance.RemoveAllApplications(m_managerStorage);

            Assert.AreEqual(0, m_managerStorage.GetApplications().Length);
        }
Example #14
0
        public void PerformMaintenanceTestRemoveExecutorsByPingTime()
        {
            Maintenance maintenance = new Maintenance();
            StorageMaintenanceParameters maintenanceParameters = new StorageMaintenanceParameters();

            maintenanceParameters.ExecutorPingTimeCutOff = new TimeSpan(20, 0, 0);

            PrepareComplexStorageForMaintenanceTests();

            maintenance.PerformMaintenance(m_managerStorage, maintenanceParameters);

            Assert.AreEqual(2, m_managerStorage.GetExecutors().Length);
            Assert.AreEqual(5, m_managerStorage.GetApplications().Length);
        }
Example #15
0
        public void PerformMaintenanceTestRemoveApplicationsByTimeCompleted()
        {
            Maintenance maintenance = new Maintenance();
            StorageMaintenanceParameters maintenanceParameters = new StorageMaintenanceParameters();

            maintenanceParameters.ApplicationTimeCompletedCutOff = new TimeSpan(20, 0, 0);

            PrepareComplexStorageForMaintenanceTests();

            maintenance.PerformMaintenance(m_managerStorage, maintenanceParameters);

            Assert.AreEqual(4, m_managerStorage.GetExecutors().Length);
            // we should have left the one that didn't have the time completed set
            // and 2 more that were not in the cut-off range
            Assert.AreEqual(3, m_managerStorage.GetApplications().Length);
        }
Example #16
0
        public void RemoveExecutorsByPingTimeTestNothingToRemove()
        {
            Maintenance maintenance = new Maintenance();

            Assert.AreEqual(0, m_managerStorage.GetExecutors().Length);

            maintenance.RemoveExecutors(m_managerStorage, DateTime.Now);

            Assert.AreEqual(0, m_managerStorage.GetExecutors().Length);
        }
Example #17
0
        public void RemoveApplicationsByApplicationStateTestRemoveOneExistingState()
        {
            Maintenance maintenance = new Maintenance();

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, DateTime.Now, false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, DateTime.Now, false, "username1"));

            Assert.AreEqual(2, m_managerStorage.GetApplications().Length);

            maintenance.RemoveApplications(m_managerStorage, ApplicationState.Stopped);

            Assert.AreEqual(1, m_managerStorage.GetApplications().Length);
        }
Example #18
0
        public void RemoveExecutorsByPingTimeTestRemoveNonExistingDates()
        {
            Maintenance maintenance = new Maintenance();
            DateTime pingTime = DateTime.Now;

            m_managerStorage.AddExecutor(new ExecutorStorageView(true, true, pingTime, "hostname", 1, "username", 1, 2, 3, 4));

            Assert.AreEqual(1, m_managerStorage.GetExecutors().Length);

            maintenance.RemoveExecutors(m_managerStorage, pingTime.AddDays(-1));

            Assert.AreEqual(1, m_managerStorage.GetExecutors().Length);
        }
Example #19
0
        public void RemoveApplicationsByTimeCreatedSpanTestRemoveMultipleOldApplications()
        {
            Maintenance maintenance = new Maintenance();

            DateTime timeCreated = DateTime.Now;

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated.AddDays(-5), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, timeCreated.AddDays(-4), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Ready, timeCreated.AddDays(1), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated.AddDays(-3), false, "username1"));
            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.Stopped, timeCreated.AddDays(2), false, "username1"));

            Assert.AreEqual(5, m_managerStorage.GetApplications().Length);

            // put a 20 hour cut-off, this should remove 3 of the applications
            maintenance.RemoveApplications(m_managerStorage, new TimeSpan(20, 0, 0));

            Assert.AreEqual(2, m_managerStorage.GetApplications().Length);
        }
Example #20
0
        public void RemoveApplicationsByTimeCreatedSpanTestRemoveNonExistingDates()
        {
            Maintenance maintenance = new Maintenance();
            DateTime timeCreated = DateTime.Now;

            m_managerStorage.AddApplication(new ApplicationStorageView(ApplicationState.AwaitingManifest, timeCreated, false, "username1"));

            Assert.AreEqual(1, m_managerStorage.GetApplications().Length);

            // one hour should be enough to avoid removing this one.
            maintenance.RemoveApplications(m_managerStorage, new TimeSpan(1, 0, 0));

            Assert.AreEqual(1, m_managerStorage.GetApplications().Length);
        }
Example #21
0
        public void Admon_PerformStorageMaintenance(SecurityCredentials sc, StorageMaintenanceParameters maintenanceParameters)
        {
            AuthenticateUser(sc);
            EnsurePermission(sc, Permission.ManageAllApps);

            logger.Debug(String.Format("Performing maintenance with parameters {0}.", maintenanceParameters));

            Maintenance maintenance = new Maintenance();

            maintenance.PerformMaintenance(ManagerStorageFactory.ManagerStorage(), maintenanceParameters);
        }