Esempio n. 1
0
        public void ApplicationShouldBeInstalledTest_UseCase12()
        {
            // Use Case #12 -- force installation exists AT THE APP LEVEL, and the force installation time is *after* the most recent
            //                 installation summary time, *installation summaries exist*, and the deployment environments *match*.
            //                 The second test/assert is for when the global setting, FreezeAllInstallations, is true.

            TestEntityContainer container = CreateTestEntityContainer("UseCase12", x => x.InstallationStart.AddSeconds(1), true, false, 5);

            bool actual = ApplicationServerLogic.ApplicationShouldBeInstalled(container.ApplicationServer, container.AppWithGroup);

            Assert.AreEqual(true, actual);  // True because an installation has not yet occurred after the force deployment time.

            /*************************************************************************************
            * Now try it with FreezeAllInstallations true to override any installation logic.
            *************************************************************************************/

            SetGlobalFreeze(true);

            //bool actualUsingFreeze = ApplicationServerLogic.ApplicationShouldBeInstalled(container.ApplicationServer, container.AppWithGroup);
            //Assert.AreEqual(false, actualUsingFreeze);  // False because FreezeAllInstallations is true.

            ApplicationServerLogic.InstallApplications(container.ApplicationServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
Esempio n. 2
0
        public void ApplicationShouldBeInstalledTest_UseCase6()
        {
            // Use Case #6 -- app does not exist in the server's ApplicationWithGroupToForceInstallList,
            //                but the custom variable does.

            string rootName = "UseCase06";

            TestHelper.CreateAndPersistEntitiesForAUseCase(rootName, 0);

            ApplicationServer appServer = ApplicationServerLogic.GetByName(TestHelper.GetServerName(rootName));

            appServer.ApplicationsWithOverrideGroup[0].CustomVariableGroups[0] = TestHelper.CreateCustomVariableGroup(rootName);
            ApplicationServerLogic.Save(appServer);  // To save with a valid group.

            // Create a new app group with a new app, but an existing group
            var appWithValidGroup = new ApplicationWithOverrideVariableGroup();

            appWithValidGroup.Application             = TestHelper.CreateApp(rootName + " " + Guid.NewGuid().ToString());
            appWithValidGroup.CustomVariableGroups[0] = appServer.ApplicationsWithOverrideGroup[0].CustomVariableGroups[0];

            // Set the app to something that doesn't already exist within the server...
            // Leave the group alone because it already exists.

            ApplicationServerLogic.SaveForceInstallation(new ServerForceInstallation(appServer, appWithValidGroup));

            SetGlobalFreeze(false);

            ApplicationServerLogic.InstallApplications(appServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
Esempio n. 3
0
        public void ApplicationShouldBeInstalledTest_UseCase5()
        {
            // Use Case #5 -- app exists in the server's ApplicationWithGroupToForceInstallList,
            //                but the custom variable is different

            string rootName = "UseCase05";

            TestHelper.CreateAndPersistEntitiesForAUseCase(rootName, 0);

            ApplicationServer appServer = ApplicationServerLogic.GetByName(TestHelper.GetServerName(rootName));

            ApplicationWithOverrideVariableGroup appWithDifferentGroup = new ApplicationWithOverrideVariableGroup();

            appWithDifferentGroup.Application = appServer.ApplicationsWithOverrideGroup[0].Application;
            // Set the group to something that doesn't already exist within the server...
            appWithDifferentGroup.CustomVariableGroups[0] = TestHelper.CreateCustomVariableGroup(rootName + " " + Guid.NewGuid().ToString());

            ApplicationServerLogic.SaveForceInstallation(new ServerForceInstallation(appServer, appWithDifferentGroup));

            SetGlobalFreeze(false);

            ApplicationServerLogic.InstallApplications(appServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
Esempio n. 4
0
        public void ApplicationShouldBeInstalledTest_UseCase7()
        {
            // Use Case #7 -- no force installation exists AT THE APP LEVEL

            // It doesn't really matter what we set here. We're getting rid of the ForceInstallation, so the app shouldn't get installed.
            TestEntityContainer container = CreateTestEntityContainer("UseCase07", x => DateTime.Now, true, false, 0);

            container.AppWithGroup.Application.ForceInstallation = null;

            ApplicationServerLogic.InstallApplications(container.ApplicationServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
Esempio n. 5
0
        public void ApplicationShouldBeInstalledTest_UseCase10()
        {
            // Use Case #10 -- force installation exists AT THE APP LEVEL, and the force installation time is in the past,
            //                 no installation summaries exist, and the deployment environments *DO NOT* match.

            TestEntityContainer container = CreateTestEntityContainer("UseCase10", x => DateTime.Now.AddDays(-1), false, false, 0);

            //bool actual = ApplicationServerLogic.ApplicationShouldBeInstalled(container.ApplicationServer, container.AppWithGroup);
            //Assert.AreEqual(false, actual);

            ApplicationServerLogic.InstallApplications(container.ApplicationServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
Esempio n. 6
0
        public void ApplicationShouldBeInstalledTest_UseCase11()
        {
            // Use Case #11 -- force installation exists AT THE APP LEVEL, and the force installation time is *before* the most recent
            //                 installation summary time, *installation summaries exist*, and the deployment environments *match*.

            TestEntityContainer container = CreateTestEntityContainer("UseCase11", x => x.InstallationStart.AddSeconds(-86400),
                                                                      true, false, 5); // 86400 seconds in a day

            //bool actual = ApplicationServerLogic.ApplicationShouldBeInstalled(container.ApplicationServer, container.AppWithGroup);
            //Assert.AreEqual(false, actual);  // False because an installation has occurred after the force deployment time.

            ApplicationServerLogic.InstallApplications(container.ApplicationServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
Esempio n. 7
0
        public void ApplicationShouldBeInstalledTest_UseCase2()
        {
            // Use Case #2 -- app group exists in the server's ApplicationWithGroupToForceInstallList
            //             -- with *null* custom variable group

            ApplicationServer appServer = GetAppServerWithInstallationSummariesFromDb();

            // Use this app
            ApplicationWithOverrideVariableGroup appWithNullGroup = appServer.ApplicationsWithOverrideGroup[0];

            ApplicationServerLogic.SaveForceInstallation(new ServerForceInstallation(appServer, appWithNullGroup));

            SetGlobalFreeze(false);

            ApplicationServerLogic.InstallApplications(appServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Once());
        }
Esempio n. 8
0
        public void ApplicationShouldBeInstalledTest_UseCase1()
        {
            // Use Case #1 -- app group is not enabled

            ApplicationServer appServer = GetAppServerWithInstallationSummariesFromDb();

            // If disabled, don't install.
            ApplicationWithOverrideVariableGroup appWithNullGroup = appServer.ApplicationsWithOverrideGroup[0];

            appWithNullGroup.Enabled = false;

            ApplicationServerLogic.SaveForceInstallation(new ServerForceInstallation(appServer, appWithNullGroup));

            SetGlobalFreeze(false);

            ApplicationServerLogic.InstallApplications(appServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
Esempio n. 9
0
        public void ApplicationShouldBeInstalledTest_UseCase14()
        {
            // An install is supposed to happen. Make sure the installer was invoked.

            SetGlobalFreeze(false);

            ApplicationServer appServer = GetAppServerWithNoInstallationSummariesFromDb();

            ForceInstallation forceInstallation = new ForceInstallation();

            forceInstallation.ForceInstallationTime   = DateTime.Now.AddDays(-1);
            forceInstallation.ForceInstallEnvironment = appServer.InstallationEnvironment;  // Make environments match

            // Use this app and group
            ApplicationWithOverrideVariableGroup appWithGroup = appServer.ApplicationsWithOverrideGroup[0];

            appWithGroup.Application.ForceInstallation = forceInstallation;

            ApplicationServerLogic.InstallApplications(appServer);
            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Once());
        }
Esempio n. 10
0
        public void ApplicationShouldBeInstalledTest_UseCase13()
        {
            // An install is not supposed to happen. Make sure the installer was not invoked.

            SetGlobalFreeze(false);

            ApplicationServer appServer = GetAppServerWithNoInstallationSummariesFromDb();

            ForceInstallation forceInstallation = new ForceInstallation();

            forceInstallation.ForceInstallationTime   = DateTime.Now.AddDays(-1);
            forceInstallation.ForceInstallEnvironment = // use an environment that's different than our app server's.
                                                        InstallationEnvironmentLogic.GetAll().Where(x => x.LogicalOrder != appServer.InstallationEnvironment.LogicalOrder).First();

            // Use this app and group
            ApplicationWithOverrideVariableGroup appWithGroup = appServer.ApplicationsWithOverrideGroup[0];

            appWithGroup.Application.ForceInstallation = forceInstallation;

            ApplicationServerLogic.InstallApplications(appServer);
            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }
        private static void CheckForApplicationsToInstall()
        {
            try
            {
                ApplicationServer appServer = GetApplicationServerForThisMachine(Environment.MachineName);

                // 26-Dec-2016: I was going to shortcut the process and check right here to see if a server
                // had any force installations to do. That would have been a mistake because an *app* can have
                // a force installation. In that case, the server won't have one, but the server would still
                // need to be submitted to ApplicationServerLogic.InstallApplications() to compare its apps
                // with any app that may have a force installation on it.
                if (appServer == null)
                {
                    return;
                }

                ApplicationServerLogic.InstallApplications(appServer);
            }
            catch (Exception ex)
            {
                // Log it and keep processing.
                CommonUtility.ProcessExceptionWithLimits(ex, PrestoTaskRunnerName);
            }
        }
Esempio n. 12
0
        public void ApplicationShouldBeInstalledTest_UseCase4()
        {
            // Use Case #4 -- app group does not exist in the server's ApplicationWithGroupToForceInstallList

            ApplicationServer appServer = GetAppServerWithInstallationSummariesFromDb();

            // Use this app
            ApplicationWithOverrideVariableGroup appWithValidGroup = appServer.ApplicationsWithOverrideGroup[0];

            appWithValidGroup.CustomVariableGroups[0] = CustomVariableGroupLogic.GetById("CustomVariableGroups/4");

            SetGlobalFreeze(false);

            // Note: We are *not* adding our app to the *force install* list of the server.
            //       In other words, there is no force installation.

            //bool actual = ApplicationServerLogic.ApplicationShouldBeInstalled(appServer, appWithValidGroup);
            //Assert.AreEqual(false, actual);

            ApplicationServerLogic.InstallApplications(appServer);

            _mockAppInstaller.Verify(x => x.InstallApplication(It.IsAny <ApplicationServer>(),
                                                               It.IsAny <ApplicationWithOverrideVariableGroup>()), Times.Never());
        }