Skip to content

Commit 5e9c256

Browse files
committed
Sync and merge conflicts
2 parents 814d63a + 028d61f commit 5e9c256

File tree

115 files changed

+11249
-432
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+11249
-432
lines changed

clu-getstart.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,13 @@ Testing will consist of scenario tests and unit tests. Scenario tests should be
118118
```
119119
- Set the environment variable 'TestCredentials' to a connection string providing the credentials to use during test execution. Possible fields include:
120120

121-
| Field | Description |
121+
| Field (case sensitive) | Description |
122122
| ------------- |:-------------|
123123
| Username | an OrgId user name |
124124
| ServicePrincipal | a service principal name |
125125
| Password | the password or application secret to sue for authentication |
126126
| TenantId | (required for Service authentication) The tenant guid to authenticate against |
127-
| SubscriptionID | (optional) Selects a particular subscription by id. If not provided, the first listed subscription will be selected |
127+
| SubscriptionId | (optional) Selects a particular subscription by id. If not provided, the first listed subscription will be selected |
128128
- The infrastructure automatically generates a resource group name and assigns the value to the bash variable ```"$resourceGroupName"```. If your scripts require additional variables, you can add these to your environment before running tests, or you can generate values using the ScriptRunner (for the tests using that runner).
129129
```C#
130130
runner.EnvironmentVariables.Add("myVariableName", runner.GenerateName("myres"));

examples/lib/setup.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/lib/testrunner.sh

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
#!/bin/bash
22
export BASEDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
3-
. $BASEDIR/assert.sh
43
. $BASEDIR/helper.sh
5-
. $BASEDIR/setup.sh
64
export groupName=`randomName testrg`
75
export location="westus"
6+
export CmdletSessionID=1010
7+
export MSYS_NO_PATHCONV=1
88

9-
login
9+
echo "Logging in as user"
10+
. $BASEDIR/loginUser.sh
1011

