Skip to content

Commit b586756

Browse files
author
Avijit Gupta
committed
Changes for multivip and testcase addition
1 parent e9807c1 commit b586756

File tree

13 files changed

+345
-35
lines changed

13 files changed

+345
-35
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,12 @@
287287
<Compile Include="FunctionalTests\IaasCmdletInfo\RemoveAzureEndpointCmdletInfo.cs" />
288288
<Compile Include="FunctionalTests\IaasCmdletInfo\RemoveAzureStaticVNetIPCmdletInfo.cs" />
289289
<Compile Include="FunctionalTests\IaasCmdletInfo\AddAzureNetworkInterfaceConfigCmdletInfo.cs" />
290+
<Compile Include="FunctionalTests\NetworkCmdletInfo\AddAzureVirtualIPCmdletInfo.cs" />
290291
<Compile Include="FunctionalTests\NetworkCmdletInfo\GetAzureReservedIPCmdletInfo.cs" />
291292
<Compile Include="FunctionalTests\NetworkCmdletInfo\NewAzureReservedIPCmdletInfo.cs" />
292293
<Compile Include="FunctionalTests\NetworkCmdletInfo\RemoveAzureReservedIPAssociationCmdletInfo.cs" />
293294
<Compile Include="FunctionalTests\NetworkCmdletInfo\RemoveAzureReservedIPCmdletInfo.cs" />
295+
<Compile Include="FunctionalTests\NetworkCmdletInfo\RemoveAzureVirtualIPCmdletInfo.cs" />
294296
<Compile Include="FunctionalTests\NetworkCmdletInfo\SetAzureReservedIPAssociationCmdletInfo.cs" />
295297
<Compile Include="FunctionalTests\PaasCmdletInfo\GetAzureDeploymentEventBySlotCmdletInfo.cs" />
296298
<Compile Include="FunctionalTests\PaasCmdletInfo\GetAzureDeploymentEventCmdletInfo.cs" />
@@ -406,6 +408,7 @@
406408
<Compile Include="FunctionalTests\Verifiers.cs" />
407409
<Compile Include="FunctionalTests\NewAzureVmTests.cs" />
408410
<Compile Include="FunctionalTests\InternaloadbalancerTests.cs" />
411+
<Compile Include="FunctionalTests\VirtualIPTests.cs" />
409412
<Compile Include="Properties\AssemblyInfo.cs" />
410413
<Compile Include="Properties\Resource.Designer.cs">
411414
<AutoGen>True</AutoGen>
@@ -467,7 +470,9 @@
467470
<None Include="Resources\thread_VHD.csv" />
468471
<None Include="Resources\upload_VHD.csv" />
469472
<None Include="Resources\vnetconfig.netcfg" />
470-
<None Include="Resources\VnetconfigWithLocation.netcfg" />
473+
<None Include="Resources\VnetconfigWithLocation.netcfg">
474+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
475+
</None>
471476
<None Include="Resources\wrongPara_VHD.csv" />
472477
</ItemGroup>
473478
<ItemGroup>

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

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public void CreateReservedIPThenWindowsVM()
177177
Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
178178
Utilities.ExecuteAndLog(() =>
179179
{
180-
PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
180+
PersistentVM vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows, username, password, subnet);
181181
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName, reservedIPName: reservedIpName);
182182
},"Create a new windows azure vm with reserved ip.");
183183
VerifyReservedIpInUse(serviceName,input);
@@ -290,7 +290,7 @@ public void CreateWindowsVMThenAssociateReservedIP()
290290
Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
291291
Utilities.ExecuteAndLog(() =>
292292
{
293-
PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
293+
PersistentVM vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows, username, password, subnet);
294294
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
295295
}, "Create a new windows azure vm without reserved ip.");
296296

