Skip to content

[Compute] PPG cmdlets and others. #9079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Compute/Compute.Test/Compute.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="25.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="27.0.0" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.2" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.11.0-preview" />
</ItemGroup>
Expand Down
206 changes: 102 additions & 104 deletions src/Compute/Compute.Test/ScenarioTests/AEMExtensionTests.ps1

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,10 @@ function Test-AvailabilitySet
Assert-AreEqual $aset.Name $asetName;
Assert-AreEqual $nonDefaultUD $aset.PlatformUpdateDomainCount;
Assert-AreEqual $nonDefaultFD $aset.PlatformFaultDomainCount;
Assert-False {$aset.Managed};
Assert-AreEqual 'Classic' $aset.Sku;
Assert-AreEqual "b" $aset.Tags["a"];

$job = $aset | Update-AzAvailabilitySet -Managed -AsJob;
$job = $aset | Update-AzAvailabilitySet -Sku 'Aligned' -AsJob;
$result = $job | Wait-Job;
Assert-AreEqual "Completed" $result.State;
$aset = Get-AzAvailabilitySet -ResourceGroupName $rgname -Name $asetName;
Expand Down
207 changes: 91 additions & 116 deletions src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/GalleryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,12 @@ public void TestGalleryCrossTenant()
{
TestRunner.RunTestScript("Test-GalleryCrossTenant");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void GalleryImageVersion()
{
TestRunner.RunTestScript("Test-GalleryImageVersion");
}
}
}
166 changes: 166 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,169 @@ function Test-GalleryCrossTenant
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Testing gallery image version commands
#>
function Test-GalleryImageVersion
{
# Setup
$rgname = Get-ComputeTestResourceName;
$galleryName = 'gallery' + $rgname;
$galleryImageName = 'galleryimage' + $rgname;
$galleryImageVersionName = 'imageversion' + $rgname;

try
{
# Common
$loc = "southcentralus";
New-AzResourceGroup -Name $rgname -Location $loc -Force;
$description1 = "Original Description";

# Gallery
New-AzGallery -ResourceGroupName $rgname -Name $galleryName -Description $description1 -Location $loc;

$gallery = Get-AzGallery -ResourceGroupName $rgname -Name $galleryName;
Verify-Gallery $gallery $rgname $galleryName $loc $description1;
$output = $gallery | Out-String;

# Gallery Image Definition
$publisherName = "galleryPublisher20180927";
$offerName = "galleryOffer20180927";
$skuName = "gallerySku20180927";
$eula = "eula";
$privacyStatementUri = "https://www.microsoft.com";
$releaseNoteUri = "https://www.microsoft.com";
$disallowedDiskTypes = "Premium_LRS";
$endOfLifeDate = [DateTime]::ParseExact('12 07 2025 18 02', 'HH mm yyyy dd MM', $null);
$minMemory = 1;
$maxMemory = 100;
$minVCPU = 2;
$maxVCPU = 32;
$purchasePlanName = "purchasePlanName";
$purchasePlanProduct = "purchasePlanProduct";
$purchasePlanPublisher = "";
$osState = "Generalized";
$osType = "Linux";

New-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $galleryImageName `
-Location $loc -Publisher $publisherName -Offer $offerName -Sku $skuName `
-OsState $osState -OsType $osType `
-Description $description1 -Eula $eula `
-PrivacyStatementUri $privacyStatementUri -ReleaseNoteUri $releaseNoteUri `
-DisallowedDiskType $disallowedDiskTypes -EndOfLifeDate $endOfLifeDate `
-MinimumMemory $minMemory -MaximumMemory $maxMemory `
-MinimumVCPU $minVCPU -MaximumVCPU $maxVCPU `
-PurchasePlanName $purchasePlanName `
-PurchasePlanProduct $purchasePlanProduct `
-PurchasePlanPublisher $purchasePlanPublisher;

$definition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $galleryImageName;
$output = $definition | Out-String;
Verify-GalleryImageDefinition $definition $rgname $galleryImageName $loc $description1 `
$eula $privacyStatementUri $releaseNoteUri `
$osType $osState $endOfLifeDate `
$publisherName $offerName $skuName `
$minVCPU $maxVCPU $minMemory $maxMemory `
$disallowedDiskTypes `
$purchasePlanName $purchasePlanPublisher $purchasePlanProduct;

# Gallery Image Version
$galleryImageVersionName = "1.0.0";

# Create a VM first
$vmsize = 'Standard_A4';
$vmname = 'vm' + $rgname;
$p = New-AzVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;

# NRP
$subnet = New-AzVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
$vnet = New-AzVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
$vnet = Get-AzVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
$subnetId = $vnet.Subnets[0].Id;
$pubip = New-AzPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
$pubip = Get-AzPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
$nic = New-AzNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
$nic = Get-AzNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;

# Adding the same Nic but not set it Primary
$p = Add-AzVMNetworkInterface -VM $p -Id $nic.Id -Primary;

# Storage Account (SA)
$stoname = 'sto' + $rgname;
$stotype = 'Standard_LRS';
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
$stoaccount = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname;

$osDiskName = 'osDisk';
$osDiskCaching = 'ReadWrite';
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";

$p = Set-AzVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;

$p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
$p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;

# OS & Image
$user = "Foo12";
$password = $PLACEHOLDER;
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
$computerName = 'test';
$vhdContainer = "https://$stoname.blob.core.windows.net/test";

# $p.StorageProfile.OSDisk = $null;
$p = Set-AzVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;

$imgRef = Get-DefaultCRPImage -loc $loc;
$p = ($imgRef | Set-AzVMSourceImage -VM $p);

# Virtual Machine
New-AzVM -ResourceGroupName $rgname -Location $loc -VM $p;

# Create Image using the VM's OS disk and data disks.
$imageName = 'image' + $rgname;
$imageConfig = New-AzImageConfig -Location $loc;
Set-AzImageOsDisk -Image $imageConfig -OsType 'Windows' -OsState 'Generalized' -BlobUri $osDiskVhdUri;
$imageConfig = Add-AzImageDataDisk -Image $imageConfig -Lun 1 -BlobUri $dataDiskVhdUri1;
$imageConfig = Add-AzImageDataDisk -Image $imageConfig -Lun 2 -BlobUri $dataDiskVhdUri2;

$image = New-AzImage -Image $imageConfig -ImageName $imageName -ResourceGroupName $rgname
$targetRegions = @(@{Name='South Central US';ReplicaCount=1;StorageAccountType='Standard_LRS'},@{Name='East US';ReplicaCount=2},@{Name='Central US'});
$tag = @{test1 = "testval1"; test2 = "testval2" };

New-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName `
-Location $loc -SourceImageId $image.Id -ReplicaCount 1 `
-PublishingProfileEndOfLifeDate $endOfLifeDate `
-StorageAccountType Standard_LRS `
-TargetRegion $targetRegions;

$version = Get-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName;
Verify-GalleryImageVersion $version $rgname $galleryImageVersionName $loc `
$image.Id 1 $endOfLifeDate $targetRegions;

Update-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName `
-Tag $tag;

$version = Get-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName;
Verify-GalleryImageVersion $version $rgname $galleryImageVersionName $loc `
$image.Id 1 $endOfLifeDate $targetRegions;

$version | Remove-AzGalleryImageVersion -Force;
$definition | Remove-AzGalleryImageDefinition -Force;
$gallery | Remove-AzGallery -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
4 changes: 2 additions & 2 deletions src/Compute/Compute.Test/ScenarioTests/LogAnalyticTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function Test-ExportLogAnalyticThrottledRequestsNegative
$to = Get-Date -Year 2018 -Month 2 -Day 28 -Hour 9;
$sasuri = 'https://fakestore.blob.core.windows.net/mylogs/fakesas';
Assert-ThrowsContains { `
$result = Export-AzLogAnalyticThrottledRequests -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByResourceName;} `
$result = Export-AzLogAnalyticThrottledRequest -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByResourceName;} `
"the given SAS URI";
}

