Skip to content

Clu #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 16, 2016
Merged

Clu #332

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
drop/clurun/osx.10.10-x64
drop/clurun/win7-x64
drop/CommandRepo
setup/*
src/artifacts
src/Common
src/ResourceManager
src/ServiceManagement
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM graemef/docker-ubuntu-mono

ENV DNX_VERSION 1.0.0-rc1-final
ENV DNX_USER_HOME /opt/dnx

# Install DNX prerequisites
RUN apt-get update && \
apt-get -qqy install \
libunwind8 \
gettext \
libssl-dev \
libcurl4-gnutls-dev \
zlib1g \
libicu-dev \
uuid-dev \
curl \
unzip \
jq

RUN curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_USER_HOME=$DNX_USER_HOME DNX_BRANCH=v$DNX_VERSION sh

RUN bash -c "source $DNX_USER_HOME/dnvm/dnvm.sh \
&& dnvm install $DNX_VERSION -r coreclr -alias default \
&& dnvm alias default | xargs -i ln -s $DNX_USER_HOME/runtimes/{} $DNX_USER_HOME/runtimes/default"

ENV PATH $PATH:$DNX_USER_HOME/runtimes/default/bin

ADD drop/clurun/ubuntu.14.04-x64 ubuntu.14.04-x64
ADD src/CLU test/clu
ADD tools tools
ADD examples examples

WORKDIR /test/clu

RUN bash -c "source $DNX_USER_HOME/dnvm/dnvm.sh \
&& nuget source enable -Name https://www.nuget.org/api/v2/ \
&& dnu restore \
|| dnvm use $DNX_VERSION -r coreclr"

ENV PATH /ubuntu.14.04-x64:$PATH

WORKDIR /test/clu/Commands.Common.ScenarioTest
70 changes: 57 additions & 13 deletions clu-getstart.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Work on CLU cmdlets

### Prerequsites
## Prerequsites

* 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).

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.

* 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

### Project Artifacts
## Project Artifacts

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.

Expand Down Expand Up @@ -47,7 +47,7 @@ CLUPackages require some additional files to direct generation of indexing, and
}
```

### Package Creation and Testing
## Package Creation and Testing
Two options
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.
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.
Expand All @@ -62,7 +62,7 @@ To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flav

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

### Quick introductions on cmdlets
## Quick introductions on cmdlets
* Run commands using the ‘az’ prefix, cmdlet nouns, and cmdlet verbs, for example, `az env get` maps to the cmdlet `Get-AzureRmEnvironment`
* Cmdlet parameters use the double dash (--) so for example, getting a subscription with a particular name would be: `az subscription get –-SubscriptionName “name of subscription"`
* To log in, 3 options
Expand All @@ -82,19 +82,19 @@ To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flav

```set AzureProfile=1010 ```

### Testing Cmdlets
## Testing Cmdlets

#### Environment setup (Windows)
### Environment setup (Windows)
- Install latest version of [Git for Windows](https://git-scm.com/download/win) that has `bash 4.x` available.
- Install `jq` using chocolatey `choco install jq` (chocolatey can be installed from [here](https://chocolatey.org/)).

#### Test Infrastructure
### Test Infrastructure
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.

#### Scenario Tests
### Scenario Tests
- 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.

##### Environment Variables for Authentication
#### Environment Variables for Authentication
Please set the environment variables for either Username/Password (no 2FA) or ServicePrincipal authentication:

**Username/Password (without 2-factor auth):**
Expand All @@ -114,7 +114,7 @@ Please set the environment variables for either Username/Password (no 2FA) or Se
| tenant | The tenant guid to authenticate against |
| spnSubscription | (optional) Selects a particular subscription by id. If not provided, the first listed subscription will be selected |

##### XUnit Automation For Bash Scenario Tests
#### XUnit Automation For Bash Scenario Tests
- The ```Commands.Common.ScenarioTest``` project contains classes that enable executing bash scenario tests in Visual Studio, or cross-platform using dnx.

- To implement an xunit bash scenario test you must
Expand Down Expand Up @@ -161,24 +161,68 @@ runner.EnvironmentVariables.Add("myVariableName", runner.GenerateName("myres"));
| ExamplesDirectory | The path to the 'examples' directory ($pshome/examples) |
| TestDirectory | The path to the directory where logs will be written |

##### Running Bash Tests using Bash shell
#### Running Tests in Docker
##### Docker Setup
**Option 1 - VirtualBox:**
Install ToolBox from this link - https://docs.docker.com/engine/installation/windows/

**Option 2 - Hyper-V:**

1. Install ToolBox from this link - https://docs.docker.com/engine/installation/windows/ (uninstall VirtualBox afterwards)
2. http://sa.muel.be/2015/run-docker-on-hyper-v-with-docker-machine/
* Increase VHD to 100GB (--hyperv-disk-size 100000)
* List of other switches for create command - https://docs.docker.com/machine/drivers/hyper-v/

##### Workflow
1. Build packages (see [instructions](#package-creation-and-testing))
2. From command line with admin priveleges navigate to azure-powershell root folder and run ```docker build .```
3. Copy image id from the output. For example in the output below the image id is *26f067684da3*:

```
Successfully built 26f067684da3
```
4. Run ```docker run -it [IMAGEID]``` to SSH into the Docker image
5. In the SSH window run:

```bash
export azureUser=<[email protected]>
export password=<your_password>
export userSubscription=<subscription>
export spn=<spn-guid>
export secret=<spn-secret>
export tenant=<spn-tenant>
export spnSubscription=<subscription>
export azureUser=<[email protected]>
export password=<your_password>
dnx test
```


#### Running Bash Tests using Bash shell
- Bash tests should be runnable from bash shell in windows/linux/mac environments.
- 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`

```bash
export azureUser=<[email protected]>
export password=<your_password>
export userSubscription=<subscription>
export spn=<spn-guid>
export secret=<spn-secret>
export tenant=<spn-tenant>
export spnSubscription=<subscription>
export azureUser=<[email protected]>
export password=<your_password>
export PATH=/<path-to-drop>/clurun/win7-x64/:$PATH
```
- All the parameters to the cmdlets should be passed in as environment variables
- 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.
- The location for ARM will be provided via variable `$location`.
- "jq" package and BASH assert (e.g. `[ "foo" == "bar" ]`) should be used to validate the responses.

##### PowerShell Tests
#### PowerShell Tests
TODO: Add section on PowerShell testing

#### Unit Tests
### Unit Tests
TODO: Add section on unit testing