Esempio n. 1
0
        private void ValidateResults(AvailabilitySetCreateOrUpdateResponse createOrUpdateResponse, AvailabilitySet inputAvailabilitySet, int expectedFD, int expectedUD)
        {
            string expectedAvailabilitySetId = Helpers.GetAvailabilitySetRef(subId, resourceGroupName, inputAvailabilitySet.Name);

            Assert.True(createOrUpdateResponse.StatusCode == HttpStatusCode.OK);

            Assert.True(createOrUpdateResponse.AvailabilitySet.Name == inputAvailabilitySet.Name);
            Assert.True(createOrUpdateResponse.AvailabilitySet.Location.ToLower() == this.location.ToLower() ||
                        createOrUpdateResponse.AvailabilitySet.Location.ToLower() == inputAvailabilitySet.Location.ToLower());

            ValidateAvailabilitySet(inputAvailabilitySet, createOrUpdateResponse.AvailabilitySet, expectedAvailabilitySetId, expectedFD, expectedUD);

            // GET AvailabilitySet
            var getResponse = computeClient.AvailabilitySets.Get(resourceGroupName, inputAvailabilitySet.Name);

            Assert.True(getResponse.StatusCode == HttpStatusCode.OK);
            ValidateAvailabilitySet(inputAvailabilitySet, getResponse.AvailabilitySet, expectedAvailabilitySetId, expectedFD, expectedUD);

            // List AvailabilitySets
            var listResponse = computeClient.AvailabilitySets.List(resourceGroupName);

            Assert.True(listResponse.StatusCode == HttpStatusCode.OK);
            ValidateAvailabilitySet(inputAvailabilitySet, listResponse.AvailabilitySets.FirstOrDefault(x => x.Name == inputAvailabilitySet.Name),
                                    expectedAvailabilitySetId, expectedFD, expectedUD);

            var listVMSizesResponse = computeClient.AvailabilitySets.ListAvailableSizes(resourceGroupName, inputAvailabilitySet.Name);

            Assert.True(listVMSizesResponse.StatusCode == HttpStatusCode.OK);
            Helpers.ValidateVirtualMachineSizeListResponse(listVMSizesResponse);

            // Delete AvailabilitySet
            var deleteOperationResponse = computeClient.AvailabilitySets.Delete(resourceGroupName, inputAvailabilitySet.Name);

            Assert.True(deleteOperationResponse.StatusCode == HttpStatusCode.OK);
        }
Esempio n. 2
0
        private void VerifyInvalidFDUDValuesFail()
        {
            var inputAvailabilitySet = new AvailabilitySet
            {
                Location = location,
                Name     = TestUtilities.GenerateName("invalidfdud"),
                Tags     = new Dictionary <string, string>()
                {
                    { "RG", "rg" },
                    { "testTag", "1" },
                },
            };

            // function to test the limits available.
            inputAvailabilitySet.PlatformFaultDomainCount = FDTooLow;
            AvailabilitySetCreateOrUpdateResponse createOrUpdateResponse = null;

            try
            {
                createOrUpdateResponse = computeClient.AvailabilitySets.CreateOrUpdate(
                    resourceGroupName,
                    inputAvailabilitySet);
            }
            catch (Hyak.Common.CloudException ex)
            {
                Assert.True(ex.Response.StatusCode == HttpStatusCode.BadRequest);
                Assert.True(ex.Error.Code == "InvalidParameter");
            }
            Assert.True(createOrUpdateResponse == null);

            inputAvailabilitySet.PlatformFaultDomainCount = FDTooHi;
            try
            {
                createOrUpdateResponse = computeClient.AvailabilitySets.CreateOrUpdate(
                    resourceGroupName,
                    inputAvailabilitySet);
            }
            catch (Hyak.Common.CloudException ex)
            {
                Assert.True(ex.Response.StatusCode == HttpStatusCode.BadRequest);
                Assert.True(ex.Error.Code == "InvalidParameter");
            }
            Assert.True(createOrUpdateResponse == null);

            inputAvailabilitySet.PlatformUpdateDomainCount = UDTooLow;
            try
            {
                createOrUpdateResponse = computeClient.AvailabilitySets.CreateOrUpdate(
                    resourceGroupName,
                    inputAvailabilitySet);
            }
            catch (Hyak.Common.CloudException ex)
            {
                Assert.True(ex.Response.StatusCode == HttpStatusCode.BadRequest);
                Assert.True(ex.Error.Code == "InvalidParameter");
            }
            Assert.True(createOrUpdateResponse == null);

            inputAvailabilitySet.PlatformUpdateDomainCount = UDTooHi;
            try
            {
                createOrUpdateResponse = computeClient.AvailabilitySets.CreateOrUpdate(
                    resourceGroupName,
                    inputAvailabilitySet);
            }
            catch (Hyak.Common.CloudException ex)
            {
                Assert.True(ex.Response.StatusCode == HttpStatusCode.BadRequest);
                Assert.True(ex.Error.Code == "InvalidParameter");
            }
            Assert.True(createOrUpdateResponse == null);
        }