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 TestGetRuntimes() { using (FileSystemHelper files = new FileSystemHelper(this)) { string manifest = RuntimePackageHelper.GetTestManifest(files); CloudRuntimeCollection runtimes; CloudRuntimeCollection.CreateCloudRuntimeCollection(out runtimes, manifest); cmdlet.GetAzureRuntimesProcess(string.Empty, manifest); IEnumerable <CloudRuntimePackage> actual = System.Management.Automation.LanguagePrimitives.GetEnumerable(mockCommandRuntime.OutputPipeline).Cast <CloudRuntimePackage>(); Assert.Equal <int>(runtimes.Count, actual.Count()); Assert.True(runtimes.All <CloudRuntimePackage>(p => actual.Any <CloudRuntimePackage>(p2 => p2.PackageUri.Equals(p.PackageUri)))); } }
public void TestGetRuntimes() { using (FileSystemHelper files = new FileSystemHelper(this)) { string manifest = RuntimePackageHelper.GetTestManifest(files); CloudRuntimeCollection runtimes; CloudRuntimeCollection.CreateCloudRuntimeCollection(out runtimes, manifest); cmdlet.GetAzureRuntimesProcess(string.Empty, manifest); List <CloudRuntimePackage> actual = mockCommandRuntime.OutputPipeline[0] as List <CloudRuntimePackage>; Assert.AreEqual <int>(runtimes.Count, actual.Count); Assert.IsTrue(runtimes.All <CloudRuntimePackage>(p => actual.Any <CloudRuntimePackage>(p2 => p2.PackageUri.Equals(p.PackageUri)))); } }
public void TestResolveRuntimePackageUrls() { // 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 service that we're going to publish string serviceName = "TEST_SERVICE_NAME"; string rootPath = files.CreateNewService(serviceName); // Add web and worker roles string defaultWebRoleName = "WebRoleDefault"; addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = defaultWebRoleName, Instances = 2 }; addNodeWebCmdlet.ExecuteCmdlet(); string defaultWorkerRoleName = "WorkerRoleDefault"; addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = defaultWorkerRoleName, Instances = 2 }; addNodeWorkerCmdlet.ExecuteCmdlet(); AddAzureNodeWebRoleCommand matchWebRole = addNodeWebCmdlet; string matchWebRoleName = "WebRoleExactMatch"; addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = matchWebRoleName, Instances = 2 }; addNodeWebCmdlet.ExecuteCmdlet(); AddAzureNodeWorkerRoleCommand matchWorkerRole = addNodeWorkerCmdlet; string matchWorkerRoleName = "WorkerRoleExactMatch"; addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = matchWorkerRoleName, Instances = 2 }; addNodeWorkerCmdlet.ExecuteCmdlet(); AddAzureNodeWebRoleCommand overrideWebRole = addNodeWebCmdlet; string overrideWebRoleName = "WebRoleOverride"; addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = overrideWebRoleName, Instances = 2 }; addNodeWebCmdlet.ExecuteCmdlet(); AddAzureNodeWorkerRoleCommand overrideWorkerRole = addNodeWorkerCmdlet; string overrideWorkerRoleName = "WorkerRoleOverride"; addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = overrideWorkerRoleName, Instances = 2 }; addNodeWorkerCmdlet.ExecuteCmdlet(); string cacheWebRoleName = "cacheWebRole"; string cacheRuntimeVersion = "1.7.0"; AddAzureNodeWebRoleCommand addAzureWebRole = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = cacheWebRoleName }; addAzureWebRole.ExecuteCmdlet(); AzureService testService = new AzureService(rootPath, null); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, matchWebRoleName, testService.Paths, version: "0.8.2"); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, matchWorkerRoleName, testService.Paths, version: "0.8.2"); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, overrideWebRoleName, testService.Paths, overrideUrl: "http://OVERRIDE"); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, overrideWorkerRoleName, testService.Paths, overrideUrl: "http://OVERRIDE"); testService.AddRoleRuntime(testService.Paths, cacheWebRoleName, Resources.CacheRuntimeValue, cacheRuntimeVersion, RuntimePackageHelper.GetTestManifest(files)); testService.Components.Save(testService.Paths); // Get the publishing process started by creating the package testService.ResolveRuntimePackageUrls(RuntimePackageHelper.GetTestManifest(files)); AzureService updatedService = new AzureService(testService.Paths.RootPath, null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, defaultWebRoleName, "http://cdn/node/default.exe;http://cdn/iisnode/default.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, defaultWorkerRoleName, "http://cdn/node/default.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, matchWorkerRoleName, "http://cdn/node/foo.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, matchWebRoleName, "http://cdn/node/foo.exe;http://cdn/iisnode/default.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, overrideWebRoleName, null, "http://OVERRIDE"); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, overrideWorkerRoleName, null, "http://OVERRIDE"); RuntimePackageHelper.ValidateRoleRuntimeVariable(updatedService.Components.GetRoleStartup(cacheWebRoleName), Resources.CacheRuntimeVersionKey, cacheRuntimeVersion); } }
public void TestResolveRuntimePackageUrls() { // 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 service that we're going to publish string serviceName = "TEST_SERVICE_NAME"; string rootPath = files.CreateNewService(serviceName); // Add web and worker roles string defaultWebRoleName = "WebRoleDefault"; addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = defaultWebRoleName, Instances = 2 }; addNodeWebCmdlet.ExecuteCmdlet(); string defaultWorkerRoleName = "WorkerRoleDefault"; addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = defaultWorkerRoleName, Instances = 2 }; addNodeWorkerCmdlet.ExecuteCmdlet(); AddAzureNodeWebRoleCommand matchWebRole = addNodeWebCmdlet; string matchWebRoleName = "WebRoleExactMatch"; addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = matchWebRoleName, Instances = 2 }; addNodeWebCmdlet.ExecuteCmdlet(); AddAzureNodeWorkerRoleCommand matchWorkerRole = addNodeWorkerCmdlet; string matchWorkerRoleName = "WorkerRoleExactMatch"; addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = matchWorkerRoleName, Instances = 2 }; addNodeWorkerCmdlet.ExecuteCmdlet(); AddAzureNodeWebRoleCommand overrideWebRole = addNodeWebCmdlet; string overrideWebRoleName = "WebRoleOverride"; addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = overrideWebRoleName, Instances = 2 }; addNodeWebCmdlet.ExecuteCmdlet(); AddAzureNodeWorkerRoleCommand overrideWorkerRole = addNodeWorkerCmdlet; string overrideWorkerRoleName = "WorkerRoleOverride"; addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = overrideWorkerRoleName, Instances = 2 }; addNodeWorkerCmdlet.ExecuteCmdlet(); string webRole2Name = "WebRole2"; AddAzureNodeWebRoleCommand addAzureWebRole = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = webRole2Name }; addAzureWebRole.ExecuteCmdlet(); CloudServiceProject testService = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath(@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Services")); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, matchWebRoleName, testService.Paths, version: "0.8.2"); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, matchWorkerRoleName, testService.Paths, version: "0.8.2"); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, overrideWebRoleName, testService.Paths, overrideUrl: "http://OVERRIDE"); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, overrideWorkerRoleName, testService.Paths, overrideUrl: "http://OVERRIDE"); bool exceptionWasThrownOnSettingCacheRole = false; try { string cacheRuntimeVersion = "1.7.0"; testService.AddRoleRuntime(testService.Paths, webRole2Name, Resources.CacheRuntimeValue, cacheRuntimeVersion, RuntimePackageHelper.GetTestManifest(files)); } catch (NotSupportedException) { exceptionWasThrownOnSettingCacheRole = true; } Assert.True(exceptionWasThrownOnSettingCacheRole); testService.Components.Save(testService.Paths); // Get the publishing process started by creating the package testService.ResolveRuntimePackageUrls(RuntimePackageHelper.GetTestManifest(files)); CloudServiceProject updatedService = new CloudServiceProject(testService.Paths.RootPath, null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, defaultWebRoleName, "http://cdn/node/default.exe;http://cdn/iisnode/default.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, defaultWorkerRoleName, "http://cdn/node/default.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, matchWorkerRoleName, "http://cdn/node/foo.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, matchWebRoleName, "http://cdn/node/foo.exe;http://cdn/iisnode/default.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, overrideWebRoleName, null, "http://OVERRIDE"); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, overrideWorkerRoleName, null, "http://OVERRIDE"); } }
public void TestSetAzureRuntimeInvalidRuntimeVersion() { using (FileSystemHelper files = new FileSystemHelper(this)) { CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); string roleName = "WebRole1"; RoleSettings roleSettings1 = cmdlet.SetAzureRuntimesProcess(roleName, "node", "0.8.99", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); RoleSettings roleSettings2 = cmdlet.SetAzureRuntimesProcess(roleName, "iisnode", "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 TestSetAzureRuntimeValidRuntimeVersions() { using (FileSystemHelper files = new FileSystemHelper(this)) { CloudServiceProject service = new CloudServiceProject(files.RootPath, serviceName, null); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); string roleName = "WebRole1"; cmdlet.PassThru = false; RoleSettings roleSettings1 = cmdlet.SetAzureRuntimesProcess(roleName, "node", "0.8.2", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); RoleSettings roleSettings2 = cmdlet.SetAzureRuntimesProcess(roleName, "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); } }
public void TestSetAzureRuntimeInvalidRuntimeType() { using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Resources.NodeScaffolding); new SetAzureServiceProjectRoleCommand().SetAzureRuntimesProcess("WebRole1", "noide", "0.8.99", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); new SetAzureServiceProjectRoleCommand().SetAzureRuntimesProcess("WebRole1", "iisnoide", "0.9.99", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); VerifyInvalidPackageJsonVersion(service.Paths.RootPath, "WebRole1", "node", "*"); VerifyInvalidPackageJsonVersion(service.Paths.RootPath, "WebRole1", "iisnode", "*"); } }
public void PublishAzureServiceManifestTest() { // 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. SimpleServiceManagement channel = new SimpleServiceManagement(); // Create a new service that we're going to publish string serviceName = "TEST_SERVICE_NAME"; NewAzureServiceProjectCommand newService = new NewAzureServiceProjectCommand(); newService.NewAzureServiceProcess(files.RootPath, serviceName); string servicePath = files.CreateDirectory(serviceName); // Add web and worker roles AddAzureNodeWebRoleCommand newWebRole = new AddAzureNodeWebRoleCommand(); string defaultWebRoleName = "WebRoleDefault"; string defaultWebRolePath = newWebRole.AddAzureNodeWebRoleProcess(defaultWebRoleName, 2, servicePath); AddAzureNodeWorkerRoleCommand newWorkerRole = new AddAzureNodeWorkerRoleCommand(); string defaultWorkerRoleName = "WorkerRoleDefault"; string defaultWorkerRolePath = newWorkerRole.AddAzureNodeWorkerRoleProcess(defaultWorkerRoleName, 2, servicePath); AddAzureNodeWebRoleCommand matchWebRole = new AddAzureNodeWebRoleCommand(); string matchWebRoleName = "WebRoleExactMatch"; string matchWebRolePath = matchWebRole.AddAzureNodeWebRoleProcess(matchWebRoleName, 2, servicePath); AddAzureNodeWorkerRoleCommand matchWorkerRole = new AddAzureNodeWorkerRoleCommand(); string matchWorkerRoleName = "WorkerRoleExactMatch"; string matchWorkerRolePath = matchWorkerRole.AddAzureNodeWorkerRoleProcess(matchWorkerRoleName, 2, servicePath); AddAzureNodeWebRoleCommand overrideWebRole = new AddAzureNodeWebRoleCommand(); string overrideWebRoleName = "WebRoleOverride"; string overrideWebRolePath = overrideWebRole.AddAzureNodeWebRoleProcess(overrideWebRoleName, 2, servicePath); AddAzureNodeWorkerRoleCommand overrideWorkerRole = new AddAzureNodeWorkerRoleCommand(); string overrideWorkerRoleName = "WorkerRoleOverride"; string overrideWorkerRolePath = matchWorkerRole.AddAzureNodeWorkerRoleProcess(overrideWorkerRoleName, 2, servicePath); AzureService testService = new AzureService(Path.Combine(files.RootPath, serviceName), null); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, matchWebRoleName, testService.Paths, version: "0.8.2"); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, matchWorkerRoleName, testService.Paths, version: "0.8.2"); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, overrideWebRoleName, testService.Paths, overrideUrl: "http://OVERRIDE"); RuntimePackageHelper.SetRoleRuntime(testService.Components.Definition, overrideWorkerRoleName, testService.Paths, overrideUrl: "http://OVERRIDE"); testService.Components.Save(testService.Paths); // Get the publishing process started by creating the package PublishAzureServiceProjectCommand publishService = new PublishAzureServiceProjectCommand(channel); publishService.InitializeSettingsAndCreatePackage(servicePath, RuntimePackageHelper.GetTestManifest(files)); AzureService updatedService = new AzureService(testService.Paths.RootPath, null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, defaultWebRoleName, "http://DATACENTER/node/default.exe;http://DATACENTER/iisnode/default.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, defaultWorkerRoleName, "http://DATACENTER/node/default.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, matchWorkerRoleName, "http://DATACENTER/node/foo.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, matchWebRoleName, "http://DATACENTER/node/foo.exe;http://DATACENTER/iisnode/default.exe", null); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, overrideWebRoleName, null, "http://OVERRIDE"); RuntimePackageHelper.ValidateRoleRuntime(updatedService.Components.Definition, overrideWorkerRoleName, null, "http://OVERRIDE"); } }