public void TestInitialize()
 {
     serviceName = Path.GetRandomFileName();
     GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
     service = new AzureServiceWrapper(Directory.GetCurrentDirectory(), Path.GetRandomFileName(), null);
     service.CreateVirtualCloudPackage();
     packagePath = service.Paths.CloudPackage;
     configPath  = service.Paths.CloudConfiguration;
     settings    = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Default];
     new ImportAzurePublishSettingsCommand().ImportAzurePublishSettingsProcess(Resources.PublishSettingsFileName, Data.AzureSdkAppDir);
 }
 public void TestInitialize()
 {
     GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
     service = new AzureServiceWrapper(Directory.GetCurrentDirectory(), Path.GetRandomFileName(), null);
     service.CreateVirtualCloudPackage();
     packagePath = service.Paths.CloudPackage;
     configPath = service.Paths.CloudConfiguration;
     settings = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Default];
     WindowsAzureProfile.Instance = new WindowsAzureProfile(new Mock<IProfileStore>().Object);
     WindowsAzureProfile.Instance.ImportPublishSettings(Data.ValidPublishSettings.First());
 }
 public void TestInitialize()
 {
     GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
     service = new AzureServiceWrapper(Directory.GetCurrentDirectory(), Path.GetRandomFileName(), null);
     service.CreateVirtualCloudPackage();
     packagePath = service.Paths.CloudPackage;
     configPath  = service.Paths.CloudConfiguration;
     settings    = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Default];
     WindowsAzureProfile.Instance = new WindowsAzureProfile(new Mock <IProfileStore>().Object);
     WindowsAzureProfile.Instance.ImportPublishSettings(Data.ValidPublishSettings.First());
 }
Example #4
0
 public void GetNextPortAddingThirdEndpoint()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         int          expectedPort = int.Parse(Resources.DefaultPort) + 1;
         AzureService service      = new AzureService(files.RootPath, serviceName, null);
         service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
         service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
         service = new AzureServiceWrapper(service.Paths.RootPath, null);
         int nextPort = service.Components.GetNextPort();
         Assert.AreEqual <int>(expectedPort, nextPort);
     }
 }
 public void GetNextPortAddingThirdEndpoint()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         int expectedPort = int.Parse(Resources.DefaultPort) + 1;
         AzureService service = new AzureService(files.RootPath, serviceName, null);
         service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
         service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
         service = new AzureServiceWrapper(service.Paths.RootPath, null);
         int nextPort = service.Components.GetNextPort();
         Assert.AreEqual<int>(expectedPort, nextPort);
     }
 }
Example #6
0
 public void GetNextPortWithEmptyPortIndpoints()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         int          expectedPort = int.Parse(Resources.DefaultPort);
         AzureService service      = new AzureService(files.RootPath, serviceName, null);
         service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
         service.Components.Definition.WebRole[0].Endpoints.InputEndpoint = null;
         service.Components.Save(service.Paths);
         service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
         service = new AzureServiceWrapper(service.Paths.RootPath, null);
         int nextPort = service.Components.GetNextPort();
         Assert.AreEqual <int>(expectedPort, nextPort);
     }
 }
Example #7
0
        /// <summary>
        /// When running this test double check that the certificate used in Azure.PublishSettings has not expired.
        /// </summary>
        public PublishContextTests()
        {
            AzurePowerShell.ProfileDirectory = Test.Utilities.Common.Data.AzureSdkAppDir;
            service = new AzureServiceWrapper(Directory.GetCurrentDirectory(), Path.GetRandomFileName(), null);
            service.CreateVirtualCloudPackage();
            packagePath            = service.Paths.CloudPackage;
            configPath             = service.Paths.CloudConfiguration;
            settings               = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Default];
            AzureSession.DataStore = new MemoryDataStore();
            ProfileClient client = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));

            AzureSession.DataStore.WriteFile(Test.Utilities.Common.Data.ValidPublishSettings.First(),
                                             File.ReadAllText(Test.Utilities.Common.Data.ValidPublishSettings.First()));
            client.ImportPublishSettings(Test.Utilities.Common.Data.ValidPublishSettings.First(), null);
            client.Profile.Save();
        }
