示例#1
0
        public void PublishAzureServiceSimpleDeployTest()
        {
            // Create a temp directory that we'll use to "publish" our service
            using (FileSystemHelper files = new FileSystemHelper(this)
            {
                EnableMonitoring = true
            })
            {
                // Import our default publish settings
                files.CreateAzureSdkDirectoryAndImportPublishSettings();

                // Create a new channel to mock the calls to Azure and
                // determine all of the results that we'll need.
                bool createdHostedService       = false;
                bool createdOrUpdatedDeployment = false;
                SimpleServiceManagement channel = new SimpleServiceManagement();
                channel.GetStorageServiceThunk           = ar => new StorageService();
                channel.CreateHostedServiceThunk         = ar => createdHostedService = true;
                channel.GetHostedServiceWithDetailsThunk = ar => { throw new EndpointNotFoundException(); };
                channel.GetStorageKeysThunk = ar => new StorageService()
                {
                    StorageServiceKeys = new StorageServiceKeys()
                    {
                        Primary = "VGVzdEtleSE="
                    }
                };
                channel.CreateOrUpdateDeploymentThunk = ar => createdOrUpdatedDeployment = true;
                channel.GetDeploymentBySlotThunk      = ar => new Deployment()
                {
                    Status           = DeploymentStatus.Starting,
                    RoleInstanceList = new RoleInstanceList(
                        new RoleInstance[] {
                        new RoleInstance()
                        {
                            InstanceName   = "Role_IN_0",
                            InstanceStatus = RoleInstanceStatus.Ready
                        }
                    })
                };

                // Create a new service that we're going to publish
                string serviceName = "TEST_SERVICE_NAME";
                NewAzureServiceCommand newService = new NewAzureServiceCommand();
                newService.NewAzureServiceProcess(files.RootPath, serviceName);
                string servicePath = files.CreateDirectory(serviceName);

                // Get the publishing process started by creating the package
                PublishAzureServiceCommand publishService = new PublishAzureServiceCommand(channel);
                publishService.ShareChannel = true;
                publishService.SkipUpload   = true;
                publishService.PublishService(servicePath);
                AzureService service = new AzureService(Path.Combine(files.RootPath, serviceName), null);

                // Verify the publish service attempted to create and update
                // the service through the mock.
                Assert.IsTrue(createdHostedService);
                Assert.IsTrue(createdOrUpdatedDeployment);
                Assert.AreEqual <string>(serviceName, service.ServiceName);
            }
        }
示例#2
0
        public void PublishAzureServiceUpgradeTest()
        {
            // Create a temp directory that we'll use to "publish" our service
            using (FileSystemHelper files = new FileSystemHelper(this)
            {
                EnableMonitoring = true
            })
            {
                // Import our default publish settings
                files.CreateAzureSdkDirectoryAndImportPublishSettings();

                // Create a new channel to mock the calls to Azure and
                // determine all of the results that we'll need.
                bool createdHostedService       = false;
                bool createdOrUpdatedDeployment = false;
                bool upgradedDeployment         = false;
                SimpleServiceManagement channel = new SimpleServiceManagement();
                channel.GetStorageServiceThunk           = ar => new StorageService();
                channel.CreateHostedServiceThunk         = ar => createdHostedService = true;
                channel.GetHostedServiceWithDetailsThunk = ar => new HostedService {
                    Deployments = new DeploymentList()
                    {
                        new Deployment {
                            DeploymentSlot = "Production"
                        }
                    }
                };
                channel.GetStorageKeysThunk = ar => new StorageService()
                {
                    StorageServiceKeys = new StorageServiceKeys()
                    {
                        Primary = "VGVzdEtleSE="
                    }
                };
                channel.CreateOrUpdateDeploymentThunk = ar => createdOrUpdatedDeployment = true;
                channel.UpgradeDeploymentThunk        = ar => upgradedDeployment = true;
                channel.GetDeploymentBySlotThunk      = ar => new Deployment()
                {
                    Status           = DeploymentStatus.Starting,
                    RoleInstanceList = new RoleInstanceList(
                        new RoleInstance[] {
                        new RoleInstance()
                        {
                            InstanceName   = "Role_IN_0",
                            InstanceStatus = RoleInstanceStatus.Ready
                        }
                    })
                };
                channel.ListCertificatesThunk = ar => new CertificateList();

                // Create a new service that we're going to publish
                string serviceName = "TEST_SERVICE_NAME";
                NewAzureServiceCommand newService = new NewAzureServiceCommand();
                newService.NewAzureServiceProcess(files.RootPath, serviceName);
                string servicePath = files.CreateDirectory(serviceName);

                // Get the publishing process started by creating the package
                PublishAzureServiceCommand publishService = new PublishAzureServiceCommand(channel);
                publishService.ShareChannel = true;
                publishService.SkipUpload   = true;
                publishService.PublishService(servicePath);

                // Verify the publish service upgraded the deployment
                Assert.IsFalse(createdHostedService);
                Assert.IsFalse(createdOrUpdatedDeployment);
                Assert.IsTrue(upgradedDeployment);
            }
        }