Skip to content

Commit e6ca066

Browse files
committed
Added copy of azure bash script to win output and added example of assert to 01-ResourceGroups.sh
1 parent 707b4b7 commit e6ca066

File tree

5 files changed

+32
-17
lines changed

5 files changed

+32
-17
lines changed

clu-getstart.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, you should se
8181
### Testing Cmdlets
8282

8383
#### Environment setup (Windows)
84-
- Install [git bash for windows](https://git-scm.com/download/win) if you dont have git installed on your system.
85-
- Install jq using chocolatey `choco install jq`. You can install chocolatey from [here](https://chocolatey.org/).
84+
- Install latest version of [Git for Windows](https://git-scm.com/download/win) that has `bash 4.x` available.
85+
- Install `jq` using chocolatey `choco install jq` (chocolatey can be installed from [here](https://chocolatey.org/)).
8686

8787
#### Test Infrastructure
88-
Testing will consist of scenario tests and unit tests. We want scenario tests to be used as examples and be available in `.ps1` and `.sh` formats.
88+
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.
8989

9090
#### Scenario Tests
9191
- 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.
@@ -96,16 +96,18 @@ Testing will consist of scenario tests and unit tests. We want scenario tests to
9696
```bash
9797
export azureuser=<[email protected]>
9898
export azurepassword=<your_password>
99+
export PATH=$PATH:/<path-to-drop>/clurun/win7-x64/
99100
. /examples/lib/testrunner.sh
100101
```
101102
- All the parameters to the cmdlets should be passed in as envt. variables
102-
- The test runners are guaranted to provide a unique resource group name via `$groupName` and reomve it at the end of the test execution.
103+
- 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.
103104
- The location for ARM will be provided via variable `$location`.
104-
- "jq" package and `./examples/lib/assert.sh` should be used to validate the responses.
105-
105+
- "jq" package and BASH assert (e.g. `[ "foo" == "bar" ]`) should be used to validate the responses.
106106

107+
##### PowerShell Tests
108+
TODO: Add section on PowerShell testing
107109

108110
#### Unit Tests
109-
TODO: Add details on unit testing
111+
TODO: Add section on unit testing
110112

111113

examples/lib/setup.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#!/bin/bash
22
# Login
33
login() {
4-
echo "Executing Login..."
4+
echo "Executing Login..."
55
export CmdletSessionId=1010
66
azure account add --username $azureuser --password $azurepassword
7+
}
78

9+
cleanup() {
10+
set +e
11+
printf "\nCleanup: removing resource group: %s\n" $groupName
12+
azure group remove --name "$groupName" --force
13+
set -e
814
}
915

10-
export -f login
16+
export -f login
17+
export -f cleanup

examples/lib/testrunner.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ export BASEDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
66
export groupName=`randomName testrg`
77
export location="westus"
88

9+
login
910

1011
for d in $( ls $BASEDIR/.. --ignore=lib ); do
1112
for f in $( ls $BASEDIR/../$d/*.sh ); do
1213
echo "running: $f"
1314
. $f
14-
assert_end examples
15+
cleanup
16+
echo "success: $f"
1517
done
1618
done

examples/resource-management/01-ResourceGroups.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,19 @@ 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 resource group new --name "$groupName" --location "$location"
6+
azure group create --name "$groupName" --location "$location"
77

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

1111
printf "\n3. Get information about resource group : %s.\n" "$groupName"
12-
resourceGroupInfo=`azure resource group get --name $groupName`
13-
printf "\nThe resource group info is: \n %s\n" "$resourceGroupInfo"
12+
resourceGroupInfo=`azure group get --name $groupName`
13+
14+
printf "\nValidating resource group name is: %s\n" "$groupName"
15+
[ $(echo $resourceGroupInfo | jq '.ResourceGroupName' --raw-output) == "$groupName" ]
1416

1517
printf "\n4. Listing all resource groups in the subscription.\n"
16-
azure resource group get
18+
azure group get
1719

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

tools/CLU/BuildAndInstallClu.bat

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,6 @@ copy /Y %~dp0\azure.sh %root%\drop\clurun\osx.10.10-x64
3333
xcopy %root%\drop\clurun\win7-x64\pkgs %root%\drop\clurun\ubuntu.14.04-x64\pkgs /S /Q /I /Y
3434
copy /Y %root%\drop\clurun\win7-x64\azure.lx %root%\drop\clurun\ubuntu.14.04-x64
3535
copy /Y %root%\drop\clurun\win7-x64\msclu.cfg %root%\drop\clurun\ubuntu.14.04-x64
36-
copy /Y %~dp0\azure.sh %root%\drop\clurun\ubuntu.14.04-x64
36+
copy /Y %~dp0\azure.sh %root%\drop\clurun\ubuntu.14.04-x64
37+
38+
copy /Y %~dp0\azure %root%\drop\clurun\win7-x64

0 commit comments

Comments
 (0)