예제 #1
0
        public void CreateDefinitionPerformanceAnyNoLocationFails()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();
                LoadBalancingMethod testMethod = LoadBalancingMethod.Performance;
                DefinitionEndpointCreateParameters endpointParam = new DefinitionEndpointCreateParameters();
                endpointParam.DomainName = ExternalDomain;
                endpointParam.Status     = EndpointStatus.Enabled;
                endpointParam.Type       = EndpointType.Any;
                endpointParam.Location   = "West US";

                try
                {
                    testCreateDefinition(testMethod, endpointParam);
                }
                catch (CloudException ce)
                {
                    if (ce.Error.Message !=
                        "The location must be specified for endpoints of type 'Any' in a policy of type 'Performance'.")
                    {
                        throw;
                    }
                }
            }
        }
예제 #2
0
        public void CreateDefinitionWithTrafficManagerEndpoint()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                LoadBalancingMethod testMethod = LoadBalancingMethod.Failover;

                // Create the nested profile
                DefinitionEndpointCreateParameters nestedEndpointParam = new DefinitionEndpointCreateParameters();
                nestedEndpointParam.DomainName = ExternalDomain;
                nestedEndpointParam.Status     = EndpointStatus.Enabled;
                nestedEndpointParam.Type       = EndpointType.Any;
                nestedEndpointParam.Location   = "West US";
                string nestedProfileDomainName = testCreateDefinition(testMethod, nestedEndpointParam);

                // Create the top level profile
                DefinitionEndpointCreateParameters topLevelEndpointParam = new DefinitionEndpointCreateParameters();
                topLevelEndpointParam.DomainName        = nestedProfileDomainName;
                topLevelEndpointParam.Status            = EndpointStatus.Enabled;
                topLevelEndpointParam.Type              = EndpointType.TrafficManager;
                topLevelEndpointParam.MinChildEndpoints = 2;
                topLevelEndpointParam.Location          = "West US";
                testCreateDefinition(testMethod, topLevelEndpointParam);
            }
        }
        public void CreateADefinitionAndEnableTheProfile(
            string profileName,
            LoadBalancingMethod loadBalancingMethod,
            IList <DefinitionEndpointCreateParameters> endpoints)
        {
            DefinitionCreateParameters       definitionParameter = new DefinitionCreateParameters();
            DefinitionMonitor                monitor             = new DefinitionMonitor();
            DefinitionDnsOptions             dnsOption           = new DefinitionDnsOptions();
            DefinitionPolicyCreateParameters policyParameter     = new DefinitionPolicyCreateParameters();
            DefinitionMonitorHTTPOptions     monitorHttpOption   = new DefinitionMonitorHTTPOptions();

            definitionParameter.DnsOptions = dnsOption;
            definitionParameter.Policy     = policyParameter;
            definitionParameter.Monitors.Add(monitor);
            monitor.HttpOptions = monitorHttpOption;

            dnsOption.TimeToLiveInSeconds = 30;

            monitorHttpOption.RelativePath       = "/randomFile.aspx";
            monitorHttpOption.Verb               = "GET";
            monitorHttpOption.ExpectedStatusCode = (int)HttpStatusCode.OK;

            monitor.Protocol = DefinitionMonitorProtocol.Http;
            //Set fixed values required by services
            monitor.IntervalInSeconds         = 30;
            monitor.TimeoutInSeconds          = 10;
            monitor.ToleratedNumberOfFailures = 3;
            monitor.Port = 80;

            policyParameter.LoadBalancingMethod = loadBalancingMethod;
            policyParameter.Endpoints           = endpoints;

            TrafficManagerClient.Definitions.Create(profileName, definitionParameter);
        }
 /// <summary>
 /// Initializes a new instance of the DefinitionPolicyCreateParameters
 /// class with required arguments.
 /// </summary>
 public DefinitionPolicyCreateParameters(LoadBalancingMethod loadBalancingMethod, IList<DefinitionEndpointCreateParameters> endpoints)
     : this()
 {
     if (endpoints == null)
     {
         throw new ArgumentNullException("endpoints");
     }
     this.LoadBalancingMethod = loadBalancingMethod;
     this.Endpoints = endpoints;
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the DefinitionPolicyCreateParameters
 /// class with required arguments.
 /// </summary>
 public DefinitionPolicyCreateParameters(LoadBalancingMethod loadBalancingMethod, IList <DefinitionEndpointCreateParameters> endpoints)
     : this()
 {
     if (endpoints == null)
     {
         throw new ArgumentNullException("endpoints");
     }
     this.LoadBalancingMethod = loadBalancingMethod;
     this.Endpoints           = endpoints;
 }
 public void CreateADefinitionAndEnableTheProfile(
     string profileName,
     LoadBalancingMethod loadBalancingMethod,
     DefinitionEndpointCreateParameters endpointParameter)
 {
     CreateADefinitionAndEnableTheProfile(
         profileName,
         loadBalancingMethod,
         new List <DefinitionEndpointCreateParameters>()
     {
         endpointParameter
     });
 }
예제 #7
0
        public void CreateDefinitionNoWeight()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();
                LoadBalancingMethod testMethod = LoadBalancingMethod.Failover;
                DefinitionEndpointCreateParameters endpointParam = new DefinitionEndpointCreateParameters();
                endpointParam.DomainName = ExternalDomain;
                endpointParam.Status     = EndpointStatus.Enabled;
                endpointParam.Type       = EndpointType.Any;

                testCreateDefinition(testMethod, endpointParam);
            }
        }
        public void CreateADefinitionAndEnableTheProfile(
            string profileName,
            string domain,
            EndpointType endpointType,
            LoadBalancingMethod testMethod = LoadBalancingMethod.Performance)
        {
            DefinitionEndpointCreateParameters endpointParameter = new DefinitionEndpointCreateParameters();

            endpointParameter.DomainName = domain;
            endpointParameter.Status     = EndpointStatus.Enabled;
            endpointParameter.Type       = endpointType;

            CreateADefinitionAndEnableTheProfile(profileName, LoadBalancingMethod.Performance, endpointParameter);
        }
