示例#1
0
 private void VerifyReservedIpNotInUse(ReservedIPContext input)
 {
     input.ServiceName    = null;
     input.InUse          = false;
     input.DeploymentName = null;
     Utilities.ExecuteAndLog(() => VerifyReservedIp(input), string.Format("Verify that the reserved ip {0} is not in use", input.ReservedIPName));
 }
示例#2
0
        public void ILBonExistingDeploymentAndDelete()
        {
            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(), null, 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);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureInternalLoadBalancer(serviceName), "Remove  Azure Internal Load Balancer");
                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.InnerException.ToString());
                throw ex;
            }
        }
示例#3
0
 private void VerifyReservedIpInUse(string serviceName, ReservedIPContext input, string deploymentName = null)
 {
     input.ServiceName    = serviceName;
     input.InUse          = true;
     input.DeploymentName = deploymentName ?? serviceName;
     Utilities.ExecuteAndLog(() => VerifyReservedIp(input), string.Format("Verify that the reserved ip {0} is in use", input.ReservedIPName));
 }
示例#4
0
 public void Cleanup()
 {
     if (cleanupIfPassed)
     {
         Utilities.ExecuteAndLog(() => CleanupService(serviceName), "Cleanup service");
     }
 }
示例#5
0
        public void CreateDeploymentWithILBAndRemoveILB()
        {
            try
            {
                string ilbName   = Utilities.GetUniqueShortName("ILB");
                string vmName    = Utilities.GetUniqueShortName(vmNamePrefix);
                var    ilbConfig = vmPowershellCmdlets.NewAzureInternalLoadBalancerConfig(ilbName);

                Utilities.ExecuteAndLog(() =>
                {
                    var vm = Utilities.CreateIaaSVMObject(vmName, InstanceSize.Small, imageName, true, username, password, false);
                    vmPowershellCmdlets.NewAzureVMWithInternalLoadBalancer(serviceName, new[] { vm }, ilbConfig, location: locationName);
                }, string.Format("Create a Vm with Internal load balancer {0}", ilbName));

                VerifyInternalLoadBalancer("Verify Internal Load Balancer", ilbConfig);
                VerifyDeployment("Verify internal load balancer name of the deployment", ilbName);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureInternalLoadBalancer(serviceName), "Remove  Azure Internal Load Balancer");
                VerifyDeployment("Get azure deployment and verify that the deployment doesnt have ILB");
                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.InnerException.ToString());
                throw ex;
            }
        }
示例#6
0
 private static void VerifyPublicIP(string publicIpName, PersistentVM vm1)
 {
     Utilities.ExecuteAndLog(() =>
     {
         var publicIpContext = vmPowershellCmdlets.GetAzurePublicIpName(publicIpName, vm1);
         Console.WriteLine("Public IP Context Properties:");
         Utilities.PrintContext(publicIpContext);
         Console.WriteLine("\n Verifing recquired properties");
         Utilities.LogAssert(() => Assert.AreEqual(publicIpName, publicIpContext.Name), "Public IP Name");
     }, "Verify Public ip of the VM");
 }
示例#7
0
        public void CreateReservedIPThenLinuxVM()
        {
            try
            {
                string reservedIpName  = Utilities.GetUniqueShortName("ResrvdIP");
                string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
                string dnsName         = Utilities.GetUniqueShortName("Dns");
                string vmName          = Utilities.GetUniqueShortName(vmNamePrefix);
                string deploymentName  = Utilities.GetUniqueShortName("Depl");
                string affinityGroup   = Utilities.GetUniqueShortName("AffGrp");
                var    input           = new ReservedIPContext()
                {
                    //Address = string.Empty,
                    DeploymentName = string.Empty,
                    Label          = reservedIpLabel,
                    InUse          = false,
                    Location       = locationName,
                    ReservedIPName = reservedIpName,
                    State          = "Created"
                };

                // Reserve a new IP
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, reservedIpLabel), "Reserve a new IP");

                //Get the reserved ip and verify the reserved Ip properties.
                VerifyReservedIpNotInUse(input);
                // Create a new VM with the reserved ip.
                DnsServer dns = null;
                Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureAffinityGroup(affinityGroup, locationName, affinityGroup, affinityGroup), "Create a new affinity group");

                Utilities.ExecuteAndLog(() =>
                {
                    PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Linux);
                    vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, affinityGroup: affinityGroup, reservedIPName: reservedIpName);
                }, "");
                VerifyReservedIpInUse(serviceName, input);
                vmPowershellCmdlets.RemoveAzureDeployment(serviceName, DeploymentSlotType.Production, true);
                VerifyReservedIpNotInUse(input);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureReservedIP(reservedIpName, true), "Release the reserved ip");
                VerifyReservedIpRemoved(reservedIpName);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureService(serviceName, true), "Delete the hosted service");
                cleanupIfPassed = false;
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureAffinityGroup(affinityGroup), "Delete the affintiy group");
                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
