Skip to content

Commit fed92be

Browse files
author
unknown
committed
Powershell parameters changed, mote tests added for vipMobility
1 parent 6de00fc commit fed92be

15 files changed

+287
-60
lines changed

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/Commands.ServiceManagement.Test.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@
424424
<None Include="AzureRTComplete_Full_Diff.playlist" />
425425
<None Include="AzureRTExtensions.playlist" />
426426
<None Include="AzureRTFull.playlist" />
427+
<None Include="Resources\HelloWorld_SDK20.cspkg">
428+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
429+
</None>
430+
<None Include="Resources\ServiceConfiguration.cscfg">
431+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
432+
</None>
427433
<None Include="MSSharedLibKey.snk" />
428434
<None Include="packages.config" />
429435
<None Include="Resources\affinityGroupData.csv" />

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/LocationBasedReservedIPTests.cs

Lines changed: 120 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
using Microsoft.VisualStudio.TestTools.UnitTesting;
1919
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
2020
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.ConfigDataInfo;
21+
using CM=Microsoft.WindowsAzure.Management.Compute.Models;
2122

2223
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests
2324
{
@@ -109,6 +110,74 @@ public void CreateReservedIPThenWindowsVM()
109110
}
110111
}
111112

113+
[TestMethod(), Priority(0), TestProperty("Feature", "IaaS"), TestCategory(Category.Network), Owner("avgupt"), Description("Test the cmdlets (Remove-AzureReservedIPAssociation, New-AzureReservedIP,Get-AzureReservedIP,Remove-AzureReservedIP)")]
114+
public void CreatePaaSDeploymentAssociateAndDisassociateReservedIp()
115+
{
116+
try
117+
{
118+
string reservedIpName = Utilities.GetUniqueShortName("ResrvdIP");
119+
string reservedIpLabel = Utilities.GetUniqueShortName("ResrvdIPLbl", 5);
120+
string deploymentName = Utilities.GetUniqueShortName("Depl");
121+
string deploymentLabel = Utilities.GetUniqueShortName("DepLbl", 5);
122+
123+
var input = new ReservedIPContext()
124+
{
125+
//Address = string.Empty,
126+
DeploymentName = string.Empty,
127+
Label = reservedIpLabel,
128+
InUse = false,
129+
Location = locationName,
130+
ReservedIPName = reservedIpName,
131+
State = "Created"
132+
};
133+
134+
// Reserve a new IP
135+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, reservedIpLabel), "Reserve a new IP");
136+
//Get the reserved ip and verify the reserved Ip properties.
137+
VerifyReservedIpNotInUse(input);
138+
// Create a new VM with the reserved ip.
139+
140+
Utilities.ExecuteAndLog(() =>
141+
vmPowershellCmdlets.NewAzureService(serviceName, locationName),
142+
"Create a Hosted Service");
143+
144+
Utilities.ExecuteAndLog(() =>
145+
vmPowershellCmdlets.NewAzureDeployment(serviceName,
146+
"HelloWorld_SDK20.cspkg", "ServiceConfiguration.cscfg", "Staging",
147+
deploymentLabel, deploymentName, doNotStart: false, warning: false),
148+
"Create a PaaS deployment");
149+
150+
151+
Utilities.ExecuteAndLog(() =>
152+
{
153+
vmPowershellCmdlets.SetAzureReservedIPAssociation(reservedIpName,
154+
serviceName, DeploymentSlotType.Staging);
155+
}, "Create a new Azure Reserved IP Association");
156+
157+
158+
VerifyReservedIpInUse(serviceName, input, deploymentName);
159+
160+
Utilities.ExecuteAndLog(() =>
161+
{
162+
vmPowershellCmdlets.RemoveAzureReservedIPAssociation(reservedIpName,
163+
serviceName, true, DeploymentSlotType.Staging);
164+
}, "Remove a new Azure Reserved IP Association");
165+
166+
VerifyReservedIpNotInUse(input);
167+
168+
Utilities.ExecuteAndLog(() =>
169+
{
170+
vmPowershellCmdlets.RemoveAzureDeployment(serviceName, "Staging", true);
171+
}, "Remove a new Azure Reserved IP Association");
172+
}
173+
catch (Exception ex)
174+
{
175+
pass = false;
176+
Console.WriteLine(ex.ToString());
177+
throw;
178+
}
179+
}
180+
112181
[TestMethod(), Priority(0), TestProperty("Feature", "IaaS"), TestCategory(Category.Network), Owner("avgupt"), Description("Test the cmdlets (Set-AzureReservedIPAssociation, New-AzureReservedIP,Get-AzureReservedIP,Remove-AzureReservedIP)")]
113182
public void CreateWindowsVMThenAssociateReservedIP()
114183
{
@@ -118,7 +187,6 @@ public void CreateWindowsVMThenAssociateReservedIP()
118187
string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
119188
string dnsName = Utilities.GetUniqueShortName("Dns");
120189
string vmName = Utilities.GetUniqueShortName(vmNamePrefix);
121-
string deploymentName = Utilities.GetUniqueShortName("Depl");
122190
var input = new ReservedIPContext()
123191
{
124192
//Address = string.Empty,
@@ -143,7 +211,7 @@ public void CreateWindowsVMThenAssociateReservedIP()
143211
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
144212
}, "Create a new windows azure vm without reserved ip.");
145213

