public AddWebRole ( string scaffolding, string name = null, int instanceCount = 1 ) : |
||
scaffolding | string | |
name | string | |
instanceCount | int | |
return |
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(Resources.NodeScaffolding); service.AddWebRole(Resources.PHPScaffolding); service = new AzureServiceWrapper(service.Paths.RootPath, null); int nextPort = service.Components.GetNextPort(); Assert.AreEqual<int>(expectedPort, nextPort); } }
public void CreateLocalPackageWithMultipleRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { string standardOutput; string standardError; AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWorkerRole(Resources.NodeScaffolding); service.AddWebRole(Resources.NodeScaffolding); service.AddWorkerRole(Resources.PHPScaffolding); service.AddWebRole(Resources.PHPScaffolding); service.CreatePackage(DevEnv.Local, out standardOutput, out standardError); AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole)); AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WebRole)); AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole2\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WorkerRole)); AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole2\approot"), Path.Combine(Resources.PHPScaffolding, Resources.WebRole)); } }
public void TestGetRuntimes() { using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Resources.NodeScaffolding); string manifest = RuntimePackageHelper.GetTestManifest(files); CloudRuntimeCollection collection = service.GetCloudRuntimes(service.Paths, manifest); RuntimePackageHelper.ValidateRuntimesMatchManifest(manifest, collection); } }
public void TestSetAzureRuntimeInvalidRuntimeVersion() { using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Resources.NodeScaffolding); new SetAzureServiceProjectRoleCommand().SetAzureRuntimesProcess("WebRole1", "node", "0.8.99", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); new SetAzureServiceProjectRoleCommand().SetAzureRuntimesProcess("WebRole1", "iisnode", "0.9.99", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); VerifyInvalidPackageJsonVersion(service.Paths.RootPath, "WebRole1", "node", "*"); VerifyInvalidPackageJsonVersion(service.Paths.RootPath, "WebRole1", "iisnode", "*"); } }
public void SetAzureInstancesProcessTestsNode() { int newRoleInstances = 10; using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Resources.NodeScaffolding); new SetAzureServiceProjectRoleCommand().SetAzureInstancesProcess("WebRole1", newRoleInstances, service.Paths.RootPath); service = new AzureService(service.Paths.RootPath, null); Assert.AreEqual<int>(newRoleInstances, service.Components.CloudConfig.Role[0].Instances.count); Assert.AreEqual<int>(newRoleInstances, service.Components.LocalConfig.Role[0].Instances.count); } }
public void SetAzureVMSizeProcessTestsCaseInsensitiveVMSizeSize() { string newRoleVMSize = "ExTraLaRge"; using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); string roleName = "WebRole1"; service.AddWebRole(Data.NodeWebRoleScaffoldingPath); cmdlet.PassThru = false; RoleSettings roleSettings = cmdlet.SetAzureVMSizeProcess("WebRole1", newRoleVMSize, service.Paths.RootPath); service = new AzureService(service.Paths.RootPath, null); Assert.AreEqual<string>(newRoleVMSize.ToLower(), service.Components.Definition.WebRole[0].vmsize.ToString().ToLower()); Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count); Assert.AreEqual<string>(roleName, roleSettings.name); } }
public void TestSetAzureRuntimeInvalidRuntimeType() { using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); string roleName = "WebRole1"; service.AddWebRole(Data.NodeWebRoleScaffoldingPath); RoleSettings roleSettings1 = cmdlet.SetAzureRuntimesProcess(roleName, "noide", "0.8.99", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); RoleSettings roleSettings2 = cmdlet.SetAzureRuntimesProcess(roleName, "iisnoide", "0.9.99", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); VerifyInvalidPackageJsonVersion(service.Paths.RootPath, roleName, "node", "*"); VerifyInvalidPackageJsonVersion(service.Paths.RootPath, roleName, "iisnode", "*"); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).Members[Parameters.RoleName].Value.ToString()); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[1]).Members[Parameters.RoleName].Value.ToString()); Assert.IsTrue(((PSObject)mockCommandRuntime.OutputPipeline[0]).TypeNames.Contains(typeof(RoleSettings).FullName)); Assert.IsTrue(((PSObject)mockCommandRuntime.OutputPipeline[1]).TypeNames.Contains(typeof(RoleSettings).FullName)); Assert.AreEqual<string>(roleName, roleSettings1.name); Assert.AreEqual<string>(roleName, roleSettings2.name); } }
public void SetAzureInstancesProcessTestsCaseInsensitive() { int newRoleInstances = 10; using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); string roleName = "WebRole1"; service.AddWebRole(Data.NodeWebRoleScaffoldingPath); cmdlet.PassThru = false; RoleSettings roleSettings = cmdlet.SetAzureInstancesProcess("WeBrolE1", newRoleInstances, service.Paths.RootPath); service = new AzureService(service.Paths.RootPath, null); Assert.AreEqual<int>(newRoleInstances, service.Components.CloudConfig.Role[0].Instances.count); Assert.AreEqual<int>(newRoleInstances, service.Components.LocalConfig.Role[0].Instances.count); Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count); Assert.AreEqual<int>(newRoleInstances, roleSettings.Instances.count); Assert.AreEqual<string>(roleName, roleSettings.name); } }
public void SetAzureServiceProjectRoleWithoutPassingRoleName() { string originalDirectory = Directory.GetCurrentDirectory(); string serviceName = "AzureService1"; AzureService service = new AzureService(Directory.GetCurrentDirectory(), serviceName, null); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); Directory.SetCurrentDirectory(Path.Combine(service.Paths.RootPath, "WebRole1")); cmdlet.RoleName = string.Empty; cmdlet.ExecuteCmdlet(); service = new AzureService(service.Paths.RootPath, null); Assert.AreEqual<string>("WebRole1", cmdlet.RoleName); Directory.SetCurrentDirectory(originalDirectory); }
public void AzureServiceAddExistingPHPRoleFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Resources.PHPScaffolding, "WebRole"); Testing.AssertThrows<ArgumentException>(() => service.AddWebRole(Resources.PHPScaffolding, "WebRole"), string.Format(Resources.AddRoleMessageRoleExists, "WebRole")); } }
public void SetAzureInstancesProcessTestsPHPRoleNameDoesNotExistServiceContainsWebRoleFail() { string roleName = "WebRole1"; string invalidRoleName = "foo"; using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Data.PHPWebRoleScaffoldingPath, roleName, 1); Testing.AssertThrows<ArgumentException>(() => service.SetRoleInstances(service.Paths, invalidRoleName, 10), string.Format(Resources.RoleNotFoundMessage, invalidRoleName)); } }
public void SetAzureServiceProjectRoleInServiecRootDirectoryFail() { string serviceName = "AzureService3"; AzureService service = new AzureService(Directory.GetCurrentDirectory(), serviceName, null); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); cmdlet.RoleName = string.Empty; Testing.AssertThrows<InvalidOperationException>(() => cmdlet.ExecuteCmdlet(), Resources.CannotFindServiceRoot); }
public void CreateLocalPackageWithOneNodeWebRoleTest() { using (FileSystemHelper files = new FileSystemHelper(this)) { string standardOutput; string standardError; AzureService service = new AzureService(files.RootPath, serviceName, null); RoleInfo webRoleInfo = service.AddWebRole(Resources.NodeScaffolding); string logsDir = Path.Combine(service.Paths.RootPath, webRoleInfo.Name, "server.js.logs"); string logFile = Path.Combine(logsDir, "0.txt"); string targetLogsFile = Path.Combine(service.Paths.LocalPackage, "roles", webRoleInfo.Name, @"approot\server.js.logs\0.txt"); files.CreateDirectory(logsDir); files.CreateEmptyFile(logFile); service.CreatePackage(DevEnv.Local, out standardOutput, out standardError); AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WebRole)); Assert.IsTrue(File.Exists(targetLogsFile)); } }
public void SetAzureInstancesProcessTestsPHP() { int newRoleInstances = 10; using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); string roleName = "WebRole1"; service.AddWebRole(Data.PHPWebRoleScaffoldingPath); RoleSettings roleSettings = cmdlet.SetAzureInstancesProcess("WebRole1", newRoleInstances, service.Paths.RootPath); service = new AzureService(service.Paths.RootPath, null); Assert.AreEqual<int>(newRoleInstances, service.Components.CloudConfig.Role[0].Instances.count); Assert.AreEqual<int>(newRoleInstances, service.Components.LocalConfig.Role[0].Instances.count); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).Members[Parameters.RoleName].Value.ToString()); Assert.IsTrue(((PSObject)mockCommandRuntime.OutputPipeline[0]).TypeNames.Contains(typeof(RoleSettings).FullName)); Assert.AreEqual<int>(newRoleInstances, roleSettings.Instances.count); Assert.AreEqual<string>(roleName, roleSettings.name); } }
public override void ExecuteCmdlet() { RootPath = RootPath ?? General.GetServiceRootPath(CurrentPath()); AzureService service = new AzureService(RootPath, null); RoleInfo roleInfo = null; if (isWebRole) { roleInfo = service.AddWebRole(Scaffolding, Name, Instances); } else { roleInfo = service.AddWorkerRole(Scaffolding, Name, Instances); } OnProcessing(roleInfo); try { service.ChangeRolePermissions(roleInfo); SafeWriteOutputPSObject(typeof(RoleSettings).FullName, Parameters.RoleName, roleInfo.Name); WriteVerbose(string.Format(successMessage, RootPath, roleInfo.Name)); } catch (UnauthorizedAccessException) { WriteWarning(Resources.AddRoleMessageInsufficientPermissions); } }
public void SetPHPRoleInstancesTest() { int newInstances = 10; using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Resources.PHPScaffolding, "WebRole", 1); service.SetRoleInstances(service.Paths, "WebRole", newInstances); Assert.AreEqual<int>(service.Components.CloudConfig.Role[0].Instances.count, newInstances); Assert.AreEqual<int>(service.Components.LocalConfig.Role[0].Instances.count, newInstances); } }
public void SetAzureVMSizeProcessTestsPHP() { string newRoleVMSize = RoleSize.Medium.ToString(); using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); string roleName = "WebRole1"; service.AddWebRole(Data.PHPWebRoleScaffoldingPath); RoleSettings roleSettings = cmdlet.SetAzureVMSizeProcess("WebRole1", newRoleVMSize, service.Paths.RootPath); service = new AzureService(service.Paths.RootPath, null); Assert.AreEqual<string>(newRoleVMSize, service.Components.Definition.WebRole[0].vmsize.ToString()); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).Members[Parameters.RoleName].Value.ToString()); Assert.IsTrue(((PSObject)mockCommandRuntime.OutputPipeline[0]).TypeNames.Contains(typeof(RoleSettings).FullName)); Assert.AreEqual<string>(roleName, roleSettings.name); } }
public void GetNextPortNullNodeWebEndpointAndNullWorkerRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { int expectedPort = int.Parse(Resources.DefaultWebPort); AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Resources.NodeScaffolding); service = new AzureService(service.Paths.RootPath, null); service.Components.Definition.WebRole.ToList().ForEach(wr => wr.Endpoints = null); int nextPort = service.Components.GetNextPort(); Assert.AreEqual<int>(expectedPort, nextPort); } }
public void AzureServiceAddNewPHPWebRoleTest() { using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); RoleInfo webRole = service.AddWebRole(Resources.PHPScaffolding, "MyWebRole", 10); AzureAssert.AzureServiceExists(Path.Combine(files.RootPath, serviceName), Resources.GeneralScaffolding, serviceName, webRoles: new WebRoleInfo[] { (WebRoleInfo)webRole }, webScaff: Path.Combine(Resources.PHPScaffolding, Resources.WebRole), roles: new RoleInfo[] { webRole }); } }
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(Resources.NodeScaffolding); service.Components.Definition.WebRole[0].Endpoints.InputEndpoint = null; service.Components.Save(service.Paths); service.AddWebRole(Resources.PHPScaffolding); service = new AzureServiceWrapper(service.Paths.RootPath, null); int nextPort = service.Components.GetNextPort(); Assert.AreEqual<int>(expectedPort, nextPort); } }
public void TestSetAzureRuntimeValidRuntimeVersionsCanInsensitive() { using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); string roleName = "WebRole1"; string caseInsensitiveName = "weBrolE1"; cmdlet.PassThru = false; RoleSettings roleSettings1 = cmdlet.SetAzureRuntimesProcess(caseInsensitiveName, "node", "0.8.2", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); RoleSettings roleSettings2 = cmdlet.SetAzureRuntimesProcess(caseInsensitiveName, "iisnode", "0.1.21", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); VerifyPackageJsonVersion(service.Paths.RootPath, roleName, "node", "0.8.2"); VerifyPackageJsonVersion(service.Paths.RootPath, roleName, "iisnode", "0.1.21"); Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count); Assert.AreEqual<string>(roleName, roleSettings1.name); Assert.AreEqual<string>(roleName, roleSettings2.name); } }