public void GetByServerAppAndGroupTest()
        {
            string            serverName = "server4";
            ApplicationServer server     = ApplicationServerLogic.GetByName(serverName);

            string      appName = "app8";
            Application app     = ApplicationLogic.GetByName(appName);

            ApplicationWithOverrideVariableGroup appWithGroup = new ApplicationWithOverrideVariableGroup();

            appWithGroup.Application = app;

            InstallationSummary mostRecentInstallationSummary = InstallationSummaryLogic.GetMostRecentByServerAppAndGroup(server, appWithGroup);

            InstallationSummary mostRecentSummaryInMemory =
                TestUtility.AllInstallationSummaries
                .Where(summary => summary.ApplicationServer.Id == server.Id &&
                       summary.ApplicationWithOverrideVariableGroup.ApplicationId == appWithGroup.Application.Id &&
                       summary.ApplicationWithOverrideVariableGroup.CustomVariableGroupId == null)
                .OrderByDescending(x => x.InstallationStart)
                .First();

            Assert.AreEqual(mostRecentSummaryInMemory.InstallationStart, mostRecentInstallationSummary.InstallationStart);
            Assert.AreEqual(serverName, mostRecentInstallationSummary.ApplicationServer.Name);
            Assert.AreEqual(appName, mostRecentInstallationSummary.ApplicationWithOverrideVariableGroup.Application.Name);
        }
Beispiel #2
0
        private static void AddManyInstallationSummariesForOneServerAndApp()
        {
            string            serverName = "server4";
            ApplicationServer server     = ApplicationServerLogic.GetByName(serverName);

            string      appName = "app8";
            Application app     = ApplicationLogic.GetByName(appName);

            ApplicationWithOverrideVariableGroup appWithGroup = new ApplicationWithOverrideVariableGroup();

            appWithGroup.Application = app;

            // Save many installation summaries, for one server, to test Raven's 128 or 1024 limit.
            DateTime originalStartTime = DateTime.Now.AddDays(-1);

            for (int i = 1; i <= NumberOfExtraInstallationSummariesForServer4AndApp8; i++)
            {
                DateTime            startTime = originalStartTime.AddMinutes(i);
                InstallationSummary summary   = new InstallationSummary(appWithGroup, server, startTime);

                summary.InstallationEnd    = startTime.AddSeconds(4);
                summary.InstallationResult = InstallationResult.Success;

                AllInstallationSummaries.Add(summary);
                InstallationSummaryLogic.Save(summary);
            }
        }
Beispiel #3
0
        private TestEntityContainer CreateTestEntityContainer(string rootName,
                                                              Func <InstallationSummary, DateTime> forceInstallationTimeFunc,
                                                              bool forceInstallEnvironmentShouldMatch, bool freezeAllInstallations, int numberOfInstallationSummariesToCreate)
        {
            // Creates all of the entities for a particular use case and stores them in a container. This is done
            // because many of the methods in this class do this same thing.

            SetGlobalFreeze(freezeAllInstallations);

            TestHelper.CreateAndPersistEntitiesForAUseCase(rootName, numberOfInstallationSummariesToCreate);

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

            // So we can check the event log and see that this test passed/failed for the right reason.
            appServer.EnableDebugLogging = _enableAppServerDebugLogging;

            // Use this app and group
            string appName = TestHelper.GetAppName(rootName);
            ApplicationWithOverrideVariableGroup appWithGroup = appServer.ApplicationsWithOverrideGroup.Where(x => x.Application.Name == appName).First();

            // Get the most recent InstallationSummary for this server.
            InstallationSummary mostRecentInstallationSummary = InstallationSummaryLogic.GetMostRecentByServerAppAndGroup(appServer, appWithGroup);

            ForceInstallation forceInstallation = new ForceInstallation();

            forceInstallation.ForceInstallationTime = forceInstallationTimeFunc.Invoke(mostRecentInstallationSummary);

            if (forceInstallEnvironmentShouldMatch)
            {
                forceInstallation.ForceInstallEnvironment = appServer.InstallationEnvironment;
            }
            else
            {
                forceInstallation.ForceInstallEnvironment =
                    InstallationEnvironmentLogic.GetAll().Where(x => x.LogicalOrder != appServer.InstallationEnvironment.LogicalOrder).First();
            }

            appWithGroup.Application.ForceInstallation = forceInstallation;

            TestEntityContainer container = new TestEntityContainer();

            container.ApplicationServer             = appServer;
            container.AppWithGroup                  = appWithGroup;
            container.ForceInstallation             = forceInstallation;
            container.MostRecentInstallationSummary = mostRecentInstallationSummary;

            return(container);
        }
        public void GetByServerAppAndGroupWithManyInstallationSummariesTest()
        {
            string            serverName = "server4";
            ApplicationServer server     = ApplicationServerLogic.GetByName(serverName);

            string      appName = "app8";
            Application app     = ApplicationLogic.GetByName(appName);

            ApplicationWithOverrideVariableGroup appWithGroup = new ApplicationWithOverrideVariableGroup();

            appWithGroup.Application = app;

            InstallationSummary mostRecentInstallationSummary = InstallationSummaryLogic.GetMostRecentByServerAppAndGroup(server, appWithGroup);

            Assert.AreEqual(serverName, mostRecentInstallationSummary.ApplicationServer.Name);
            Assert.AreEqual(appName, mostRecentInstallationSummary.ApplicationWithOverrideVariableGroup.Application.Name);
        }