146-
Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.SetAzureReservedIPAssociation(reservedIpName, serviceName, serviceName); }, "Create a new Azure Reserved IP Association");
214+
Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.SetAzureReservedIPAssociation(reservedIpName, serviceName); }, "Create a new Azure Reserved IP Association");
147215

148216

149217
VerifyReservedIpInUse(serviceName, input);
@@ -161,6 +229,51 @@ public void CreateWindowsVMThenAssociateReservedIP()
161229
}
162230
}
163231

232+
[TestMethod(), Priority(0), TestProperty("Feature", "IaaS"), TestCategory(Category.Network), Owner("avgupt"), Description("Expected failure when trying to associate to staging slot in IaaS (Set-AzureReservedIPAssociation, New-AzureReservedIP,Get-AzureReservedIP,Remove-AzureReservedIP)")]
233+
public void TestAssociateReservedIPToStageSlotIaaSFails()
234+
{
235+
try
236+
{
237+
string reservedIpName = Utilities.GetUniqueShortName("ResrvdIP");
238+
string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
239+
string dnsName = Utilities.GetUniqueShortName("Dns");
240+
string vmName = Utilities.GetUniqueShortName(vmNamePrefix);
241+
var input = new ReservedIPContext()
242+
{
243+
//Address = string.Empty,
244+
DeploymentName = string.Empty,
245+
Label = reservedIpLabel,
246+
InUse = false,
247+
Location = locationName,
248+
ReservedIPName = reservedIpName,
249+
State = "Created"
250+
};
251+
252+
// Reserve a new IP
253+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, reservedIpLabel), "Reserve a new IP");
254+
//Get the reserved ip and verify the reserved Ip properties.
255+
VerifyReservedIpNotInUse(input);
256+
// Create a new VM with the reserved ip.
257+
DnsServer dns = null;
258+
Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
259+
Utilities.ExecuteAndLog(() =>
260+
{
261+
PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
262+
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
263+
}, "Create a new windows azure vm without reserved ip.");
264+
265+
Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.SetAzureReservedIPAssociation(reservedIpName,
266+
serviceName, DeploymentSlotType.Staging); }, "Create a new Azure Reserved IP Association");
267+
}
268+
catch (Exception ex)
269+
{
270+
pass = true;
271+
Console.WriteLine(ex.ToString());
272+
return;
273+
}
274+
throw new Exception("Test Did not fail as expected when association was tried on stage slot in IaaS");
275+
}
276+
164277
[TestMethod(), Priority(0), TestProperty("Feature", "IaaS"), TestCategory(Category.Network), Owner("avgupt"), Description("Test the cmdlets (Remove-AzureReservedIPAssociation, New-AzureReservedIP,Get-AzureReservedIP,Remove-AzureReservedIP)")]
165278
public void CreateWindowsVMWithReservedIPThenDisassociateReservedIP()
166279
{
@@ -170,7 +283,6 @@ public void CreateWindowsVMWithReservedIPThenDisassociateReservedIP()
170283
string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
171284
string dnsName = Utilities.GetUniqueShortName("Dns");
172285
string vmName = Utilities.GetUniqueShortName(vmNamePrefix);
173-
string deploymentName = Utilities.GetUniqueShortName("Depl");
174286
var input = new ReservedIPContext()
175287
{
176288
//Address = string.Empty,
@@ -197,7 +309,7 @@ public void CreateWindowsVMWithReservedIPThenDisassociateReservedIP()
197309

198310
VerifyReservedIpInUse(serviceName, input);
199311

200-
Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.RemoveAzureReservedIPAssociation(reservedIpName, serviceName, serviceName); }, "Remove an Azure Reserved IP Association");
312+
Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.RemoveAzureReservedIPAssociation(reservedIpName, serviceName, true); }, "Remove an Azure Reserved IP Association");
201313

