コード例 #1
0
        public void TestInstallAndExecuteSharpRemote()
        {
            var watchdog = new SharpRemote.Watchdog.Watchdog(CreateWatchdog());

            InstalledApplication app;

            using (IApplicationInstaller installer = watchdog.StartInstallation(SharpRemote("0.1")))
            {
                DeploySharpRemote(installer);
                app = installer.Commit();
            }

            app.Should().NotBeNull();

            // Let's verify that the deployment actually worked...
            VerifyPostSharpDeployment(app);

            // Now that SharpRemote is deployed we can start an actual instance...
            var instance = new ApplicationInstanceDescription
            {
                ApplicationName = app.Name,
                Executable      = app.Files.First(x => x.Filename.EndsWith("SampleBrowser.exe")),
                Name            = "Test Host"
            };

            watchdog.RegisterApplicationInstance(instance);

            // Due to the watchdog being executed on the same computer, we expect
            // the process to be running now...
            IsBrowserRunning().Should().BeTrue();
        }
コード例 #2
0
        public void TestColdUpdate1()
        {
            var watchdog = new SharpRemote.Watchdog.Watchdog(CreateWatchdog());

            InstalledApplication  app, update;
            ApplicationDescriptor desc = SharpRemote("0.5");

            using (IApplicationInstaller installer = watchdog.StartInstallation(desc))
            {
                DeploySharpRemote(installer);
                app = installer.Commit();
            }

            // Let's try patching the pdb...
            using (IApplicationInstaller installer = watchdog.StartInstallation(desc, Installation.ColdUpdate))
            {
                string pdb = Path.Combine(SharpRemoteFolder, "SharpRemote.pdb");
                installer.AddFile(pdb, Environment.SpecialFolder.LocalApplicationData);
                update = installer.Commit();
            }

            // The update should consists of all files from the first installation *AND* the pdb
            // we installed as an update
            update.Files.Count.Should().Be(app.Files.Count + 1);
            List <InstalledFile> updated = update.Files.Except(app.Files).ToList();

            updated.Count.Should().Be(1);
            updated[0].Filename.Should().Be("SharpRemote.pdb");
            updated[0].Folder.Should().Be(Environment.SpecialFolder.LocalApplicationData);
            updated[0].Id.Should().Be(4);
        }
コード例 #3
0
 public ApplicationUpdateManager(
     string clusterId,
     IApplicationDeploymentDirectory applicationDeploymentDirectory,
     IApplicationPool applicationPool, 
     IApplicationDownloader applicationDownloader, 
     IApplicationInstaller applicationInstaller)
 {
     _clusterId = clusterId;
     _applicationDeploymentDirectory = applicationDeploymentDirectory;
     _applicationPool = applicationPool;
     _applicationDownloader = applicationDownloader;
     _applicationInstaller = applicationInstaller;
 }
コード例 #4
0
 public ApplicationUpdateManager(
     string cloudServiceDeploymentId,
     IApplicationDeploymentDirectory applicationDeploymentDirectory,
     IApplicationPool applicationPool,
     IApplicationDownloader applicationDownloader,
     IApplicationInstaller applicationInstaller)
 {
     _cloudServiceDeploymentId       = cloudServiceDeploymentId;
     _applicationDeploymentDirectory = applicationDeploymentDirectory;
     _applicationPool       = applicationPool;
     _applicationDownloader = applicationDownloader;
     _applicationInstaller  = applicationInstaller;
 }
コード例 #5
0
 public ApplicationUpdateManager(
     string clusterId,
     string instanceId,
     IApplicationDeploymentDirectory applicationDeploymentDirectory,
     IApplicationPool applicationPool,
     IApplicationDownloader applicationDownloader,
     IApplicationInstaller applicationInstaller,
     IDeploymentStatusWriter deploymentStatusWriter)
 {
     _clusterId       = clusterId;
     this._instanceId = instanceId;
     _applicationDeploymentDirectory = applicationDeploymentDirectory;
     _applicationPool        = applicationPool;
     _applicationDownloader  = applicationDownloader;
     _applicationInstaller   = applicationInstaller;
     _deploymentStatusWriter = deploymentStatusWriter;
 }