1112
for d in $( ls $BASEDIR/.. --ignore=lib ); do
1213
for f in $( ls $BASEDIR/../$d/*.sh ); do
1314
echo "running: $f"
1415
. $f
15-
cleanup
16+
set +e
17+
printf "\nCleanup: removing resource group: %s\n" $groupName
18+
azure group remove --name "$groupName" --force
19+
set -e
1620
echo "success: $f"
1721
done
18-
done
22+
done
23+
24+
export MSYS_NO_PATHCONV=
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Param(
2+
[string]$resourceGroupName,
3+
[string]$resourceGroupLocation
4+
)
5+
6+
Write-Host "Skip"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
set -e
3+
printf "\n=== Managing Virtual Hard Disks in Azure Compute ===\n"
4+
5+
printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
6+
azure group create -n "$groupName" --location "$location"
7+
8+
printf "\n2. Creating a new storage account '%s' in type '%s'.\n" "$storageAccountName" "$storageAccountType"
9+
azure storage account new --resourcegroupname "$groupName" --name "$storageAccountName" --location "$location" --type "$storageAccountType"
10+
11+
printf "\n3. Uploading a virtual hard disk to: %s.\n" "$storageAccountName"
12+
azure vhd add -o --resourcegroupname "$groupName" --destination https://"$storageAccountName".blob.core.windows.net/test/test.vhd --localfilepath $BASEDIR/test.vhd
13+
14+
printf "\n4. Downloading a virtual hard disk"
15+
azure vhd save -o --resourcegroupname "$groupName" --sourceuri https://"$storageAccountName".blob.core.windows.net/test/test.vhd --localfilepath ./test_downloaded_by_clu.vhd
16+
17+
printf "\n5. Validating the downloaded file is the same.\n"
18+
diffResult=`diff ./test_downloaded_by_clu.vhd $BASEDIR/test_uploaded_byps.vhd`
19+
if [ "$diffResult" = "" ]; then
20+
echo "Checked"
21+
else
22+
echo "Different!" 1>&2
23+
exit 1
24+
fi
25+
26+
printf "\n6. Removing resource group: %s.\n" "$groupName"
27+
azure group remove -n "$groupName" -f

examples/virtual-hard-disk/test.vhd

26.1 MB
Binary file not shown.
Binary file not shown.

src/CLU/CLUCoreCLR.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Co
5757
EndProject
5858
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.ScenarioTest.CLU", "Microsoft.ScenarioTests.CLU\Microsoft.ScenarioTest.CLU.xproj", "{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}"
5959
EndProject
60+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "VhdManagement", "VhdManagement\VhdManagement.xproj", "{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}"
61+
EndProject
62+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sync", "Sync\Sync.xproj", "{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}"
63+
ProjectSection(ProjectDependencies) = postProject
64+
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9} = {094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}
65+
EndProjectSection
66+
EndProject
6067
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Network", "Microsoft.Azure.Commands.Network\Microsoft.Azure.Commands.Network.xproj", "{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}"
6168
EndProject
6269
Global
@@ -241,6 +248,14 @@ Global
241248
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Release|Any CPU.Build.0 = Release|Any CPU
242249
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Release|x64.ActiveCfg = Release|Any CPU
243250
{C4DCF4EA-62E7-431E-ADB5-16FD6CFEA5D6}.Release|x64.Build.0 = Release|Any CPU
251+
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
252+
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
253+
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
254+
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Release|Any CPU.Build.0 = Release|Any CPU
255+
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
256+
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
257+
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
258+
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Release|Any CPU.Build.0 = Release|Any CPU
244259
EndGlobalSection
245260
GlobalSection(SolutionProperties) = preSolution
246261
HideSolutionNode = FALSE

src/CLU/Commands.Common.ScenarioTest/EnvironmentCredentialsProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ protected virtual IDictionary<string, string> GetSettings(string key)
4545
var environmentValue = Environment.GetEnvironmentVariable(key);
4646
if (string.IsNullOrWhiteSpace(environmentValue))
4747
{
48-
throw new InvalidOperationException($"Unable to create credentials. " +
49-
"Please set environment ${key}");
48+
throw new InvalidOperationException($"Unable to create credentials. Please set environment variable `{key}`");
5049
}
5150
IDictionary<string, string> settings = new Dictionary<string, string>();
5251
foreach (

src/CLU/Commands.Common.ScenarioTest/ExampleScriptRunner.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,18 @@ public class ExampleScriptRunner
3333
string _sessionId;
3434
Random _generator;
3535
string _resourceGroupName;
36+
string _storageAccountName;
3637
IClientFactory _clientFactory = new ClientFactory();
3738
TestContext _context;
3839
ResourceManagementClient _client;
3940
const string DefaultLocation = "westus";
4041
const string ResourceGroupNameKey = "groupName";
41-
const string locationKey = "location";
42+
const string LocationKey = "location";
43+
const string BaseDir = "BASEDIR";
4244
const string SessionKey = "CmdletSessionID";
45+
const string StorageAccountTypeKey = "storageAccountType";
46+
const string StorageAccountNameKey = "storageAccountName";
47+
const string DefaultStorageAccountType = "Standard_GRS";
4348

4449
public ExampleScriptRunner(string sessionId) : this(new Random(), sessionId)
4550
{
@@ -96,14 +101,18 @@ public string RunScript(string testName)
96101
{
97102
Trace.Listeners.Add(listener);
98103
_resourceGroupName = CreateRandomName();
104+
_storageAccountName = CreateRandomName() + "sto";
99105
if (File.Exists(deploymentTemplatePath))
100106
{
101107
DeployTemplate(deploymentTemplatePath, _resourceGroupName);
102108
}
103109

110+
process.EnvironmentVariables[BaseDir] = testDirectory;
104111
process.EnvironmentVariables[SessionKey] = _sessionId;
105112
process.EnvironmentVariables[ResourceGroupNameKey] = _resourceGroupName;
106-
process.EnvironmentVariables[locationKey] = DefaultLocation;
113+
process.EnvironmentVariables[LocationKey] = DefaultLocation;
114+
process.EnvironmentVariables[StorageAccountTypeKey] = DefaultStorageAccountType;
115+
process.EnvironmentVariables[StorageAccountNameKey] = _storageAccountName;
107116
foreach (var helper in _context.EnvironmentHelpers)
108117
{
109118
helper.TrySetupScriptEnvironment(_context, _clientFactory, process.EnvironmentVariables);

src/CLU/Commands.Common.ScenarioTest/ProcessHelper.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,16 @@ private void SetEnvironmentVariables(ProcessStartInfo startInfo)
173173

174174
private void ProcessError(object sender, DataReceivedEventArgs e)
175175
{
176-
Logger.Instance.WriteError(e.Data);
176+
if (e.Data != null)
177+
{
178+
Logger.Instance.WriteError(e.Data);
179+
}
177180
}
178181

179182
private void ProcessOutput(object sender, DataReceivedEventArgs e)
180183
{
181-
Logger.Instance.WriteMessage(e.Data);
182184
_processOutput.Append(e.Data);
185+
Logger.Instance.WriteMessage(e.Data);
183186
}
184187

185188
private void EndProcess()

src/CLU/Commands.Common.ScenarioTest/SampleTest.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,19 @@ public SampleTest(ScenarioTestFixture fixture)
3131
{
3232
_collectionState = fixture;
3333
}
34+
3435
[Fact]
35-
public void RunSampleTest()
36+
public void ResourceGroupsTest()
3637
{
3738
var helper = _collectionState.GetRunner("resource-management");
3839
helper.RunScript("01-ResourceGroups");
3940
}
4041

42+
[Fact]
43+
public void VirtualHardDisksTest()
44+
{
45+
var helper = _collectionState.GetRunner("virtual-hard-disk");
46+
helper.RunScript("01-VirtualHardDisks");
47+
}
4148
}
4249
}

src/CLU/Commands.Common.ScenarioTest/ScenarioTestFixture.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
using Microsoft.Azure.Commands.Common.Authentication.Models;
1717
using Microsoft.Azure.Commands.Common.ScenarioTest;
1818
using Microsoft.Azure.Commands.Models;
19-
using Moq.Protected;
2019
using Newtonsoft.Json;
2120

2221
namespace Microsoft.Azure.Commands.Common.ScenarioTest
@@ -34,6 +33,10 @@ public ScenarioTestFixture()
3433
var helper = GetRunner("lib");
3534
var profileText = helper.RunScript(credentials.LoginScriptName);
3635
var profile = JsonConvert.DeserializeObject<PSAzureProfile>(profileText);
36+
if (profile == null)
37+
{
38+
throw new ArgumentOutOfRangeException(nameof(profile), $"Deserialized profile is null: `{profileText}`");
39+
}
3740
AzureContext = (AzureContext) (profile.Context);
3841
}
3942

src/CLU/Commands.Common.ScenarioTest/project.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"Commands.Common": "",
2121
"Commands.Common.Authentication": "",
2222
"Commands.ResourceManager.Common": "",
23-
"Commands.ScenarioTests.ResourceManager.Common": "",
2423
"Microsoft.Azure.Commands.Profile": "",
2524
"Microsoft.Azure.Management.Resources": "3.3.0-preview",
2625
"Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",

src/CLU/Microsoft.Azure.Commands.Compute/Microsoft.Azure.Commands.Compute.xproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@
1414
<PropertyGroup>
1515
<SchemaVersion>2.0</SchemaVersion>
1616
</PropertyGroup>
17+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
18+
<ProduceOutputsOnBuild>True</ProduceOutputsOnBuild>
19+
</PropertyGroup>
1720
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
1821
</Project>

0 commit comments

Comments
 (0)