Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #688 from ogail/672

Fix messaging for Add-AzureCacheWorkerRole cmdlet
  • Loading branch information...
commit bcf55552dd5c16b52acb94f0686317a6ddd17cea 2 parents b515cd1 + 18735c0
Abdelrahman Elogeel ogail authored
Showing with 192 additions and 136 deletions.
  1. +94 −94 WindowsAzurePowershell/src/Management.CloudService.Test/TestData/Data.cs
  2. +38 −6 WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/AddAzureCacheWorkerRoleTests.cs
  3. +1 −3 WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/NewAzureServiceTests.cs
  4. +1 −1  WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/SetAzureServiceProjectTests.cs
  5. +1 −1  WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/StartAzureServiceTests.cs
  6. +1 −1  WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/StopAzureServiceTests.cs
  7. +3 −3 WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Model/AzureServiceTests.cs
  8. +4 −4 WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Model/DeploymentStatusManagerTests.cs
  9. +1 −1  WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Model/ServicePathInfoTests.cs
  10. +18 −19 WindowsAzurePowershell/src/Management.CloudService/Cmdlet/AddAzureCacheWorkerRole.cs
  11. +4 −3 WindowsAzurePowershell/src/Management.CloudService/Cmdlet/NewAzureServiceProject.cs
  12. +22 −0 ...owsAzurePowershell/src/Management.CloudService/Microsoft.WindowsAzure.Management.CloudService.format.ps1xml
  13. +4 −0 WindowsAzurePowershell/src/Management.CloudService/Model/Parameters.cs