コード例 #6
0
        public void TestHotUpdate1()
        {
            var watchdog = new SharpRemote.Watchdog.Watchdog(CreateWatchdog());

            InstalledApplication  app;
            ApplicationDescriptor desc = SharpRemote("0.7");

            using (IApplicationInstaller installer = watchdog.StartInstallation(desc))
            {
                DeploySharpRemote(installer);
                app = installer.Commit();
            }

            // Let's start a browser application to ensure that some files from the update are now in use...
            ApplicationInstanceDescription instance = CreateBrowserInstance(app);

            watchdog.RegisterApplicationInstance(instance);
            IsBrowserRunning().Should().BeTrue();

            // Performing a cold update should be possible because it kills the app(s) first..
            using (IApplicationInstaller installer = watchdog.StartInstallation(desc, Installation.HotUpdate))
            {
                IsBrowserRunning().Should().BeTrue("because the update shouldn't kill any instance");

                string browser = Path.Combine(SharpRemoteFolder, "SampleBrowser.exe");
                installer.AddFile(browser, Environment.SpecialFolder.LocalApplicationData);

                InstallationFailedException exception = null;
                try
                {
                    installer.Commit();
                }
                catch (InstallationFailedException e)
                {
                    exception = e;
                }
                exception.Should().NotBeNull();
                exception.Message.Should().Be("Application of 'SharpRemote 0.7' failed");
                var inner = exception.InnerException;
                (inner is IOException || inner is UnauthorizedAccessException).Should().BeTrue();
            }
        }
コード例 #7
0
        public void TestInstallConcurrently1()
        {
            var watchdog = new SharpRemote.Watchdog.Watchdog(CreateWatchdog());

            InstalledApplication app1, app2;

            using (IApplicationInstaller installer1 = watchdog.StartInstallation(SharpRemote("0.2")))
                using (IApplicationInstaller installer2 = watchdog.StartInstallation(SharpRemote("0.3")))
                {
                    DeploySharpRemote(installer2);
                    DeploySharpRemote(installer1);
                    app2 = installer2.Commit();
                    app1 = installer1.Commit();
                }

            app2.Should().NotBeNull();
            app1.Should().NotBeNull();

            // Let's verify that the deployment actually worked...
            VerifyPostSharpDeployment(app1);
            VerifyPostSharpDeployment(app2);
        }
コード例 #8
0
        public void TestColdUpdate2()
        {
            var watchdog = new SharpRemote.Watchdog.Watchdog(CreateWatchdog());

            InstalledApplication  app, update;
            ApplicationDescriptor desc = SharpRemote("0.6");

            using (IApplicationInstaller installer = watchdog.StartInstallation(desc))
            {
                DeploySharpRemote(installer);
                app = installer.Commit();
            }

            // Let's start a browser application to ensure that some files from the update are now in use...
            ApplicationInstanceDescription instance = CreateBrowserInstance(app);

            watchdog.RegisterApplicationInstance(instance);
            IsBrowserRunning().Should().BeTrue();

            // Performing a cold update should be possible because it kills the app(s) first..
            using (IApplicationInstaller installer = watchdog.StartInstallation(desc, Installation.ColdUpdate))
            {
                IsBrowserRunning().Should().BeFalse("because the update needed to kill the browser");

                string pdb = Path.Combine(SharpRemoteFolder, "SharpRemote.dll");
                installer.AddFile(pdb, Environment.SpecialFolder.LocalApplicationData);
                string browser = Path.Combine(SharpRemoteFolder, "SampleBrowser.exe");
                installer.AddFile(browser, Environment.SpecialFolder.LocalApplicationData);
                update = installer.Commit();

                IsBrowserRunning()
                .Should()
                .BeTrue("because after the update's finished all application instances should be running again");
            }

            // The update shouldn't have written new files, not even their file sizes should've changed...
            app.Files.Should().BeEquivalentTo(update.Files);
        }
コード例 #9
0
        public void TestInstallConcurrently2()
        {
            var watchdog = new SharpRemote.Watchdog.Watchdog(CreateWatchdog());

            InstalledApplication  app1;
            ApplicationDescriptor desc = SharpRemote("0.4");

            using (IApplicationInstaller installer1 = watchdog.StartInstallation(desc))
            {
                DeploySharpRemote(installer1);

                new Action(() => watchdog.StartInstallation(desc))
                .ShouldThrow <InstallationFailedException>()
                .WithMessage(
                    "There already is a pending installation for the same application - this installation must be completed or aborted in order for a new installation to be allowed");

                app1 = installer1.Commit();
            }

            app1.Should().NotBeNull();

            // Let's verify that the deployment actually worked...
            VerifyPostSharpDeployment(app1);
        }
コード例 #10
0
        private void DeploySharpRemote(IApplicationInstaller installer)
        {
            List <string> fileNames = SharpRemoteFiles.Select(x => Path.Combine(SharpRemoteFolder, x)).ToList();

            installer.AddFiles(fileNames, Environment.SpecialFolder.LocalApplicationData);
        }