Expand Down Expand Up @@ -79,7 +79,7 @@ function Test-ExportLogAnalytics
Assert-True { $output.Contains(".csv"); }
Assert-True { $output.Contains("RequestRateByInterval"); }

$result = Export-AzLogAnalyticThrottledRequests -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByOperationName -GroupByResourceName;
$result = Export-AzLogAnalyticThrottledRequest -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByOperationName -GroupByResourceName;
Assert-AreEqual "Succeeded" $result.Status;
$output = $result | Out-String;
Assert-True { $output.Contains(".csv"); }
Expand Down
6 changes: 1 addition & 5 deletions src/Compute/Compute.Test/ScenarioTests/NewVhdVMTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ public NewVhdVMTests(Xunit.Abstractions.ITestOutputHelper output)
{
}

#if NETSTANDARD
[Fact(Skip = "Resources -> ResourceManager, needs re-recorded")]
[Fact]
[Trait(Category.RunType, Category.DesktopOnly)]
#else
[Fact(Skip = "Resources -> ResourceManager, needs re-recorded")]
#endif
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestWithValidVhdDiskFile()
{
Expand Down
49 changes: 49 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/PPGTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;

namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
{
public class PPGTests : ComputeTestRunner
{
public PPGTests(Xunit.Abstractions.ITestOutputHelper output)
: base(output)

{
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestPPG()
{
TestRunner.RunTestScript("Test-ProximityPlacementGroup");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestPPGAvSet()
{
TestRunner.RunTestScript("Test-ProximityPlacementGroupAvSet");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestPPGVM()
{
TestRunner.RunTestScript("Test-ProximityPlacementGroupVM");
}
}
}
Loading