コード例 #1
0
        public void CreateReservedIPThenWindowsVM()
        {
            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()
                {
                    //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(() =>
                    {
                         PersistentVM vm = CreateVMObjectWithDataDiskSubnetAndAvailibilitySet(vmName, OS.Windows);
                         vmPowershellCmdlets.NewAzureVM(serviceName, new[] { vm }, vnet, new[] { dns }, location: locationName, reservedIPName: reservedIpName);
                    },"Create a new windows azure vm with reserved ip.");
                VerifyReservedIpInUse(serviceName,input);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureVM(vmName, serviceName, true), "Remove Azure VM and verify that a warning is given.");
                VerifyReservedIpNotInUse(input);
                Utilities.ExecuteAndLog(() => vmPowershellCmdlets.RemoveAzureReservedIP(reservedIpName, true), "Release the reserved ip");
                VerifyReservedIpRemoved(reservedIpName);
                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
コード例 #2
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()
                {
                    //Address = string.Empty,
                    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(), null,  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;
            }
        }
コード例 #3
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));
 }
コード例 #4
0
 private void VerifyReservedIpInUse(string serviceName,ReservedIPContext input)
 {
     input.ServiceName = serviceName;
     input.InUse = true;
     input.DeploymentName = serviceName;
     Utilities.ExecuteAndLog(() => VerifyReservedIp(input), string.Format("Verify that the reserved ip {0} is in use", input.ReservedIPName));
 }
コード例 #5
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);
     }
 }
コード例 #6
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;
            }
        }
コード例 #7
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 deploymentName1 = Utilities.GetUniqueShortName("Depl");
                string deploymentName2 = 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 _configName = Convert.ToString(TestContext.DataRow["configName"]);
                var _configNameupdate = Convert.ToString(TestContext.DataRow["updateConfig"]);

                string _packagePath = (new FileInfo(Directory.GetCurrentDirectory() + "\\" + _packageName)).FullName;
                string _configPath1 = StoreConfigFileWithReservedIp(_configName, reservedIpName1);
                string _configPath2 = StoreConfigFileWithReservedIp(_configName, reservedIpName2);
                string _configPath1update = StoreConfigFileWithReservedIp(_configNameupdate, reservedIpName1);
                string _configPath2update = StoreConfigFileWithReservedIp(_configNameupdate, reservedIpName2);

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

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

                vmPowershellCmdlets.MoveAzureDeployment(serviceName);

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

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

                pass = true;
            }
            catch (Exception ex)
            {
                pass = false;
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
コード例 #8
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 = 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.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");
        }
コード例 #9
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;
            }
        }