示例#1
0
 internal static bool AzureReservedIPInUse(ReservedIPContext rsvIP, string name, string label, string affname,
                                           string ip = null, string deploymentName = null, string svcName = null)
 {
     AzureReservedIP(rsvIP, name, label, affname, ip, deploymentName, svcName, null);
     Assert.AreEqual(true, rsvIP.InUse);
     return(true);
 }
示例#2
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));
 }
示例#3
0
 internal static bool AzureReservedIPNotInUse(ReservedIPContext rsvIP, string name, string label, string affname,
                                              string id = null)
 {
     AzureReservedIP(rsvIP, name, label, affname, null, null, null, id);
     Assert.AreEqual(false, rsvIP.InUse);
     return(true);
 }
示例#4
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));
 }
示例#5
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;
            }
        }
示例#6
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;
            }
        }
示例#7
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;
            }
        }
示例#8
0
 internal static bool AzureReservedIP(ReservedIPContext rsvIP, string name, string label, string affname,
                                      string ip, string dep, string svcName, string id)
 {
     Utilities.PrintContext(rsvIP);
     Assert.AreEqual(name, rsvIP.ReservedIPName, "Reserved IP names are not equal!");
     Assert.AreEqual(label, rsvIP.Label, "Reserved IP labels are not equal!");
     Assert.AreEqual(affname, rsvIP.AffinityGroup, "Reserved IP affinity groups are not equal!");
     if (!string.IsNullOrEmpty(ip))
     {
         Assert.AreEqual(ip, rsvIP.Address, "Reserved IP addresses are not equal!");
     }
     Assert.AreEqual(dep, rsvIP.DeploymentName, "Reserved IP deployment names are not equal!");
     Assert.AreEqual(svcName, rsvIP.ServiceName, "Reserved IP service names are not equal!");
     if (!string.IsNullOrEmpty(id))
     {
         Assert.AreEqual(id, rsvIP.Id, "Reserved IP IDs are not equal!");
     }
     return(true);
 }
示例#9
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");
        }
示例#10
0
        /// <summary>
        /// Verify the properties of the reserved ip
        /// </summary>
        /// <param name="input">ReservedIpContext object containing expected values</param>
        private void VerifyReservedIp(ReservedIPContext input)
        {
            var reservedIps = vmPowershellCmdlets.GetAzureReservedIP(input.ReservedIPName);

            if (reservedIps.Count > 0)
            {
                var reservedIpContext = reservedIps[0];
                Utilities.PrintContext(reservedIpContext);
                Utilities.LogAssert(() => Assert.IsFalse(string.IsNullOrEmpty(reservedIpContext.Address)), "Address");
                Utilities.LogAssert(() => Assert.AreEqual(input.Location, reservedIpContext.Location), "Location");
                Utilities.LogAssert(() => Assert.AreEqual(input.ReservedIPName, reservedIpContext.ReservedIPName), "ReservedIPName");
                Utilities.LogAssert(() => Assert.AreEqual(input.State, reservedIpContext.State), "State");
                Utilities.LogAssert(() => Assert.AreEqual(input.DeploymentName, reservedIpContext.DeploymentName), "DeploymentName");
                Utilities.LogAssert(() => Assert.AreEqual(input.InUse, reservedIpContext.InUse), "InUse");
                Utilities.LogAssert(() => Assert.AreEqual(input.ServiceName, reservedIpContext.ServiceName), "ServiceName");
            }
            else
            {
                Assert.Fail("Didnt find reserved ip with name {0}", input.ReservedIPName);
            }
        }
示例#11
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;
            }
        }
示例#12
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;
            }
        }