202314
VerifyReservedIpNotInUse(input);
203315
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVM(vmName, serviceName, true), "Remove Azure VM and verify that a warning is given.");
@@ -244,11 +356,11 @@ public void CreateWindowsVMThenReservedExistingIP()
244356
}, "Create a new windows azure vm without reserved ip.");
245357

246358
// Reserve an existing IP
247-
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, serviceName, serviceName, reservedIpLabel), "Reserve existing deployment IP");
359+
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, serviceName, reservedIpLabel), "Reserve existing deployment IP");
248360

249361
VerifyReservedIpInUse(serviceName, input);
250362

251-
Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.RemoveAzureReservedIPAssociation(reservedIpName, serviceName, serviceName); }, "Remove an Azure Reserved IP Association");
363+
Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.RemoveAzureReservedIPAssociation(reservedIpName, serviceName, true); }, "Remove an Azure Reserved IP Association");
252364

253365
VerifyReservedIpNotInUse(input);
254366
Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVM(vmName, serviceName, true), "Remove Azure VM and verify that a warning is given.");
@@ -447,11 +559,11 @@ private void VerifyReservedIpNotInUse(ReservedIPContext input)
447559
Utilities.ExecuteAndLog(() => VerifyReservedIp(input), string.Format("Verify that the reserved ip {0} is not in use", input.ReservedIPName));
448560
}
449561

450-
private void VerifyReservedIpInUse(string serviceName,ReservedIPContext input)
562+
private void VerifyReservedIpInUse(string serviceName,ReservedIPContext input, string deploymentName = null)
451563
{
452564
input.ServiceName = serviceName;
453565
input.InUse = true;
454-
input.DeploymentName = serviceName;
566+
input.DeploymentName = deploymentName ?? serviceName;
455567
Utilities.ExecuteAndLog(() => VerifyReservedIp(input), string.Format("Verify that the reserved ip {0} is in use", input.ReservedIPName));
456568
}
457569

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/NetworkCmdletInfo/NewAzureReservedIPCmdletInfo.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// ----------------------------------------------------------------------------------
1414

1515
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
16+
using Microsoft.WindowsAzure.Management.Compute.Models;
1617

1718
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
1819
{
@@ -31,12 +32,12 @@ public NewAzureReservedIPCmdletInfo(string name, string location, string label)
3132
}
3233
}
3334

34-
public NewAzureReservedIPCmdletInfo(string name, string location, string serviceName, string deploymentName, string label): this(name, location, label)
35+
public NewAzureReservedIPCmdletInfo(string name, string location, string serviceName, string slot, string label): this(name, location, label)
3536
{
3637
this.cmdletName = Utilities.NewAzureReservedIPCmdletName;
3738

3839
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
39-
this.cmdletParams.Add(new CmdletParam("DeploymentName", deploymentName));
40+
this.cmdletParams.Add(new CmdletParam("Slot", slot));
4041
}
4142
}
4243
}

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/NetworkCmdletInfo/RemoveAzureReservedIPAssociationCmdletInfo.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,28 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
1516
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
1617

1718
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
1819
{
1920
class RemoveAzureReservedIPAssociationCmdletInfo : CmdletsInfo
2021
{
21-
public RemoveAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName, string deploymentName)
22+
public RemoveAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName, string slot, bool force)
2223
{
2324
this.cmdletName = Utilities.RemoveAzureReservedIPAssociationCmdletName;
2425

2526
this.cmdletParams.Add(new CmdletParam("ReservedIPName", reservedIpName));
2627
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
27-
this.cmdletParams.Add(new CmdletParam("DeploymentName", deploymentName));
28+
this.cmdletParams.Add(new CmdletParam("Slot", slot));
29+
if (force)
30+
{
31+
this.cmdletParams.Add(new CmdletParam("Force"));
32+
}
33+
}
34+
public RemoveAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName)
35+
: this(reservedIpName, serviceName, DeploymentSlotType.Production, true)
36+
{
2837
}
2938
}
3039
}

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/NetworkCmdletInfo/SetAzureReservedIPAssociationCmdletInfo.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,24 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Model;
1516
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
1617

