public void AddAzureWebRoleWillRecreateDeploymentSettings() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName); string settingsFilePath = Path.Combine(rootPath, Resources.SettingsFileName); string originalDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(rootPath); File.Delete(settingsFilePath); Assert.IsFalse(File.Exists(settingsFilePath)); addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName }; addWebCmdlet.ExecuteCmdlet(); AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, "AzureService", roleName), Path.Combine(Resources.GeneralScaffolding, Resources.WebRole)); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName)); Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]); Assert.IsTrue(File.Exists(settingsFilePath)); Directory.SetCurrentDirectory(originalDirectory); } }
public void DisableRemoteDesktopForEmptyService() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); disableRDCmdlet.DisableRemoteDesktop(); } }
public void DisableRemoteDesktopForWebRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string root = files.CreateNewService("NEW_SERVICE"); new AddAzureNodeWebRoleCommand().AddAzureNodeWebRoleProcess("WebRole", 1, root); new DisableAzureServiceProjectRemoteDesktopCommand().DisableRemoteDesktop(); } }
public void EnableAzureMemcacheRoleProcessOnCacheWorkerRoleFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string cacheRoleName = "WorkerRole"; string expected = string.Format(Resources.InvalidCacheRoleName, cacheRoleName); addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath); Testing.AssertThrows <Exception>(() => enableCacheCmdlet.EnableAzureMemcacheRoleProcess(cacheRoleName, cacheRoleName, rootPath)); } }
public void AddAzurePythonWebRoleProcess() { var pyInstall = AddAzureDjangoWebRoleCommand.FindPythonInterpreterPath(); if (pyInstall == null) { Assert.Inconclusive("Python is not installed on this machine and therefore the Python tests cannot be run"); return; } string stdOut, stdErr; ProcessHelper.StartAndWaitForProcess( new ProcessStartInfo( Path.Combine(pyInstall, "python.exe"), string.Format("-m django.bin.django-admin") ), out stdOut, out stdErr ); if (stdOut.IndexOf("django-admin.py") == -1) { Assert.Inconclusive("Django is not installed on this machine and therefore the Python tests cannot be run. Please 'pip install Django==1.5'"); return; } using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); addPythonWebCmdlet = new AddAzureDjangoWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime }; addPythonWebCmdlet.CommandRuntime = mockCommandRuntime; string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreatePython, rootPath, roleName); mockCommandRuntime.ResetPipelines(); addPythonWebCmdlet.ExecuteCmdlet(); AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.PythonScaffolding, Resources.WebRole)); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName)); Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]); Assert.IsTrue(Directory.Exists(Path.Combine(rootPath, roleName, roleName))); Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, "manage.py"))); Assert.IsTrue(Directory.Exists(Path.Combine(rootPath, roleName, roleName, roleName))); Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "__init__.py"))); Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "settings.py"))); Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "urls.py"))); Assert.IsTrue(File.Exists(Path.Combine(rootPath, roleName, roleName, roleName, "wsgi.py"))); } }
public void AddAzureWorkerRoleWithMissingScaffoldXmlFail() { string scaffoldingPath = "TemplateMissingScaffoldXml"; Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, scaffoldingPath)); using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WorkerRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); addWorkerCmdlet = new AddAzureWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath }; Testing.AssertThrows<FileNotFoundException>(() => addWorkerCmdlet.ExecuteCmdlet()); } }
public void TestCreatePackageWithEmptyServiceSuccessfull() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); string rootPath = Path.Combine(files.RootPath, "NEW_SERVICE"); string packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName); cmdlet.ExecuteCmdlet(); PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject; Assert.Equal <string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]); Assert.Equal <string>(packagePath, obj.GetVariableValue <string>(Parameters.PackagePath)); Assert.True(File.Exists(packagePath)); } }
public void TestCreatePackageWithEmptyServiceSuccessfull() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); string rootPath = Path.Combine(files.RootPath, "NEW_SERVICE"); string packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName); cmdlet.ExecuteCmdlet(); PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject; Assert.AreEqual<string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]); Assert.AreEqual<string>(packagePath, obj.GetVariableValue<string>(Parameters.PackagePath)); Assert.IsTrue(File.Exists(packagePath)); } }
public void EnableRemoteDesktopUnicodeAndShortPasswordFails() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); Testing.AssertThrows <ArgumentException>(() => EnableRemoteDesktop("㯑䲘䄂㮉", "㯑䲘")); } }
public void DisableRemoteDesktopForWebRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); disableRDCmdlet.PassThru = true; disableRDCmdlet.DisableRemoteDesktop(); Assert.True((bool)mockCommandRuntime.OutputPipeline[1]); } }
public void EnableRemoteDesktopForMultipleWebAndWorkerRolesTwice() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole_1", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole_2", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole_1", Instances = 1 }; addNodeWorkerCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole_2", Instances = 1 }; addNodeWorkerCmdlet.ExecuteCmdlet(); mockCommandRuntime.ResetPipelines(); enableRDCmdlet.PassThru = true; EnableRemoteDesktop("user", "GoodPassword!"); enableRDCmdlet.PassThru = false; EnableRemoteDesktop("other", "OtherPassword!"); // Verify the roles have been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); VerifyWebRole(service.Components.Definition.WebRole[0], false); VerifyWebRole(service.Components.Definition.WebRole[0], false); VerifyWorkerRole(service.Components.Definition.WorkerRole[0], true); VerifyWorkerRole(service.Components.Definition.WorkerRole[1], false); VerifyRoleSettings(service); Assert.Equal <int>(1, mockCommandRuntime.OutputPipeline.Count); Assert.True((bool)mockCommandRuntime.OutputPipeline[0]); } }
public void AddAzureNodeWebRoleProcess() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime }; string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreateNode, rootPath, roleName); addNodeWebCmdlet.ExecuteCmdlet(); AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.NodeScaffolding, Resources.WebRole)); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName)); Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]); } }
public void AddAzureWorkerRoleProcess() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WorkerRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName); TestMockSupport.TestExecutionFolder = rootPath; addWorkerCmdlet = new AddAzureWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName }; addWorkerCmdlet.ExecuteCmdlet(); AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.GeneralScaffolding, Resources.WorkerRole)); Assert.Equal<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName)); Assert.Equal<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]); } }
public void AddAzureWebRoleWithMissingScaffoldXmlFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName); string originalDirectory = Directory.GetCurrentDirectory(); string scaffoldingPath = "TemplateMissingScaffoldXml"; addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath }; Testing.AssertThrows <FileNotFoundException>(() => addWebCmdlet.ExecuteCmdlet()); } }
public void EnableAzureMemcacheRoleProcessCacheRoleDoesNotExistFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string cacheRoleName = "WorkerRole"; string webRoleName = "WebRole"; string expected = string.Format(Resources.RoleNotFoundMessage, cacheRoleName); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = webRoleName }; addNodeWebCmdlet.ExecuteCmdlet(); Testing.AssertThrows <Exception>(() => enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, cacheRoleName, rootPath)); } }
public void DisableRemoteDesktopForWebAndWorkerRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole" }; addNodeWorkerCmdlet.ExecuteCmdlet(); disableRDCmdlet.DisableRemoteDesktop(); } }
public void TestCreatePackageSuccessfull() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); string rootPath = Path.Combine(files.RootPath, "NEW_SERVICE"); string packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName); CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath(@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Services")); service.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath); cmdlet.ExecuteCmdlet(); PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject; Assert.Equal <string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]); Assert.Equal <string>(packagePath, obj.GetVariableValue <string>(Parameters.PackagePath)); Assert.True(File.Exists(packagePath)); } }
public void EnableRemoteDesktopForWebRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); EnableRemoteDesktop("user", "GoodPassword!"); // Verify the role has been setup with forwarding, access, // and certs AzureService service = new AzureService(rootPath, null); VerifyWebRole(service.Components.Definition.WebRole[0], true); VerifyRoleSettings(service); } }
public void EnableDisableRemoteDesktopForWebRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); EnableAzureRemoteDesktopCommandTest.EnableRemoteDesktop("user", "GoodPassword!"); disableRDCmdlet.DisableRemoteDesktop(); // Verify the role has been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath(@"..\..\..\..\..\Package\Debug\ServiceManagement\Azure\Services")); EnableAzureRemoteDesktopCommandTest.VerifyWebRole(service.Components.Definition.WebRole[0], true); VerifyDisableRoleSettings(service); } }
public void EnableAzureMemcacheRoleProcess() { using (FileSystemHelper files = new FileSystemHelper(this)) { string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string cacheRoleName = "WorkerRole"; string webRoleName = "WebRole"; string expectedMessage = string.Format(Resources.EnableMemcacheMessage, webRoleName, cacheRoleName, Resources.MemcacheEndpointPort); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = webRoleName }; addNodeWebCmdlet.ExecuteCmdlet(); addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath); mockCommandRuntime.ResetPipelines(); enableCacheCmdlet.PassThru = true; enableCacheCmdlet.CacheRuntimeVersion = "2.3.0"; enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, cacheRoleName, rootPath); AssertCachingEnabled(files, serviceName, rootPath, webRoleName, expectedMessage); } }
public void TestPublishWithDefaultLocation() { RemoveDeployments(); clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny <HostedServiceCreateParameters>(), It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); clientMocks.ManagementClientMock.Setup(c => c.Locations.ListAsync(It.IsAny <CancellationToken>())) .Returns(Tasks.FromResult(new LocationsListResponse { Locations = { new LocationsListResponse.Location { DisplayName = "East US", Name = "EastUS" } } })); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); cloudServiceProject.AddWebRole(Test.Utilities.Common.Data.NodeWebRoleScaffoldingPath); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService()); clientMocks.ManagementClientMock.Verify(c => c.Locations.ListAsync(It.IsAny <CancellationToken>()), Times.Once); } }
public void AddAzureWebRoleWithMissingScaffoldXmlFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string scaffoldingPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TemplateMissingScaffoldXml"); if (Directory.Exists(scaffoldingPath)) { Directory.Delete(scaffoldingPath, true); } string rootPath = files.CreateNewService(serviceName); string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName); string originalDirectory = Directory.GetCurrentDirectory(); addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath }; Assert.Throws <DirectoryNotFoundException>(() => addWebCmdlet.ExecuteCmdlet()); } }
public void EnableRemoteDesktopUnicode() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); EnableRemoteDesktop("㯑䲘䄂㮉", "㯑䲘䄂㮉㮉㮉㮉L"); // Verify the role has been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); VerifyWebRole(service.Components.Definition.WebRole[0], true); VerifyRoleSettings(service); } }
public void TestCreatePackageWithMultipleRolesSuccessfull() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); string rootPath = Path.Combine(files.RootPath, "NEW_SERVICE"); string packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName); CloudServiceProject service = new CloudServiceProject(rootPath, null); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath); service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); cmdlet.ExecuteCmdlet(); PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject; Assert.AreEqual <string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]); Assert.AreEqual <string>(packagePath, obj.GetVariableValue <string>(Parameters.PackagePath)); Assert.IsTrue(File.Exists(packagePath)); } }
public void TestPublishWithCurrentStorageAccount() { using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService cloudServiceProject = new AzureService(rootPath, null); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); subscription.CurrentStorageAccount = storageName; ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); cloudBlobUtilityMock.Verify(f => f.UploadPackageToBlob( serviceManagementChannelMock.Object, subscription.CurrentStorageAccount, subscription.SubscriptionId, It.IsAny <string>(), It.IsAny <BlobRequestOptions>()), Times.Once()); } }
public void AddAzureWebRoleProcess() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName); string originalDirectory = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(rootPath); addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName }; addWebCmdlet.ExecuteCmdlet(); AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, "AzureService", roleName), Path.Combine(Resources.GeneralScaffolding, Resources.WebRole)); Assert.Equal <string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue <string>(Parameters.RoleName)); Assert.Equal <string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]); Directory.SetCurrentDirectory(originalDirectory); } }
public void AddAzurePHPWebRoleWillRecreateDeploymentSettings() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); addPHPWebCmdlet = new AddAzurePHPWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime }; string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreatePHP, rootPath, roleName); string settingsFilePath = Path.Combine(rootPath, Resources.SettingsFileName); File.Delete(settingsFilePath); Assert.False(File.Exists(settingsFilePath)); addPHPWebCmdlet.ExecuteCmdlet(); AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), Path.Combine(Resources.PHPScaffolding, Resources.WebRole)); Assert.Equal <string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue <string>(Parameters.RoleName)); Assert.Equal <string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]); Assert.True(File.Exists(settingsFilePath)); } }
public void EnableAzureMemcacheRoleProcess() { using (FileSystemHelper files = new FileSystemHelper(this)) { string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string cacheRoleName = "WorkerRole"; string webRoleName = "WebRole"; string expectedMessage = string.Format(Resources.EnableMemcacheMessage, webRoleName, cacheRoleName, Resources.MemcacheEndpointPort); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = webRoleName }; addNodeWebCmdlet.ExecuteCmdlet(); addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath); mockCommandRuntime.ResetPipelines(); enableCacheCmdlet.PassThru = true; enableCacheCmdlet.CacheRuntimeVersion = "2.0.0"; enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, cacheRoleName, rootPath); AssertCachingEnabled(files, serviceName, rootPath, webRoleName, expectedMessage); } }
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(); CloudServiceProject testService = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("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"); 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)); 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"); RuntimePackageHelper.ValidateRoleRuntimeVariable(updatedService.Components.GetRoleStartup(cacheWebRoleName), Resources.CacheRuntimeVersionKey, cacheRuntimeVersion); } }
public void EnableAzureMemcacheWithNoCacheWorkerRolesFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string webRoleName = "WebRole"; string expectedMessage = string.Format(Resources.NoCacheWorkerRoles); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = webRoleName }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole" }; addNodeWorkerCmdlet.ExecuteCmdlet(); mockCommandRuntime.ResetPipelines(); enableCacheCmdlet.PassThru = true; enableCacheCmdlet.CacheRuntimeVersion = "2.3.0"; Testing.AssertThrows<Exception>(() => enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, null, rootPath), expectedMessage); } }
public void EnableAzureMemcacheRoleProcessOnWorkerRoleSuccess() { using (FileSystemHelper files = new FileSystemHelper(this)) { string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string cacheRoleName = "CacheWorkerRole"; string workerRoleName = "WorkerRole"; string expectedMessage = string.Format(Resources.EnableMemcacheMessage, workerRoleName, cacheRoleName, Resources.MemcacheEndpointPort); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = workerRoleName }; addNodeWorkerCmdlet.ExecuteCmdlet(); addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath); mockCommandRuntime.ResetPipelines(); enableCacheCmdlet.PassThru = true; enableCacheCmdlet.EnableAzureMemcacheRoleProcess(workerRoleName, cacheRoleName, rootPath); WorkerRole workerRole = Testing.GetWorkerRole(rootPath, workerRoleName); AzureAssert.RuntimeUrlAndIdExists(workerRole.Startup.Task, Resources.CacheRuntimeValue); AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, serviceName, workerRoleName), Path.Combine(Resources.CacheScaffolding, Resources.WorkerRole)); AzureAssert.StartupTaskExists(workerRole.Startup.Task, Resources.CacheStartupCommand); AzureAssert.InternalEndpointExists(workerRole.Endpoints.InternalEndpoint, new InternalEndpoint { name = Resources.MemcacheEndpointName, protocol = InternalProtocol.tcp, port = Resources.MemcacheEndpointPort }); LocalStore localStore = new LocalStore { name = Resources.CacheDiagnosticStoreName, cleanOnRoleRecycle = false }; AzureAssert.LocalResourcesLocalStoreExists(localStore, workerRole.LocalResources); DefinitionConfigurationSetting diagnosticLevel = new DefinitionConfigurationSetting { name = Resources.CacheClientDiagnosticLevelAssemblyName }; AzureAssert.ConfigurationSettingExist(diagnosticLevel, workerRole.ConfigurationSettings); ConfigConfigurationSetting clientDiagnosticLevel = new ConfigConfigurationSetting { name = Resources.ClientDiagnosticLevelName, value = Resources.ClientDiagnosticLevelValue }; AzureAssert.ConfigurationSettingExist(clientDiagnosticLevel, Testing.GetCloudRole(rootPath, workerRoleName).ConfigurationSettings); AzureAssert.ConfigurationSettingExist(clientDiagnosticLevel, Testing.GetLocalRole(rootPath, workerRoleName).ConfigurationSettings); string workerConfigPath = string.Format(@"{0}\{1}\{2}", rootPath, workerRoleName, "web.config"); string workerCloudConfig = File.ReadAllText(workerConfigPath); Assert.IsTrue(workerCloudConfig.Contains("configSections")); Assert.IsTrue(workerCloudConfig.Contains("dataCacheClients")); Assert.AreEqual<string>(expectedMessage, mockCommandRuntime.VerboseStream[0]); Assert.AreEqual<string>(workerRoleName, (mockCommandRuntime.OutputPipeline[0] as PSObject).GetVariableValue<string>(Parameters.RoleName)); } }
public void EnableRemoteDesktopForWebRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string root = files.CreateNewService("NEW_SERVICE"); new AddAzureNodeWebRoleCommand().AddAzureNodeWebRoleProcess("WebRole", 1, root); EnableRemoteDesktop("user", "GoodPassword!"); // Verify the role has been setup with forwarding, access, // and certs AzureService service = new AzureService(root, null); VerifyWebRole(service.Components.Definition.WebRole[0], true); VerifyRoleSettings(service); } }
public void TestCreatePackageWithMultipleRolesSuccessfull() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); string rootPath = Path.Combine(files.RootPath, "NEW_SERVICE"); string packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName); CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath); service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); cmdlet.ExecuteCmdlet(); PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject; Assert.AreEqual<string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]); Assert.AreEqual<string>(packagePath, obj.GetVariableValue<string>(Parameters.PackagePath)); Assert.IsTrue(File.Exists(packagePath)); } }
public void AddAzureWebRoleWithTemplateFolder() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName); string originalDirectory = Directory.GetCurrentDirectory(); string scaffoldingPath = "MyWebTemplateFolder"; Directory.SetCurrentDirectory(rootPath); addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath }; addWebCmdlet.ExecuteCmdlet(); AzureAssert.ScaffoldingExists(Path.Combine(rootPath, roleName), scaffoldingPath); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).GetVariableValue<string>(Parameters.RoleName)); Assert.AreEqual<string>(expectedVerboseMessage, mockCommandRuntime.VerboseStream[0]); Directory.SetCurrentDirectory(originalDirectory); } }
public void AddAzureWebRoleWithMissingScaffoldXmlFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WebRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string expectedVerboseMessage = string.Format(Resources.AddRoleMessageCreate, rootPath, roleName); string originalDirectory = Directory.GetCurrentDirectory(); string scaffoldingPath = "TemplateMissingScaffoldXml"; addWebCmdlet = new AddAzureWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath }; Testing.AssertThrows<FileNotFoundException>(() => addWebCmdlet.ExecuteCmdlet()); } }
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 TestPublishWithCurrentStorageAccount() { RemoveDeployments(); clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); subscription.CurrentStorageAccountName = storageName; ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); cloudBlobUtilityMock.Verify(f => f.UploadPackageToBlob( clientMocks.StorageManagementClientMock.Object, subscription.CurrentStorageAccountName, It.IsAny<string>(), It.IsAny<BlobRequestOptions>()), Times.Once()); } }
public void ThrowsErrorForInvalidCacheVersion() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); string rootPath = Path.Combine(files.RootPath, "NEW_SERVICE"); string packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName); string cacheRoleName = "WorkerRole1"; AddAzureCacheWorkerRoleCommand addCacheWorkerCmdlet = new AddAzureCacheWorkerRoleCommand() { CommandRuntime = mockCommandRuntime }; EnableAzureMemcacheRoleCommand enableCacheCmdlet = new EnableAzureMemcacheRoleCommand() { CacheRuntimeVersion = "1.8.0", CommandRuntime = mockCommandRuntime }; CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); addCacheWorkerCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath); enableCacheCmdlet.EnableAzureMemcacheRoleProcess("WebRole1", cacheRoleName, rootPath); Testing.AssertThrows<Exception>( () => cmdlet.ExecuteCmdlet(), string.Format(Resources.CacheMismatchMessage, "WebRole1", "2.4.0")); } }
public void TestPublishWithDefaultLocation() { RemoveDeployments(); clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); clientMocks.ManagementClientMock.Setup(c => c.Locations.ListAsync(It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new LocationsListResponse { Locations = { new LocationsListResponse.Location {DisplayName = "East US", Name = "EastUS"} } })); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService()); clientMocks.ManagementClientMock.Verify(c => c.Locations.ListAsync(It.IsAny<CancellationToken>()), Times.Once); } }
public void EnableRemoteDesktopForMultipleWebAndWorkerRolesTwice() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole_1", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole_2", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole_1", Instances = 1 }; addNodeWorkerCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole_2", Instances = 1 }; addNodeWorkerCmdlet.ExecuteCmdlet(); mockCommandRuntime.ResetPipelines(); enableRDCmdlet.PassThru = true; EnableRemoteDesktop("user", "GoodPassword!"); enableRDCmdlet.PassThru = false; EnableRemoteDesktop("other", "OtherPassword!"); // Verify the roles have been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); VerifyWebRole(service.Components.Definition.WebRole[0], false); VerifyWebRole(service.Components.Definition.WebRole[0], false); VerifyWorkerRole(service.Components.Definition.WorkerRole[0], true); VerifyWorkerRole(service.Components.Definition.WorkerRole[1], false); VerifyRoleSettings(service); Assert.AreEqual<int>(1, mockCommandRuntime.OutputPipeline.Count); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]); } }
public void DisableRemoteDesktopForWebAndWorkerRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole" }; addNodeWorkerCmdlet.ExecuteCmdlet(); disableRDCmdlet.DisableRemoteDesktop(); } }
public void EnableAzureMemcacheRoleProcessOnCacheWorkerRoleFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string cacheRoleName = "WorkerRole"; string expected = string.Format(Resources.InvalidCacheRoleName, cacheRoleName); addCacheRoleCmdlet.AddAzureCacheWorkerRoleProcess(cacheRoleName, 1, rootPath); Testing.AssertThrows<Exception>(() => enableCacheCmdlet.EnableAzureMemcacheRoleProcess(cacheRoleName, cacheRoleName, rootPath)); } }
public void EnableDisableEnableRemoteDesktopForWebAndWorkerRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole" }; addNodeWorkerCmdlet.ExecuteCmdlet(); EnableAzureRemoteDesktopCommandTest.EnableRemoteDesktop("user", "GoodPassword!"); disableRDCmdlet.DisableRemoteDesktop(); EnableAzureRemoteDesktopCommandTest.EnableRemoteDesktop("user", "GoodPassword!"); // Verify the roles have been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); EnableAzureRemoteDesktopCommandTest.VerifyWebRole(service.Components.Definition.WebRole[0], false); EnableAzureRemoteDesktopCommandTest.VerifyWorkerRole(service.Components.Definition.WorkerRole[0], true); EnableAzureRemoteDesktopCommandTest.VerifyRoleSettings(service); } }
public void AddAzureWorkerRoleWithMissingScaffoldXmlFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { string roleName = "WorkerRole1"; string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string scaffoldingPath = "TemplateMissingScaffoldXml"; addWorkerCmdlet = new AddAzureWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = roleName, TemplateFolder = scaffoldingPath }; Testing.AssertThrows<FileNotFoundException>(() => addWorkerCmdlet.ExecuteCmdlet()); } }
public void TestUpgradeCloudService() { clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); clientMocks.ComputeManagementClientMock.Setup( c => c.Deployments.UpgradeBySlotAsync(It.IsAny<string>(), DeploymentSlot.Production, It.IsAny<DeploymentUpgradeParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(CreateComputeOperationResponse("req002"))); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); clientMocks.ComputeManagementClientMock.Verify(c => c.Deployments.UpgradeBySlotAsync(serviceName, DeploymentSlot.Production, It.IsAny<DeploymentUpgradeParameters>(), It.IsAny<CancellationToken>()), Times.Once); } }
public void EnableAzureMemcacheRoleProcessUsingNonCacheWorkerRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { string serviceName = "AzureService"; string rootPath = files.CreateNewService(serviceName); string workerRoleName = "WorkerRole"; string webRoleName = "WebRole"; string expected = string.Format(Resources.NotCacheWorkerRole, workerRoleName); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = webRoleName }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = workerRoleName }; addNodeWorkerCmdlet.ExecuteCmdlet(); Testing.AssertThrows<Exception>(() => enableCacheCmdlet.EnableAzureMemcacheRoleProcess(webRoleName, workerRoleName, rootPath)); } }
public void DisableRemoteDesktopForWebRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); disableRDCmdlet.PassThru = true; disableRDCmdlet.DisableRemoteDesktop(); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[1]); } }
public void EnableRemoteDesktopUnicode() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); EnableRemoteDesktop("㯑䲘䄂㮉", "㯑䲘䄂㮉㮉㮉㮉L"); // Verify the role has been setup with forwarding, access, // and certs CloudServiceProject service = new CloudServiceProject(rootPath, FileUtilities.GetContentFilePath("Services")); VerifyWebRole(service.Components.Definition.WebRole[0], true); VerifyRoleSettings(service); } }
public void EnableRemoteDesktopBasicParameterValidation() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); Testing.AssertThrows<ArgumentException>( () => EnableRemoteDesktop(null, null)); Testing.AssertThrows<ArgumentException>( () => EnableRemoteDesktop(string.Empty, string.Empty)); Testing.AssertThrows<ArgumentException>( () => EnableRemoteDesktop("user", null)); Testing.AssertThrows<ArgumentException>( () => EnableRemoteDesktop("user", string.Empty)); Testing.AssertThrows<ArgumentException>( () => EnableRemoteDesktop("user", "short")); Testing.AssertThrows<ArgumentException>( () => EnableRemoteDesktop("user", "onlylower")); Testing.AssertThrows<ArgumentException>( () => EnableRemoteDesktop("user", "ONLYUPPER")); Testing.AssertThrows<ArgumentException>( () => EnableRemoteDesktop("user", "1234567890")); } }
public void EnableRemoteDesktopUnicodeAndShortPasswordFails() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); Testing.AssertThrows<ArgumentException>(() => EnableRemoteDesktop("㯑䲘䄂㮉", "㯑䲘")); } }
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 EnableRemoteDesktopForEmptyService() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); Testing.AssertThrows<InvalidOperationException>(() => EnableRemoteDesktop("user", "GoodPassword!")); } }
public void TestCreateStorageServiceWithPublish() { RemoveDeployments(); clientMocks.ComputeManagementClientMock.Setup( c => c.HostedServices.CreateAsync(It.IsAny<HostedServiceCreateParameters>(), It.IsAny<CancellationToken>())) .Returns(Tasks.FromResult(new OperationResponse { RequestId = "request001", StatusCode = HttpStatusCode.OK })); storageService.Clear(); using (var files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); var cloudServiceProject = new CloudServiceProject(rootPath, null); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); clientMocks.StorageManagementClientMock.Verify(c => c.StorageAccounts.CreateAsync(It.IsAny<StorageAccountCreateParameters>(), It.IsAny<CancellationToken>()), Times.Once); } }