Skip to content

AzureRT - VHD Commands & Tests #1532

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 24 commits into from
Dec 24, 2015
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
6 changes: 6 additions & 0 deletions examples/virtual-hard-disk/01-VirtualHardDisks.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Param(
[string]$resourceGroupName,
[string]$resourceGroupLocation
)

Write-Host "Skip"
27 changes: 27 additions & 0 deletions examples/virtual-hard-disk/01-VirtualHardDisks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
set -e
printf "\n=== Managing Virtual Hard Disks in Azure Compute ===\n"

printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
azure group create -n "$groupName" --location "$location"

printf "\n2. Creating a new storage account '%s' in type '%s'.\n" "$storageAccountName" "$storageAccountType"
azure storage account new --resourcegroupname "$groupName" --name "$storageAccountName" --location "$location" --type "$storageAccountType"

printf "\n3. Uploading a virtual hard disk to: %s.\n" "$storageAccountName"
azure vhd add -o --resourcegroupname "$groupName" --destination https://"$storageAccountName".blob.core.windows.net/test/test.vhd --localfilepath $BASEDIR/test.vhd

printf "\n4. Downloading a virtual hard disk"
azure vhd save -o --resourcegroupname "$groupName" --sourceuri https://"$storageAccountName".blob.core.windows.net/test/test.vhd --localfilepath ./test_downloaded_by_clu.vhd

printf "\n5. Validating the downloaded file is the same.\n"
diffResult=`diff ./test_downloaded_by_clu.vhd $BASEDIR/test_uploaded_byps.vhd`
if [ "$diffResult" = "" ]; then
echo "Checked"
else
echo "Different!" 1>&2
exit 1
fi

printf "\n6. Removing resource group: %s.\n" "$groupName"
azure group remove -n "$groupName" -f
Binary file added examples/virtual-hard-disk/test.vhd
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions src/CLU/CLUCoreCLR.sln
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Co
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.ScenarioTest.CLU", "Microsoft.ScenarioTests.CLU\Microsoft.ScenarioTest.CLU.xproj", "{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "VhdManagement", "VhdManagement\VhdManagement.xproj", "{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sync", "Sync\Sync.xproj", "{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}"
ProjectSection(ProjectDependencies) = postProject
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9} = {094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -147,6 +154,14 @@ Global
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.Build.0 = Release|Any CPU
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Release|Any CPU.Build.0 = Release|Any CPU
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
7 changes: 7 additions & 0 deletions src/CLU/Commands.Common.ScenarioTest/ExampleScriptRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,17 @@ public class ExampleScriptRunner
string _sessionId;
Random _generator;
string _resourceGroupName;
string _storageAccountName;
IClientFactory _clientFactory = new ClientFactory();
TestContext _context;
ResourceManagementClient _client;
const string DefaultLocation = "westus";
const string ResourceGroupNameKey = "groupName";
const string locationKey = "location";
const string SessionKey = "CmdletSessionID";
const string storageAccountTypeKey = "storageAccountType";
const string storageAccountNameKey = "storageAccountName";
const string DefaultStorageAccountType = "Standard_GRS";

public ExampleScriptRunner(string sessionId) : this(new Random(), sessionId)
{
Expand Down Expand Up @@ -96,6 +100,7 @@ public string RunScript(string testName)
{
Trace.Listeners.Add(listener);
_resourceGroupName = CreateRandomName();
_storageAccountName = CreateRandomName() + "sto";
if (File.Exists(deploymentTemplatePath))
{
DeployTemplate(deploymentTemplatePath, _resourceGroupName);
Expand All @@ -104,6 +109,8 @@ public string RunScript(string testName)
process.EnvironmentVariables[SessionKey] = _sessionId;
process.EnvironmentVariables[ResourceGroupNameKey] = _resourceGroupName;
process.EnvironmentVariables[locationKey] = DefaultLocation;
process.EnvironmentVariables[storageAccountTypeKey] = DefaultStorageAccountType;
process.EnvironmentVariables[storageAccountNameKey] = _storageAccountName;
foreach (var helper in _context.EnvironmentHelpers)
{
helper.TrySetupScriptEnvironment(_context, _clientFactory, process.EnvironmentVariables);
Expand Down
7 changes: 7 additions & 0 deletions src/CLU/Commands.Common.ScenarioTest/SampleTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,19 @@ public SampleTest(ScenarioTestFixture fixture)
{
_collectionState = fixture;
}

[Fact]
public void RunSampleTest()
{
var helper = _collectionState.GetRunner("resource-management");
helper.RunScript("01-ResourceGroups");
}

[Fact]
public void RunVirtualHardDiskTest()
{
var helper = _collectionState.GetRunner("virtual-hard-disk");
helper.RunScript("01-VirtualHardDisks");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
Loading