Skip to content

Commit 62f1f04

Browse files
committed
2 parents c5d59cd + aea4da6 commit 62f1f04

File tree

395 files changed

+51417
-507
lines changed

Some content is hidden

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

395 files changed

+51417
-507
lines changed

clu-getstart.md

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
### Prerequsites
44

5-
Visual Studio 2015 RTM with ASP.NET. For details, check out the [installation doc](http://docs.asp.net/en/latest/getting-started/installing-on-windows.html).
5+
* Visual Studio 2015 RTM with ASP.NET. For details, check out the [installation doc](http://docs.asp.net/en/latest/getting-started/installing-on-windows.html).
66

77
Note, after done, run `dnvm list` command to check the 'coreclr' runtime is installed with right version of `1.0.0-rc1-final`. If not, run `dnvm install 1.0.0-rc1-final -r coreclr -a x64 -p`. Remember always use `-p` flag, so the selection can persist.
88

9+
* Get the latest dotnet from "https://azureclu.blob.core.windows.net/tools/dotnet-win-x64.latest.zip", unzip, then add its bin folder to the PATH
10+
911
### Project Artifacts
1012

1113
CLUPackages require some additional files to direct generation of indexing, and to provide shortcuts when files are installed. These files can be copied from the Profile project and updated for each package.
@@ -92,6 +94,26 @@ Testing will consist of scenario tests and unit tests. Scenario tests should be
9294
#### Scenario Tests
9395
- 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.
9496

97+
##### Environment Variables for Authentication
98+
Please set the environment variables for either Username/Password (no 2FA) or ServicePrincipal authentication:
99+
100+
**Username/Password (without 2-factor auth):**
101+
102+
| Field (case sensitive) | Description |
103+
| ------------- |:-------------|
104+
| azureUser | an OrgId user name |
105+
| password | a service principal name |
106+
| userSubscription | (optional) Selects a particular subscription by id. If not provided, the first listed subscription will be selected |
107+
108+
**Service Principal:**
109+
110+
| Field (case sensitive) | Description |
111+
| ------------- |:-------------|
112+
| spn | The tenant guid to authenticate against |
113+
| secret | the password or application secret to sue for authentication |
114+
| tenant | The tenant guid to authenticate against |
115+
| spnSubscription | (optional) Selects a particular subscription by id. If not provided, the first listed subscription will be selected |
116+
95117
##### XUnit Automation For Bash Scenario Tests
96118
- The ```Commands.Common.ScenarioTest``` project contains classes that enable executing bash scenario tests in Visual Studio, or cross-platform using dnx.
97119

@@ -116,20 +138,22 @@ Testing will consist of scenario tests and unit tests. Scenario tests should be
116138
_fixture.GetRunner("resource-management").RunScript("01-ResourceGroups");
117139
}
118140
```
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).
141+
- Set the [environment variables](#Environment_Variables_for_Authentication) for either Username/Password (no 2FA) or ServicePrincipal authentication
142+
- Update PATH to include location of CLU bin drop.
143+
```bash
144+
export PATH=/<path-to-drop>/clurun/win7-x64/:$PATH
145+
```
146+
- The infrastructure automatically generates the following environment variables:
147+
- `BASEDIR` - directory path where test script is located
148+
- `location` - default "WestUS" location
149+
- `groupName` - randomly generated resource group name (note: the test guarantees that this resource group is deleted at the end of a test run; any other resource groups generated as part of the test run need to be deleted by the test)
150+
- `storageAccountType` - default "Standard_GRS" storage account type
151+
- `storageAccountName` - randomly generated storage account name
152+
- If the script 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).
129153
```C#
130-
runner.EnvironmentVariables.Add("myVariableName", runner.GenerateName("myres"));
154+
runner.EnvironmentVariables.Add("myVariableName", runner.GenerateName("myres"));
131155
```
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:
156+
- Tests can be executed in Visual Studio, or by running ```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:
133157

134158
| Environment Variable | Description |
135159
| ------------- |:-------------|
@@ -138,14 +162,14 @@ Testing will consist of scenario tests and unit tests. Scenario tests should be
138162

139163
##### Running Bash Tests using Bash shell
140164
- Bash tests should be runnable from bash shell in windows/linux/mac environments.
141-
- To manually run the tests; please set the following envt. variables for authentication and run `./examples/lib/testrunner.sh`
165+
- To manually run the tests; please set [environment variables](#Environment_Variables_for_Authentication) for authentication as well as update PATH and run `./examples/lib/testrunner.sh`
166+
142167
```bash
143-
export azureuser=<username@contosocorp.com>
144-
export azurepassword=<your_password>
145-
export PATH=$PATH:/<path-to-drop>/clurun/win7-x64/
146-
. /examples/lib/testrunner.sh
168+
export azureUser=<[email protected]>
169+
export password=<your_password>
170+
export PATH=/<path-to-drop>/clurun/win7-x64/:$PATH
147171
```
148-
- All the parameters to the cmdlets should be passed in as envt. variables
172+
- All the parameters to the cmdlets should be passed in as environment variables
149173
- The current test runners will provide a unique resource group name via `$groupName` but may not remove it at the end if the test fails.
150174
- The location for ARM will be provided via variable `$location`.
151175
- "jq" package and BASH assert (e.g. `[ "foo" == "bar" ]`) should be used to validate the responses.
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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
set -e
3+
printf "\n=== Managing Virtual Machine Sizes in Azure Compute ===\n"
4+
5+
printf "\n1. Showing VM size results in location: %s.\n" "$location"
6+
azure vmsize get --location "$location"
7+
8+
printf "\n2. Checking VM size results in location: %s.\n" "$location"
9+
vmSizeResult=`azure vmsize get --location "$location"`
10+
11+
if [[ $vmSizeResult == "" ]]; then
12+
echo "Failure: No VM sizes!" 1>&2
13+
exit 1
14+
else
15+
echo "Success: Non-empty Results."
16+
fi
17+
18+
filterResult=`azure vmsize get --location "$location" | cat | jq 'select(.name | contains("Standard_A0"))' --raw-output`
19+
if [[ "$filterResult" == "" ]]; then
20+
echo "Failure: Standard_A0 vm size not found." 1>&2
21+
exit 1
22+
else
23+
echo "Success: Standard_A0 vm size found."
24+
fi
25+
26+
filterResult=`azure vmsize get --location "$location" | cat | jq 'select(.name | contains("Standard_G1"))' --raw-output`
27+
if [[ "$filterResult" == "" ]]; then
28+
echo "Failure: Standard_G1 vm size not found." 1>&2
29+
exit 1
30+
else
31+
echo "Success: Standard_G1 vm size found."
32+
fi
33+
34+
filterResult=`azure vmsize get --location "$location" | cat | jq 'select(.name | contains("NonStandard_A1"))' --raw-output`
35+
if [[ "$filterResult" == "" ]]; then
36+
echo "Success: NonStandard_A1 vm size not found."
37+
else
38+
echo "Failure: NonStandard_A1 vm size found." 1>&2
39+
exit 1
40+
fi
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: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
set -e
3+
printf "\n=== Managing Virtual Machine Creation 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. Create virtual network.\n"
12+
result=`azure virtual network new --resourcegroupname "$groupName" --name test --location "$location" --addressprefix "[\"10.0.0.0/16\"]" --subnet "[{\"Name\":\"test\",\"AddressPrefix\":\"10.0.0.0/24\"}]" --force`
13+
14+
contextResult=`azure context get`
15+
16+
subId=`echo $contextResult | jq '.Subscription.SubscriptionId' --raw-output`
17+
18+
subnetId="/subscriptions/$subId/resourceGroups/$groupName/providers/Microsoft.Network/virtualNetworks/test/subnets/test"
19+
20+
printf "\n4. Create network interface with:\r\nsubId='%s' \r\n& \r\nsubnetId='$subnetId'.\n" "$subId"
21+
export MSYS_NO_PATHCONV=1
22+
azure network interface new --name test --resourcegroupname "$groupName" --location "$location" --subnetid "$subnetId"
23+
export MSYS_NO_PATHCONV=
24+
25+
nicId="/subscriptions/$subId/resourceGroups/$groupName/providers/Microsoft.Network/networkInterfaces/test"
26+
27+
vhdUri="https://$storageAccountName.blob.core.windows.net/$storageAccountName/$storageAccountName.vhd"
28+
29+
vmStr="{\"Name\":\"test\",\"HardwareProfile\":{\"VmSize\":\"Standard_A1\"},\"NetworkProfile\":{\"NetworkInterfaces\":[{\"Id\":\"$nicId\"}]},\"OSProfile\":{\"ComputerName\":\"test\",\"AdminPassword\":\"BaR@1234\",\"AdminUsername\":\"Foo12\"},\"StorageProfile\":{\"ImageReference\":{\"Offer\":\"WindowsServer\",\"Publisher\":\"MicrosoftWindowsServer\",\"Sku\":\"2008-R2-SP1\",\"Version\":\"latest\"},\"OSDisk\":{\"Caching\":\"ReadWrite\",\"CreateOption\":\"FromImage\",\"Name\":\"osDisk\",\"Vhd\":{\"Uri\":\"$vhdUri\"}}}}"
30+
31+
printf "\n5. Create virtual machine with\r\nnicId='%s'\r\nvhdUri='%s'\r\nvmStr='%s'\n" "$nicId" "$vhdUri" "$vmStr"
32+
33+
azure vm new --resourcegroupname "$groupName" --location "$location" --vmprofile "$vmStr"
34+
35+
printf "\n6. Removing resource group: %s.\n" "$groupName"
36+
azure group remove -n "$groupName" -f

examples/lib/loginService.sh

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

examples/lib/loginUser.sh

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

examples/lib/testrunner.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
#!/bin/bash
2-
export BASEDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
3-
. $BASEDIR/helper.sh
4-
. $BASEDIR/setup.sh
2+
export TESTDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
3+
. $TESTDIR/helper.sh
54
export groupName=`randomName testrg`
65
export location="westus"
6+
export MSYS_NO_PATHCONV=1
77

8-
login
8+
echo "Logging in as user"
9+
. $TESTDIR/loginUser.sh
910

10-
for d in $( ls $BASEDIR/.. --ignore=lib ); do
11-
for f in $( ls $BASEDIR/../$d/*.sh ); do
11+
for d in $( ls $TESTDIR/.. --ignore=lib ); do
12+
for f in $( ls $TESTDIR/../$d/*.sh ); do
1213
echo "running: $f"
14+
BASEDIR=$(cd "$(dirname "$f")" && pwd)
1315
. $f
14-
cleanup
16+
set +e
17+
printf "\nCleanup: removing resource group: %s\n" $groupName
18+
azure group remove --name "$groupName" --force
19+
set -e
1520
echo "success: $f"
1621
done
17-
done
22+
done
23+
24+
export MSYS_NO_PATHCONV=
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
Param(
2-
[string]$resourceGroupName,
3-
[string]$resourceGroupLocation
2+
[string]$groupName,
3+
[string]$location
44
)
55

66
Write-Host "=== Managing Resource Groups in Azure ==="
77

88
Write-Host "1. Create a new resource group"
9-
New-AzureRmResourceGroup -Name $resourceGroupName -Location $resourceGroupLocation
9+
New-AzureRmResourceGroup -Name $groupName -Location $location
1010

1111
Write-Host "2. Update group tags"
12-
Set-AzureRmResourceGroup -Name $resourceGroupName -Tags @{Name = "testtag"; Value = "testval"}
12+
Set-AzureRmResourceGroup -Name $groupName -Tags @{Name = "testtag"; Value = "testval"}
1313

1414
Write-Host "3. Get information about resource group"
15-
$resourceGroup = Get-AzureRmResourceGroup -Name $resourceGroupName
15+
$resourceGroup = Get-AzureRmResourceGroup -Name $groupName
1616
Write-Host $resourceGroup
1717

1818
Write-Host "4. List all resource groups in the subscription"
1919
Get-AzureRmResourceGroup
2020

2121
Write-Host "5. Remove resource group"
22-
Remove-AzureRmResourceGroup -Name $resourceGroupName -Force
22+
Remove-AzureRmResourceGroup -Name $groupName -Force
2323

2424
Write-Host "6. Validations"
25-
Assert-AreEqual $resourceGroup.ResourceGroupName $resourceGroupName
25+
Assert-AreEqual $resourceGroup.ResourceGroupName $groupName
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
Param(
2+
[string]$groupName,
3+
[string]$location,
4+
[string]$rName,
5+
)
6+
7+
Write-Host "=== Managing Resources in Azure ==="
8+
9+
Write-Host "1. Creating a new resource group"
10+
New-AzureRmResourceGroup -Name $groupName -Location $location
11+
$destinationGroupName = $groupName + "Destination"
12+
13+
Write-Host "2. Registering Resource Provider Namespace."
14+
$providerNamespace="Providers.Test"
15+
Register-AzureRmResourceProvider -ProviderNamespace $providerNamespace -Force
16+
17+
Write-Host "3. Creating a new Resource"
18+
$resourceType = $providerNamespace + "/statefulResources"
19+
$apiversion="2014-04-01"
20+
New-AzureRmResource -Name $rName -Location $location -Tags @{Name = "testtag"; Value = "testval"} -ResourceGroupName $groupName -ResourceType $resourceType -PropertyObject @{"administratorLogin" = "adminuser"; "administratorLoginPassword" = "P@ssword1"} -ApiVersion $apiversion -Force
21+
22+
Write-Host "4. Get information about Resource"
23+
$resourceInfo = Get-AzureRmResource -ResourceGroupName $groupName
24+
Write-Host "Validating Resource name"
25+
Assert-AreEqual $rName $resourceInfo.Name
26+
27+
Write-Host "5. Find Resource with name"
28+
$foundResource = Find-AzureRmResource -ResourceType $resourceType -ResourceNameContains $rName
29+
Write-Host "Validating Resource name"
30+
Assert-AreEqual $rName $foundResource.Name
31+
32+
Write-Host "6. Update Resource"
33+
Set-AzureRmResource -ResourceGroupName $groupName -ResourceName $rName -ResourceType $resourceType -Tags @{Name = "testtagUpdated"; Value = "testvalueUpdated"} -Force
34+
35+
Write-Host "7. Move Resource to resource group"
36+
New-AzureRmResourceGroup -Name $destinationGroupName -Location $location
37+
Move-AzureRmResource -DestinationResourceGroupName $destinationGroupName -ResourceId $resourceInfo.ResourceId -Force
38+
39+
Write-Host "8. Removing resource"
40+
$foundResource = Find-AzureRmResource -ResourceType $resourceType -ResourceNameContains $rName
41+
Remove-AzureRmResource -ResourceId $foundResource.ResourceId -Force
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/bin/bash
2+
set -e
3+
printf "\n=== Managing Resources in Azure ===\n"
4+
5+
printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
6+
azure group create --name "$groupName" --location "$location"
7+
destinationGroupName=$groupName"Destination"
8+
9+
printf "\n2. Registering Resource Provider Namespace.\n"
10+
providerNamespace="Providers.Test"
11+
azure resource provider register --ProviderNamespace $providerNamespace --Force
12+
13+
printf "\n3. Creating a new Resource: %s.\n" "$resourceName"
14+
resourceType="$providerNamespace/statefulResources"
15+
tags='[{"Name": "testtag", "Value": "testvalue"}]'
16+
properties='{"administratorLogin": "adminuser", "administratorLoginPassword": "P@ssword1"}'
17+
apiversion="2014-04-01"
18+
azure resource create --Name $resourceName --Location $location --Tags "$tags" --ResourceGroupName $groupName --ResourceType $resourceType --PropertyObject "$properties" --ApiVersion $apiversion --Force
19+
20+
printf "\n4. Get information about Resource : %s.\n" "$resourceName"
21+
resourceInfo=$(azure resource get -n $resourceName)
22+
printf "\nValidating Resource name is: %s\n" "$resourceName"
23+
[ $(echo $resourceInfo | jq '.Name' --raw-output) == "$resourceName" ]
24+
25+
printf "\n5. Find Resource with name '%s' and type '%s'.\n" "$resourceName" "$resourceType"
26+
foundResource=$(azure resource find -n "$resourceName" -t $resourceType)
27+
printf "\nValidating Resource name is: %s.\n" "$resourceName"
28+
[ $(echo $foundResource | jq '.Name' --raw-output) == "$resourceName" ]
29+
30+
printf "\n6. Update Resource.\n"
31+
tagsUpdate='[{"Name": "testtagUpdated", "Value": "testvalueUpdated"}]'
32+
azure resource set --ResourceGroupName $groupName --ResourceName $resourceName --ResourceType $resourceType --Tags "$tagsUpdate" -f
33+
34+
printf "\n7. Move Resource to resource group: %s.\n" "$destinationGroupName"
35+
azure group create --name "$destinationGroupName" --location "$location"
36+
resourceId=$(echo $resourceInfo | jq '.Id')
37+
arrayId="[$resourceId]"
38+
azure resource move -g "$destinationGroupName" --ResourceId "$arrayId" -f
39+
40+
printf "\n8. Removing resource: %s.\n" "$resourceName"
41+
foundResource=$(azure resource find -n "$resourceName" -t $resourceType)
42+
resourceId=$(echo $foundResource | jq '.Id' --raw-output)
43+
echo $resourceId
44+
export MSYS_NO_PATHCONV=1
45+
azure resource remove --Id "$resourceId" -f
46+
export MSYS_NO_PATHCONV=
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Param(
2+
[string]$groupName,
3+
[string]$location
4+
)
5+
6+
Write-Host "=== Provisioning Deployments in Azure ==="
7+
8+
Write-Host "1. Create a new resource group"
9+
New-AzureRmResourceGroup -Name $groupName -Location $location
10+
11+
Write-Host "2. Test template"
12+
$siteName = Get-ResourceName
13+
$list = Test-AzureResourceGroupTemplate -ResourceGroupName $groupName -TemplateFile sampleTemplate.json -siteName $siteName -hostingPlanName $siteName -siteLocation $location -sku Free -workerSize 0
14+
Write-Host $list
15+
# Assert
16+
Assert-AreEqual 0 @($list).Count
17+
18+
Write-Host "3. Provisioning Deployment"
19+
$deployment = New-AzureRmResourceGroupDeployment -Name $siteName -ResourceGroupName $groupName -TemplateFile sampleTemplate.json -TemplateParameterFile sampleTemplateParams.json
20+
Write-Host $deployment
21+
# Assert
22+
Assert-AreEqual Succeeded $deployment.ProvisioningState
23+
24+

0 commit comments

Comments
 (0)