protected void EnsureClientsInitialized(bool useSPN = false) { if (!m_initialized) { lock (m_lock) { if (!m_initialized) { var handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; if (useSPN) { m_ResourcesClient = ComputeManagementTestUtilities.GetResourceManagementClientWithSpn(handler); m_CrpClient = ComputeManagementTestUtilities.GetComputeManagementClientWithSpn(handler); m_SrpClient = ComputeManagementTestUtilities.GetStorageManagementClientSpn(handler); m_NrpClient = ComputeManagementTestUtilities.GetNetworkResourceProviderClientSpn(handler); } else { m_ResourcesClient = ComputeManagementTestUtilities.GetResourceManagementClient(handler); m_CrpClient = ComputeManagementTestUtilities.GetComputeManagementClient(handler); m_SrpClient = ComputeManagementTestUtilities.GetStorageManagementClient(handler); m_NrpClient = ComputeManagementTestUtilities.GetNetworkResourceProviderClient(handler); } m_subId = m_CrpClient.Credentials.SubscriptionId; m_location = ComputeManagementTestUtilities.DefaultLocation; } } } }
public void TestVMImageGet() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(new RDFETestEnvironmentFactory(), new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var vmimage = _pirClient.VirtualMachineImages.Get(parameters); Assert.True(vmimage.VirtualMachineImage.Name == "1.0.0"); Assert.True(vmimage.VirtualMachineImage.Location == "westus"); Assert.True(vmimage.VirtualMachineImage.PurchasePlan.Name == "name"); Assert.True(vmimage.VirtualMachineImage.PurchasePlan.Publisher == "publisher"); Assert.True(vmimage.VirtualMachineImage.PurchasePlan.Product == "product"); Assert.True(vmimage.VirtualMachineImage.OSDiskImage.OperatingSystem == "Linux"); Assert.True(vmimage.VirtualMachineImage.DataDiskImages.Count(ddi => ddi.Lun == 123456789) != 0); } }
public void TestVMImageListFilters() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(); VirtualMachineImageListParameters listParametersWithFilter = new VirtualMachineImageListParameters() { Location = listParameters.Location, PublisherName = listParameters.PublisherName, Offer = listParameters.Offer, Skus = listParameters.Skus, }; // Filter: top - Negative Test listParametersWithFilter.FilterExpression = "$top=0"; var vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 0); // Filter: top - Positive Test listParametersWithFilter.FilterExpression = "$top=1"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 1); // Filter: top - Positive Test listParametersWithFilter.FilterExpression = "$top=2"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 2); Assert.True(vmimages.Resources.Count(vmi => vmi.Name == AvailableWindowsServerImageVersions[1]) != 0); // Filter: orderby - Positive Test listParametersWithFilter.FilterExpression = "$orderby=name desc"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.Equal(AvailableWindowsServerImageVersions.Length, vmimages.Resources.Count); for (int i = 0; i < AvailableWindowsServerImageVersions.Length; i++) { Assert.Equal(AvailableWindowsServerImageVersions[i], vmimages.Resources[i].Name); } // Filter: orderby - Positive Test listParametersWithFilter.FilterExpression = "$top=2&$orderby=name asc"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 2); Assert.True(vmimages.Resources[0].Name == AvailableWindowsServerImageVersions.Last()); Assert.True(vmimages.Resources[1].Name == AvailableWindowsServerImageVersions.Reverse().Skip(1).First()); // Filter: top orderby - Positive Test listParametersWithFilter.FilterExpression = "$top=1&$orderby=name desc"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 1); Assert.True(vmimages.Resources[0].Name == AvailableWindowsServerImageVersions[0]); // Filter: top orderby - Positive Test listParametersWithFilter.FilterExpression = "$top=1&$orderby=name asc"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 1); Assert.True(vmimages.Resources[0].Name == AvailableWindowsServerImageVersions.Last()); } }
protected void EnsureClientsInitialized(MockContext context) { if (!m_initialized) { lock (m_lock) { if (!m_initialized) { m_ResourcesClient = ComputeManagementTestUtilities.GetResourceManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); m_CrpClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); m_SrpClient = ComputeManagementTestUtilities.GetStorageManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); m_NrpClient = ComputeManagementTestUtilities.GetNetworkManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); m_subId = m_CrpClient.SubscriptionId; if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION"))) { m_location = ComputeManagementTestUtilities.DefaultLocation; } else { m_location = Environment.GetEnvironmentVariable("AZURE_VM_TEST_LOCATION").Replace(" ", "").ToLower(); } } } } }
public void TestVMImageGet() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(); var vmimage = _pirClient.VirtualMachineImages.Get(parameters); Assert.Equal(parameters.Version, vmimage.VirtualMachineImage.Name); Assert.Equal(parameters.Location, vmimage.VirtualMachineImage.Location, StringComparer.OrdinalIgnoreCase); // FIXME: This doesn't work with a real Windows Server images, which is what's in the query parameters. // Bug 4196378 /* * Assert.True(vmimage.VirtualMachineImage.PurchasePlan.Name == "name"); * Assert.True(vmimage.VirtualMachineImage.PurchasePlan.Publisher == "publisher"); * Assert.True(vmimage.VirtualMachineImage.PurchasePlan.Product == "product"); */ Assert.True(vmimage.VirtualMachineImage.OSDiskImage.OperatingSystem == "Windows"); //Assert.True(vmimage.VirtualMachineImage.DataDiskImages.Count(ddi => ddi.Lun == 123456789) != 0); } }
public void TestExtImgGet() { using (MockContext context = MockContext.Start(this.GetType())) { ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var vmimageext = _pirClient.VirtualMachineExtensionImages.Get( parameters.Location, parameters.PublisherName, parameters.Type, "2.0"); Assert.True(vmimageext.Name == "2.0"); Assert.True(vmimageext.Location == "westus"); Assert.True(vmimageext.OperatingSystem == "Windows"); Assert.True(vmimageext.ComputeRole == "IaaS"); Assert.True(vmimageext.HandlerSchema == null); Assert.True(vmimageext.VmScaleSetEnabled == false); Assert.True(vmimageext.SupportsMultipleExtensions == false); } }
private void Initialize(MockContext context) { handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; resourcesClient = ComputeManagementTestUtilities.GetResourceManagementClient(context, handler); computeClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, handler); subId = computeClient.SubscriptionId; location = m_location; baseResourceGroupName = ComputeManagementTestUtilities.GenerateName(TestPrefix); resourceGroup1Name = baseResourceGroupName + "_1"; resourceGroup1 = resourcesClient.ResourceGroups.CreateOrUpdate( resourceGroup1Name, new ResourceGroup { Location = location, Tags = new Dictionary <string, string>() { { resourceGroup1Name, DateTime.UtcNow.ToString("u") } } }); }
public void TestListVMRunCommands() { using (MockContext context = MockContext.Start(this.GetType())) { var computeClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); string location = ComputeManagementTestUtilities.DefaultLocation.Replace(" ", ""); string documentId = "RunPowerShellScript"; // Verify the List of commands IEnumerable <RunCommandDocumentBase> runCommandListResponse = computeClient.VirtualMachineRunCommands.List(location); Assert.NotNull(runCommandListResponse); Assert.True(runCommandListResponse.Count() > 0, "ListRunCommands should return at least 1 command"); RunCommandDocumentBase documentBase = runCommandListResponse.FirstOrDefault(x => string.Equals(x.Id, documentId)); Assert.NotNull(documentBase); // Verify Get a specific RunCommand RunCommandDocument document = computeClient.VirtualMachineRunCommands.Get(location, documentId); Assert.NotNull(document); Assert.NotNull(document.Script); Assert.True(document.Script.Count > 0, "Script should contain at least one command."); Assert.NotNull(document.Parameters); Assert.True(document.Parameters.Count == 2, "Script should have 2 parameters."); } }
public void TestListVMSizes() { using (MockContext context = MockContext.Start(this.GetType())) { var computeClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); string location = ComputeManagementTestUtilities.DefaultLocation.Replace(" ", ""); var virtualMachineSizeListResponse = computeClient.VirtualMachineSizes.List(location); Helpers.ValidateVirtualMachineSizeListResponse(virtualMachineSizeListResponse); } }
public void TestVMImageListSkus() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(); var skus = _pirClient.VirtualMachineImages.ListSkus(parameters); Assert.True(skus.Resources.Count > 0); Assert.True(skus.Resources.Count(sku => sku.Name == parameters.Skus) != 0); } }
public void TestVMImageListPublishers() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(); var publishers = _pirClient.VirtualMachineImages.ListPublishers(parameters); Assert.True(publishers.Resources.Count > 0); Assert.True(publishers.Resources.Count(pub => pub.Name == parameters.PublisherName) != 0); } }
public void TestListVMSizes() { using (var context = UndoContext.Current) { context.Start(); var computeClient = ComputeManagementTestUtilities.GetComputeManagementClient(); string location = ComputeManagementTestUtilities.DefaultLocation.Replace(" ", ""); VirtualMachineSizeListResponse virtualMachineSizeListResponse = computeClient.VirtualMachineSizes.List(location); Assert.True(virtualMachineSizeListResponse.StatusCode == HttpStatusCode.OK); Helpers.ValidateVirtualMachineSizeListResponse(virtualMachineSizeListResponse); } }
public void TestVMImageListNoFilter() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(); var vmimages = _pirClient.VirtualMachineImages.List(listParameters); Assert.True(vmimages.Resources.Count > 0); Assert.True(vmimages.Resources.Count(vmi => vmi.Name == AvailableWindowsServerImageVersions[0]) != 0); Assert.True(vmimages.Resources.Count(vmi => vmi.Name == AvailableWindowsServerImageVersions[1]) != 0); } }
public void TestListSkus() { using (MockContext context = MockContext.Start(this.GetType())) { var computeClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); IPage <ResourceSku> skus = computeClient.ResourceSkus.List(includeExtendedLocations: "true"); Assert.True(skus.Any(), "Assert that the array of skus has at least 1 member."); Assert.True(skus.Any(sku => sku.ResourceType == "availabilitySets"), "Assert that the sku list at least contains" + "one availability set."); Assert.True(skus.Any(sku => sku.ResourceType == "virtualMachines"), "Assert that the sku list at least contains" + "one virtual machine."); Assert.True(skus.Any(sku => sku.LocationInfo != null), "Assert that the sku list has non null location info in it."); //Removing below Assert because API now returns some skus without location. Get-AzComputeResourceSku | Where-Object { $_.LocationInfo.count -ne 1} //Assert.True(skus.All(sku => sku.LocationInfo.Count == 1), "There should be exactly one location info per entry."); Assert.True(skus.Any(sku => sku.LocationInfo[0].Location.Equals("westus", StringComparison.Ordinal)), "Assert that it has entry for one of the CRP regions (randomly picked)."); // EastUS2EUAP is one of the regions where UltraSSD is enabled, hence verifying that CRP and ARM are returning correct // properties related to UltraSSD in the SKUs API var vmSkusInEastUS2Euap = skus.Where( s => s.Locations[0].Equals("eastus2euap", StringComparison.OrdinalIgnoreCase) && s.ResourceType == "virtualMachines").ToList(); var ultraSSDSupportingSku = vmSkusInEastUS2Euap.First(s => s.Name == "Standard_B2s"); var nonUltraSSDSupportingSku = vmSkusInEastUS2Euap.First(s => s.Name == "Standard_A7"); Assert.NotNull(ultraSSDSupportingSku.LocationInfo); Assert.Equal(2, ultraSSDSupportingSku.LocationInfo.Count); Assert.NotNull(ultraSSDSupportingSku.LocationInfo[0].ZoneDetails); Assert.Equal(1, ultraSSDSupportingSku.LocationInfo[0].ZoneDetails.Count); Assert.NotNull(ultraSSDSupportingSku.LocationInfo[0].ZoneDetails[0].Name); Assert.NotNull(ultraSSDSupportingSku.LocationInfo[0].ZoneDetails[0].Capabilities); Assert.Equal(1, ultraSSDSupportingSku.LocationInfo[0].ZoneDetails[0].Capabilities.Count); Assert.Equal("UltraSSDAvailable", ultraSSDSupportingSku.LocationInfo[0].ZoneDetails[0].Capabilities[0].Name); Assert.Equal("True", ultraSSDSupportingSku.LocationInfo[0].ZoneDetails[0].Capabilities[0].Value); Assert.NotNull(nonUltraSSDSupportingSku.LocationInfo); // ZoneDetails should not be set for a SKU which does not support ultraSSD. This is because we do not have any // other zonal capability currently. //Assert.Null(nonUltraSSDSupportingSku.LocationInfo[0].ZoneDetails); Assert.Equal(0, nonUltraSSDSupportingSku.LocationInfo[0].ZoneDetails.Count); // Validate that extendedlocations are included for a supported sku Assert.NotEmpty(vmSkusInEastUS2Euap.Where(s => s.Name == "Standard_D4s_v3").First().LocationInfo.Where(info => info.ExtendedLocations != null)); // Validate that extendedlocations are not included for an unsupported sku Assert.Empty(vmSkusInEastUS2Euap.Where(s => s.Name == "Basic_A0").First().LocationInfo.Where(info => info.ExtendedLocations != null)); } }
public void TestVMImageListPublishers() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var publishers = _pirClient.VirtualMachineImages.ListPublishers( ComputeManagementTestUtilities.DefaultLocation); Assert.True(publishers.Count > 0); Assert.True(publishers.Count(pub => pub.Name == "MicrosoftWindowsServer") != 0); } }
public void TestExtImgListVersionsNoFilter() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(new RDFETestEnvironmentFactory(), new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var vmextimg = _pirClient.VirtualMachineExtensionImages.ListVersions(parameters); Assert.True(vmextimg.Resources.Count > 0); Assert.True(vmextimg.Resources.Count(vmi => vmi.Name == "1.1.0") != 0); } }
public void TestVMImageListSkus() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(new RDFETestEnvironmentFactory(), new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var skus = _pirClient.VirtualMachineImages.ListSkus(parameters); Assert.True(skus.Resources.Count > 0); Assert.True(skus.Resources.Count(sku => sku.Name == "Enterprise") != 0); } }
public void TestVMImageListSkus() { using (MockContext context = MockContext.Start(this.GetType())) { ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var skus = _pirClient.VirtualMachineImages.ListSkus( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer"); Assert.True(skus.Count > 0); Assert.True(skus.Count(sku => sku.Name == "2012-R2-Datacenter") != 0); } }
public void TestExtImgListTypes() { using (MockContext context = MockContext.Start(this.GetType())) { ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var vmextimg = _pirClient.VirtualMachineExtensionImages.ListTypes( parameters.Location, parameters.PublisherName); Assert.True(vmextimg.Count > 0); Assert.True(vmextimg.Count(vmi => vmi.Name == "VMAccessAgent") != 0); } }
public void TestExtImgListVersionsFilters() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(new RDFETestEnvironmentFactory(), new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); VirtualMachineExtensionImageListVersionsParameters listVersionsParamers = new VirtualMachineExtensionImageListVersionsParameters() { Location = parameters.Location, Type = parameters.Type, PublisherName = parameters.PublisherName, }; // Filter: startswith - Positive Test listVersionsParamers.FilterExpression = "$filter=startswith(name,'1.1')"; var vmextimg = _pirClient.VirtualMachineExtensionImages.ListVersions(listVersionsParamers); Assert.True(vmextimg.Resources.Count > 0); Assert.True(vmextimg.Resources.Count(vmi => vmi.Name == "1.1.0") != 0); // Filter: startswith - Negative Test listVersionsParamers.FilterExpression = "$filter=startswith(name,'1.0')"; vmextimg = _pirClient.VirtualMachineExtensionImages.ListVersions(listVersionsParamers); Assert.True(vmextimg.Resources.Count == 0); Assert.True(vmextimg.Resources.Count(vmi => vmi.Name == "1.1.0") == 0); // Filter: top - Positive Test listVersionsParamers.FilterExpression = "$top=1"; vmextimg = _pirClient.VirtualMachineExtensionImages.ListVersions(listVersionsParamers); Assert.True(vmextimg.Resources.Count == 1); Assert.True(vmextimg.Resources.Count(vmi => vmi.Name == "1.1.0") != 0); // Filter: top - Negative Test listVersionsParamers.FilterExpression = "$top=0"; vmextimg = _pirClient.VirtualMachineExtensionImages.ListVersions(listVersionsParamers); Assert.True(vmextimg.Resources.Count == 0); } }
public void TestVMImageListNoFilter() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter"); Assert.True(vmimages.Count > 0); //Assert.True(vmimages.Count(vmi => vmi.Name == AvailableWindowsServerImageVersions[0]) != 0); //Assert.True(vmimages.Count(vmi => vmi.Name == AvailableWindowsServerImageVersions[1]) != 0); } }
private void Initialize() { handler = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; resourcesClient = ComputeManagementTestUtilities.GetResourceManagementClient(handler); computeClient = ComputeManagementTestUtilities.GetComputeManagementClient(handler); subId = computeClient.Credentials.SubscriptionId; location = ComputeManagementTestUtilities.DefaultLocation; resourceGroupName = TestUtilities.GenerateName(testPrefix); resourceGroup = resourcesClient.ResourceGroups.CreateOrUpdate( resourceGroupName, new ResourceGroup { Location = location }); }
public void TestListSkus() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { var computeClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); IPage <ResourceSku> skus = computeClient.ResourceSkus.List(); Assert.True(skus.Any(), "Assert that the array of skus has at least 1 member."); Assert.True(skus.Any(sku => sku.ResourceType == "availabilitySets"), "Assert that the sku list at least contains" + "one availability set."); Assert.True(skus.Any(sku => sku.ResourceType == "virtualMachines"), "Assert that the sku list at least contains" + "one virtual machine."); Assert.True(skus.Any(sku => sku.LocationInfo != null), "Assert that the sku list has non null location info in it."); Assert.True(skus.All(sku => sku.LocationInfo.Count == 1), "There should be exactly one location info per entry."); Assert.True(skus.Any(sku => sku.LocationInfo[0].Location.Equals("westus", StringComparison.Ordinal)), "Assert that it has entry for one of the CRP regions (randomly picked)."); } }
public void TestVMImageGet() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); string[] availableWindowsServerImageVersions = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter").Select(t => t.Name).ToArray(); var vmimage = _pirClient.VirtualMachineImages.Get( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", availableWindowsServerImageVersions[0]); Assert.Equal(availableWindowsServerImageVersions[0], vmimage.Name); Assert.Equal(ComputeManagementTestUtilities.DefaultLocation, vmimage.Location, StringComparer.OrdinalIgnoreCase); // FIXME: This doesn't work with a real Windows Server images, which is what's in the query parameters. // Bug 4196378 /* * Assert.True(vmimage.VirtualMachineImage.PurchasePlan.Name == "name"); * Assert.True(vmimage.VirtualMachineImage.PurchasePlan.Publisher == "publisher"); * Assert.True(vmimage.VirtualMachineImage.PurchasePlan.Product == "product"); */ Assert.Equal(OperatingSystemTypes.Windows, vmimage.OsDiskImage.OperatingSystem); //Assert.True(vmimage.VirtualMachineImage.DataDiskImages.Count(ddi => ddi.Lun == 123456789) != 0); } }
public void TestExtImgGet() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(new RDFETestEnvironmentFactory(), new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var vmimageext = _pirClient.VirtualMachineExtensionImages.Get(parameters); Assert.True(vmimageext.VirtualMachineExtensionImage.Name == "1.1.0"); Assert.True(vmimageext.VirtualMachineExtensionImage.Location == "westus"); Assert.True(vmimageext.VirtualMachineExtensionImage.OperatingSystem == "Windows"); Assert.True(vmimageext.VirtualMachineExtensionImage.ComputeRole == "PaaS"); Assert.True(string.IsNullOrEmpty(vmimageext.VirtualMachineExtensionImage.HandlerSchema)); Assert.True(vmimageext.VirtualMachineExtensionImage.VMScaleSetEnabled == false); Assert.True(vmimageext.VirtualMachineExtensionImage.SupportsMultipleExtensions == false); } }
public void TestVMImageListFilters() { using (var context = UndoContext.Current) { context.Start(); ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(new RDFETestEnvironmentFactory(), new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); VirtualMachineImageListParameters listParametersWithFilter = new VirtualMachineImageListParameters() { Location = listParameters.Location, PublisherName = listParameters.PublisherName, Offer = listParameters.Offer, Skus = listParameters.Skus, }; // Filter: top - Negative Test listParametersWithFilter.FilterExpression = "$top=0"; var vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 0); // Filter: top - Positive Test listParametersWithFilter.FilterExpression = "$top=1"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 1); // Filter: top - Positive Test listParametersWithFilter.FilterExpression = "$top=2"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 2); Assert.True(vmimages.Resources.Count(vmi => vmi.Name == "1.0.0") != 0); Assert.True(vmimages.Resources.Count(vmi => vmi.Name == "1.1.0") != 0); // Filter: orderby - Positive Test listParametersWithFilter.FilterExpression = "$orderby=name desc"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 2); Assert.True(vmimages.Resources[0].Name == "1.1.0"); Assert.True(vmimages.Resources[1].Name == "1.0.0"); // Filter: orderby - Positive Test listParametersWithFilter.FilterExpression = "$orderby=name asc"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 2); Assert.True(vmimages.Resources[0].Name == "1.0.0"); Assert.True(vmimages.Resources[1].Name == "1.1.0"); // Filter: top orderby - Positive Test listParametersWithFilter.FilterExpression = "$top=1&$orderby=name desc"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 1); Assert.True(vmimages.Resources[0].Name == "1.1.0"); // Filter: top orderby - Positive Test listParametersWithFilter.FilterExpression = "$top=1&$orderby=name asc"; vmimages = _pirClient.VirtualMachineImages.List(listParametersWithFilter); Assert.True(vmimages.Resources.Count == 1); Assert.True(vmimages.Resources[0].Name == "1.0.0"); } }
public void TestVMImageListFilters() { using (MockContext context = MockContext.Start(this.GetType())) { ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); // Filter: top - Negative Test var vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", top: 0); Assert.True(vmimages.Count == 0); // Filter: top - Positive Test vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", top: 1); Assert.True(vmimages.Count == 1); // Filter: top - Positive Test vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", top: 2); Assert.True(vmimages.Count == 2); // Filter: orderby - Positive Test vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", orderby: "name desc"); // Filter: orderby - Positive Test vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", top: 2, orderby: "name asc"); Assert.True(vmimages.Count == 2); // Filter: top orderby - Positive Test vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", top: 1, orderby: "name desc"); Assert.True(vmimages.Count == 1); // Filter: top orderby - Positive Test vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", top: 1, orderby: "name asc"); Assert.True(vmimages.Count == 1); } }
public void TestVMImageListFilters() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); var query = new Microsoft.Rest.Azure.OData.ODataQuery <VirtualMachineImageResource>(); // Filter: top - Negative Test query.Top = 0; var vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", query); Assert.True(vmimages.Count == 0); // Filter: top - Positive Test query.Top = 1; vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", query); Assert.True(vmimages.Count == 1); // Filter: top - Positive Test query.Top = 2; vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", query); Assert.True(vmimages.Count == 2); // Filter: orderby - Positive Test query.Top = null; query.OrderBy = "name desc"; vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", query); // Filter: orderby - Positive Test query.Top = 2; query.OrderBy = "name asc"; vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", query); Assert.True(vmimages.Count == 2); // Filter: top orderby - Positive Test query.Top = 1; query.OrderBy = "name desc"; vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", query); Assert.True(vmimages.Count == 1); // Filter: top orderby - Positive Test query.Top = 1; query.OrderBy = "name asc"; vmimages = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, "MicrosoftWindowsServer", "WindowsServer", "2012-R2-Datacenter", query); Assert.True(vmimages.Count == 1); } }
public void TestVMImageAutomaticOSUpgradeProperties() { using (MockContext context = MockContext.Start(this.GetType().FullName)) { ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); // Validate if images supporting automatic OS upgrades return // AutomaticOSUpgradeProperties.AutomaticOSUpgradeSupported = true in GET VMImageVesion call string imagePublisher = "MicrosoftWindowsServer"; string imageOffer = "WindowsServer"; string imageSku = "2016-Datacenter"; string[] availableWindowsServerImageVersions = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, imagePublisher, imageOffer, imageSku).Select(t => t.Name).ToArray(); string firstVersion = availableWindowsServerImageVersions.First(); string lastVersion = null; if (availableWindowsServerImageVersions.Length >= 2) { lastVersion = availableWindowsServerImageVersions.Last(); } var vmimage = _pirClient.VirtualMachineImages.Get( ComputeManagementTestUtilities.DefaultLocation, imagePublisher, imageOffer, imageSku, firstVersion); Assert.True(vmimage.AutomaticOSUpgradeProperties.AutomaticOSUpgradeSupported); if (!string.IsNullOrEmpty(lastVersion)) { vmimage = _pirClient.VirtualMachineImages.Get( ComputeManagementTestUtilities.DefaultLocation, imagePublisher, imageOffer, imageSku, lastVersion); Assert.True(vmimage.AutomaticOSUpgradeProperties.AutomaticOSUpgradeSupported); } // Validate if image not whitelisted to support automatic OS upgrades, return // AutomaticOSUpgradeProperties.AutomaticOSUpgradeSupported = false in GET VMImageVesion call imagePublisher = "Canonical"; imageOffer = "UbuntuServer"; imageSku = "18.10-DAILY"; string[] availableUbuntuImageVersions = _pirClient.VirtualMachineImages.List( ComputeManagementTestUtilities.DefaultLocation, imagePublisher, imageOffer, imageSku).Select(t => t.Name).ToArray(); firstVersion = availableUbuntuImageVersions.First(); lastVersion = null; if (availableUbuntuImageVersions.Length >= 2) { lastVersion = availableUbuntuImageVersions.Last(); } vmimage = _pirClient.VirtualMachineImages.Get( ComputeManagementTestUtilities.DefaultLocation, imagePublisher, imageOffer, imageSku, firstVersion); Assert.False(vmimage.AutomaticOSUpgradeProperties.AutomaticOSUpgradeSupported); if (!string.IsNullOrEmpty(lastVersion)) { vmimage = _pirClient.VirtualMachineImages.Get( ComputeManagementTestUtilities.DefaultLocation, imagePublisher, imageOffer, imageSku, lastVersion); Assert.False(vmimage.AutomaticOSUpgradeProperties.AutomaticOSUpgradeSupported); } } }
public void TestExtImgListVersionsFilters() { using (MockContext context = MockContext.Start(this.GetType())) { ComputeManagementClient _pirClient = ComputeManagementTestUtilities.GetComputeManagementClient(context, new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }); // Filter: startswith - Positive Test parameters.FilterExpression = null; var extImages = _pirClient.VirtualMachineExtensionImages.ListVersions( parameters.Location, parameters.PublisherName, parameters.Type); Assert.True(extImages.Count > 0); string ver = extImages.First().Name; var query = new Microsoft.Rest.Azure.OData.ODataQuery <Microsoft.Azure.Management.Compute.Models.VirtualMachineExtensionImage>(); query.SetFilter(f => f.Name.StartsWith(ver)); parameters.FilterExpression = "$filter=startswith(name,'" + ver + "')"; var vmextimg = _pirClient.VirtualMachineExtensionImages.ListVersions( parameters.Location, parameters.PublisherName, parameters.Type, query); Assert.True(vmextimg.Count > 0); Assert.True(vmextimg.Count(vmi => vmi.Name == "2.0") != 0); // Filter: startswith - Negative Test query.SetFilter(f => f.Name.StartsWith("1.0")); parameters.FilterExpression = "$filter=startswith(name,'1.0')"; vmextimg = _pirClient.VirtualMachineExtensionImages.ListVersions( parameters.Location, parameters.PublisherName, parameters.Type, query); Assert.True(vmextimg.Count == 0); Assert.True(vmextimg.Count(vmi => vmi.Name == "2.0") == 0); // Filter: top - Positive Test query.Filter = null; query.Top = 1; parameters.FilterExpression = "$top=1"; vmextimg = _pirClient.VirtualMachineExtensionImages.ListVersions( parameters.Location, parameters.PublisherName, parameters.Type, query); Assert.True(vmextimg.Count == 1); Assert.True(vmextimg.Count(vmi => vmi.Name == "2.0") != 0); // Filter: top - Negative Test query.Top = 0; parameters.FilterExpression = "$top=0"; vmextimg = _pirClient.VirtualMachineExtensionImages.ListVersions( parameters.Location, parameters.PublisherName, parameters.Type, query); Assert.True(vmextimg.Count == 0); } }