Example #8
0
        public void TestInitialize()
        {
            CmdletSubscriptionExtensions.SessionManager = new InMemorySessionManager();

            serviceName = Path.GetRandomFileName();
            GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
            service = new AzureServiceWrapper(Directory.GetCurrentDirectory(), Path.GetRandomFileName(), null);
            service.CreateVirtualCloudPackage();
            packagePath                 = service.Paths.CloudPackage;
            configPath                  = service.Paths.CloudConfiguration;
            settings                    = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Default];
            mockCommandRuntime          = new MockCommandRuntime();
            importCmdlet                = new ImportAzurePublishSettingsCommand();
            importCmdlet.CommandRuntime = mockCommandRuntime;
            importCmdlet.ImportSubscriptionFile(Data.ValidPublishSettings.First(), null);
            importCmdlet.SubscriptionClient = CreateMockSubscriptionClient();
        }
Example #9
0
        /// <summary>
        /// This method handles most possible cases that user can do to create role
        /// </summary>
        /// <param name="webRole">Count of web roles to add</param>
        /// <param name="workerRole">Count of worker role to add</param>
        /// <param name="addWebBeforeWorker">Decides in what order to add roles. There are three options, note that value between brackets is the value to pass:
        /// 1. Web then, interleaving (0): interleave adding and start by adding web role first.
        /// 2. Worker then, interleaving (1): interleave adding and start by adding worker role first.
        /// 3. Web then worker (2): add all web roles then worker roles.
        /// 4. Worker then web (3): add all worker roles then web roles.
        /// By default this parameter is set to 0
        /// </param>
        private void AddNodeRoleTest(int webRole, int workerRole, int order = 0)
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureServiceWrapper wrappedService = new AzureServiceWrapper(files.RootPath, serviceName, null);
                AzureService        service        = new AzureService(Path.Combine(files.RootPath, serviceName), null);

                WebRoleInfo[] webRoles = null;
                if (webRole > 0)
                {
                    webRoles = new WebRoleInfo[webRole];
                    for (int i = 0; i < webRoles.Length; i++)
                    {
                        webRoles[i] = new WebRoleInfo(string.Format("{0}{1}", Resources.WebRole, i + 1), 1);
                    }
                }


                WorkerRoleInfo[] workerRoles = null;
                if (workerRole > 0)
                {
                    workerRoles = new WorkerRoleInfo[workerRole];
                    for (int i = 0; i < workerRoles.Length; i++)
                    {
                        workerRoles[i] = new WorkerRoleInfo(string.Format("{0}{1}", Resources.WorkerRole, i + 1), 1);
                    }
                }

                RoleInfo[] roles = (webRole + workerRole > 0) ? new RoleInfo[webRole + workerRole] : null;
                if (order == 0)
                {
                    for (int i = 0, w = 0, wo = 0; i < webRole + workerRole;)
                    {
                        if (w++ < webRole)
                        {
                            roles[i++] = wrappedService.AddWebRole(Data.NodeWebRoleScaffoldingPath);
                        }
                        if (wo++ < workerRole)
                        {
                            roles[i++] = wrappedService.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
                        }
                    }
                }
                else if (order == 1)
                {
                    for (int i = 0, w = 0, wo = 0; i < webRole + workerRole;)
                    {
                        if (wo++ < workerRole)
                        {
                            roles[i++] = wrappedService.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath);
                        }
                        if (w++ < webRole)
                        {
                            roles[i++] = wrappedService.AddWebRole(Data.NodeWebRoleScaffoldingPath);
                        }
                    }
                }
                else if (order == 2)
                {
                    wrappedService.AddRole(Data.NodeWebRoleScaffoldingPath, Data.NodeWorkerRoleScaffoldingPath, webRole, workerRole);
                    webRoles.CopyTo(roles, 0);
                    Array.Copy(workerRoles, 0, roles, webRole, workerRoles.Length);
                }
                else if (order == 3)
                {
                    wrappedService.AddRole(Data.NodeWebRoleScaffoldingPath, Data.NodeWorkerRoleScaffoldingPath, 0, workerRole);
                    workerRoles.CopyTo(roles, 0);
                    wrappedService.AddRole(Data.NodeWebRoleScaffoldingPath, Data.NodeWorkerRoleScaffoldingPath, webRole, 0);
                    Array.Copy(webRoles, 0, roles, workerRole, webRoles.Length);
                }
                else
                {
                    throw new ArgumentException("value for order parameter is unknown");
                }

                AzureAssert.AzureServiceExists(Path.Combine(files.RootPath, serviceName), Resources.GeneralScaffolding, serviceName, webRoles: webRoles, workerRoles: workerRoles, webScaff: Data.NodeWebRoleScaffoldingPath, workerScaff: Data.NodeWorkerRoleScaffoldingPath, roles: roles);
            }
        }
 public void GetNextPortWithEmptyPortIndpoints()
 {
     using (FileSystemHelper files = new FileSystemHelper(this))
     {
         int expectedPort = int.Parse(Resources.DefaultPort);
         CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null);
         service.AddWebRole(Data.NodeWebRoleScaffoldingPath);
         service.Components.Definition.WebRole[0].Endpoints.InputEndpoint = null;
         service.Components.Save(service.Paths);
         service.AddWebRole(Data.PHPWebRoleScaffoldingPath);
         service = new AzureServiceWrapper(service.Paths.RootPath, null);
         int nextPort = service.Components.GetNextPort();
         Assert.AreEqual<int>(expectedPort, nextPort);
     }
 }
        public void TestInitialize()
        {
            Management.Extensions.CmdletSubscriptionExtensions.SessionManager = new InMemorySessionManager();

            serviceName = Path.GetRandomFileName();
            GlobalPathInfo.GlobalSettingsDirectory = Data.AzureSdkAppDir;
            service = new AzureServiceWrapper(Directory.GetCurrentDirectory(), Path.GetRandomFileName(), null);
            service.CreateVirtualCloudPackage();
            packagePath = service.Paths.CloudPackage;
            configPath = service.Paths.CloudConfiguration;
            settings = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Default];
            mockCommandRuntime = new MockCommandRuntime();
            importCmdlet = new ImportAzurePublishSettingsCommand();
            importCmdlet.CommandRuntime = mockCommandRuntime;
            importCmdlet.ImportSubscriptionFile(Data.ValidPublishSettings.First(), null);
        }
        private void AddPHPRoleTest(int webRole, int workerRole, int order = 0)
        {
            using (FileSystemHelper files = new FileSystemHelper(this))
            {
                AzureServiceWrapper wrappedService = new AzureServiceWrapper(files.RootPath, serviceName, null);
                AzureService service = new AzureService(Path.Combine(files.RootPath, serviceName), null);

                WebRoleInfo[] webRoles = null;
                if (webRole > 0)
                {
                    webRoles = new WebRoleInfo[webRole];
                    for (int i = 0; i < webRoles.Length; i++)
                    {
                        webRoles[i] = new WebRoleInfo(string.Format("{0}{1}", Resources.WebRole, i + 1), 1);
                    }
                }

                WorkerRoleInfo[] workerRoles = null;
                if (workerRole > 0)
                {
                    workerRoles = new WorkerRoleInfo[workerRole];
                    for (int i = 0; i < workerRoles.Length; i++)
                    {
                        workerRoles[i] = new WorkerRoleInfo(string.Format("{0}{1}", Resources.WorkerRole, i + 1), 1);
                    }
                }

                RoleInfo[] roles = (webRole + workerRole > 0) ? new RoleInfo[webRole + workerRole] : null;
                if (order == 0)
                {
                    for (int i = 0, w = 0, wo = 0; i < webRole + workerRole; )
                    {
                        if (w++ < webRole) roles[i++] = wrappedService.AddWebRole(Resources.PHPScaffolding);
                        if (wo++ < workerRole) roles[i++] = wrappedService.AddWorkerRole(Resources.PHPScaffolding);
                    }
                }
                else if (order == 1)
                {
                    for (int i = 0, w = 0, wo = 0; i < webRole + workerRole; )
                    {
                        if (wo++ < workerRole) roles[i++] = wrappedService.AddWorkerRole(Resources.PHPScaffolding);
                        if (w++ < webRole) roles[i++] = wrappedService.AddWebRole(Resources.PHPScaffolding);
                    }
                }
                else if (order == 2)
                {
                    wrappedService.AddRole(Resources.PHPScaffolding, webRole, workerRole);
                    webRoles.CopyTo(roles, 0);
                    Array.Copy(workerRoles, 0, roles, webRole, workerRoles.Length);
                }
                else if (order == 3)
                {
                    wrappedService.AddRole(Resources.PHPScaffolding, 0, workerRole);
                    workerRoles.CopyTo(roles, 0);
                    wrappedService.AddRole(Resources.PHPScaffolding, webRole, 0);
                    Array.Copy(webRoles, 0, roles, workerRole, webRoles.Length);
                }
                else
                {
                    throw new ArgumentException("value for order parameter is unknown");
                }

                AzureAssert.AzureServiceExists(Path.Combine(files.RootPath, serviceName), Resources.GeneralScaffolding, serviceName, webRoles: webRoles, workerRoles: workerRoles, webScaff: Path.Combine(Resources.PHPScaffolding, Resources.WebRole), workerScaff: Path.Combine(Resources.PHPScaffolding, Resources.WorkerRole), roles: roles);
            }
        }