Beispiel #5
0
        private static void CreateInstallationSummaries(Application app, ApplicationServer server, int numberOfInstallationSummariesToCreate)
        {
            DateTime originalStartTime = DateTime.Now.AddDays(-1);

            for (int x = 0; x < numberOfInstallationSummariesToCreate; x++)
            {
                var appWithGroup = new ApplicationWithOverrideVariableGroup()
                {
                    Application = app, ApplicationId = app.Id
                };
                DateTime startTime = originalStartTime.AddMinutes(x);

                InstallationSummary summary = new InstallationSummary(appWithGroup, server, startTime);

                var resultContainer = new InstallationResultContainer();
                resultContainer.InstallationResult = InstallationResult.Success;

                summary.SetResults(resultContainer, startTime.AddSeconds(4));

                InstallationSummaryLogic.Save(summary);
            }
        }
Beispiel #6
0
        private static void AddInstallationSummaries()
        {
            AllInstallationSummaries = new List <InstallationSummary>();

            List <Application>       allApps    = new List <Application>(ApplicationLogic.GetAll(true));
            List <ApplicationServer> allServers = new List <ApplicationServer>(ApplicationServerLogic.GetAll(true));

            ApplicationWithOverrideVariableGroup appWithGroup;
            DateTime originalStartTime = DateTime.Now.AddDays(-1);

            int totalOuterLoops = TotalNumberOfInstallationSummaries / TotalNumberOfEachEntityToCreate;

            int runningTotal = 1;  // Count of total summaries overall

            for (int i = 1; i <= totalOuterLoops; i++)
            {
                for (int x = 0; x < TotalNumberOfEachEntityToCreate - 1; x++)  // We use "- 1" here so we have some entities without an installation summary (for testing)
                {
                    appWithGroup = new ApplicationWithOverrideVariableGroup()
                    {
                        Application = allApps[x], ApplicationId = allApps[x].Id
                    };
                    DateTime startTime = originalStartTime.AddMinutes(runningTotal);

                    InstallationSummary summary = new InstallationSummary(appWithGroup, allServers[x], startTime);

                    summary.InstallationEnd    = startTime.AddSeconds(4);
                    summary.InstallationResult = InstallationResult.Success;

                    AllInstallationSummaries.Add(summary);
                    InstallationSummaryLogic.Save(summary);

                    runningTotal++;
                }
            }
        }
Beispiel #7
0
 public void SaveInstallationSummary(InstallationSummary installationSummary)
 {
     Invoke(() => InstallationSummaryLogic.Save(installationSummary));
 }
Beispiel #8
0
 public IEnumerable <InstallationSummary> GetMostRecentByStartTimeServerAndApplication(int numberToRetrieve, string serverId, string appId, DateTime endDate)
 {
     return(Invoke(() => InstallationSummaryLogic.GetMostRecentByStartTimeServerAndApplication(numberToRetrieve, serverId, appId, endDate)));
 }
Beispiel #9
0
 public IEnumerable <InstallationSummary> GetMostRecentByStartTime(int numberToRetrieve, DateTime endDate)
 {
     return(Invoke(() => InstallationSummaryLogic.GetMostRecentByStartTime(numberToRetrieve, endDate)));
 }