188 WindowsAzurePowershell/src/Management.CloudService.Test/TestData/Data.cs
View
@@ -27,22 +27,22 @@ static class Data
// To Do:
// Add invalid service/storage account name data: http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/75b05a42-cd3b-4ab8-aa26-dc8366ede115
// Add invalid deployment name data
- public static List<string> ValidServiceName { get; private set; }
- public static List<string> ValidSubscriptionName { get; private set; }
- public static List<string> ValidServiceRootName { get; private set; }
- public static List<string> ValidDeploymentName { get; private set; }
- public static List<string> ValidStorageName { get; private set; }
+ public static List<string> ValidServiceNames { get; private set; }
+ public static List<string> ValidSubscriptionNames { get; private set; }
+ public static List<string> ValidServiceRootNames { get; private set; }
+ public static List<string> ValidDeploymentNames { get; private set; }
+ public static List<string> ValidStorageNames { get; private set; }
public static List<string> ValidPublishSettings { get; private set; }
- public static List<string> ValidRoleName { get; private set; }
+ public static List<string> ValidRoleNames { get; private set; }
public static List<int> ValidRoleInstances { get; private set; }
- public static List<string> InvalidServiceRootName { get; private set; }
- public static List<string> InvalidLocation { get; private set; }
- public static List<string> InvalidSlot { get; private set; }
+ public static List<string> InvalidServiceRootNames { get; private set; }
+ public static List<string> InvalidLocations { get; private set; }
+ public static List<string> InvalidSlots { get; private set; }
public static List<string> InvalidPublishSettings { get; private set; }
- public static List<string> InvalidServiceName { get; private set; }
- public static List<string> InvalidRoleName { get; private set; }
- public static List<string> InvalidFileName { get; private set; }
- public static List<string> InvalidPath { get; private set; }
+ public static List<string> InvalidServiceNames { get; private set; }
+ public static List<string> InvalidRoleNames { get; private set; }
+ public static List<string> InvalidFileNames { get; private set; }
+ public static List<string> InvalidPaths { get; private set; }
public static List<int> InvalidRoleInstances { get; private set; }
public static StorageServiceList ValidStorageService { get; private set; }
public static string AzureSdkAppDir { get; private set; }
@@ -53,22 +53,22 @@ static Data()
AzureSdkAppDir = Path.Combine(Directory.GetCurrentDirectory(), Management.Properties.Resources.AzureDirectory);
TestResultDirectory = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
- ValidServiceName = new List<string>();
+ ValidServiceNames = new List<string>();
InitializeValidServiceNameData();
- ValidSubscriptionName = new List<string>();
+ ValidSubscriptionNames = new List<string>();
InitializeValidSubscriptionNameData();
- ValidServiceRootName = new List<string>();
+ ValidServiceRootNames = new List<string>();
InitializeValidServiceRootNameData();
- ValidDeploymentName = new List<string>();
+ ValidDeploymentNames = new List<string>();
InitializeValidDeploymentNameData();
- ValidStorageName = new List<string>();
+ ValidStorageNames = new List<string>();
InitializeValidStorageNameData();
- InvalidServiceRootName = new List<string>();
+ InvalidServiceRootNames = new List<string>();
InitializeInvalidServiceRootNameData();
ValidPublishSettings = new List<string>();
@@ -77,19 +77,19 @@ static Data()
InvalidPublishSettings = new List<string>();
InitializeInvalidPublishSettingsData();
- InvalidLocation = new List<string>();
+ InvalidLocations = new List<string>();
InitializeInvalidLocationData();
- InvalidSlot = new List<string>();
+ InvalidSlots = new List<string>();
InitializeInvalidSlotData();
- InvalidServiceName = new List<string>();
+ InvalidServiceNames = new List<string>();
InitializeInvalidServiceNameData();
- ValidRoleName = new List<string>();
+ ValidRoleNames = new List<string>();
InitializeValidRoleNameData();
- InvalidRoleName = new List<string>();
+ InvalidRoleNames = new List<string>();
InitializeInvalidRoleNameData();
ValidRoleInstances = new List<int>();
@@ -98,10 +98,10 @@ static Data()
InvalidRoleInstances = new List<int>();
InitializeInvalidRoleInstancesData();
- InvalidFileName = new List<string>();
+ InvalidFileNames = new List<string>();
InitializeInvalidFileNameData();
- InvalidPath = new List<string>();
+ InvalidPaths = new List<string>();
InitializeInvalidPathData();
ValidStorageService = new StorageServiceList();
@@ -143,9 +143,9 @@ private static void InitializeValidStorageServiceData()
private static void InitializeInvalidPathData()
{
- foreach (string invalidFolderName in InvalidServiceRootName)
+ foreach (string invalidFolderName in InvalidServiceRootNames)
{
- InvalidPath.Add(string.Format("{0}\\{1}", Directory.GetCurrentDirectory(), invalidFolderName));
+ InvalidPaths.Add(string.Format("{0}\\{1}", Directory.GetCurrentDirectory(), invalidFolderName));
}
}
@@ -164,10 +164,10 @@ private static void InitializeInvalidFileNameData()
{
continue;
}
- j %= ValidServiceRootName.Count - 1;
- StringBuilder invalidFile = new StringBuilder(ValidServiceRootName[j]);
+ j %= ValidServiceRootNames.Count - 1;
+ StringBuilder invalidFile = new StringBuilder(ValidServiceRootNames[j]);
invalidFile[invalidFile.Length / 2] = invalidFileNameChars[i];
- InvalidFileName.Add(invalidFile.ToString());
+ InvalidFileNames.Add(invalidFile.ToString());
}
}
@@ -189,38 +189,38 @@ private static void InitializeValidRoleInstancesData()
private static void InitializeInvalidRoleNameData()
{
- InvalidRoleName.AddRange(InvalidServiceRootName);
+ InvalidRoleNames.AddRange(InvalidServiceRootNames);
}
private static void InitializeValidRoleNameData()
{
- ValidRoleName.Add("WebRole1");
- ValidRoleName.Add("MyWebRole");
- ValidRoleName.Add("WorkerRole");
- ValidRoleName.Add("Node_WebRole");
+ ValidRoleNames.Add("WebRole1");
+ ValidRoleNames.Add("MyWebRole");
+ ValidRoleNames.Add("WorkerRole");
+ ValidRoleNames.Add("Node_WebRole");
}
private static void InitializeInvalidSlotData()
{
- InvalidSlot.Add(string.Empty);
- InvalidSlot.Add(null);
- InvalidSlot.Add("Praduction");
- InvalidSlot.Add("Pddqdww");
- InvalidSlot.Add("Stagging");
- InvalidSlot.Add("Sagiang");
+ InvalidSlots.Add(string.Empty);
+ InvalidSlots.Add(null);
+ InvalidSlots.Add("Praduction");
+ InvalidSlots.Add("Pddqdww");
+ InvalidSlots.Add("Stagging");
+ InvalidSlots.Add("Sagiang");
}
private static void InitializeInvalidLocationData()
{
- InvalidLocation.Add(string.Empty);
- InvalidLocation.Add(null);
- InvalidLocation.Add("My Home");
- InvalidLocation.Add("AnywhereUS");
- InvalidLocation.Add("USA");
- InvalidLocation.Add("Microsoft");
- InvalidLocation.Add("Near");
- InvalidLocation.Add("Anywhere Africa");
- InvalidLocation.Add("Anywhhere US");
+ InvalidLocations.Add(string.Empty);
+ InvalidLocations.Add(null);
+ InvalidLocations.Add("My Home");
+ InvalidLocations.Add("AnywhereUS");
+ InvalidLocations.Add("USA");
+ InvalidLocations.Add("Microsoft");
+ InvalidLocations.Add("Near");
+ InvalidLocations.Add("Anywhere Africa");
+ InvalidLocations.Add("Anywhhere US");
}
private static void InitializeInvalidPublishSettingsData()
@@ -242,75 +242,75 @@ private static void InitializeInvalidServiceRootNameData()
for (int i = 0, j = 0; i < invalidPathNameChars.Length; i++)
{
- StringBuilder invalidPath = new StringBuilder(ValidServiceRootName[j]);
+ StringBuilder invalidPath = new StringBuilder(ValidServiceRootNames[j]);
invalidPath[invalidPath.Length / 2] = invalidPathNameChars[i];
- j %= ValidServiceRootName.Count;
- InvalidServiceRootName.Add(invalidPath.ToString());
+ j %= ValidServiceRootNames.Count;
+ InvalidServiceRootNames.Add(invalidPath.ToString());
}
}
private static void InitializeValidStorageNameData()
{
- ValidStorageName.AddRange(ValidServiceName);
+ ValidStorageNames.AddRange(ValidServiceNames);
}
private static void InitializeValidDeploymentNameData()
{
- ValidDeploymentName.Add("MyDeployment");
- ValidDeploymentName.Add("Storage deployment");
- ValidDeploymentName.Add("_deployment name");
- ValidDeploymentName.Add("deploy service1");
+ ValidDeploymentNames.Add("MyDeployment");
+ ValidDeploymentNames.Add("Storage deployment");
+ ValidDeploymentNames.Add("_deployment name");
+ ValidDeploymentNames.Add("deploy service1");
}
private static void InitializeValidSubscriptionNameData()
{
- ValidSubscriptionName.Add("Windows Azure Sandbox 9-220");
- ValidSubscriptionName.Add("_MySubscription");
- ValidSubscriptionName.Add("This is my subscription");
- ValidSubscriptionName.Add("Windows Azure Sandbox 284-1232");
+ ValidSubscriptionNames.Add("Windows Azure Sandbox 9-220");
+ ValidSubscriptionNames.Add("_MySubscription");
+ ValidSubscriptionNames.Add("This is my subscription");
+ ValidSubscriptionNames.Add("Windows Azure Sandbox 284-1232");
}
private static void InitializeValidServiceNameData()
{
- ValidServiceName.Add("HelloNode");
- ValidServiceName.Add("node.jsservice");
- ValidServiceName.Add("node_js_service");
- ValidServiceName.Add("node-js-service");
- ValidServiceName.Add("node-js-service123");
- ValidServiceName.Add("123node-js-service123");
- ValidServiceName.Add("123node-js2service");
+ ValidServiceNames.Add("HelloNode");
+ ValidServiceNames.Add("node.jsservice");
+ ValidServiceNames.Add("node_js_service");
+ ValidServiceNames.Add("node-js-service");
+ ValidServiceNames.Add("node-js-service123");
+ ValidServiceNames.Add("123node-js-service123");
+ ValidServiceNames.Add("123node-js2service");
}
private static void InitializeInvalidServiceNameData()
{
- InvalidServiceName.Add("Hello\\Node");
- InvalidServiceName.Add("Hello/Node");
- InvalidServiceName.Add("Node App Sample");
- InvalidServiceName.Add("My$app");
- InvalidServiceName.Add("My@app");
- InvalidServiceName.Add("My#app");
- InvalidServiceName.Add("My%app");
- InvalidServiceName.Add("My^app");
- InvalidServiceName.Add("My&app");
- InvalidServiceName.Add("My*app");
- InvalidServiceName.Add("My+app");
- InvalidServiceName.Add("My=app");
- InvalidServiceName.Add("My{app");
- InvalidServiceName.Add("My}app");
- InvalidServiceName.Add("My(app");
- InvalidServiceName.Add("My)app");
- InvalidServiceName.Add("My[app");
- InvalidServiceName.Add("My]app");
- InvalidServiceName.Add("My|app");
- InvalidServiceName.Add("-MyDomain");
- InvalidServiceName.Add("MyDomain-");
- InvalidServiceName.Add("-MyDomain-");
- InvalidServiceName.Add(new string('a', 64));
+ InvalidServiceNames.Add("Hello\\Node");
+ InvalidServiceNames.Add("Hello/Node");
+ InvalidServiceNames.Add("Node App Sample");
+ InvalidServiceNames.Add("My$app");
+ InvalidServiceNames.Add("My@app");
+ InvalidServiceNames.Add("My#app");
+ InvalidServiceNames.Add("My%app");
+ InvalidServiceNames.Add("My^app");
+ InvalidServiceNames.Add("My&app");
+ InvalidServiceNames.Add("My*app");
+ InvalidServiceNames.Add("My+app");
+ InvalidServiceNames.Add("My=app");
+ InvalidServiceNames.Add("My{app");
+ InvalidServiceNames.Add("My}app");
+ InvalidServiceNames.Add("My(app");
+ InvalidServiceNames.Add("My)app");
+ InvalidServiceNames.Add("My[app");
+ InvalidServiceNames.Add("My]app");
+ InvalidServiceNames.Add("My|app");
+ InvalidServiceNames.Add("-MyDomain");
+ InvalidServiceNames.Add("MyDomain-");
+ InvalidServiceNames.Add("-MyDomain-");
+ InvalidServiceNames.Add(new string('a', 64));
}
private static void InitializeValidServiceRootNameData()
{
- ValidServiceRootName.AddRange(ValidServiceName);
+ ValidServiceRootNames.AddRange(ValidServiceNames);
}
}
}
44 WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/AddAzureCacheWorkerRoleTests.cs
View
@@ -15,28 +15,41 @@
namespace Microsoft.WindowsAzure.Management.CloudService.Test.Tests
{
using System.IO;
+ using System.Management.Automation;
using CloudService.Cmdlet;
using CloudService.Properties;
+ using Microsoft.WindowsAzure.Management.CloudService.ServiceConfigurationSchema;
+ using Microsoft.WindowsAzure.Management.CloudService.ServiceDefinitionSchema;
using Utilities;
using VisualStudio.TestTools.UnitTesting;
- using Microsoft.WindowsAzure.Management.CloudService.ServiceDefinitionSchema;
- using Microsoft.WindowsAzure.Management.CloudService.ServiceConfigurationSchema;
using ConfigConfigurationSetting = Microsoft.WindowsAzure.Management.CloudService.ServiceConfigurationSchema.ConfigurationSetting;
+ using Microsoft.WindowsAzure.Management.CloudService.Model;
+ using System;
[TestClass]
public class AddAzureCacheWorkerRoleTests : TestBase
{
+ FakeWriter writer;
+ AddAzureCacheWorkerRoleCommand cmdlet;
+
+ [TestInitialize]
+ public void SetupTest()
+ {
+ writer = new FakeWriter();
+ cmdlet = new AddAzureCacheWorkerRoleCommand();
+ cmdlet.Writer = writer;
+ }
+
[TestMethod]
- public void AddAzureCacheWorkerRoleProcess()
+ public void AddNewCacheWorkerRoleSuccessful()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
string servicePath = Path.Combine(files.RootPath, "AzureService");
string roleName = "WorkerRole";
+ int expectedInstanceCount = 10;
new NewAzureServiceProjectCommand().NewAzureServiceProcess(files.RootPath, "AzureService");
- new AddAzureCacheWorkerRoleCommand().AddAzureCacheWorkerRoleProcess(roleName, 1, servicePath);
-
- WorkerRole cacheWorkerRole = Testing.GetWorkerRole(servicePath, roleName);
+ WorkerRole cacheWorkerRole = cmdlet.AddAzureCacheWorkerRoleProcess(roleName, expectedInstanceCount, servicePath);
RoleSettings cacheRoleSettings = Testing.GetRole(servicePath, roleName);
AzureAssert.ScaffoldingExists(Path.Combine(files.RootPath, "AzureService", "WorkerRole"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole));
@@ -52,6 +65,25 @@ public void AddAzureCacheWorkerRoleProcess()
AzureAssert.ConfigurationSettingExist(new ConfigConfigurationSetting { name = Resources.DiagnosticLevelName, value = Resources.DiagnosticLevelValue }, cacheRoleSettings.ConfigurationSettings);
AzureAssert.ConfigurationSettingExist(new ConfigConfigurationSetting { name = Resources.CachingCacheSizePercentageSettingName, value = string.Empty }, cacheRoleSettings.ConfigurationSettings);
AzureAssert.ConfigurationSettingExist(new ConfigConfigurationSetting { name = Resources.CachingConfigStoreConnectionStringSettingName, value = string.Empty }, cacheRoleSettings.ConfigurationSettings);
+
+ PSObject actualOutput = writer.OutputChannel[0] as PSObject;
+ Assert.AreEqual<string>(roleName, actualOutput.Members[Parameters.CacheWorkerRoleName].Value.ToString());
+ Assert.AreEqual<int>(expectedInstanceCount, int.Parse(actualOutput.Members[Parameters.Instances].Value.ToString()));
+ }
+ }
+
+ [TestMethod]
+ public void AddNewCacheWorkerRoleWithInvalidNamesFail()
+ {
+ using (FileSystemHelper files = new FileSystemHelper(this))
+ {
+ string servicePath = Path.Combine(files.RootPath, "AzureService");
+ new NewAzureServiceProjectCommand().NewAzureServiceProcess(files.RootPath, "AzureService");
+
+ foreach (string invalidName in TestData.Data.InvalidRoleNames)
+ {
+ Testing.AssertThrows<ArgumentException>(() => cmdlet.AddAzureCacheWorkerRoleProcess(invalidName, 1, servicePath));
+ }
}
}
}
4 WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/NewAzureServiceTests.cs
View
@@ -67,9 +67,7 @@ public void NewAzureServiceWithInvalidNames()
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
- string[] invalidNames = { "invalid<name", "inva>l", "*name" };
-
- foreach (string name in invalidNames)
+ foreach (string name in TestData.Data.InvalidServiceNames)
{
cmdlet.ServiceName = name;
Testing.AssertThrows<ArgumentException>(() => cmdlet.ExecuteCmdlet());
2  WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/SetAzureServiceProjectTests.cs
View
@@ -28,7 +28,7 @@ public class SetAzureServiceProjectTests : TestBase
[TestMethod]
public void SetAzureServiceProjectTestsSubscriptionValid()
{
- foreach (string item in Data.ValidSubscriptionName)
+ foreach (string item in Data.ValidSubscriptionNames)
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
2  WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/StartAzureServiceTests.cs
View
@@ -54,7 +54,7 @@ public void SetDeploymentStatusProcessTest()
files.CreateAzureSdkDirectoryAndImportPublishSettings();
AzureService service = new AzureService(files.RootPath, serviceName, null);
var startAzureService = new StartAzureService(channel) { ShareChannel = true };
- startAzureService.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName);
+ startAzureService.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName);
Assert.IsTrue(statusUpdated);
}
2  WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Cmdlet/StopAzureServiceTests.cs
View
@@ -54,7 +54,7 @@ public void SetDeploymentStatusProcessTest()
files.CreateAzureSdkDirectoryAndImportPublishSettings();
AzureService service = new AzureService(files.RootPath, serviceName, null);
var stopAzureService = new StopAzureService(channel) { ShareChannel = true };
- stopAzureService.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName);
+ stopAzureService.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName);
Assert.IsTrue(statusUpdated);
}
6 WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Model/AzureServiceTests.cs
View
@@ -54,7 +54,7 @@ public void AzureServiceCreateNewNullParentDirectoryFail()
[TestMethod]
public void AzureServiceCreateNewInvalidParentDirectoryFail()
{
- foreach (string invalidName in Data.InvalidFileName)
+ foreach (string invalidName in Data.InvalidFileNames)
{
Testing.AssertThrows<ArgumentException>(() => new AzureService(string.Empty, serviceName, null), string.Format(Resources.InvalidOrEmptyArgumentMessage, "service parent directory"));
}
@@ -87,7 +87,7 @@ public void AzureServiceCreateNewNullServiceNameFail()
[TestMethod]
public void AzureServiceCreateNewInvalidServiceNameFail()
{
- foreach (string invalidFileName in Data.InvalidFileName)
+ foreach (string invalidFileName in Data.InvalidFileNames)
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
@@ -101,7 +101,7 @@ public void AzureServiceCreateNewInvalidDnsServiceNameFail()
{
char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
- foreach (string invalidDnsName in Data.InvalidServiceName)
+ foreach (string invalidDnsName in Data.InvalidServiceNames)
{
using (FileSystemHelper files = new FileSystemHelper(this))
{
8 WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Model/DeploymentStatusManagerTests.cs
View
@@ -57,7 +57,7 @@ public void SetDeploymentStatusProcessTest()
AzureService service = new AzureService(files.RootPath, serviceName, null);
var deploymentManager = new DeploymentStatusManager(channel);
deploymentManager.ShareChannel = true;
- deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName);
+ deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName);
Assert.IsTrue(statusUpdated);
}
@@ -85,7 +85,7 @@ public void SetDeploymentStatusProcessSetTransitioningServiceTest()
AzureService service = new AzureService(files.RootPath, serviceName, null);
var deploymentManager = new DeploymentStatusManager(channel);
deploymentManager.ShareChannel = true;
- resultMessage = deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName);
+ resultMessage = deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName);
Assert.IsFalse(statusUpdated);
Assert.AreEqual<string>(expectedMessage, resultMessage);
@@ -114,7 +114,7 @@ public void SetDeploymentStatusProcessSetStatusToActualStatusTest()
AzureService service = new AzureService(files.RootPath, serviceName, null);
var deploymentManager = new DeploymentStatusManager(channel);
deploymentManager.ShareChannel = true;
- resultMessage = deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName);
+ resultMessage = deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName);
Assert.IsFalse(statusUpdated);
Assert.AreEqual<string>(expectedMessage, resultMessage);
@@ -142,7 +142,7 @@ public void SetDeploymentStatusProcessDeploymentDoesNotExistTest()
AzureService service = new AzureService(files.RootPath, serviceName, null);
var deploymentManager = new DeploymentStatusManager(channel);
deploymentManager.ShareChannel = true;
- resultMessage = deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName);
+ resultMessage = deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName);
Assert.IsFalse(statusUpdated);
Assert.AreEqual<string>(expectedMessage, resultMessage);
2  WindowsAzurePowershell/src/Management.CloudService.Test/Tests/Model/ServicePathInfoTests.cs
View
@@ -64,7 +64,7 @@ public void ServicePathInfoTestNullRootPathFail()
[TestMethod]
public void ServicePathInfoTestInvalidRootPathFail()
{
- foreach (string invalidDirectoryName in Data.InvalidServiceRootName)
+ foreach (string invalidDirectoryName in Data.InvalidServiceRootNames)
{
try
{
37 WindowsAzurePowershell/src/Management.CloudService/Cmdlet/AddAzureCacheWorkerRole.cs
View
@@ -40,18 +40,12 @@ namespace Microsoft.WindowsAzure.Management.CloudService.Cmdlet
public class AddAzureCacheWorkerRoleCommand : AddRole
{
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
- protected override void ProcessRecord()
+ public override void ExecuteCmdlet()
{
- try
- {
- base.ProcessRecord();
- string result = AddAzureCacheWorkerRoleProcess(base.Name, base.Instances, base.GetServiceRootPath());
- SafeWriteObject(result);
- }
- catch (Exception ex)
- {
- SafeWriteError(ex);
- }
+ base.ExecuteCmdlet();
+
+ SkipChannelInit = true;
+ AddAzureCacheWorkerRoleProcess(base.Name, base.Instances, base.GetServiceRootPath());
}
private AzureService CachingConfigurationFactoryMethod(string rootPath, RoleInfo cacheWorkerRole, string sdkVersion)
@@ -73,21 +67,26 @@ private AzureService CachingConfigurationFactoryMethod(string rootPath, RoleInfo
/// <param name="workerRoleName">The cache worker role name</param>
/// <param name="instances">The instance count</param>
/// <param name="rootPath">The service root path</param>
- /// <returns>The resulted message</returns>
+ /// <returns>The added cache worker role</returns>
[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
- public string AddAzureCacheWorkerRoleProcess(string workerRoleName, int instances, string rootPath)
+ public WorkerRole AddAzureCacheWorkerRoleProcess(string workerRoleName, int instances, string rootPath)
{
RoleInfo nodeWorkerRole;
- // Create node worker role.
- string message = new AddAzureNodeWorkerRoleCommand().AddAzureNodeWorkerRoleProcess(workerRoleName, instances, rootPath, out nodeWorkerRole);
-
+ // Create cache worker role.
+ new AddAzureNodeWorkerRoleCommand().AddAzureNodeWorkerRoleProcess(workerRoleName, instances, rootPath, out nodeWorkerRole);
AzureService azureService = CachingConfigurationFactoryMethod(rootPath, nodeWorkerRole, new AzureTool().AzureSdkVersion);
-
- // Save changes
azureService.Components.Save(azureService.Paths);
+ WorkerRole cacheWorkerRole = azureService.Components.GetWorkerRole(nodeWorkerRole.Name);
+
+ // Write output
+ SafeWriteOutputPSObject(
+ cacheWorkerRole.GetType().FullName,
+ Parameters.CacheWorkerRoleName, nodeWorkerRole.Name,
+ Parameters.Instances, nodeWorkerRole.InstanceCount
+ );
- return message;
+ return azureService.Components.GetWorkerRole(workerRoleName);
}
/// <summary>
7 WindowsAzurePowershell/src/Management.CloudService/Cmdlet/NewAzureServiceProject.cs
View
@@ -14,14 +14,13 @@
namespace Microsoft.WindowsAzure.Management.CloudService.Cmdlet
{
- using System;
using System.IO;
using System.Management.Automation;
+ using System.Security.Permissions;
using Common;
+ using Microsoft.Samples.WindowsAzure.ServiceManagement;
using Model;
using Properties;
- using Services;
- using Microsoft.Samples.WindowsAzure.ServiceManagement;
/// <summary>
/// Create scaffolding for a new hosted service. Generates a basic folder structure,
@@ -31,6 +30,7 @@ namespace Microsoft.WindowsAzure.Management.CloudService.Cmdlet
public class NewAzureServiceProjectCommand : CloudCmdlet<IServiceManagement>
{
[Parameter(Position = 0, Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Name of the cloud project")]
+ [ValidateNotNullOrEmpty]
public string ServiceName { get; set; }
internal AzureService NewAzureServiceProcess(string parentDirectory, string serviceName)
@@ -50,6 +50,7 @@ internal AzureService NewAzureServiceProcess(string parentDirectory, string serv
return newService;
}
+ [PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
22 ...AzurePowershell/src/Management.CloudService/Microsoft.WindowsAzure.Management.CloudService.format.ps1xml
View
@@ -23,5 +23,27 @@
</ListEntries>
</ListControl>
</View>
+ <View>
+ <Name>Microsoft.WindowsAzure.Management.CloudService.ServiceDefinitionSchema.WorkerRole</Name>
+ <ViewSelectedBy>
+ <TypeName>Microsoft.WindowsAzure.Management.CloudService.ServiceDefinitionSchema.WorkerRole</TypeName>
+ </ViewSelectedBy>
+ <ListControl>
+ <ListEntries>
+ <ListEntry>
+ <ListItems>
+ <ListItem>
+ <Label>CacheWorkerRoleName</Label>
+ <PropertyName>CacheWorkerRoleName</PropertyName>
+ </ListItem>
+ <ListItem>
+ <Label>Instances</Label>
+ <PropertyName>Instances</PropertyName>
+ </ListItem>
+ </ListItems>
+ </ListEntry>
+ </ListEntries>
+ </ListControl>
+ </View>
</ViewDefinitions>
</Configuration>
4 WindowsAzurePowershell/src/Management.CloudService/Model/Parameters.cs
View
@@ -10,5 +10,9 @@ class Parameters
public const string ServiceName = "ServiceName";
public const string RootPath = "RootPath";
+
+ public const string CacheWorkerRoleName = "CacheWorkerRoleName";
+
+ public const string Instances = "Instances";
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.