Skip to content

Commit 5864702

Browse files
committed
Merge branch 'clu' of https://github.com/Azure/azure-powershell into clu
2 parents 6568986 + c7bb764 commit 5864702

File tree

97 files changed

+1548
-178
lines changed

Some content is hidden

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

97 files changed

+1548
-178
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 | 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/loginService.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
azure account add --spn --appid "$spn" --secret "$secret" -t "$tenant" -s "$subscription"

examples/lib/loginUser.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
azure account add -u "$azureUser" -p "$password" -s "$subscription"

examples/resource-management/01-ResourceGroups.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ set -e
33
printf "\n=== Managing Resource Groups in Azure ===\n"
44

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

88
printf "\n2. Updating the group %s with tags.\n" "$groupName"
9-
azure group set --name "$groupName" --tags "[{\"Value\":\"testval\",\"Name\":\"testtag\"}]"
9+
azure group set -n "$groupName" --tags "[{\"Value\":\"testval\",\"Name\":\"testtag\"}]"
1010

1111
printf "\n3. Get information about resource group : %s.\n" "$groupName"
12-
resourceGroupInfo=`azure group get --name $groupName`
12+
resourceGroupInfo=`azure group get -n $groupName`
1313

1414
printf "\nValidating resource group name is: %s\n" "$groupName"
1515
[ $(echo $resourceGroupInfo | jq '.ResourceGroupName' --raw-output) == "$groupName" ]
@@ -18,4 +18,4 @@ printf "\n4. Listing all resource groups in the subscription.\n"
1818
azure group get
1919

2020
printf "\n5. Removing resource group: %s.\n" "$groupName"
21-
azure group remove --name "$groupName" --force
21+
azure group remove -n "$groupName" -f

src/CLU/CLUCoreCLR.sln

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 14
4-
VisualStudioVersion = 14.0.23107.0
4+
VisualStudioVersion = 14.0.24720.0
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Commands.Common", "Commands.Common\Commands.Common.xproj", "{5F567ACA-595E-436D-83DB-A21E08F82DF6}"
77
EndProject
@@ -37,8 +37,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU.Run", "Micros
3737
EndProject
3838
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU", "Microsoft.CLU\Microsoft.CLU.xproj", "{D0A59671-088D-463B-B060-2ADAFFB9C3F6}"
3939
EndProject
40-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.CLU.Test", "Microsoft.CLU.Test\Microsoft.CLU.Test.xproj", "{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}"
41-
EndProject
4240
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Compute", "Microsoft.Azure.Commands.Compute\Microsoft.Azure.Commands.Compute.xproj", "{04F9968A-5662-4508-BEE2-31F56848FCBA}"
4341
ProjectSection(ProjectDependencies) = postProject
4442
{99B1290D-A073-4907-8018-51C714431778} = {99B1290D-A073-4907-8018-51C714431778}
@@ -47,6 +45,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Co
4745
{45B05B68-516F-4D74-897F-56D12894946C} = {45B05B68-516F-4D74-897F-56D12894946C}
4846
EndProjectSection
4947
EndProject
48+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Commands.Common.ScenarioTest", "Commands.Common.ScenarioTest\Commands.Common.ScenarioTest.xproj", "{B1D3CB1F-C0CA-401F-8146-B2E9C1EF460F}"
49+
EndProject
5050
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Compute.Test", "Microsoft.Azure.Commands.Compute.Test\Microsoft.Azure.Commands.Compute.Test.xproj", "{13C34370-51A4-4726-81B8-BE0996FC9CFF}"
5151
ProjectSection(ProjectDependencies) = postProject
5252
{3910613E-4ED2-49E2-8CCF-966D586665AC} = {3910613E-4ED2-49E2-8CCF-966D586665AC}
@@ -55,6 +55,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Azure.Commands.Co
5555
{04F9968A-5662-4508-BEE2-31F56848FCBA} = {04F9968A-5662-4508-BEE2-31F56848FCBA}
5656
EndProjectSection
5757
EndProject
58+
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.ScenarioTest.CLU", "Microsoft.ScenarioTests.CLU\Microsoft.ScenarioTest.CLU.xproj", "{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}"
59+
EndProject
5860
Global
5961
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6062
Debug|Any CPU = Debug|Any CPU
@@ -129,18 +131,22 @@ Global
129131
{D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
130132
{D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
131133
{D0A59671-088D-463B-B060-2ADAFFB9C3F6}.Release|Any CPU.Build.0 = Release|Any CPU
132-
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
133-
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
134-
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
135-
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.Build.0 = Release|Any CPU
136134
{04F9968A-5662-4508-BEE2-31F56848FCBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
137135
{04F9968A-5662-4508-BEE2-31F56848FCBA}.Debug|Any CPU.Build.0 = Debug|Any CPU
138136
{04F9968A-5662-4508-BEE2-31F56848FCBA}.Release|Any CPU.ActiveCfg = Release|Any CPU
139137
{04F9968A-5662-4508-BEE2-31F56848FCBA}.Release|Any CPU.Build.0 = Release|Any CPU
138+
{B1D3CB1F-C0CA-401F-8146-B2E9C1EF460F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
139+
{B1D3CB1F-C0CA-401F-8146-B2E9C1EF460F}.Debug|Any CPU.Build.0 = Debug|Any CPU
140+
{B1D3CB1F-C0CA-401F-8146-B2E9C1EF460F}.Release|Any CPU.ActiveCfg = Release|Any CPU
141+
{B1D3CB1F-C0CA-401F-8146-B2E9C1EF460F}.Release|Any CPU.Build.0 = Release|Any CPU
140142
{13C34370-51A4-4726-81B8-BE0996FC9CFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
141143
{13C34370-51A4-4726-81B8-BE0996FC9CFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
142144
{13C34370-51A4-4726-81B8-BE0996FC9CFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
143145
{13C34370-51A4-4726-81B8-BE0996FC9CFF}.Release|Any CPU.Build.0 = Release|Any CPU
146+
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
147+
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
148+
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
149+
{91422B55-28A5-48DE-BCA0-30C3E30FFB1C}.Release|Any CPU.Build.0 = Release|Any CPU
144150
EndGlobalSection
145151
GlobalSection(SolutionProperties) = preSolution
146152
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
{

0 commit comments

Comments
 (0)