示例#8
0
 /// <summary>
 /// Verifies that the properties of the result of Get-azureInternalLoadBalancer is same as expected.
 /// </summary>
 /// <param name="ilbName"></param>
 private void VerifyInternalLoadBalancer(string verificationMessage, InternalLoadBalancerConfig expectedIlbConfig)
 {
     Utilities.ExecuteAndLog(() =>
     {
         var ilbConfig = vmPowershellCmdlets.GetAzureInternalLoadBalancer(serviceName);
         Console.WriteLine("ILB Context Properties:");
         Utilities.PrintContext(ilbConfig);
         Console.WriteLine("\n Verifing recquired properties");
         Utilities.LogAssert(() => Assert.AreEqual(expectedIlbConfig.InternalLoadBalancerName, ilbConfig.InternalLoadBalancerName), "InternalLoadBalancerName");
         Utilities.LogAssert(() => Assert.AreEqual(serviceName, ilbConfig.ServiceName), "ServiceName");
         Utilities.LogAssert(() => Assert.AreEqual(serviceName, ilbConfig.DeploymentName), "DeploymentName");
         Utilities.LogAssert(() => Assert.AreEqual(expectedIlbConfig.IPAddress, ilbConfig.IPAddress), "IPAddress");
         Utilities.LogAssert(() => Assert.AreEqual(expectedIlbConfig.SubnetName, ilbConfig.SubnetName), "SubnetName");
     }, verificationMessage);
 }
示例#9
0
        public void CreateWindowsVMThenReservedExistingIP()
        {
            try
            {
                string reservedIpName  = Utilities.GetUniqueShortName("ResrvdIP");
                string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
                string dnsName         = Utilities.GetUniqueShortName("Dns");
                string vmName          = Utilities.GetUniqueShortName(vmNamePrefix);
                string deploymentName  = Utilities.GetUniqueShortName("Depl");
                var    input           = new ReservedIPContext()
                {
                    DeploymentName = string.Empty,
                    Label          = reservedIpLabel,
                    InUse          = false,
                    Location       = locationName,
                    ReservedIPName = reservedIpName,
                    State          = "Created"
                };

                // Create a new VM with the reserved ip.
                DnsServer dns = null;
                Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
                Utilities.ExecuteAndLog(() =>
                {
                    PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
                    vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
                }, "Create a new windows azure vm without reserved ip.");

                // Reserve an existing IP
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, serviceName, reservedIpLabel), "Reserve existing deployment IP");

                VerifyReservedIpInUse(serviceName, input);

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

                VerifyReservedIpNotInUse(input);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVM(vmName, serviceName, true), "Remove Azure VM and verify that a warning is given.");
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureReservedIP(reservedIpName, true), "Release the reserved ip");
                VerifyReservedIpRemoved(reservedIpName);
                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
示例#10
0
        public void CreateReservedIPThenLinuxQuickVM()
        {
            try
            {
                string reservedIpName  = Utilities.GetUniqueShortName("ResrvdIP");
                string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
                string dnsName         = Utilities.GetUniqueShortName("Dns");
                string vmName          = Utilities.GetUniqueShortName(vmNamePrefix);
                string deploymentName  = Utilities.GetUniqueShortName("Depl");
                string affinityGroup   = Utilities.GetUniqueShortName("AffGrp");
                var    input           = new ReservedIPContext()
                {
                    DeploymentName = string.Empty,
                    Label          = reservedIpLabel,
                    InUse          = false,
                    Location       = locationName,
                    ReservedIPName = reservedIpName,
                    State          = "Created"
                };
                imageName = vmPowershellCmdlets.GetAzureVMImageName(new[] { "Linux" }, false);

                // Reserve a new IP
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, reservedIpLabel), "Reserve a new IP");
                VerifyReservedIpNotInUse(input);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureAffinityGroup(affinityGroup, locationName, affinityGroup, affinityGroup), "Create a new affinity group");
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureQuickVM(OS.Linux,
                                                                                  vmName, serviceName, imageName, username, password, locationName,
                                                                                  InstanceSize.Small.ToString(), false, reservedIpName),
                                        "Create a new Azure windows Quick VM with reserved ip.");
                VerifyReservedIpInUse(serviceName, input);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.StopAzureVM(vmName, serviceName, true), "Stop Azure VM and stay provisioned.");
                VerifyReservedIpInUse(serviceName, input);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureService(serviceName, true), "Delete the hosted service");
                cleanupIfPassed = false;
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureReservedIP(reservedIpName, true), "Release the reserved ip");;
                VerifyReservedIpRemoved(reservedIpName);
                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
