Exemplo n.º 1
0
        //[Trait("Name", "TestVMScaleSetRollingUpgradeHistory")]
        public async Task TestVMScaleSetRollingUpgradeHistory()
        {
            EnsureClientsInitialized(LocationSouthCentralUs);

            // Create resource group
            var    rgName             = Recording.GenerateAssetName(TestPrefix);
            var    vmssName           = Recording.GenerateAssetName("vmss");
            string storageAccountName = Recording.GenerateAssetName(TestPrefix);
            VirtualMachineScaleSet inputVMScaleSet;

            ImageReference imageRef = await GetPlatformVMImage(useWindowsImage : true);

            imageRef.Version = "latest";

            var storageAccountOutput = await CreateStorageAccount(rgName, storageAccountName);

            await WaitForCompletionAsync(await VirtualMachineScaleSetsOperations.StartDeleteAsync(rgName, "VMScaleSetDoesNotExist"));

            var getTwoVirtualMachineScaleSet = await CreateVMScaleSet_NoAsyncTracking(
                rgName,
                vmssName,
                storageAccountOutput,
                imageRef,
                null,
                (vmScaleSet) =>
            {
                vmScaleSet.Overprovision      = false;
                vmScaleSet.UpgradePolicy.Mode = UpgradeMode.Rolling;
            },
                createWithManagedDisks : true,
                createWithPublicIpAddress : false,
                createWithHealthProbe : true);

            VirtualMachineScaleSet getResponse = getTwoVirtualMachineScaleSet.Item1;

            inputVMScaleSet = getTwoVirtualMachineScaleSet.Item2;
            ValidateVMScaleSet(inputVMScaleSet, getResponse, hasManagedDisks: true);
            WaitSeconds(600);
            var vmssStatus = await VirtualMachineScaleSetsOperations.GetInstanceViewAsync(rgName, vmssName);

            await WaitForCompletionAsync(await VirtualMachineScaleSetRollingUpgradesOperations.StartStartOSUpgradeAsync(rgName, vmssName));

            var rollingUpgrade        = VirtualMachineScaleSetsOperations.GetOSUpgradeHistoryAsync(rgName, vmssName);
            var rollingUpgradeHistory = await rollingUpgrade.ToEnumerableAsync();

            Assert.NotNull(rollingUpgradeHistory);
            Assert.True(rollingUpgradeHistory.Count() == 1);
            Assert.AreEqual(inputVMScaleSet.Sku.Capacity, rollingUpgradeHistory.First().Properties.Progress.SuccessfulInstanceCount);
        }