Skip to content

Commit 0ace147

Browse files
committed
Merge remote-tracking branch 'origin/clu' into DynamicParameters
2 parents b9c4de3 + 39b1a20 commit 0ace147

File tree

169 files changed

+11562
-530
lines changed

Some content is hidden

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

169 files changed

+11562
-530
lines changed

clu-getstart.md

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,17 @@ CLUPackages require some additional files to direct generation of indexing, and
4646
```
4747

4848
### Package Creation and Testing
49-
2 options
50-
* Run `<repo-root>\tools\CLU\SetupEnv.bat` which build and generate all cmdlet packages and deploy to under `<repo root>\drop` folder. When you have a clean environment, you should always do this first.
51-
* Run `<repo-root>\tools\CLU\BuildCmdlet` <name like: Microsoft.Azure.Commands.Profile>", this will build and refresh an individual cmdlet package.
49+
Two options
50+
1. Run `<repo-root>\tools\CLU\BuildAndInstallClu.bat` which build and generate all cmdlet packages and deploy to under `<repo root>\drop\clurun` folder, with 3 flavors `win7-x64`, `osx.10.10-x64` and `ubuntu.14.04-x64`. When you have a clean environment or just pull from upstream, you should clean temporary bits such as `git clean -xdf`, and run this command.
51+
2. Run `<repo-root>\tools\CLU\BuildCmdlet <package name like Microsoft.Azure.Commands.Profile>` <name like: Microsoft.Azure.Commands.Profile>", this will build and refresh an individual cmdlet package.
5252

53-
Once you are done with #1, in the same command window, you can type "azure help" to explore and run cmdlets.
53+
After #1 above is finished, you can run `drop\clurun\<platform>\azure.bat help` to explore.
5454

55-
To debug, set environment variable of `DebugCLU` to "1"(#1 should set it up already). When you run any command, you will see a prompt telling you to attach debugger.
55+
To debug, set environment variable of `DebugCLU` to "1". Then on running any command, you will be prompted to attach a debugger.
5656

57-
To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, you should see subfolders for "osx" and "ubuntu", copy the folder to your target machine, and run the "azure.sh" inside. Make sure set execution permission using `chmod +x azure.sh clurun`
57+
There is also `<repo-root>\tools\CLU\SetupEnv.bat` which is a windows batch wrapping around the `BuildAndInstallClu.bat`, plus set the `DebugCLU` for you, and add the `drop\clurun\win7-x64\azure.bat` to the PATH environment variable.
58+
59+
To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flavor folder to your target machine, and run the "azure.sh" inside. Make sure set execution permission using `chmod +x azure.sh clurun`
5860

5961
(All of those are subject to change, contact yugangw or adxsdkdev for any questions)
6062

@@ -88,9 +90,53 @@ To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, you should se
8890
Testing will consist of scenario tests and unit tests. Scenario tests should be written in a form of an example and be available in `.ps1` and `.sh` formats.
8991

9092
#### Scenario Tests
91-
- Scenario tests should be saved under `./examples` directory and grouped by the package or service area. Each scenario tests should consist of both `.ps1` and `.sh` files and should cover "P0" scenarios.
92-
93-
##### Bash Tests
93+
- Scenario tests should be saved under `./examples` directory with one directory per package. Each scenario tests should (eventually) consist of both `.ps1` and `.sh` files and should cover "P0" scenarios.
94+
95+
##### XUnit Automation For Bash Scenario Tests
96+
- The ```Commands.Common.ScenarioTest``` project contains classes that enable executing bash scenario tests in Visual Studio, or cross-platform using dnx.
97+
98+
- To implement an xunit bash scenario test you must
99+
- Add a ```[Collection("SampleCollection")]``` attribute to your test class
100+
- Add a field to your class of type ```ScenarioTestFixture``` and add a constructor that initializes it
101+
```C#
102+
[Collection("SampleCollection")]
103+
public class SampleTestClass
104+
{
105+
ScenarioTestFixture _fixture;
106+
public SampleTestClass(ScenarioTestFixture fixture)
107+
{
108+
_fixture = fixture;
109+
}
110+
```
111+
- Use the fixture in your test method to create a script runner for your directory and to run your test script:
112+
```C#
113+
[Fact]
114+
public void RunSampleTest()
115+
{
116+
_fixture.GetRunner("resource-management").RunScript("01-ResourceGroups");
117+
}
118+
```
119+
- Set the environment variable 'TestCredentials' to a connection string providing the credentials to use during test execution. Possible fields include:
120+
121+
| Field (case sensitive) | Description |
122+
| ------------- |:-------------|
123+
| Username | an OrgId user name |
124+
| ServicePrincipal | a service principal name |
125+
| Password | the password or application secret to sue for authentication |
126+
| 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 |
128+
- 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).
129+
```C#
130+
runner.EnvironmentVariables.Add("myVariableName", runner.GenerateName("myres"));
131+
```
132+
- Tests can be executed in vs, or by runnign ```dnx test project.json```. If you execute dnx test from the project directory, it will work without modification and a log file for each script will be written to the test results directory ```..\TestResults```. If you execute dnx test from a different directory, you must set the following environment variables to provide the path to the examples directory and where to write log files:
133+
134+
| Environment Variable | Description |
135+
| ------------- |:-------------|
136+
| ExamplesDirectory | The path to the 'examples' directory ($pshome/examples) |
137+
| TestDirectory | The path to the directory where logs will be written |
138+
139+
##### Running Bash Tests using Bash shell
94140
- Bash tests should be runnable from bash shell in windows/linux/mac environments.
95141
- To manually run the tests; please set the following envt. variables for authentication and run `./examples/lib/testrunner.sh`
96142
```bash

examples/lib/loginUser.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
#!/bin/bash
2+
echo "Logging in as user"
23
azure account add -u "$azureUser" -p "$password" -s "$subscription"

examples/lib/setup.sh

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

examples/lib/testrunner.sh

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
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+
. $BASEDIR/loginUser.sh
1010

1111
for d in $( ls $BASEDIR/.. --ignore=lib ); do
1212
for f in $( ls $BASEDIR/../$d/*.sh ); do
1313
echo "running: $f"
1414
. $f
15-
cleanup
15+
set +e
16+
printf "\nCleanup: removing resource group: %s\n" $groupName
17+
azure group remove --name "$groupName" --force
18+
set -e
1619
echo "success: $f"
1720
done
18-
done
21+
done
22+
23+
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
Global
6168
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6269
Debug|Any CPU = Debug|Any CPU
@@ -147,6 +154,14 @@ Global
147154
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
148155
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
149156
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.Build.0 = Release|Any CPU
157+
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
158+
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
159+
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
160+
{094A32EA-BABC-4A0C-9B6C-3CF7F6EABEC9}.Release|Any CPU.Build.0 = Release|Any CPU
161+
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
162+
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
163+
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
164+
{6EDCB32A-8420-48FC-99CE-94BEA12D2FD2}.Release|Any CPU.Build.0 = Release|Any CPU
150165
EndGlobalSection
151166
GlobalSection(SolutionProperties) = preSolution
152167
HideSolutionNode = FALSE

src/CLU/Commands.Common.Authentication/Authentication/AdalTokenProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Commands.Common.Authentication.Properties;
1615
using Microsoft.Azure.Commands.Common.Authentication.Models;
1716
using System;
17+
using Commands.Common.Authentication.Properties;
1818

1919
namespace Microsoft.Azure.Commands.Common.Authentication
2020
{

src/CLU/Commands.Common.Authentication/Authentication/ServicePrincipalTokenProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Commands.Common.Authentication.Properties;
1615
using Microsoft.Azure.Commands.Common.Authentication.Models;
1716
using Microsoft.IdentityModel.Clients.ActiveDirectory;
1817
using Microsoft.Rest;
1918
using System;
19+
using Commands.Common.Authentication.Properties;
2020

2121
namespace Microsoft.Azure.Commands.Common.Authentication
2222
{

src/CLU/Commands.Common.Authentication/ClientFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Commands.Common.Authentication.Properties;
1615
using Microsoft.Azure.Commands.Common.Authentication.Models;
1716
using Microsoft.Rest;
1817
using System;
@@ -23,6 +22,7 @@
2322
using System.Net.Http;
2423
using System.Net.Http.Headers;
2524
using System.Reflection;
25+
using Commands.Common.Authentication.Properties;
2626

2727
namespace Microsoft.Azure.Commands.Common.Authentication.Factories
2828
{

src/CLU/Commands.Common.Authentication/Commands.Common.Authentication.xproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
88
<PropertyGroup Label="Globals">
99
<ProjectGuid>4ce82310-d016-497d-93a0-0323a3e62064</ProjectGuid>
10-
<RootNamespace>Microsoft.Azure.Commands.Common.Authentication</RootNamespace>
10+
<RootNamespace>Commands.Common.Authentication</RootNamespace>
1111
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
1212
<OutputPath Condition="'$(OutputPath)'=='' ">..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
1313
</PropertyGroup>

src/CLU/Commands.Common.Authentication/JsonUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Commands.Common.Authentication.Properties;
1615
using Newtonsoft.Json;
1716
using Newtonsoft.Json.Linq;
1817
using System;
1918
using System.Collections.Generic;
2019
using System.Diagnostics.CodeAnalysis;
20+
using Commands.Common.Authentication.Properties;
2121

2222
namespace Microsoft.Azure.Commands.Common.Authentication
2323
{

src/CLU/Commands.Common.Authentication/Models/AzureEnvironment.Methods.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Commands.Common.Authentication.Properties;
1615
using System;
1716
using System.Collections.Generic;
17+
using Commands.Common.Authentication.Properties;
1818

1919
namespace Microsoft.Azure.Commands.Common.Authentication.Models
2020
{

src/CLU/Commands.Common.Authentication/Models/AzureSMProfile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Commands.Common.Authentication.Properties;
1615
using Microsoft.Rest;
1716
using Newtonsoft.Json;
1817
using System;
1918
using System.Collections.Generic;
2019
using System.Linq;
20+
using Commands.Common.Authentication.Properties;
2121

2222
namespace Microsoft.Azure.Commands.Common.Authentication.Models
2323
{

src/CLU/Commands.Common.Authentication/Models/DiskDataStore.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
// limitations under the License.
1313
// ----------------------------------------------------------------------------------
1414

15-
using Commands.Common.Authentication.Properties;
1615
using System;
1716
using System.IO;
1817
using System.Security.Cryptography.X509Certificates;
1918
using System.Text;
19+
using Commands.Common.Authentication.Properties;
2020

2121
namespace Microsoft.Azure.Commands.Common.Authentication.Models
2222
{

src/CLU/Commands.Common.Authentication/Properties/Resources.Designer.cs

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)