示例#11
0
        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;
            }
        }
示例#12
0
        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;
            }
        }
示例#14
0
        public void TestAssociateReservedIPToStageSlotIaaSFails()
        {
            try
            {
                string reservedIpName  = Utilities.GetUniqueShortName("ResrvdIP");
                string reservedIpLabel = Utilities.GetUniqueShortName(" ResrvdIPLbl", 5);
                string dnsName         = Utilities.GetUniqueShortName("Dns");
                string vmName          = Utilities.GetUniqueShortName(vmNamePrefix);
                var    input           = new ReservedIPContext()
                {
                    DeploymentName = string.Empty,
                    Label          = reservedIpLabel,
                    InUse          = false,
                    Location       = locationName,
                    ReservedIPName = reservedIpName,
                    State          = "Created"
                };

                // Reserve a new IP
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, reservedIpLabel), "Reserve a new IP");
                //Get the reserved ip and verify the reserved Ip properties.
                VerifyReservedIpNotInUse(input);
                // Create a new VM with the reserved ip.
                DnsServer dns = null;
                Utilities.ExecuteAndLog(() => { dns = vmPowershellCmdlets.NewAzureDns(dnsName, DNS_IP); }, "Create a new Azure DNS");
                Utilities.ExecuteAndLog(() =>
                {
                    PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
                    vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName);
                }, "Create a new windows azure vm without reserved ip.");

                Utilities.ExecuteAndLog(() => { vmPowershellCmdlets.SetAzureReservedIPAssociation(reservedIpName,
                                                                                                  serviceName, DeploymentSlotType.Staging); }, "Create a new Azure Reserved IP Association");
            }
            catch (Exception ex)
            {
                pass = true;
                Console.WriteLine(ex.ToString());
                return;
            }
            throw new Exception("Test Did not fail as expected when association was tried on stage slot in IaaS");
        }
示例#15
0
        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);
        }
示例#16
0
 private void VerifyDeployment(string verificationMessage, string internalLoadBalancerName = null, string vnet = null)
 {
     Utilities.ExecuteAndLog(() =>
     {
         var deploymentContext = vmPowershellCmdlets.GetAzureDeployment(serviceName);
         Console.WriteLine("Deployment Context Properties:");
         Utilities.PrintContext(deploymentContext);
         Console.WriteLine("\n Verifing recquired properties");
         Utilities.LogAssert(() => Assert.AreEqual(internalLoadBalancerName, deploymentContext.InternalLoadBalancerName), "InternalLoadBalancerName");
         Utilities.LogAssert(() =>
         {
             if (internalLoadBalancerName == null)
             {
                 Assert.AreEqual(deploymentContext.LoadBalancers.Count, 0);
             }
             else
             {
                 Assert.AreEqual(internalLoadBalancerName, deploymentContext.LoadBalancers[0].Name);
             }
         }, "LoadBalancers");
         Utilities.LogAssert(() => Assert.AreEqual(vnet, deploymentContext.VNetName), "VNetName");
     }, verificationMessage);
 }
示例#17
0
 public static void ClassCleanup()
 {
     Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVNetConfig(), "Remove Azure Vnet config after tests");
 }
