summaryrefslogtreecommitdiff
path: root/acceptance/README.md
blob: 48fa672a7c2dca5e6186a864381f6886895384e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# Acceptance Testing for Chef Client
This folder contains acceptance tests that are required for Chef client
release readiness.

## Getting started
The tests use the _chef-acceptance_ gem as the high level framework.
All the gems needed to run these tests can be installed with Bundler.

### Important Note!
Before running chef-acceptance, you *MUST* do the following on your current session:

```
export APPBUNDLER_ALLOW_RVM=true
```

## Pre-requisites / One time set up

### Set up for local VM (Vagrant)

If you intend to run the acceptance tests on a local VM, the supported solution is to use Vagrant.
Ensure that Vagrant is installed on the machine that tests will run from, along with a
virtualization driver (E.g.: VirtualBox).

Set up the KITCHEN_DRIVER environment variable appropriately (value should be "vagrant").  E.g.:
```
export KITCHEN_DRIVER=vagrant
```
Add this to your shell profile or startup script as needed.

### Set up for cloud VM (EC2)

If you intend to run the acceptance tests on a cloud VM, the supported solution is to use EC2.

The steps you will need to do are:

1. Add your AWS credentials to the machine - e.g., to the ~/.aws/credentials directory.
   - The easiest way to do this is to download the aws command line (`brew install awscli` on OS/X) and run `aws configure`.
2. Create or import a SSH key to AWS. (If you already have one, you can skip the import/create)
   - In the AWS console, click Key Pairs, then Create Key Pair or Import Key Pair.
3. Copy or move the private key file (USERNAME.pem) to the SSH folder (e.g. `~/.ssh/USERNAME.pem`).
   - If you Created a key pair in step 2, download the private key and move it to `~/.ssh`.
   - If you Importd a key pair in step 2, just ensure your private key is in `~/.ssh` and has the same name as the key pair (`~/.ssh/USERNAME` or `~/.ssh/USERNAME.pem`).
4. Set AWS_SSH_KEY_ID to the SSH key name.
   - This is **optional** if your AWS SSH key name is your local username.
   - You may want to set this in your shell `.profile`.

     ```shell
     export AWS_SSH_KEY_ID=name-of-private-key
     ```
5. Set the private key to only be readable by root

   ```shell
   chmod 0400 ~/.ssh/USERNAME.pem
   ```
6. Set up the KITCHEN_DRIVER environment variable appropriately (value should be "ec2"). (This is optional, as ec2 is the default.) E.g.:

   ```shell
   export KITCHEN_DRIVER=ec2
   ```
   Add this to your shell profile or startup script as needed.
7. **Connect to Chef VPN**. The instances you create will not have public IPs!

### Setting up and running a test suite
To get started, do a bundle install from the acceptance directory:
```shell
chef/acceptance$ bundle install --binstubs
```

To get some basic info and ensure chef-acceptance can be run, do:
```shell
chef/acceptance$ bin/chef-acceptance info
```

To run a particular test suite, do the following:
```shell
chef/acceptance$ bin/chef-acceptance test TEST_SUITE
```

To restrict which OS's will run, use the KITCHEN_INSTANCES environment variable:

```shell
chef/acceptance$ export KITCHEN_INSTANCES=*-ubuntu-1404
chef/acceptance$ bin/chef-acceptance test cookbook-git
```

If KITCHEN_INSTANCES is not specified, the default instances are default-ubuntu-1404 and default-windows-windows-2012r2. All selected instances will be run in *parallel* if the driver supports it (ec2 does, vagrant doesn't).