Пример #1
0
        public void TestInitialize()
        {
            _dataRootPath            = Path.Combine(Directory.GetCurrentDirectory(), "Data", "EndToEndTest");
            _testDirPath             = Path.Combine(Directory.GetCurrentDirectory(), "EndToEndTest");
            _deploymentDirPath       = Path.Combine(_testDirPath, "Deployments");
            _applicationsInstallPath = Path.Combine(_testDirPath, Constants.ApplicationsRootFolderName);

            FileUtils.CopyDir(_dataRootPath, _deploymentDirPath, overwrite: true).Wait();

            CopyTestProcessExeToTestApps();

            _diContainer = new UnityContainer();
            DiModule.RegisterTypes(_diContainer, new YamsConfigBuilder("UseDevelopmentStorage=true", "deploymentId1", "1", "instanceId", _applicationsInstallPath).Build());

            // Replace the IRemoteDirectory default implementation (which uses Azure) with a LocalDirectory implementation
            // so we can use local test data.
            _diContainer.RegisterType <IRemoteDirectory>(new ContainerControlledLifetimeManager(),
                                                         new InjectionFactory(
                                                             c => new LocalDirectory(_deploymentDirPath)));

            IUpdateSessionManager updateSessionManager = new StubIUpdateSessionManager
            {
                TryStartUpdateSessionString = applicationId => Task.FromResult(true),
                EndUpdateSessionString      = applicationId => Task.FromResult(true)
            };

            // Replace the update session manager with a stub that always starts an update session (since we don't have multiple instances
            // updating in a test)
            _diContainer.RegisterInstance(updateSessionManager);

            // we don't start yams because that will make it update based on a timer that is hard to manage in a test. Instead, we call
            // applicationUpdateManager.CheckForUpdates() manually in a test.
            _yamsEntryPoint = new YamsEntryPoint(_diContainer);
        }
Пример #2
0
        public async Task RunAsync()
        {
            WorkerRoleConfig config = new WorkerRoleConfig();
            YamsConfig yamsConfig = new YamsConfigBuilder(
                // mandatory configs
                config.StorageDataConnectionString,
                DeploymentIdUtils.CloudServiceDeploymentId,
                RoleEnvironment.CurrentRoleInstance.UpdateDomain.ToString(),
                RoleEnvironment.CurrentRoleInstance.Id,
                config.CurrentRoleInstanceLocalStoreDirectory)
                // optional configs
                .SetCheckForUpdatesPeriodInSeconds(config.UpdateFrequencyInSeconds)
                .SetApplicationRestartCount(config.ApplicationRestartCount)
                .Build();
            _yamsEntryPoint = new YamsEntryPoint(yamsConfig);

            try
            {
                Trace.TraceInformation("Yams is starting");
                await _yamsEntryPoint.Start();
                Trace.TraceInformation("Yams has started");
                while (true)
                {
                    await Task.Delay(1000);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
        }
Пример #3
0
        public void TestInitialize()
        {
            _dataRootPath = Path.Combine(Directory.GetCurrentDirectory(), "Data", "EndToEndTest");
            _testDirPath = Path.Combine(Directory.GetCurrentDirectory(), "EndToEndTest");
            _deploymentDirPath = Path.Combine(_testDirPath, "Deployments");
            _applicationsInstallPath = Path.Combine(_testDirPath, Constants.ApplicationsRootFolderName);

            FileUtils.CopyDir(_dataRootPath, _deploymentDirPath, overwrite: true).Wait();

            CopyTestProcessExeToTestApps();

            _diContainer = new UnityContainer();
            DiModule.RegisterTypes(_diContainer, new YamsConfigBuilder("UseDevelopmentStorage=true", "deploymentId1", "1", "instanceId", _applicationsInstallPath).Build());

            // Replace the IRemoteDirectory default implementation (which uses Azure) with a LocalDirectory implementation
            // so we can use local test data.
            _diContainer.RegisterType<IRemoteDirectory>(new ContainerControlledLifetimeManager(),
                new InjectionFactory(
                    c => new LocalDirectory(_deploymentDirPath)));

            IUpdateSessionManager updateSessionManager = new StubIUpdateSessionManager
            {
                TryStartUpdateSessionString = applicationId => Task.FromResult(true),
                EndUpdateSessionString = applicationId => Task.FromResult(true)
            };

            // Replace the update session manager with a stub that always starts an update session (since we don't have multiple instances
            // updating in a test)
            _diContainer.RegisterInstance(updateSessionManager);

            // we don't start yams because that will make it update based on a timer that is hard to manage in a test. Instead, we call
            // applicationUpdateManager.CheckForUpdates() manually in a test.
            _yamsEntryPoint = new YamsEntryPoint(_diContainer);
        }
Пример #4
0
        public async Task RunAsync()
        {
            WorkerRoleConfig config     = new WorkerRoleConfig();
            YamsConfig       yamsConfig = new YamsConfigBuilder(
                // mandatory configs
                config.StorageDataConnectionString,
                DeploymentIdUtils.CloudServiceDeploymentId,
                RoleEnvironment.CurrentRoleInstance.UpdateDomain.ToString(),
                RoleEnvironment.CurrentRoleInstance.Id,
                config.CurrentRoleInstanceLocalStoreDirectory)
                                          // optional configs
                                          .SetCheckForUpdatesPeriodInSeconds(config.UpdateFrequencyInSeconds)
                                          .SetApplicationRestartCount(config.ApplicationRestartCount)
                                          .Build();

            _yamsEntryPoint = new YamsEntryPoint(yamsConfig);

            try
            {
                Trace.TraceInformation("Yams is starting");
                await _yamsEntryPoint.Start();

                Trace.TraceInformation("Yams has started");
                while (true)
                {
                    await Task.Delay(1000);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
        }