예제 #9
0
        public void CreateDefinitionAnyWithLocation()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();
                LoadBalancingMethod testMethod = LoadBalancingMethod.Performance;
                DefinitionEndpointCreateParameters endpointParam = new DefinitionEndpointCreateParameters();
                endpointParam.DomainName = ExternalDomain;
                endpointParam.Status     = EndpointStatus.Enabled;
                endpointParam.Type       = EndpointType.Any;
                endpointParam.Weight     = 1;
                endpointParam.Location   = "West US";

                testCreateDefinition(testMethod, endpointParam);
            }
        }
예제 #10
0
        public void CreateDefinitionWebsite()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();
                //Arrange
                using (TrafficManagerTestBase _testFixture = new TrafficManagerTestBase())
                {
                    string websiteDomain           = _testFixture.CreateTestWebsite();
                    LoadBalancingMethod testMethod = LoadBalancingMethod.Performance;
                    DefinitionEndpointCreateParameters endpointParam = new DefinitionEndpointCreateParameters();
                    endpointParam.DomainName = websiteDomain;
                    endpointParam.Status     = EndpointStatus.Enabled;
                    endpointParam.Type       = EndpointType.AzureWebsite;
                    endpointParam.Weight     = 3;

                    //Arrange + Act + Assert
                    testCreateDefinition(testMethod, endpointParam);
                }
            }
        }
예제 #11
0
        private string testCreateDefinition(LoadBalancingMethod testMethod, DefinitionEndpointCreateParameters endpoint)
        {
            //Arrange
            using (TrafficManagerTestBase _testFixture = new TrafficManagerTestBase())
            {
                string profileName = _testFixture.CreateTestProfile();

                _testFixture.CreateADefinitionAndEnableTheProfile(
                    profileName,
                    testMethod,
                    endpoint);

                //Act, try 'List'
                DefinitionsListResponse listResponse = _testFixture.TrafficManagerClient.Definitions.List(profileName);

                //Assert
                Assert.Equal(1, listResponse.Count());
                Assert.Equal(testMethod, listResponse.First().Policy.LoadBalancingMethod);

                //Act, try 'Get'
                DefinitionGetResponse getResponse = _testFixture.TrafficManagerClient.Definitions.Get(profileName);

                //Assert
                Assert.Equal(testMethod, getResponse.Definition.Policy.LoadBalancingMethod);
                Assert.Equal(1, getResponse.Definition.Policy.Endpoints.Count);
                Assert.Equal(endpoint.Type, getResponse.Definition.Policy.Endpoints[0].Type);
                Assert.Equal(endpoint.Weight ?? 1, getResponse.Definition.Policy.Endpoints[0].Weight);
                Assert.Equal(endpoint.Location, getResponse.Definition.Policy.Endpoints[0].Location);
                Assert.Equal(endpoint.MinChildEndpoints, getResponse.Definition.Policy.Endpoints[0].MinChildEndpoints);

                //verify the profile itself has an associated definition enabled.
                //(due to the service limitation of one defintion per one profile, the enabled version is 1 always
                ProfileGetResponse profileGetResponse = _testFixture.TrafficManagerClient.Profiles.Get(profileName);
                Assert.Equal(1, profileGetResponse.Profile.StatusDetails.EnabledDefinitionVersion);

                return(profileGetResponse.Profile.DomainName);
            }
        }