@@ -340,7 +340,7 @@ public void TestAssociateReservedIPToStageSlotIaaSFails()
340340
Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
341341
Utilities.ExecuteAndLog(() =>
342342
{
343-
PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
343+
PersistentVM vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows, username, password, subnet);
344344
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
345345
}, "Create a new windows azure vm without reserved ip.");
346346

@@ -384,7 +384,7 @@ public void CreateWindowsVMWithReservedIPThenDisassociateReservedIP()
384384
Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
385385
Utilities.ExecuteAndLog(() =>
386386
{
387-
PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
387+
PersistentVM vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows, username, password, subnet);
388388
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName, reservedIPName: reservedIpName);
389389
}, "Create a new windows azure vm with reserved ip.");
390390

@@ -431,7 +431,7 @@ public void CreateWindowsVMThenReservedExistingIP()
431431
Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
432432
Utilities.ExecuteAndLog(() =>
433433
{
434-
PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
434+
PersistentVM vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows, username, password, subnet);
435435
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
436436
}, "Create a new windows azure vm without reserved ip.");
437437

@@ -489,7 +489,7 @@ public void CreateReservedIPThenLinuxVM()
489489

490490
Utilities.ExecuteAndLog(() =>
491491
{
492-
PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Linux);
492+
PersistentVM vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Linux, username, password, subnet);
493493
vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, affinityGroup: affinityGroup, reservedIPName: reservedIpName);
494494
}, "");
495495
VerifyReservedIpInUse(serviceName, input);
@@ -649,34 +649,6 @@ private void VerifyReservedIpRemoved(string reservedIpName)
649649
Utilities.VerifyFailure(() => vmPowershellCmdlets.GetAzureReservedIP(reservedIpName), ResourceNotFoundException);
650650
}
651651

