public void AddEndPointACLsonExistingDeployment() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string newAzureQuickVMName = Utilities.GetUniqueShortName(vmNamePrefix); imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows", "testvmimage" }, false); vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, newAzureQuickVMName, serviceName, imageName, username, password, locationName); PersistentVMRoleContext vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, serviceName); Assert.AreEqual(newAzureQuickVMName, vmRoleCtxt.Name, true); NetworkAclObject aclObj = vmPowershellCmdlets.NewAzureAclConfig(); vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 100, ACLAction.Deny, "172.0.0.0/8", "notes3"); AzureEndPointConfigInfo epConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 80, 80, "web", aclObj); vmPowershellCmdlets.AddEndPoint(newAzureQuickVMName, serviceName, new[] { epConfigInfo }); // Cleanup vmPowershellCmdlets.RemoveAzureVM(newAzureQuickVMName, serviceName); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, serviceName)); pass = true; }
public void ModifyingVM() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string newAzureQuickVMName = Utilities.GetUniqueShortName(vmNamePrefix); if (string.IsNullOrEmpty(imageName)) { imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows", "testvmimage" }, false); } vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, newAzureQuickVMName, serviceName, imageName, username, password, locationName); AddAzureDataDiskConfig azureDataDiskConfigInfo1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0); AddAzureDataDiskConfig azureDataDiskConfigInfo2 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk2", 1); AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(ProtocolInfo.tcp, 1433, 2000, "sql"); AddAzureDataDiskConfig[] dataDiskConfig = { azureDataDiskConfigInfo1, azureDataDiskConfigInfo2 }; vmPowershellCmdlets.AddVMDataDisksAndEndPoint(newAzureQuickVMName, serviceName, dataDiskConfig, azureEndPointConfigInfo); SetAzureDataDiskConfig setAzureDataDiskConfig1 = new SetAzureDataDiskConfig(HostCaching.ReadWrite, 0); SetAzureDataDiskConfig setAzureDataDiskConfig2 = new SetAzureDataDiskConfig(HostCaching.ReadWrite, 0); SetAzureDataDiskConfig[] diskConfig = { setAzureDataDiskConfig1, setAzureDataDiskConfig2 }; vmPowershellCmdlets.SetVMDataDisks(newAzureQuickVMName, serviceName, diskConfig); vmPowershellCmdlets.GetAzureDataDisk(newAzureQuickVMName, serviceName); // Cleanup vmPowershellCmdlets.RemoveAzureVM(newAzureQuickVMName, serviceName); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, serviceName)); pass = true; }
public PersistentVMConfigInfo(AzureVMConfigInfo vmConfig, AzureProvisioningConfigInfo provConfig, AddAzureDataDiskConfig diskConfig, AzureEndPointConfigInfo endPointConfig) { this.VmConfig = vmConfig; this.ProvConfig = provConfig; this.DiskConfig = diskConfig; this.EndPointConfig = endPointConfig; }
public AddAzureEndpointCmdletInfo(AzureEndPointConfigInfo endPointConfig) { this.cmdletName = Utilities.AddAzureEndpointCmdletName; this.cmdletParams.Add(new CmdletParam("Name", endPointConfig.EndpointName)); this.cmdletParams.Add(new CmdletParam("LocalPort", endPointConfig.EndpointLocalPort)); if (endPointConfig.EndpointPublicPort.HasValue) { this.cmdletParams.Add(new CmdletParam("PublicPort", endPointConfig.EndpointPublicPort)); } this.cmdletParams.Add(new CmdletParam("Protocol", endPointConfig.EndpointProtocol.ToString())); this.cmdletParams.Add(new CmdletParam("VM", endPointConfig.Vm)); if (endPointConfig.ParamSet == AzureEndPointConfigInfo.ParameterSet.LoadBalanced) { this.cmdletParams.Add(new CmdletParam("LBSetName", endPointConfig.LBSetName)); } else if (endPointConfig.ParamSet == AzureEndPointConfigInfo.ParameterSet.LoadBalancedProbe) { this.cmdletParams.Add(new CmdletParam("LBSetName", endPointConfig.LBSetName)); this.cmdletParams.Add(new CmdletParam("ProbePort", endPointConfig.ProbePort)); this.cmdletParams.Add(new CmdletParam("ProbeProtocol", endPointConfig.ProbeProtocol.ToString())); this.cmdletParams.Add(new CmdletParam("ProbePath", endPointConfig.ProbePath)); if (endPointConfig.ProbeInterval.HasValue) { this.cmdletParams.Add(new CmdletParam("ProbeIntervalInSeconds", endPointConfig.ProbeInterval)); } if (endPointConfig.ProbeTimeout.HasValue) { this.cmdletParams.Add(new CmdletParam("ProbeTimeoutInSeconds", endPointConfig.ProbeTimeout)); } } }
public SetAzureEndpointCmdletInfo(AzureEndPointConfigInfo endPointConfig) { this.cmdletName = Utilities.SetAzureEndpointCmdletName; this.cmdletParams.Add(new CmdletParam("Name", endPointConfig.EndpointName)); this.cmdletParams.Add(new CmdletParam("LocalPort", endPointConfig.EndpointLocalPort)); if (endPointConfig.EndpointPublicPort.HasValue) { this.cmdletParams.Add(new CmdletParam("PublicPort", endPointConfig.EndpointPublicPort)); } this.cmdletParams.Add(new CmdletParam("Protocol", endPointConfig.EndpointProtocol.ToString())); this.cmdletParams.Add(new CmdletParam("VM", endPointConfig.Vm)); if (endPointConfig.Acl != null) { this.cmdletParams.Add(new CmdletParam("ACL", endPointConfig.Acl)); } if (endPointConfig.DirectServerReturn) { this.cmdletParams.Add(new CmdletParam("DirectServerReturn", endPointConfig.DirectServerReturn)); } if (!string.IsNullOrEmpty(endPointConfig.LoadBalancerDistribution)) { this.cmdletParams.Add(new CmdletParam("LoadBalancerDistribution", endPointConfig.LoadBalancerDistribution)); } if (!string.IsNullOrEmpty(endPointConfig.VirtualIPName)) { this.cmdletParams.Add(new CmdletParam("VirtualIPName", endPointConfig.VirtualIPName)); } }
public PersistentVM SetAzureEndPoint(AzureEndPointConfigInfo endPointConfig) { if (null != endPointConfig) { return(RunPSCmdletAndReturnFirst <PersistentVM>(new SetAzureEndpointCmdletInfo(endPointConfig))); } return(null); }
public AddAzureEndpointCmdletInfo(AzureEndPointConfigInfo endPointConfig) { this.cmdletName = Utilities.AddAzureEndpointCmdletName; this.cmdletParams.Add(new CmdletParam("Name", endPointConfig.EndpointName)); this.cmdletParams.Add(new CmdletParam("LocalPort", endPointConfig.EndpointLocalPort)); if (endPointConfig.EndpointPublicPort.HasValue) { this.cmdletParams.Add(new CmdletParam("PublicPort", endPointConfig.EndpointPublicPort)); } if (endPointConfig.Acl != null) { this.cmdletParams.Add(new CmdletParam("ACL", endPointConfig.Acl)); } this.cmdletParams.Add(new CmdletParam("Protocol", endPointConfig.EndpointProtocol.ToString())); this.cmdletParams.Add(new CmdletParam("VM", endPointConfig.Vm)); if (endPointConfig.ParamSet == AzureEndPointConfigInfo.ParameterSet.DefaultProbe) { this.cmdletParams.Add(new CmdletParam("LBSetName", endPointConfig.LBSetName)); this.cmdletParams.Add(new CmdletParam("DefaultProbe")); } if (endPointConfig.ParamSet == AzureEndPointConfigInfo.ParameterSet.LoadBalancedNoProbe) { this.cmdletParams.Add(new CmdletParam("LBSetName", endPointConfig.LBSetName)); this.cmdletParams.Add(new CmdletParam("NoProbe")); } else if (endPointConfig.ParamSet == AzureEndPointConfigInfo.ParameterSet.CustomProbe) { this.cmdletParams.Add(new CmdletParam("LBSetName", endPointConfig.LBSetName)); this.cmdletParams.Add(new CmdletParam("ProbePort", endPointConfig.ProbePort)); this.cmdletParams.Add(new CmdletParam("ProbeProtocol", endPointConfig.ProbeProtocol.ToString())); if ("http" == endPointConfig.ProbeProtocol.ToString()) { this.cmdletParams.Add(new CmdletParam("ProbePath", endPointConfig.ProbePath)); } if (endPointConfig.ProbeInterval.HasValue) { this.cmdletParams.Add(new CmdletParam("ProbeIntervalInSeconds", endPointConfig.ProbeInterval)); } if (endPointConfig.ProbeTimeout.HasValue) { this.cmdletParams.Add(new CmdletParam("ProbeTimeoutInSeconds", endPointConfig.ProbeTimeout)); } } if (endPointConfig.DirectServerReturn) { this.cmdletParams.Add(new CmdletParam("DirectServerReturn", endPointConfig.DirectServerReturn)); } if (!string.IsNullOrEmpty(endPointConfig.InternalLoadBalancerName)) { this.cmdletParams.Add(new CmdletParam("InternalLoadBalancerName", endPointConfig.InternalLoadBalancerName)); } }
public PersistentVM AddAzureEndPoint(AzureEndPointConfigInfo endPointConfig) { AddAzureEndpointCmdletInfo addAzureEndPointCmdletInfo = new AddAzureEndpointCmdletInfo(endPointConfig); WindowsAzurePowershellCmdlet azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(addAzureEndPointCmdletInfo); Collection<PSObject> result = azurePowershellCmdlet.Run(); if (result.Count == 1) { return (PersistentVM)result[0].BaseObject; } return null; }
private static PersistentVM CreateVMWithEndpointDataDiskAndPublicIP(string vmName, string endpointName, string disklabel1, string publicIpName, string serviceName, int localPort, int publicport) { var vm1 = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, true, username, password); var endpointConfiginput = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, TCP_PROTOCAL, localPort, publicport, endpointName, serviceName: serviceName); endpointConfiginput.Vm = vm1; vm1 = vmPowershellCmdlets.AddAzureEndPoint(endpointConfiginput); var dataDiskConfig1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 128, disklabel1, 0); dataDiskConfig1.Vm = vm1; vm1 = vmPowershellCmdlets.AddAzureDataDisk(dataDiskConfig1); vm1 = (PersistentVM)vmPowershellCmdlets.SetAzurePublicIp(publicIpName, vm1); return(vm1); }
public SetAzureLoadBalancedEndpointCmdletInfo(AzureEndPointConfigInfo endPointConfig, AzureEndPointConfigInfo.ParameterSet paramset) { this.cmdletName = Utilities.SetAzureLoadBalancedEndpointCmdletName; this.cmdletParams.Add(new CmdletParam("ServiceName", endPointConfig.ServiceName)); this.cmdletParams.Add(new CmdletParam("LocalPort", endPointConfig.EndpointLocalPort)); if (endPointConfig.EndpointPublicPort.HasValue) { this.cmdletParams.Add(new CmdletParam("PublicPort", endPointConfig.EndpointPublicPort)); } this.cmdletParams.Add(new CmdletParam("Protocol", endPointConfig.EndpointProtocol.ToString())); this.cmdletParams.Add(new CmdletParam("LBSetName", endPointConfig.LBSetName)); switch (paramset) { case AzureEndPointConfigInfo.ParameterSet.CustomProbe: switch (endPointConfig.ProbeProtocol.ToString()) { case "tcp": this.cmdletParams.Add(new CmdletParam("ProbeProtocolTCP")); break; case "http": this.cmdletParams.Add(new CmdletParam("ProbeProtocolHTTP")); this.cmdletParams.Add(new CmdletParam("ProbePath", endPointConfig.ProbePath)); break; default: break; } break; case AzureEndPointConfigInfo.ParameterSet.DefaultProbe: case AzureEndPointConfigInfo.ParameterSet.LoadBalancedNoProbe: default: break; } if (endPointConfig.Acl != null) { this.cmdletParams.Add(new CmdletParam("ACL", endPointConfig.Acl)); } if (endPointConfig.DirectServerReturn) { this.cmdletParams.Add(new CmdletParam("DirectServerReturn", endPointConfig.DirectServerReturn)); } }
public SetAzureLoadBalancedEndpointCmdletInfo(AzureEndPointConfigInfo endPointConfig, AzureEndPointConfigInfo.ParameterSet paramset) { this.cmdletName = Utilities.SetAzureLoadBalancedEndpointCmdletName; this.cmdletParams.Add(new CmdletParam("ServiceName", endPointConfig.ServiceName)); this.cmdletParams.Add(new CmdletParam("LocalPort", endPointConfig.EndpointLocalPort)); if (endPointConfig.EndpointPublicPort.HasValue) { this.cmdletParams.Add(new CmdletParam("PublicPort", endPointConfig.EndpointPublicPort)); } this.cmdletParams.Add(new CmdletParam("Protocol", endPointConfig.EndpointProtocol.ToString())); this.cmdletParams.Add(new CmdletParam("LBSetName", endPointConfig.LBSetName)); switch (paramset) { case AzureEndPointConfigInfo.ParameterSet.CustomProbe : switch (endPointConfig.ProbeProtocol.ToString()) { case "tcp": this.cmdletParams.Add(new CmdletParam("ProbeProtocolTCP")); break; case "http": this.cmdletParams.Add(new CmdletParam("ProbeProtocolHTTP")); this.cmdletParams.Add(new CmdletParam("ProbePath", endPointConfig.ProbePath)); break; default: break; } break; case AzureEndPointConfigInfo.ParameterSet.DefaultProbe : case AzureEndPointConfigInfo.ParameterSet.LoadBalancedNoProbe : default : break; } if (endPointConfig.Acl != null) { this.cmdletParams.Add(new CmdletParam("ACL", endPointConfig.Acl)); } if (endPointConfig.DirectServerReturn) { this.cmdletParams.Add(new CmdletParam("DirectServerReturn", endPointConfig.DirectServerReturn)); } }
public void CreateDeploymentWithILBSubnetAndAddILBEndpoint() { try { string ilbName = Utilities.GetUniqueShortName("ILB"); string vmName = Utilities.GetUniqueShortName(vmNamePrefix); string endpointName = Utilities.GetUniqueShortName("endpoint"); var ilbConfig = vmPowershellCmdlets.NewAzureInternalLoadBalancerConfig(ilbName, subNet); Utilities.ExecuteAndLog(() => { var vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, true, username, password, false); vm = vmPowershellCmdlets.SetAzureSubnet(vm, new string[] { subNet }); vmPowershellCmdlets.NewAzureVMWithInternalLoadBalancer(serviceName, new[] { vm }, ilbConfig, vnetName, locationName); }, string.Format("Create a Vm with Internal load balancer {0}", ilbName)); ilbConfig.SubnetName = subNet; VerifyInternalLoadBalancer("Verify Internal Load Balancer", ilbConfig); var endpointConfig = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, TCP_PROTOCAL, LOCAL_PORT_NUMBER1, PUBLIC_PORT_NUMBER1, endpointName, internalLoadBalancer: ilbName); Utilities.ExecuteAndLog(() => { var vmRoleContext = vmPowershellCmdlets.GetAzureVM(vmName, serviceName); endpointConfig.Vm = vmRoleContext.VM; var vm = vmPowershellCmdlets.AddAzureEndPoint(endpointConfig); vmPowershellCmdlets.UpdateAzureVM(vmName, serviceName, vm); }, "Add Azure endpoint to the vm"); VerifyEndpoint("Verify Azure endpoint", vmName, endpointConfig); VerifyDeployment("Verify internal load balancer name and vnet name of the deployment", ilbName, vnetName); ilbConfig.IPAddress = ipAddress; VerifyInternalLoadBalancer("Verify ILB name, subnet, ip address of the ILB", ilbConfig); pass = true; } catch (Exception ex) { pass = false; Console.WriteLine(ex.InnerException.ToString()); throw ex; } }
public void ILBonExistingDeploymentWithVnet() { try { string ilbName = Utilities.GetUniqueShortName("ILB"); string vmName = Utilities.GetUniqueShortName(vmNamePrefix); string endpointName = Utilities.GetUniqueShortName("endpoint"); IPAddress ipAddress = IPAddress.Parse(GetAvailableIpAddressinVnet()); string lbsetName = Utilities.GetUniqueShortName("LbSet"); var ilbConfig = vmPowershellCmdlets.NewAzureInternalLoadBalancerConfig(ilbName, subNet, ipAddress); Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, vmName, serviceName, imageName, username, password, locationName, InstanceSize.Small.ToString(), false, null, vnetName); }, "Create a Vm using New-AzureQuickVM"); vmPowershellCmdlets.AddAzureInternalLoadBalancer(ilbName, serviceName, subNet, ipAddress); ilbConfig.SubnetName = subNet; ilbConfig.IPAddress = ipAddress.ToString(); VerifyInternalLoadBalancer("Verify Internal Load Balancer", ilbConfig); var endpointConfig = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, TCP_PROTOCAL, LOCAL_PORT_NUMBER1, PUBLIC_PORT_NUMBER1, endpointName, internalLoadBalancer: ilbName); Utilities.ExecuteAndLog(() => { var vmRoleContext = vmPowershellCmdlets.GetAzureVM(vmName, serviceName); endpointConfig.Vm = vmRoleContext.VM; var vm = vmPowershellCmdlets.AddAzureEndPoint(endpointConfig); vmPowershellCmdlets.UpdateAzureVM(vmName, serviceName, vm); }, "Add Azure endpoint to the vm"); VerifyEndpoint("Verify Azure endpoint", vmName, endpointConfig); pass = true; } catch (Exception ex) { pass = false; Console.WriteLine(ex.InnerException.ToString()); throw ex; } }
public void CreateDeploymentWithILBIPaddressAndSetILBEndpoint() { try { string ilbName = Utilities.GetUniqueShortName("ILB"); string vmName = Utilities.GetUniqueShortName(vmNamePrefix); string endpointName = Utilities.GetUniqueShortName("endpoint"); IPAddress ipAddress = IPAddress.Parse(GetAvailableIpAddressinVnet()); string lbsetName = Utilities.GetUniqueShortName("LbSet"); var ilbConfig = vmPowershellCmdlets.NewAzureInternalLoadBalancerConfig(ilbName, subNet, ipAddress); Utilities.ExecuteAndLog(() => { var vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, true, username, password, false); var endpointConfiginput = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.LoadBalancedNoProbe, TCP_PROTOCAL, LOCAL_PORT_NUMBER1, PUBLIC_PORT_NUMBER1, endpointName, lbsetName, null, false, ilbName); endpointConfiginput.Vm = vm; vm = vmPowershellCmdlets.AddAzureEndPoint(endpointConfiginput); vmPowershellCmdlets.NewAzureVMWithInternalLoadBalancer(serviceName, new[] { vm }, ilbConfig, vnetName, locationName); }, string.Format("Create a Vm with Internal load balancer {0}", ilbName)); ilbConfig.SubnetName = subNet; ilbConfig.IPAddress = ipAddress.ToString(); VerifyInternalLoadBalancer("Verify Internal Load Balancer", ilbConfig); var loadBalancerEndpointConfig = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.LoadBalancedNoProbe, UDP_PROTOCAL, LOCAL_PORT_NUMBER2, PUBLIC_PORT_NUMBER2, endpointName, lbsetName, internalLoadBalancer: ilbName, serviceName: serviceName); vmPowershellCmdlets.SetAzureLoadBalancedEndPoint(loadBalancerEndpointConfig, AzureEndPointConfigInfo.ParameterSet.LoadBalancedNoProbe); VerifyInternalLoadBalancer("Verify Internal Load Balancer", ilbConfig); VerifyEndpoint("Verify Azure endpoint", vmName, loadBalancerEndpointConfig); VerifyDeployment("Verify internal load balancer name and vnet name of the deployment", ilbName, vnetName); ilbConfig.IPAddress = ipAddress.ToString(); VerifyInternalLoadBalancer("Verify ILB name, subnet, ip address of the ILB", ilbConfig); pass = true; } catch (Exception ex) { pass = false; Console.WriteLine(ex.InnerException.ToString()); throw ex; } }
public void AddEndPointACLsWithNewDeployment() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix); string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix); if (string.IsNullOrEmpty(imageName)) { imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows", "testvmimage" }, false); } vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName); NetworkAclObject aclObj = vmPowershellCmdlets.NewAzureAclConfig(); vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 100, ACLAction.Permit, "172.0.0.0/8", "notes1"); vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 200, ACLAction.Deny, "10.0.0.0/8", "notes2"); AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName); AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.ExtraSmall, imageName); AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0); AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.DefaultProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", aclObj, true); PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1); PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2); PersistentVM[] VMs = { persistentVM1, persistentVM2 }; vmPowershellCmdlets.NewAzureVM(serviceName, VMs); // Cleanup vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName); vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, serviceName); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName)); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, serviceName)); pass = true; }
private void VerifyEndpoint(string verificationMessage, string vmName, AzureEndPointConfigInfo endpointConfig) { Utilities.ExecuteAndLog(() => { var vmRole = vmPowershellCmdlets.GetAzureVM(vmName, serviceName); var endpointCollection = vmPowershellCmdlets.GetAzureEndPoint(vmRole.VM); var inputEndpointCollection = from c in endpointCollection where c.Name.Equals(endpointConfig.EndpointName) select c; var endpointConfigInfo = inputEndpointCollection.First(); Console.WriteLine("Endpoint Configuraion Properties:"); Utilities.PrintContext(endpointConfigInfo); ipAddress = endpointConfigInfo.Vip; Console.WriteLine("\n Verifing recquired properties"); Utilities.LogAssert(() => Assert.AreEqual(string.IsNullOrEmpty(endpointConfig.LBSetName) ? null : endpointConfig.LBSetName, endpointConfigInfo.LBSetName), "LBSetName"); Utilities.LogAssert(() => Assert.AreEqual(endpointConfig.EndpointLocalPort, endpointConfig.EndpointLocalPort), "EndpointLocalPort"); Utilities.LogAssert(() => Assert.AreEqual(endpointConfig.EndpointName, endpointConfig.EndpointName), "EndpointName"); Utilities.LogAssert(() => Assert.AreEqual(endpointConfig.EndpointProtocol, endpointConfig.EndpointProtocol), "EndpointProtocol"); Utilities.LogAssert(() => Assert.AreEqual(endpointConfig.InternalLoadBalancerName, endpointConfig.InternalLoadBalancerName), "InternalLoadBalancerName"); }, verificationMessage); }
public SetAzureEndpointCmdletInfo(AzureEndPointConfigInfo endPointConfig) { this.cmdletName = Utilities.SetAzureEndpointCmdletName; this.cmdletParams.Add(new CmdletParam("Name", endPointConfig.EndpointName)); this.cmdletParams.Add(new CmdletParam("LocalPort", endPointConfig.EndpointLocalPort)); if (endPointConfig.EndpointPublicPort.HasValue) { this.cmdletParams.Add(new CmdletParam("PublicPort", endPointConfig.EndpointPublicPort)); } this.cmdletParams.Add(new CmdletParam("Protocol", endPointConfig.EndpointProtocol.ToString())); this.cmdletParams.Add(new CmdletParam("VM", endPointConfig.Vm)); if (endPointConfig.Acl != null) { this.cmdletParams.Add(new CmdletParam("ACL", endPointConfig.Acl)); } if (endPointConfig.DirectServerReturn) { this.cmdletParams.Add(new CmdletParam("DirectServerReturn", endPointConfig.DirectServerReturn)); } }
public void AdvancedProvisioning() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix); string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix); if (string.IsNullOrEmpty(imageName)) { imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows", "testvmimage" }, false); } vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName); AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName); AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.ExtraSmall, imageName); AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0); AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null); PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1); PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2); PersistentVM[] VMs = { persistentVM1, persistentVM2 }; vmPowershellCmdlets.NewAzureVM(serviceName, VMs); // Cleanup vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName); vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, serviceName); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName)); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, serviceName)); pass = true; }
public void SetEndPoint(string vmName, string serviceName, AzureEndPointConfigInfo endPointConfig) { endPointConfig.Vm = GetAzureVM(vmName, serviceName).VM; UpdateAzureVM(vmName, serviceName, SetAzureEndPoint(endPointConfig)); }
public void RemoveAndCreateDeploymentWithReservedIP() { try { vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null); string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix); string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix); if (string.IsNullOrEmpty(imageName)) { imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); } AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName); AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.Small, imageName); AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0); AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null); PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1); PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2); // Create a new deployment vmPowershellCmdlets.NewAzureVM(svcNameLoc, new [] {persistentVM1}, locationName); // Reserve the ip of the deployment vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName1, svcNameLoc, svcNameLoc, rsvIPLabel); // Get the deployment and verify var deploymentReturned = vmPowershellCmdlets.GetAzureDeployment(svcNameLoc); Utilities.PrintContext(deploymentReturned); // Verify the reserved ip var reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0]; Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1, deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName, deploymentReturned.ServiceName); // Remove the VMs and verify Console.WriteLine("\nRemoving VMs...\n"); vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, svcNameLoc); // Verify the reserved ip reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0]; Verify.AzureReservedIPNotInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1); // Remove the service Console.WriteLine("\nRemoving the service...\n"); vmPowershellCmdlets.RemoveAzureService(svcNameLoc); // Verify the reserved ip reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0]; Verify.AzureReservedIPNotInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1); // Re-deploy the VM and verify vmPowershellCmdlets.NewAzureVMWithReservedIP(svcNameAG, new[] { persistentVM2 },rsvIpName1, affName1); // Get the deployment and verify deploymentReturned = vmPowershellCmdlets.GetAzureDeployment(svcNameAG); Utilities.PrintContext(deploymentReturned); // Verify the reserved ip reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0]; Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1, deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName, deploymentReturned.ServiceName); // Remove the VM vmPowershellCmdlets.RemoveAzureService(svcNameAG); // Remove the reserved IP and verify vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1); Utilities.VerifyFailure( () => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException); pass = true; } catch (Exception e) { Console.WriteLine(e); throw; } }
public void TestVirtualIPLifecycle() { try { string dnsName = Utilities.GetUniqueShortName("Dns"); string vmName = Utilities.GetUniqueShortName(vmNamePrefix); string vipName = Utilities.GetUniqueShortName("Vip"); string endpointName = Utilities.GetUniqueShortName("Endpoint"); // Create a new VM with the reserved ip. DnsServer dns = null; Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS"); PersistentVM vm = null; Utilities.ExecuteAndLog(() => { vm = Utilities.CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows, username, password, subnet); vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName); }, "Create a new windows azure vm without reserved ip."); Utilities.ExecuteAndLog(() => vmPowershellCmdlets.AddAzureVirtualIP(vipName, serviceName), "Adding Azure VirtualIP"); var deployment = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production); var retrievedVip = deployment.VirtualIPs.FirstOrDefault(vip => string.Equals(vip.Name, vipName)); Assert.IsNotNull(retrievedVip); Assert.IsTrue(string.IsNullOrEmpty(retrievedVip.Address)); AzureEndPointConfigInfo endpointInfo = new AzureEndPointConfigInfo { EndpointName = endpointName, EndpointProtocol = ProtocolInfo.tcp, EndpointLocalPort = 1000, EndpointPublicPort = 444, VirtualIPName = vipName, Vm = vm }; var updatedVM = vmPowershellCmdlets.AddAzureEndPoint(endpointInfo); vmPowershellCmdlets.UpdateAzureVM(vmName, serviceName, updatedVM); deployment = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production); retrievedVip = deployment.VirtualIPs.FirstOrDefault(vip => string.Equals(vip.Name, vipName)); Assert.IsNotNull(retrievedVip); Assert.IsTrue(!string.IsNullOrEmpty(retrievedVip.Address)); AzureEndPointConfigInfo removeEndpointInfo = new AzureEndPointConfigInfo { EndpointName = endpointName, EndpointProtocol = ProtocolInfo.tcp, EndpointLocalPort = 1000, EndpointPublicPort = 444, VirtualIPName = vipName, Vm = updatedVM }; updatedVM = vmPowershellCmdlets.RemoveAzureEndPoint(endpointName, updatedVM); vmPowershellCmdlets.UpdateAzureVM(vmName, serviceName, updatedVM); deployment = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production); retrievedVip = deployment.VirtualIPs.FirstOrDefault(vip => string.Equals(vip.Name, vipName)); Assert.IsNotNull(retrievedVip); Assert.IsTrue(string.IsNullOrEmpty(retrievedVip.Address)); Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVirtualIP(vipName, serviceName), "Adding Azure VirtualIP"); deployment = vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production); retrievedVip = deployment.VirtualIPs.FirstOrDefault(vip => string.Equals(vip.Name, vipName)); Assert.IsNull(retrievedVip); cleanupIfPassed = false; vmPowershellCmdlets.RemoveAzureDeployment(serviceName, "Production", true); pass = true; } catch (Exception ex) { pass = false; Console.WriteLine(ex.ToString()); throw; } }
public void CreateDeploymentWithReservedIPNegativeTest() { try { string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix); string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix); if (string.IsNullOrEmpty(imageName)) { imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); } var azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall.ToString(), imageName); var azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.Small.ToString(), imageName); var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); var azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0); var azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null); var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); var persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, null); PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1); PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2); PersistentVM[] VMs = { persistentVM1, persistentVM2 }; // AG1 on location 1 vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null); // AG2 on location 2 var anotherLocation = GetLocation("PersistentVMRole", locationName); vmPowershellCmdlets.NewAzureAffinityGroup(affName2, anotherLocation.Name, null, null); // Reserve an ip on AG1 vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName2); var rsvIPreturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0]; Verify.AzureReservedIPNotInUse(rsvIPreturned, rsvIpName1, null, affName2); // Try to create a new deployment with AG2 and the reserved IP Utilities.VerifyFailure( () => vmPowershellCmdlets.NewAzureVMWithReservedIP(svcNameAG, VMs, rsvIpName1, affName1), BadRequestException); // Create a new deployment with location 2, and then reserved the IP of it vmPowershellCmdlets.NewAzureVM(svcNameLoc, VMs, locationName); Utilities.VerifyFailure( () => vmPowershellCmdlets.NewAzureReservedIP(rsvIpName2, affName2, svcNameLoc, svcNameLoc), BadRequestException); // Remove the reserved IP and verify vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1); Utilities.VerifyFailure( () => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException); pass = true; } catch (Exception e) { Console.WriteLine(e); throw; } }
public void RemoveAzureReservedIPWithDeploymentTest() { try { vmPowershellCmdlets.NewAzureAffinityGroup(affName1, locationName, null, null); string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix); if (string.IsNullOrEmpty(imageName)) { imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); } var azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall.ToString(), imageName); var azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); var azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0); var azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null); var persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1); //PersistentVM[] VMs = { persistentVM1, persistentVM2 }; PersistentVM[] VMs = { persistentVM1 }; // Create a new deployment vmPowershellCmdlets.NewAzureVMWithAG(svcNameAG, VMs, affName1); // Reserve the ip of the deployment vmPowershellCmdlets.NewAzureReservedIP(rsvIpName1, affName1, svcNameAG, svcNameAG, rsvIPLabel); // Get the deployment and verify var deploymentReturned = vmPowershellCmdlets.GetAzureDeployment(svcNameAG); // Verify the reserved ip var reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0]; Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1, deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName, deploymentReturned.ServiceName); // Stop-deallocate the first VM and verify reserved ip Utilities.VerifyFailure(() => vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1), BadRequestException); vmPowershellCmdlets.StopAzureVM(newAzureVM1Name, svcNameAG, false, true); // Verify the reserved ip reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0]; Verify.AzureReservedIPInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1, deploymentReturned.VirtualIPs[0].Address, deploymentReturned.DeploymentName, deploymentReturned.ServiceName); // Stop-deallocate the second VM and verify reserved ip Utilities.VerifyFailure(() => vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1), BadRequestException); // Remove all VMs and service and verify reserved ip vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, svcNameAG, true); // Verify the reserved ip reservedIPReturned = vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1)[0]; Verify.AzureReservedIPNotInUse(reservedIPReturned, rsvIpName1, rsvIPLabel, affName1); // Remove the reserved IP and verify vmPowershellCmdlets.RemoveAzureReservedIP(rsvIpName1); Utilities.VerifyFailure( () => vmPowershellCmdlets.GetAzureReservedIP(rsvIpName1), ResourceNotFoundException); pass = true; } catch (Exception e) { Console.WriteLine(e); throw; } }
public void DevTestProvisioning() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix); //Find a Windows VM Image imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); //vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName); //Specify a small Windows image, with username and pw AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName); AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 80, 80, "Http"); PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, null, azureEndPointConfigInfo); PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1); //Add all the endpoints that are added by the Dev Test feature in Azure Tools azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 443, 443, "Https"); azureEndPointConfigInfo.Vm = persistentVM1; persistentVM1 = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo); azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 1433, 1433, "MSSQL"); azureEndPointConfigInfo.Vm = persistentVM1; persistentVM1 = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo); azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 8172, 8172, "WebDeploy"); azureEndPointConfigInfo.Vm = persistentVM1; persistentVM1 = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo); // Make a storage account named "devtestNNNNN" string storageAcctName = "devtest" + new Random().Next(10000, 99999); vmPowershellCmdlets.NewAzureStorageAccount(storageAcctName, locationName); vmPowershellCmdlets.SetAzureSubscription(defaultAzureSubscription.SubscriptionName, storageAcctName); // When making a new azure VM, you can't specify a location if you want to use the existing service PersistentVM[] VMs = { persistentVM1 }; vmPowershellCmdlets.NewAzureVM(serviceName, VMs, locationName); var svcDeployment = vmPowershellCmdlets.GetAzureDeployment(serviceName); Assert.AreEqual(svcDeployment.ServiceName, serviceName); var vmDeployment = vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName); Assert.AreEqual(vmDeployment.InstanceName, newAzureVM1Name); // Cleanup vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName)); //TODO: Is failing for me because of active containers //Utilities.RetryActionUntilSuccess(() => vmPowershellCmdlets.RemoveAzureStorageAccount(storageAcctName), "in use", 10, 30); ServiceManagementTest.SetDefaultStorage(); pass = true; }
internal void AddVMDataDisksAndEndPoint(string vmName, string serviceName, AddAzureDataDiskConfig[] dataDiskConfig, AzureEndPointConfigInfo endPointConfig) { AddVMDataDisks(vmName, serviceName, dataDiskConfig); AddEndPoint(vmName, serviceName, new [] {endPointConfig}); }
public PersistentVM SetAzureEndPoint(AzureEndPointConfigInfo endPointConfig) { if (null != endPointConfig) { SetAzureEndpointCmdletInfo setAzureEndpointCmdletInfo = SetAzureEndpointCmdletInfo.BuildNoLoadBalancedCmdletInfo(endPointConfig); WindowsAzurePowershellCmdlet azurePowershellCmdlet = new WindowsAzurePowershellCmdlet(setAzureEndpointCmdletInfo); Collection<PSObject> result = azurePowershellCmdlet.Run(); if (result.Count == 1) { return (PersistentVM)result[0].BaseObject; } } return null; }
public void AzureEndpointTest() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string ep1Name = "tcp1"; int ep1LocalPort = 60010; int ep1PublicPort = 60011; string ep1LBSetName = "lbset1"; int ep1ProbePort = 60012; string ep1ProbePath = string.Empty; int? ep1ProbeInterval = 7; int? ep1ProbeTimeout = null; NetworkAclObject ep1AclObj = null; bool ep1DirectServerReturn = false; string ep2Name = "tcp2"; int ep2LocalPort = 60020; int ep2PublicPort = 60021; int ep2LocalPortChanged = 60030; int ep2PublicPortChanged = 60031; string ep2LBSetName = "lbset2"; int ep2ProbePort = 60022; string ep2ProbePath = @"/"; int? ep2ProbeInterval = null; int? ep2ProbeTimeout = 32; NetworkAclObject ep2AclObj = null; bool ep2DirectServerReturn = false; AzureEndPointConfigInfo ep1Info = new AzureEndPointConfigInfo( AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, ep1LocalPort, ep1PublicPort, ep1Name, ep1LBSetName, ep1ProbePort, ProtocolInfo.tcp, ep1ProbePath, ep1ProbeInterval, ep1ProbeTimeout, ep1AclObj, ep1DirectServerReturn); AzureEndPointConfigInfo ep2Info = new AzureEndPointConfigInfo( AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, ep2LocalPort, ep2PublicPort, ep2Name, ep2LBSetName, ep2ProbePort, ProtocolInfo.http, ep2ProbePath, ep2ProbeInterval, ep2ProbeTimeout, ep2AclObj, ep2DirectServerReturn); string defaultVm = Utilities.GetUniqueShortName(vmNamePrefix); Assert.IsNull(vmPowershellCmdlets.GetAzureVM(defaultVm, serviceName)); vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, defaultVm, serviceName, imageName, username, password, locationName); Console.WriteLine("Service Name: {0} is created.", serviceName); try { foreach (AzureEndPointConfigInfo.ParameterSet p in Enum.GetValues(typeof(AzureEndPointConfigInfo.ParameterSet))) { string pSetName = Enum.GetName(typeof(AzureEndPointConfigInfo.ParameterSet), p); Console.WriteLine("--Begin Endpoint Test with '{0}' parameter set.", pSetName); ep1Info.ParamSet = p; ep2Info.ParamSet = p; ep1Info.Acl = vmPowershellCmdlets.NewAzureAclConfig(); ep2Info.Acl = vmPowershellCmdlets.NewAzureAclConfig(); ep2Info.EndpointLocalPort = ep2LocalPort; ep2Info.EndpointPublicPort = ep2PublicPort; // Add two new endpoints Console.WriteLine("-----Add 2 new endpoints."); vmPowershellCmdlets.AddEndPoint(defaultVm, serviceName, new[] { ep1Info, ep2Info }); // Add-AzureEndpoint with Get-AzureVM and Update-AzureVm CheckEndpoint(defaultVm, serviceName, new[] { ep1Info, ep2Info }); // Change the endpoint if (p == AzureEndPointConfigInfo.ParameterSet.NoLB) { Console.WriteLine("-----Change the second endpoint."); ep2Info.EndpointLocalPort = ep2LocalPortChanged; ep2Info.EndpointPublicPort = ep2PublicPortChanged; vmPowershellCmdlets.SetEndPoint(defaultVm, serviceName, ep2Info); // Set-AzureEndpoint with Get-AzureVM and Update-AzureVm CheckEndpoint(defaultVm, serviceName, new[] { ep2Info }); } else { Console.WriteLine("-----Change the second endpoint."); ep2Info.ServiceName = serviceName; ep2Info.EndpointLocalPort = ep2LocalPortChanged; ep2Info.EndpointPublicPort = ep2PublicPortChanged; vmPowershellCmdlets.SetLBEndPoint(defaultVm, serviceName, ep2Info, p); CheckEndpoint(defaultVm, serviceName, new[] { ep2Info }); } // Remove Endpoint Console.WriteLine("-----Remove endpoints."); vmPowershellCmdlets.RemoveEndPoint(defaultVm, serviceName, new[] { ep1Name, ep2Name }); // Remove-AzureEndpoint CheckEndpointRemoved(defaultVm, serviceName, new[] { ep1Info, ep2Info }); Console.WriteLine("Endpoint Test passed with '{0}' parameter set.", pSetName); } pass = true; } catch (Exception e) { pass = false; Assert.Fail("Exception occurred: {0}", e.ToString()); } }
public void AddEndPointACLsonExistingDeployment() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string newAzureQuickVMName = Utilities.GetUniqueShortName(vmNamePrefix); imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, newAzureQuickVMName, serviceName, imageName, username, password, locationName); PersistentVMRoleContext vmRoleCtxt = vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, serviceName); Assert.AreEqual(newAzureQuickVMName, vmRoleCtxt.Name, true); NetworkAclObject aclObj = vmPowershellCmdlets.NewAzureAclConfig(); vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 100, ACLAction.Deny, "172.0.0.0/8", "notes3"); AzureEndPointConfigInfo epConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 80, 80, "web", aclObj); vmPowershellCmdlets.AddEndPoint(newAzureQuickVMName, serviceName, new[] { epConfigInfo }); // Cleanup vmPowershellCmdlets.RemoveAzureVM(newAzureQuickVMName, serviceName); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, serviceName)); pass = true; }
internal void AddVMDataDisksAndEndPoint(string vmName, string serviceName, AddAzureDataDiskConfig[] dataDiskConfig, AzureEndPointConfigInfo endPointConfig) { AddVMDataDisks(vmName, serviceName, dataDiskConfig); AddEndPoint(vmName, serviceName, new [] { endPointConfig }); }
public PersistentVM AddAzureEndPoint(AzureEndPointConfigInfo endPointConfig) { return(RunPSCmdletAndReturnFirst <PersistentVM>(new AddAzureEndpointCmdletInfo(endPointConfig))); }
public void ModifyingVM() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string newAzureQuickVMName = Utilities.GetUniqueShortName(vmNamePrefix); if (string.IsNullOrEmpty(imageName)) imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, newAzureQuickVMName, serviceName, imageName, username, password, locationName); AddAzureDataDiskConfig azureDataDiskConfigInfo1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0); AddAzureDataDiskConfig azureDataDiskConfigInfo2 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk2", 1); AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.NoLB, ProtocolInfo.tcp, 1433, 2000, "sql"); AddAzureDataDiskConfig[] dataDiskConfig = { azureDataDiskConfigInfo1, azureDataDiskConfigInfo2 }; vmPowershellCmdlets.AddVMDataDisksAndEndPoint(newAzureQuickVMName, serviceName, dataDiskConfig, azureEndPointConfigInfo); SetAzureDataDiskConfig setAzureDataDiskConfig1 = new SetAzureDataDiskConfig(HostCaching.ReadWrite, 0); SetAzureDataDiskConfig setAzureDataDiskConfig2 = new SetAzureDataDiskConfig(HostCaching.ReadWrite, 0); SetAzureDataDiskConfig[] diskConfig = { setAzureDataDiskConfig1, setAzureDataDiskConfig2 }; vmPowershellCmdlets.SetVMDataDisks(newAzureQuickVMName, serviceName, diskConfig); vmPowershellCmdlets.GetAzureDataDisk(newAzureQuickVMName, serviceName); // Cleanup vmPowershellCmdlets.RemoveAzureVM(newAzureQuickVMName, serviceName); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureQuickVMName, serviceName)); pass = true; }
public void AzureIaaSBVT() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); DateTime prevTime = DateTime.Now; string diskLabel1 = "disk1"; int diskSize1 = 30; int lunSlot1 = 0; string diskLabel2 = "disk2"; int diskSize2 = 50; int lunSlot2 = 2; string ep1Name = "tcp1"; int ep1LocalPort = 60010; int ep1PublicPort = 60011; string ep1LBSetName = "lbset1"; int ep1ProbePort = 60012; string ep1ProbePath = string.Empty; int? ep1ProbeInterval = 7; int? ep1ProbeTimeout = null; NetworkAclObject ep1AclObj = vmPowershellCmdlets.NewAzureAclConfig(); bool ep1DirectServerReturn = false; string ep2Name = "tcp2"; int ep2LocalPort = 60020; int ep2PublicPort = 60021; int ep2LocalPortChanged = 60030; int ep2PublicPortChanged = 60031; string ep2LBSetName = "lbset2"; int ep2ProbePort = 60022; string ep2ProbePath = @"/"; int? ep2ProbeInterval = null; int? ep2ProbeTimeout = 32; NetworkAclObject ep2AclObj = vmPowershellCmdlets.NewAzureAclConfig(); bool ep2DirectServerReturn = false; string cerFileName = "testcert.cer"; string thumbprintAlgorithm = "sha1"; try { // Create a certificate X509Certificate2 certCreated = Utilities.CreateCertificate(password); byte[] certData2 = certCreated.Export(X509ContentType.Cert); File.WriteAllBytes(cerFileName, certData2); // Install the .cer file to local machine. StoreLocation certStoreLocation = StoreLocation.CurrentUser; StoreName certStoreName = StoreName.My; X509Certificate2 installedCert = Utilities.InstallCert(cerFileName, certStoreLocation, certStoreName); PSObject certToUpload = vmPowershellCmdlets.RunPSScript( String.Format("Get-Item cert:\\{0}\\{1}\\{2}", certStoreLocation.ToString(), certStoreName.ToString(), installedCert.Thumbprint))[0]; string certData = Convert.ToBase64String(((X509Certificate2)certToUpload.BaseObject).RawData); string newAzureVMName = Utilities.GetUniqueShortName(vmNamePrefix); if (string.IsNullOrEmpty(imageName)) { imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); } RecordTimeTaken(ref prevTime); // // New-AzureService and verify with Get-AzureService // vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName); Assert.IsTrue(Verify.AzureService(serviceName, serviceName, locationName)); RecordTimeTaken(ref prevTime); // // Add-AzureCertificate and verify with Get-AzureCertificate // vmPowershellCmdlets.AddAzureCertificate(serviceName, certToUpload); Assert.IsTrue(Verify.AzureCertificate(serviceName, certCreated.Thumbprint, thumbprintAlgorithm, certData)); RecordTimeTaken(ref prevTime); // // Remove-AzureCertificate // vmPowershellCmdlets.RemoveAzureCertificate(serviceName, certCreated.Thumbprint, thumbprintAlgorithm); Assert.IsTrue(Utilities.CheckRemove(vmPowershellCmdlets.GetAzureCertificate, serviceName, certCreated.Thumbprint, thumbprintAlgorithm)); RecordTimeTaken(ref prevTime); // // New-AzureVMConfig // var azureVMConfigInfo = new AzureVMConfigInfo(newAzureVMName, InstanceSize.Small.ToString(), imageName); PersistentVM vm = vmPowershellCmdlets.NewAzureVMConfig(azureVMConfigInfo); RecordTimeTaken(ref prevTime); // // Add-AzureCertificate // vmPowershellCmdlets.AddAzureCertificate(serviceName, certToUpload); // // New-AzureCertificateSetting // CertificateSettingList certList = new CertificateSettingList(); certList.Add(vmPowershellCmdlets.NewAzureCertificateSetting(certStoreName.ToString(), installedCert.Thumbprint)); RecordTimeTaken(ref prevTime); // // Add-AzureProvisioningConfig // AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, certList, username, password); azureProvisioningConfig.Vm = vm; vm = vmPowershellCmdlets.AddAzureProvisioningConfig(azureProvisioningConfig); RecordTimeTaken(ref prevTime); // // Add-AzureDataDisk (two disks) // AddAzureDataDiskConfig azureDataDiskConfigInfo1 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, diskSize1, diskLabel1, lunSlot1); azureDataDiskConfigInfo1.Vm = vm; vm = vmPowershellCmdlets.AddAzureDataDisk(azureDataDiskConfigInfo1); AddAzureDataDiskConfig azureDataDiskConfigInfo2 = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, diskSize2, diskLabel2, lunSlot2); azureDataDiskConfigInfo2.Vm = vm; vm = vmPowershellCmdlets.AddAzureDataDisk(azureDataDiskConfigInfo2); RecordTimeTaken(ref prevTime); // // Add-AzureEndpoint (two endpoints) // AzureEndPointConfigInfo azureEndPointConfigInfo1 = new AzureEndPointConfigInfo( AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, ep1LocalPort, ep1PublicPort, ep1Name, ep1LBSetName, ep1ProbePort, ProtocolInfo.tcp, ep1ProbePath, ep1ProbeInterval, ep1ProbeTimeout, ep1AclObj, ep1DirectServerReturn, null, null, LoadBalancerDistribution.SourceIP); azureEndPointConfigInfo1.Vm = vm; vm = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo1); AzureEndPointConfigInfo azureEndPointConfigInfo2 = new AzureEndPointConfigInfo( AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, ep2LocalPort, ep2PublicPort, ep2Name, ep2LBSetName, ep2ProbePort, ProtocolInfo.http, ep2ProbePath, ep2ProbeInterval, ep2ProbeTimeout, ep2AclObj, ep2DirectServerReturn); azureEndPointConfigInfo2.Vm = vm; vm = vmPowershellCmdlets.AddAzureEndPoint(azureEndPointConfigInfo2); RecordTimeTaken(ref prevTime); // // Set-AzureAvailabilitySet // string testAVSetName = "testAVSet1"; vm = vmPowershellCmdlets.SetAzureAvailabilitySet(testAVSetName, vm); RecordTimeTaken(ref prevTime); // // New-AzureDns // string dnsName = "OpenDns1"; string ipAddress = "208.67.222.222"; DnsServer dns = vmPowershellCmdlets.NewAzureDns(dnsName, ipAddress); RecordTimeTaken(ref prevTime); // // New-AzureVM // vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, null, new[] { dns }, null, null, null, null); RecordTimeTaken(ref prevTime); // // Get-AzureVM without any parameter (List VMs) // var vmlist = vmPowershellCmdlets.GetAzureVM(); Console.WriteLine("The number of VMs: {0}", vmlist.Count); Assert.AreNotSame(0, vmlist.Count, "No VM exists!!!"); PersistentVMRoleListContext returnedVMlist = vmlist.First(item => item.ServiceName.Equals(serviceName) && item.Name.Equals(newAzureVMName)); Assert.IsNotNull(returnedVMlist, "Created VM does not exist!!!"); Utilities.PrintContext((PersistentVMRoleContext)returnedVMlist); // // Get-AzureVM // PersistentVMRoleContext returnedVM = vmPowershellCmdlets.GetAzureVM(newAzureVMName, serviceName); vm = returnedVM.VM; RecordTimeTaken(ref prevTime); // // Verify AzureDataDisk // Assert.IsTrue(Verify.AzureDataDisk(vm, diskLabel1, diskSize1, lunSlot1, HostCaching.None), "Data disk is not properly added"); Assert.IsTrue(Verify.AzureDataDisk(vm, diskLabel2, diskSize2, lunSlot2, HostCaching.None), "Data disk is not properly added"); Console.WriteLine("Data disk added correctly."); RecordTimeTaken(ref prevTime); // // Verify AzureEndpoint // Assert.IsTrue(Verify.AzureEndpoint(vm, new[] { azureEndPointConfigInfo1, azureEndPointConfigInfo2 })); // // Verify RDP & PowerShell Endpoints // var endpoints = vmPowershellCmdlets.GetAzureEndPoint(vm); Assert.IsTrue(endpoints.Count(e => e.Name == "PowerShell" && e.LocalPort == 5986 && e.Protocol == "tcp") == 1); Assert.IsTrue(endpoints.Count(e => e.Name == "RemoteDesktop" && e.LocalPort == 3389 && e.Protocol == "tcp") == 1); // // Verify AzureDns // Assert.IsTrue(Verify.AzureDns(vmPowershellCmdlets.GetAzureDeployment(serviceName).DnsSettings, dns)); // // Verify AzureAvailibilitySet // Assert.IsTrue(Verify.AzureAvailabilitySet(vm, testAVSetName)); // // Verify AzureOsDisk // Assert.IsTrue(Verify.AzureOsDisk(vm, "Windows", HostCaching.ReadWrite)); // // Set-AzureDataDisk // SetAzureDataDiskConfig setAzureDataDiskConfigInfo = new SetAzureDataDiskConfig(HostCaching.ReadOnly, lunSlot1); setAzureDataDiskConfigInfo.Vm = vm; vm = vmPowershellCmdlets.SetAzureDataDisk(setAzureDataDiskConfigInfo); RecordTimeTaken(ref prevTime); // // Remove-AzureDataDisk // RemoveAzureDataDiskConfig removeAzureDataDiskConfig = new RemoveAzureDataDiskConfig(lunSlot2, vm); vm = vmPowershellCmdlets.RemoveAzureDataDisk(removeAzureDataDiskConfig); RecordTimeTaken(ref prevTime); // // Set-AzureEndpoint // azureEndPointConfigInfo2 = new AzureEndPointConfigInfo( AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, ep2LocalPortChanged, ep2PublicPortChanged, ep2Name, ep2LBSetName, ep2ProbePort, ProtocolInfo.http, ep2ProbePath, ep2ProbeInterval, ep2ProbeTimeout, ep2AclObj, ep2DirectServerReturn); azureEndPointConfigInfo2.Vm = vm; vm = vmPowershellCmdlets.SetAzureEndPoint(azureEndPointConfigInfo2); RecordTimeTaken(ref prevTime); // // Remove-AzureEndpoint // vm = vmPowershellCmdlets.RemoveAzureEndPoint(azureEndPointConfigInfo1.EndpointName, vm); RecordTimeTaken(ref prevTime); // // Set-AzureVMSize // var vmSizeConfig = new SetAzureVMSizeConfig(InstanceSize.Medium.ToString()); vmSizeConfig.Vm = vm; vm = vmPowershellCmdlets.SetAzureVMSize(vmSizeConfig); RecordTimeTaken(ref prevTime); // // Set-AzureOSDisk // vm = vmPowershellCmdlets.SetAzureOSDisk(HostCaching.ReadOnly, vm); // // Update-AzureVM // vmPowershellCmdlets.UpdateAzureVM(newAzureVMName, serviceName, vm); RecordTimeTaken(ref prevTime); // // Get-AzureVM and Verify the VM // vm = vmPowershellCmdlets.GetAzureVM(newAzureVMName, serviceName).VM; // Verify setting data disk Assert.IsTrue(Verify.AzureDataDisk(vm, diskLabel1, diskSize1, lunSlot1, HostCaching.ReadOnly), "Data disk is not properly added"); // Verify removing a data disk Assert.AreEqual(1, vmPowershellCmdlets.GetAzureDataDisk(vm).Count, "DataDisk is not removed."); // Verify setting an endpoint Assert.IsTrue(Verify.AzureEndpoint(vm, new[] { azureEndPointConfigInfo2 })); // Verify removing an endpoint Assert.IsFalse(Verify.AzureEndpoint(vm, new[] { azureEndPointConfigInfo1 })); // Verify os disk Assert.IsTrue(Verify.AzureOsDisk(vm, "Windows", HostCaching.ReadOnly)); // // Remove-AzureVM // vmPowershellCmdlets.RemoveAzureVM(newAzureVMName, serviceName); RecordTimeTaken(ref prevTime); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVMName, serviceName)); pass = true; } catch (Exception e) { Console.WriteLine(e.ToString()); throw; } }
public void AdvancedProvisioning() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix); string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix); if (string.IsNullOrEmpty(imageName)) { imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); } vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName); AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName); AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.ExtraSmall, imageName); AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0); AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.CustomProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", 80, ProtocolInfo.http, @"/", null, null); PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1); PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2); PersistentVM[] VMs = { persistentVM1, persistentVM2 }; vmPowershellCmdlets.NewAzureVM(serviceName, VMs); // Cleanup vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName); vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, serviceName); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName)); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, serviceName)); pass = true; }
private bool CheckEndpointRemoved(string vmName, string serviceName, AzureEndPointConfigInfo[] epInfos) { var serverEndpoints = vmPowershellCmdlets.GetAzureEndPoint(vmPowershellCmdlets.GetAzureVM(vmName, serviceName)); // List the endpoints found for debugging. Console.WriteLine("***** Checking for Removed Endpoints ******************************************"); Console.WriteLine("***** Listing Returned Endpoints"); foreach (InputEndpointContext ep in serverEndpoints) { Console.WriteLine("Endpoint - Name:{0} Protocol:{1} Port:{2} LocalPort:{3} Vip:{4}", ep.Name, ep.Protocol, ep.Port, ep.LocalPort, ep.Vip); if (!string.IsNullOrEmpty(ep.LBSetName)) { Console.WriteLine("\t- LBSetName:{0}", ep.LBSetName); Console.WriteLine("\t- Probe - Port:{0} Protocol:{1} Interval:{2} Timeout:{3}", ep.ProbePort, ep.ProbeProtocol, ep.ProbeIntervalInSeconds, ep.ProbeTimeoutInSeconds); } } Console.WriteLine("*******************************************************************************"); // Check if the specified endpoints were found. foreach (AzureEndPointConfigInfo epInfo in epInfos) { bool found = false; foreach (InputEndpointContext ep in serverEndpoints) { if (epInfo.CheckInputEndpointContext(ep)) { found = true; Console.WriteLine("Endpoint found: {0}", epInfo.EndpointName); break; } } Assert.IsFalse(found, string.Format("Error: Endpoint '{0}' was found!", epInfo.EndpointName)); } return true; }
public void AddEndPoint(string vmName, string serviceName, AzureEndPointConfigInfo [] endPointConfigs) { PersistentVM vm = GetAzureVM(vmName, serviceName).VM; foreach (AzureEndPointConfigInfo config in endPointConfigs) { config.Vm = vm; vm = AddAzureEndPointNoLB(config); } UpdateAzureVM(vmName, serviceName, vm); }
public void AzureEndpointTest() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string ep1Name = "tcp1"; int ep1LocalPort = 60010; int ep1PublicPort = 60011; string ep1LBSetName = "lbset1"; int ep1ProbePort = 60012; string ep1ProbePath = string.Empty; int? ep1ProbeInterval = 7; int? ep1ProbeTimeout = null; NetworkAclObject ep1AclObj = null; bool ep1DirectServerReturn = false; string ep2Name = "tcp2"; int ep2LocalPort = 60020; int ep2PublicPort = 60021; int ep2LocalPortChanged = 60030; int ep2PublicPortChanged = 60031; string ep2LBSetName = "lbset2"; int ep2ProbePort = 60022; string ep2ProbePath = @"/"; int? ep2ProbeInterval = null; int? ep2ProbeTimeout = 32; NetworkAclObject ep2AclObj = null; bool ep2DirectServerReturn = false; AzureEndPointConfigInfo ep1Info = new AzureEndPointConfigInfo( AzureEndPointConfigInfo.ParameterSet.CustonProbe, ProtocolInfo.tcp, ep1LocalPort, ep1PublicPort, ep1Name, ep1LBSetName, ep1ProbePort, ProtocolInfo.tcp, ep1ProbePath, ep1ProbeInterval, ep1ProbeTimeout, ep1AclObj, ep1DirectServerReturn); AzureEndPointConfigInfo ep2Info = new AzureEndPointConfigInfo( AzureEndPointConfigInfo.ParameterSet.CustonProbe, ProtocolInfo.tcp, ep2LocalPort, ep2PublicPort, ep2Name, ep2LBSetName, ep2ProbePort, ProtocolInfo.http, ep2ProbePath, ep2ProbeInterval, ep2ProbeTimeout, ep2AclObj, ep2DirectServerReturn); string defaultVm = Utilities.GetUniqueShortName(vmNamePrefix); Assert.IsNull(vmPowershellCmdlets.GetAzureVM(defaultVm, serviceName)); vmPowershellCmdlets.NewAzureQuickVM(OS.Windows, defaultVm, serviceName, imageName, username, password, locationName); Console.WriteLine("Service Name: {0} is created.", serviceName); try { foreach (AzureEndPointConfigInfo.ParameterSet p in Enum.GetValues(typeof(AzureEndPointConfigInfo.ParameterSet))) { string pSetName = Enum.GetName(typeof(AzureEndPointConfigInfo.ParameterSet), p); Console.WriteLine("--Begin Endpoint Test with '{0}' parameter set.", pSetName); ep1Info.ParamSet = p; ep2Info.ParamSet = p; ep1Info.Acl = vmPowershellCmdlets.NewAzureAclConfig(); ep2Info.Acl = vmPowershellCmdlets.NewAzureAclConfig(); ep2Info.EndpointLocalPort = ep2LocalPort; ep2Info.EndpointPublicPort = ep2PublicPort; // Add two new endpoints Console.WriteLine("-----Add 2 new endpoints."); vmPowershellCmdlets.AddEndPoint(defaultVm, serviceName, new[] { ep1Info, ep2Info }); // Add-AzureEndpoint with Get-AzureVM and Update-AzureVm CheckEndpoint(defaultVm, serviceName, new[] { ep1Info, ep2Info }); // Change the endpoint if (p == AzureEndPointConfigInfo.ParameterSet.NoLB) { Console.WriteLine("-----Change the second endpoint."); ep2Info.EndpointLocalPort = ep2LocalPortChanged; ep2Info.EndpointPublicPort = ep2PublicPortChanged; vmPowershellCmdlets.SetEndPoint(defaultVm, serviceName, ep2Info); // Set-AzureEndpoint with Get-AzureVM and Update-AzureVm CheckEndpoint(defaultVm, serviceName, new[] { ep2Info }); } else { Console.WriteLine("-----Change the second endpoint."); ep2Info.ServiceName = serviceName; ep2Info.EndpointLocalPort = ep2LocalPortChanged; ep2Info.EndpointPublicPort = ep2PublicPortChanged; vmPowershellCmdlets.SetLBEndPoint(defaultVm, serviceName, ep2Info, p); CheckEndpoint(defaultVm, serviceName, new[] { ep2Info }); } // Remove Endpoint Console.WriteLine("-----Remove endpoints."); vmPowershellCmdlets.RemoveEndPoint(defaultVm, serviceName, new[] { ep1Name, ep2Name }); // Remove-AzureEndpoint CheckEndpointRemoved(defaultVm, serviceName, new[] { ep1Info, ep2Info }); Console.WriteLine("Endpoint Test passed with '{0}' parameter set.", pSetName); } pass = true; } catch (Exception e) { pass = false; Assert.Fail("Exception occurred: {0}", e.ToString()); } }
public void AddEndPointACLsWithNewDeployment() { StartTest(MethodBase.GetCurrentMethod().Name, testStartTime); string newAzureVM1Name = Utilities.GetUniqueShortName(vmNamePrefix); string newAzureVM2Name = Utilities.GetUniqueShortName(vmNamePrefix); if (string.IsNullOrEmpty(imageName)) imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Windows" }, false); vmPowershellCmdlets.NewAzureService(serviceName, serviceName, locationName); NetworkAclObject aclObj = vmPowershellCmdlets.NewAzureAclConfig(); vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 100, ACLAction.Permit, "172.0.0.0/8", "notes1"); vmPowershellCmdlets.SetAzureAclConfig(SetACLConfig.AddRule, aclObj, 200, ACLAction.Deny, "10.0.0.0/8", "notes2"); AzureVMConfigInfo azureVMConfigInfo1 = new AzureVMConfigInfo(newAzureVM1Name, InstanceSize.ExtraSmall, imageName); AzureVMConfigInfo azureVMConfigInfo2 = new AzureVMConfigInfo(newAzureVM2Name, InstanceSize.ExtraSmall, imageName); AzureProvisioningConfigInfo azureProvisioningConfig = new AzureProvisioningConfigInfo(OS.Windows, username, password); AddAzureDataDiskConfig azureDataDiskConfigInfo = new AddAzureDataDiskConfig(DiskCreateOption.CreateNew, 50, "datadisk1", 0); AzureEndPointConfigInfo azureEndPointConfigInfo = new AzureEndPointConfigInfo(AzureEndPointConfigInfo.ParameterSet.DefaultProbe, ProtocolInfo.tcp, 80, 80, "web", "lbweb", aclObj, true); PersistentVMConfigInfo persistentVMConfigInfo1 = new PersistentVMConfigInfo(azureVMConfigInfo1, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVMConfigInfo persistentVMConfigInfo2 = new PersistentVMConfigInfo(azureVMConfigInfo2, azureProvisioningConfig, azureDataDiskConfigInfo, azureEndPointConfigInfo); PersistentVM persistentVM1 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo1); PersistentVM persistentVM2 = vmPowershellCmdlets.GetPersistentVM(persistentVMConfigInfo2); PersistentVM[] VMs = { persistentVM1, persistentVM2 }; vmPowershellCmdlets.NewAzureVM(serviceName, VMs); // Cleanup vmPowershellCmdlets.RemoveAzureVM(newAzureVM1Name, serviceName); vmPowershellCmdlets.RemoveAzureVM(newAzureVM2Name, serviceName); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM1Name, serviceName)); Assert.AreEqual(null, vmPowershellCmdlets.GetAzureVM(newAzureVM2Name, serviceName)); pass = true; }