예제 #12
0
        public void CreateDefinitionCloudService()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();
                System.Diagnostics.Trace.WriteLine("Cloud service test");

                //Arrange
                using (TrafficManagerTestBase _testFixture = new TrafficManagerTestBase())
                {
                    string serviceDomain           = _testFixture.CreateTestCloudService();
                    LoadBalancingMethod testMethod = LoadBalancingMethod.Failover;
                    DefinitionEndpointCreateParameters endpointParam = new DefinitionEndpointCreateParameters();
                    endpointParam.DomainName = serviceDomain;
                    endpointParam.Status     = EndpointStatus.Enabled;
                    endpointParam.Type       = EndpointType.CloudService;
                    endpointParam.Weight     = 2;

                    //Arrange + Act + Assert
                    testCreateDefinition(testMethod, endpointParam);
                }
            }
        }
        public void CreateADefinitionAndEnableTheProfile(
            string profileName,
            LoadBalancingMethod loadBalancingMethod,
            IList<DefinitionEndpointCreateParameters> endpoints)
        {
            DefinitionCreateParameters definitionParameter = new DefinitionCreateParameters();
            DefinitionMonitor monitor = new DefinitionMonitor();
            DefinitionDnsOptions dnsOption = new DefinitionDnsOptions();
            DefinitionPolicyCreateParameters policyParameter = new DefinitionPolicyCreateParameters();
            DefinitionMonitorHTTPOptions monitorHttpOption = new DefinitionMonitorHTTPOptions();

            definitionParameter.DnsOptions = dnsOption;
            definitionParameter.Policy = policyParameter;
            definitionParameter.Monitors.Add(monitor);
            monitor.HttpOptions = monitorHttpOption;

            dnsOption.TimeToLiveInSeconds = 30;

            monitorHttpOption.RelativePath = "/randomFile.aspx";
            monitorHttpOption.Verb = "GET";
            monitorHttpOption.ExpectedStatusCode = (int)HttpStatusCode.OK;

            monitor.Protocol = DefinitionMonitorProtocol.Http;
            //Set fixed values required by services   
            monitor.IntervalInSeconds = 30;
            monitor.TimeoutInSeconds = 10;
            monitor.ToleratedNumberOfFailures = 3;
            monitor.Port = 80;

            policyParameter.LoadBalancingMethod = loadBalancingMethod;
            policyParameter.Endpoints = endpoints;

            TrafficManagerClient.Definitions.Create(profileName, definitionParameter);
        }
 public void CreateADefinitionAndEnableTheProfile(
     string profileName,
     LoadBalancingMethod loadBalancingMethod,
     DefinitionEndpointCreateParameters endpointParameter)
 {
     CreateADefinitionAndEnableTheProfile(
         profileName,
         loadBalancingMethod,
         new List<DefinitionEndpointCreateParameters>() { endpointParameter });
 }
        public void CreateADefinitionAndEnableTheProfile(
            string profileName,
            string domain,
            EndpointType endpointType,
            LoadBalancingMethod testMethod = LoadBalancingMethod.Performance)
        {
            DefinitionEndpointCreateParameters endpointParameter = new DefinitionEndpointCreateParameters();
            endpointParameter.DomainName = domain;
            endpointParameter.Status = EndpointStatus.Enabled;
            endpointParameter.Type = endpointType;

            CreateADefinitionAndEnableTheProfile(profileName, LoadBalancingMethod.Performance, endpointParameter);
        }
        private string testCreateDefinition(LoadBalancingMethod testMethod, DefinitionEndpointCreateParameters endpoint)
        {
            //Arrange
            using (TrafficManagerTestBase _testFixture = new TrafficManagerTestBase())
            {
                string profileName = _testFixture.CreateTestProfile();

                _testFixture.CreateADefinitionAndEnableTheProfile(
                    profileName,
                    testMethod,
                    endpoint);

                //Act, try 'List'
                DefinitionsListResponse listResponse = _testFixture.TrafficManagerClient.Definitions.List(profileName);

                //Assert
                Assert.Equal(1, listResponse.Count());
                Assert.Equal(testMethod, listResponse.First().Policy.LoadBalancingMethod);

                //Act, try 'Get'
                DefinitionGetResponse getResponse = _testFixture.TrafficManagerClient.Definitions.Get(profileName);

                //Assert
                Assert.Equal(testMethod, getResponse.Definition.Policy.LoadBalancingMethod);
                Assert.Equal(1, getResponse.Definition.Policy.Endpoints.Count);
                Assert.Equal(endpoint.Type, getResponse.Definition.Policy.Endpoints[0].Type);
                Assert.Equal(endpoint.Weight ?? 1, getResponse.Definition.Policy.Endpoints[0].Weight);
                Assert.Equal(endpoint.Location, getResponse.Definition.Policy.Endpoints[0].Location);
                Assert.Equal(endpoint.MinChildEndpoints, getResponse.Definition.Policy.Endpoints[0].MinChildEndpoints);

                //verify the profile itself has an associated definition enabled.
                //(due to the service limitation of one defintion per one profile, the enabled version is 1 always 
                ProfileGetResponse profileGetResponse = _testFixture.TrafficManagerClient.Profiles.Get(profileName);
                Assert.Equal(1, profileGetResponse.Profile.StatusDetails.EnabledDefinitionVersion);

                return profileGetResponse.Profile.DomainName;
            }
        }