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()); }
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()); }
private ApplicationServer GetAppServerWithNoInstallationSummariesFromDb() { var appServer = ApplicationServerLogic.GetByName("server10"); appServer.EnableDebugLogging = _enableAppServerDebugLogging; return(appServer); }
private static void TestHighNumberOfSessionRequests() { PrestoServerUtility.RegisterRavenDataClasses(); var appServer = ApplicationServerLogic.GetByName("PBG1MES22S105"); Debug.WriteLine(appServer.Name); }
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); } }
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); }
private static void AddAppServers() { IEnumerable <InstallationEnvironment> environments = InstallationEnvironmentLogic.GetAll(); for (int i = 1; i <= TotalNumberOfEachEntityToCreate; i++) { ApplicationServer server = new ApplicationServer(); server.Name = "server" + i; server.InstallationEnvironment = environments.Where(x => x.LogicalOrder == 1).First(); // 1st env is dev server.Description = "Description " + i; server.EnableDebugLogging = false; Application app = ApplicationLogic.GetByName("app" + i); server.ApplicationsWithOverrideGroup.Add(new ApplicationWithOverrideVariableGroup() { Enabled = true, Application = app }); CustomVariableGroup group = CustomVariableGroupLogic.GetByName("group" + i); server.CustomVariableGroups.Add(group); ApplicationServerLogic.Save(server); } }
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()); }
private static ApplicationServer CreateAppServer(string rootName, Application app, CustomVariableGroup group) { ApplicationServer server = new ApplicationServer(); server.Name = rootName + " server"; server.InstallationEnvironment = _defaultEnv; server.Description = rootName + " server description"; server.EnableDebugLogging = false; server.ApplicationsWithOverrideGroup.Add(new ApplicationWithOverrideVariableGroup() { Enabled = true, Application = app }); // Add the generic apps to the server, so we have more than just the one above. _genericApps.ForEach(x => server.ApplicationsWithOverrideGroup.Add( new ApplicationWithOverrideVariableGroup() { Enabled = true, Application = x })); server.CustomVariableGroups.Add(group); ApplicationServerLogic.Save(server); return(server); }
public void GetByNameTest() { string name = "server2"; ApplicationServer server = ApplicationServerLogic.GetByName(name); Assert.AreEqual(name, server.Name); }
public ApplicationServer SaveServer(ApplicationServer applicationServer) { return(Invoke(() => { ApplicationServerLogic.Save(applicationServer); return applicationServer; })); }
public void SaveForceInstallations(List <ServerForceInstallation> serverForceInstallations) { Invoke(() => { ApplicationServerLogic.SaveForceInstallations(serverForceInstallations); LogAppsToBeInstalled(serverForceInstallations); } ); }
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()); }
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()); }
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 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()); }
private static ApplicationServer GetApplicationServerForThisMachine(string serverName) { // Get the app server, on which this process is running. ApplicationServer appServer = ApplicationServerLogic.GetByName(serverName); if (appServer == null) { Logger.LogWarning(string.Format(CultureInfo.CurrentCulture, PrestoTaskRunnerResources.AppServerNotFound, serverName), PrestoTaskRunnerName); } return(appServer); }
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); }
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()); }
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()); }
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()); }
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()); }
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()); }
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++; } } }
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); } }
public void RemoveForceInstallation(ServerForceInstallation forceInstallation) { Invoke(() => ApplicationServerLogic.RemoveForceInstallation(forceInstallation)); }
public void InstallPrestoSelfUpdater(ApplicationServer appServer, ApplicationWithOverrideVariableGroup appWithGroup) { Invoke(() => ApplicationServerLogic.InstallPrestoSelfUpdater(appServer, appWithGroup)); }
public IEnumerable <ApplicationServerDtoSlim> GetAllServersDtoSlim() { return(Invoke(() => ApplicationServerLogic.GetAllSlim().ToDtoSlim())); }
public IEnumerable <ApplicationServer> GetAllServers(bool includeArchivedApps) { return(Invoke(() => ApplicationServerLogic.GetAll(includeArchivedApps))); }
public ApplicationServer GetServerById(string id) { return(Invoke(() => ApplicationServerLogic.GetById(id))); }