652-
private PersistentVM CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(string vmName, OS os)
653-
{
654-
string disk1 = "Disk1";
655-
int diskSize = 30;
656-
string availabilitySetName = Utilities.GetUniqueShortName("AvailSet");
657-
string img = string.Empty;
658-
659-
bool isWindowsOs = false;
660-
if (os == OS.Windows)
661-
{
662-
img = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
663-
isWindowsOs = true;
664-
}
665-
else
666-
{
667-
img = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Linux" }, false);
668-
isWindowsOs = false;
669-
}
670-
671-
PersistentVM vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, img, isWindowsOs,username, password);
672-
AddAzureDataDiskConfig azureDataDiskConfigInfo1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, diskSize, disk1, 0, HostCaching.ReadWrite.ToString());
673-
azureDataDiskConfigInfo1.Vm = vm;
674-
675-
vm = vmPowershellCmdlets.SetAzureSubnet(vm, new string[] {subnet});
676-
vm = vmPowershellCmdlets.SetAzureAvailabilitySet(availabilitySetName, vm);
677-
return vm;
678-
}
679-
680652
#endregion Helper Methods
681653
}
682654
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
16+
{
17+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
18+
19+
public class AddAzureVirtualIPCmdletInfo : CmdletsInfo
20+
{
21+
public AddAzureVirtualIPCmdletInfo(string virtualIPName, string serviceName)
22+
{
23+
this.cmdletName = Utilities.AddAzureVirtualIPCmdletName;
24+
this.cmdletParams.Add(new CmdletParam("VirtualIPName", virtualIPName));
25+
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
26+
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.NetworkCmdletInfo
16+
{
17+
using Microsoft.WindowsAzure.Commands.ServiceManagement.Test.FunctionalTests.PowershellCore;
18+
19+
public class RemoveAzureVirtualIPCmdletInfo : CmdletsInfo
20+
{
21+
public RemoveAzureVirtualIPCmdletInfo(string virtualIPName, string serviceName, bool force = true)
22+
{
23+
this.cmdletName = Utilities.RemoveAzureVirtualIPCmdletName;
24+
this.cmdletParams.Add(new CmdletParam("VirtualIPName", virtualIPName));
25+
this.cmdletParams.Add(new CmdletParam("ServiceName", serviceName));
26+
this.cmdletParams.Add(new CmdletParam("Force", force));
27+
}
28+
}
29+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,14 @@ internal ManagementOperationContext RemoveAzureReservedIP(string name, bool forc
890890
{
891891
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new RemoveAzureReservedIPCmdletInfo(name, force));
892892
}
893+
internal ManagementOperationContext AddAzureVirtualIP(string virtualIPName, string serviceName)
894+
{
895+
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new AddAzureVirtualIPCmdletInfo(virtualIPName, serviceName));
896+
}
897+
internal ManagementOperationContext RemoveAzureVirtualIP(string virtualIPName, string serviceName, bool force = true)
898+
{
899+
return RunPSCmdletAndReturnFirst<ManagementOperationContext>(new RemoveAzureVirtualIPCmdletInfo(virtualIPName, serviceName, force));
900+
}
893901

894902
#endregion
895903

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ private static string GetServiceManagementUrl(string publishSettingsFile)
168168

169169
public static void SetTestSettings()
170170
{
171+
System.Net.ServicePointManager.ServerCertificateValidationCallback +=
172+
delegate(object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
173+
System.Security.Cryptography.X509Certificates.X509Chain chain,
174+
System.Net.Security.SslPolicyErrors sslPolicyErrors)
175+
{
176+
return true; // **** Always accept
177+
};
178+
171179
vmPowershellCmdlets = new ServiceManagementCmdletTestHelper();
172180
CredentialHelper.GetTestSettings(Resource.TestSettings);
173181

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ internal class Utilities
139139
public const string RemoveAzureReservedIPCmdletName = "Remove-AzureReservedIP";
140140
public const string SetAzureReservedIPAssociationCmdletName = "Set-AzureReservedIPAssociation";
141141
public const string RemoveAzureReservedIPAssociationCmdletName = "Remove-AzureReservedIPAssociation";
142+
public const string AddAzureVirtualIPCmdletName = "Add-AzureVirtualIP";
143+
public const string RemoveAzureVirtualIPCmdletName = "Remove-AzureVirtualIP";
144+
142145

143146
// AzureRole & AzureRoleInstnace
144147
public const string GetAzureRoleCmdletName = "Get-AzureRole";
@@ -470,6 +473,34 @@ public static bool CheckRemove<Arg, Ret>(Func<Arg, Ret> fn, Arg name)
470473
}
471474
}
472475

476+
public static PersistentVM CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(string vmName, OS os, string username, string password, string subnet)
477+
{
478+
string disk1 = "Disk1";
479+
int diskSize = 30;
480+
string availabilitySetName = Utilities.GetUniqueShortName("AvailSet");
481+
string img = string.Empty;
482+
483+
bool isWindowsOs = false;
484+
if (os == OS.Windows)
485+
{
486+
img = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false);
487+
isWindowsOs = true;
488+
}
489+
else
490+
{
491+
img = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Linux" }, false);
492+
isWindowsOs = false;
493+
}
494+
495+
PersistentVM vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, img, isWindowsOs, username, password);
496+
AddAzureDataDiskConfig azureDataDiskConfigInfo1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, diskSize, disk1, 0, HostCaching.ReadWrite.ToString());
497+
azureDataDiskConfigInfo1.Vm = vm;
498+
499+
vm = vmPowershellCmdlets.SetAzureSubnet(vm, new string[] { subnet });
500+
vm = vmPowershellCmdlets.SetAzureAvailabilitySet(availabilitySetName, vm);
501+
return vm;
502+
}
503+
473504
// CheckRemove checks if 'fn(name)' exists. 'fn(name)' is usually 'Get-AzureXXXXX name'
474505
public static bool CheckRemove<Arg1, Arg2, Ret>(Func<Arg1, Arg2, Ret> fn, Arg1 name1, Arg2 name2)
475506
{

0 commit comments

Comments
 (0)