1718
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
1819
{
1920
public class SetAzureReservedIPAssociationCmdletInfo : CmdletsInfo
2021
{
21-
public SetAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName, string deploymentName)
22+
public SetAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName, string slot)
2223
{
2324
this.cmdletName = Utilities.SetAzureReservedIPAssociationCmdletName;
2425

2526
this.cmdletParams.Add(new CmdletParam("ReservedIPName", reservedIpName));
2627
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
27-
this.cmdletParams.Add(new CmdletParam("DeploymentName", deploymentName));
28+
this.cmdletParams.Add(new CmdletParam("Slot", slot));
2829
}
30+
public SetAzureReservedIPAssociationCmdletInfo(string reservedIpName, string serviceName) : this(reservedIpName, serviceName, DeploymentSlotType.Production)
31+
{
32+
}
33+
2934
}
3035
}

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementCmdletTestHelper.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -856,19 +856,19 @@ internal ManagementOperationContext NewAzureReservedIP(string name, string locat
856856
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new NewAzureReservedIPCmdletInfo(name, location, label));
857857
}
858858

859-
internal ManagementOperationContext NewAzureReservedIP(string name, string location, string serviceName, string deploymentName, string label = null)
859+
internal ManagementOperationContext NewAzureReservedIP(string name, string location, string serviceName, string label = null, string slot = SM.DeploymentSlotType.Production)
860860
{
861-
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new NewAzureReservedIPCmdletInfo(name, location, serviceName, deploymentName, label));
861+
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new NewAzureReservedIPCmdletInfo(name, location, serviceName, slot, label));
862862
}
863863

864-
internal ManagementOperationContext SetAzureReservedIPAssociation(string reservedIpName, string serviceName, string deploymentName)
864+
internal ManagementOperationContext SetAzureReservedIPAssociation(string reservedIpName, string serviceName, string slot = SM.DeploymentSlotType.Production)
865865
{
866-
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new SetAzureReservedIPAssociationCmdletInfo(reservedIpName, serviceName, deploymentName));
866+
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new SetAzureReservedIPAssociationCmdletInfo(reservedIpName, serviceName, slot));
867867
}
868868

869-
internal ManagementOperationContext RemoveAzureReservedIPAssociation(string reservedIpName, string serviceName, string deploymentName)
869+
internal ManagementOperationContext RemoveAzureReservedIPAssociation(string reservedIpName, string serviceName, bool force, string slot = SM.DeploymentSlotType.Production)
870870
{
871-
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new RemoveAzureReservedIPAssociationCmdletInfo(reservedIpName, serviceName, deploymentName));
871+
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new RemoveAzureReservedIPAssociationCmdletInfo(reservedIpName, serviceName, slot, force));
872872
}
873873

874874
internal Collection<SM.ReservedIPContext> GetAzureReservedIP(string name = null)

src/ServiceManagement/Compute/Commands.ServiceManagement.Test/FunctionalTests/ServiceManagementTest.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,21 @@ private static string GetServiceManagementUrl(string publishSettingsFile)
143143
XDocument psf = XDocument.Load(publishSettingsFile);
144144
XElement pubData = psf.Descendants().FirstOrDefault();
145145
XElement pubProfile = pubData.Elements().ToList()[0];
146-
return pubProfile.Attribute("Url").Value;
146+
XAttribute urlattr = pubProfile.Attribute("Url");
147+
string url = string.Empty;
148+
if (urlattr != null)
149+
{
150+
url = urlattr.Value;
151+
}
152+
else
153+
{
154+
var subscriptions = pubProfile.Elements("Subscription").ToList();
155+
if (subscriptions.Any())
156+
{
157+
url = subscriptions[0].Attribute("ServiceManagementUrl").Value;
158+
}
159+
}
160+
return url;
147161
}
148162
catch
149163
{

0 commit comments

Comments
 (0)