Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<Compile Include="ScenarioTests\ComputeCloudExceptionTests.cs" />
<Compile Include="ScenarioTests\ContainerServiceTests.cs" />
<Compile Include="ScenarioTests\DiagnosticsExtensionTests.cs" />
<Compile Include="ScenarioTests\DiskRPTests.cs" />
<Compile Include="ScenarioTests\ImageTests.cs" />
<Compile Include="ScenarioTests\SqlIaaSExtensionTests.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down Expand Up @@ -239,6 +240,9 @@
<Content Include="ConfigFiles\DiagnosticsExtensionPublicConfig.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="ScenarioTests\DiskRPTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="ScenarioTests\AddVhdTests.ps1">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down Expand Up @@ -335,4 +339,4 @@
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// ----------------------------------------------------------------------------------
//
// 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 DiskRPTests
{
public DiskRPTests(Xunit.Abstractions.ITestOutputHelper output)
{
ServiceManagemenet.Common.Models.XunitTracingInterceptor.AddToContext(new ServiceManagemenet.Common.Models.XunitTracingInterceptor(output));
}

[Fact]
public void TestDisk()
{
ComputeTestController.NewInstance.RunPsTest("Test-Disk");
}


[Fact]
public void TestSnapshot()
{
ComputeTestController.NewInstance.RunPsTest("Test-Snapshot");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# ----------------------------------------------------------------------------------
#
# 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.
# ----------------------------------------------------------------------------------

<#
.SYNOPSIS
Testing disk and snapshot commands
#>
function Test-Disk
{
# Setup
$rgname = Get-ComputeTestResourceName;
$diskname = 'disk' + $rgname;

try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
$subId = Get-SubscriptionIdFromResourceGroup $rgname;
$mocksourcevault = 'https://myvault.vault-int.azure-int.net/secrets/123/';
$mockkey = '/subscriptions/' + $subId + '/resourceGroups/' + $rgname + '/providers/Microsoft.KeyVault/vaults/TestVault123';
$access = 'Read';

# Config create test
$diskconfig = New-AzureRmDiskConfig -Location $loc -DiskSizeGB 5 -AccountType StandardLRS -OsType Windows -CreateOption Empty -EncryptionSettingsEnabled $true;
# Encryption test
$diskconfig = Set-AzureRmDiskDiskEncryptionKey -Disk $diskconfig -SecretUrl $mockkey -SourceVaultId $mocksourcevault;
$diskconfig = Set-AzureRmDiskKeyEncryptionKey -Disk $diskconfig -KeyUrl $mockkey;
$diskconfig.EncryptionSettings.Enabled = $false;
$diskconfig.EncryptionSettings.DiskEncryptionKey = $null;
$diskconfig.EncryptionSettings.KeyEncryptionKey = $null;
New-AzureRmDisk -ResourceGroupName $rgname -DiskName $diskname -Disk $diskconfig;

# Get disk test
Get-AzureRmDisk -ResourceGroupName $rgname -DiskName $diskname;

# Grant access test
Grant-AzureRmDiskAccess -ResourceGroupName $rgname -DiskName $diskname -Access $access -DurationInSecond 5;
Revoke-AzureRmDiskAccess -ResourceGroupName $rgname -DiskName $diskname;

#Config update test
$updateconfig = New-AzureRmDiskConfig -Location $loc;
$updateconfig = New-AzureRmDiskUpdateConfig -DiskSizeGB 10 -AccountType PremiumLRS -OsType Windows -CreateOption Empty;
Update-AzureRmDisk -ResourceGroupName $rgname -DiskName $diskname -DiskUpdate $updateconfig;

# Remove test
Remove-AzureRmDisk -ResourceGroupName $rgname -DiskName $diskname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

function Test-Snapshot
{
# Setup
$rgname = Get-ComputeTestResourceName;
$snapshotname = 'snapshot' + $rgname;

try
{
# Common
$loc = Get-ComputeVMLocation;
New-AzureRmResourceGroup -Name $rgname -Location $loc -Force;
$subId = Get-SubscriptionIdFromResourceGroup $rgname;
$mocksourcevault = 'https://myvault.vault-int.azure-int.net/secrets/123/';
$mockkey = '/subscriptions/' + $subId + '/resourceGroups/' + $rgname + '/providers/Microsoft.KeyVault/vaults/TestVault123';
$access = 'Read';

# Config and create test
$snapshotconfig = New-AzureRmSnapshotConfig -Location $loc -DiskSizeGB 5 -AccountType StandardLRS -OsType Windows -CreateOption Empty -EncryptionSettingsEnabled $true;
$snapshotconfig = Set-AzureRmSnapshotDiskEncryptionKey -Snapshot $snapshotconfig -SecretUrl $mockkey -SourceVaultId $mocksourcevault;
$snapshotconfig = Set-AzureRmSnapshotKeyEncryptionKey -Snapshot $snapshotconfig -KeyUrl $mockkey;
$snapshotconfig.EncryptionSettings.Enabled = $false;
$snapshotconfig.EncryptionSettings.DiskEncryptionKey = $null;
$snapshotconfig.EncryptionSettings.KeyEncryptionKey = $null;
New-AzureRmSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname -Snapshot $snapshotconfig;

# Get snapshot test
Get-AzureRmSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname;

# Grant access test
Grant-AzureRmSnapshotAccess -ResourceGroupName $rgname -SnapshotName $snapshotname -Access $access -DurationInSecond 5;
Revoke-AzureRmSnapshotAccess -ResourceGroupName $rgname -SnapshotName $snapshotname;

# Config update test
$updateconfig = New-AzureRmSnapshotConfig -Location $loc;
$updateconfig = New-AzureRmSnapshotUpdateConfig -DiskSizeGB 10 -AccountType PremiumLRS -OsType Windows -CreateOption Empty;
Update-AzureRmSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname -SnapshotUpdate $updateconfig;

# Remove test
Remove-AzureRmSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname -Force;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Loading