Exemplo n.º 1
0
        public async Task ValidateSupportedVmSizesFileContent()
        {
            var configuration         = GetInMemoryConfig();
            var mockAzureProxy        = GetMockAzureProxy();
            var mockLogger            = new Mock <ILogger>().Object;
            var storageAccessProvider = new StorageAccessProvider(mockLogger, configuration, mockAzureProxy.Object);

            var configurationUtils = new ConfigurationUtils(configuration, mockAzureProxy.Object, storageAccessProvider, mockLogger);

            await configurationUtils.ProcessAllowedVmSizesConfigurationFileAsync();

            var expectedSupportedVmSizesFileContent =
                "VM Size Family       $/hour   $/hour  Memory  CPUs   Disk     Dedicated CPU\n" +
                "                  dedicated  low pri   (GiB)        (GiB)  quota (per fam.)\n" +
                "VmSize1 VmFamily1    11.000   22.000       3     2     20               100\n" +
                "VmSize2 VmFamily2    33.000   44.000       6     4     40                 0\n" +
                "VmSize3 VmFamily3    55.000      N/A      12     8     80               300";

            mockAzureProxy.Verify(m => m.UploadBlobAsync(It.Is <Uri>(x => x.AbsoluteUri.Contains("supported-vm-sizes")), It.Is <string>(s => s.Equals(expectedSupportedVmSizesFileContent))), Times.Exactly(1));
        }
Exemplo n.º 2
0
        public async Task UnsupportedVmSizeInAllowedVmSizesFileIsIgnoredAndTaggedWithWarning()
        {
            var configuration         = GetInMemoryConfig();
            var mockAzureProxy        = GetMockAzureProxy();
            var mockLogger            = new Mock <ILogger>().Object;
            var storageAccessProvider = new StorageAccessProvider(mockLogger, configuration, mockAzureProxy.Object);

            var configurationUtils = new ConfigurationUtils(configuration, mockAzureProxy.Object, storageAccessProvider, mockLogger);

            await configurationUtils.ProcessAllowedVmSizesConfigurationFileAsync();

            Assert.AreEqual("VmSize1,VmSize2", configuration["AllowedVmSizes"]);

            var expectedAllowedVmSizesFileContent =
                "VmSize1\n" +
                "#SomeComment\n" +
                "VmSize2\n" +
                "VmSizeNonExistent <-- WARNING: This VM size is either misspelled or not supported in your region. It will be ignored.";

            mockAzureProxy.Verify(m => m.UploadBlobAsync(It.Is <Uri>(x => x.AbsoluteUri.Contains("allowed-vm-sizes")), It.Is <string>(s => s.Equals(expectedAllowedVmSizesFileContent))), Times.Exactly(1));
        }