示例#18
0
        public void CreatePaaSDeploymentAssociateAndDisassociateReservedIp()
        {
            try
            {
                string reservedIpName  = Utilities.GetUniqueShortName("ResrvdIP");
                string reservedIpLabel = Utilities.GetUniqueShortName("ResrvdIPLbl", 5);
                string deploymentName  = Utilities.GetUniqueShortName("Depl");
                string deploymentLabel = Utilities.GetUniqueShortName("DepLbl", 5);

                var input = new ReservedIPContext()
                {
                    DeploymentName = string.Empty,
                    Label          = reservedIpLabel,
                    InUse          = false,
                    Location       = locationName,
                    ReservedIPName = reservedIpName,
                    State          = "Created"
                };

                // Reserve a new IP
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName, locationName, reservedIpLabel), "Reserve a new IP");
                //Get the reserved ip and verify the reserved Ip properties.
                VerifyReservedIpNotInUse(input);
                // Create a new VM with the reserved ip.

                Utilities.ExecuteAndLog(() =>
                                        vmPowershellCmdlets.NewAzureService(serviceName, locationName),
                                        "Create a Hosted Service");

                Utilities.ExecuteAndLog(() =>
                                        vmPowershellCmdlets.NewAzureDeployment(serviceName,
                                                                               "HelloWorld_SDK20.cspkg", "ServiceConfiguration.cscfg", "Staging",
                                                                               deploymentLabel, deploymentName, doNotStart: false, warning: false),
                                        "Create a PaaS deployment");


                Utilities.ExecuteAndLog(() =>
                {
                    vmPowershellCmdlets.SetAzureReservedIPAssociation(reservedIpName,
                                                                      serviceName, DeploymentSlotType.Staging);
                }, "Create a new Azure Reserved IP Association");


                VerifyReservedIpInUse(serviceName, input, deploymentName);

                Utilities.ExecuteAndLog(() =>
                {
                    vmPowershellCmdlets.RemoveAzureReservedIPAssociation(reservedIpName,
                                                                         serviceName, true, DeploymentSlotType.Staging);
                }, "Remove a new Azure Reserved IP Association");

                VerifyReservedIpNotInUse(input);

                Utilities.ExecuteAndLog(() =>
                {
                    vmPowershellCmdlets.RemoveAzureDeployment(serviceName, "Staging", true);
                }, "Remove a new Azure Reserved IP Association");
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
示例#19
0
        public void CreateReservedIPThenPaaSVM()
        {
            try
            {
                string reservedIpName1  = Utilities.GetUniqueShortName("ResrvdIP1");;
                string reservedIpName2  = Utilities.GetUniqueShortName("ResrvdIP2");;
                string reservedIpLabel1 = Utilities.GetUniqueShortName("ResrvdIPLbl", 5);
                string reservedIpLabel2 = Utilities.GetUniqueShortName("ResrvdIPLbl", 5);
                string dnsName          = Utilities.GetUniqueShortName("Dns");
                string deploymentName   = Utilities.GetUniqueShortName("Depl");
                var    input1           = new ReservedIPContext()
                {
                    DeploymentName = string.Empty,
                    Label          = reservedIpLabel1,
                    InUse          = false,
                    Location       = locationName,
                    ReservedIPName = reservedIpName1,
                    State          = "Created"
                };

                var input2 = new ReservedIPContext()
                {
                    DeploymentName = string.Empty,
                    Label          = reservedIpLabel2,
                    InUse          = false,
                    Location       = locationName,
                    ReservedIPName = reservedIpName2,
                    State          = "Created"
                };

                // Reserve a new IP
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName1, locationName, reservedIpLabel1), "Reserve a new IP");
                //Get the reserved ip and verify the reserved Ip properties.
                VerifyReservedIpNotInUse(input1);

                // Reserve a new IP
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.NewAzureReservedIP(reservedIpName2, locationName, reservedIpLabel2), "Reserve a new IP");
                //Get the reserved ip and verify the reserved Ip properties.
                VerifyReservedIpNotInUse(input2);

                vmPowershellCmdlets.NewAzureService(serviceName, locationName);


                var _packageName       = Convert.ToString(TestContext.DataRow["packageName"]);
                var _configName1       = Convert.ToString(TestContext.DataRow["configName1"]);
                var _configName2       = Convert.ToString(TestContext.DataRow["configName2"]);
                var _configName1update = Convert.ToString(TestContext.DataRow["updateConfig1"]);
                var _configName2update = Convert.ToString(TestContext.DataRow["updateConfig2"]);

                var _packagePath       = new FileInfo(Directory.GetCurrentDirectory() + "\\" + _packageName);
                var _configPath1       = new FileInfo(Directory.GetCurrentDirectory() + "\\" + _configName1);
                var _configPath2       = new FileInfo(Directory.GetCurrentDirectory() + "\\" + _configName2);
                var _configPath1update = new FileInfo(Directory.GetCurrentDirectory() + "\\" + _configName1update);
                var _configPath2update = new FileInfo(Directory.GetCurrentDirectory() + "\\" + _configName2update);


                vmPowershellCmdlets.NewAzureDeployment(serviceName, _packagePath.FullName, _configPath1.FullName,
                                                       DeploymentSlotType.Production, "label", deploymentName, false, false);

                vmPowershellCmdlets.NewAzureDeployment(serviceName, _packagePath.FullName, _configPath2.FullName,
                                                       DeploymentSlotType.Staging, "label", deploymentName, false, false);



                vmPowershellCmdlets.MoveAzureDeployment(serviceName);

                vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Production);
                vmPowershellCmdlets.GetAzureDeployment(serviceName, DeploymentSlotType.Staging);

                vmPowershellCmdlets.SetAzureDeploymentConfig(serviceName, DeploymentSlotType.Production, _configPath1update.FullName);
                vmPowershellCmdlets.SetAzureDeploymentConfig(serviceName, DeploymentSlotType.Staging, _configPath2update.FullName);



                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
示例#20
0
        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;
            }
        }