Skip to content
This repository has been archived by the owner on Apr 23, 2019. It is now read-only.

Commit

Permalink
Added test-kitchen
Browse files Browse the repository at this point in the history
* MySQL test
* App creation test
* Nginx is running test
  • Loading branch information
michiels committed Oct 16, 2014
1 parent e48f120 commit de462dc
Show file tree
Hide file tree
Showing 36 changed files with 592 additions and 24 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.rake_test_cache
recipes.tgz
/config/servers.rb
bin/

nodes/*.json
!nodes/sample_host.json
Expand All @@ -12,3 +11,10 @@ nodes/*.json

.bundle/install.log
.bundle

.kitchen
.kitchen/
.kitchen.local.yml
.librarian

.rbenv-vars
30 changes: 30 additions & 0 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
driver:
name: digitalocean

platforms:
- name: ubuntu-14-04-x64
driver_config:
region: ams1
size: 2gb
server_name: chef-repo-test

suites:
- name: full-stack
run_list:
- role[mysql]
- role[rails_passenger]
attributes:
mysql:
server_debian_password: "test"
server_root_password: "test"
server_repl_password: "test"
active_applications:
intercity_sample_app:
domain_names: ['intercity.io']
database_info:
adapter: mysql2
username: intercity
password: r4nd0m
database: intercity_sample_app
ruby_version: 2.1.2
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ This project makes use of the [Sementic Versioning](http://semver.org/)
- Backup support (Support for filesystem, mysql and postgresql, backup to S3)
- Backup compression using GZip
- Added ruby 2.1.3 to the ruby binary list
- test-kitchen to automatically test the cookbooks and resulting server setup

### Deprecated
- Nothing

### Removed
- Nothing
- Removed the sudos cookbook because it is not needed for the Unicorn stack anymore

### Fixed
- Removed spaces from the .rbenv-vars template file
Expand Down
8 changes: 7 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
source "https://rubygems.org"

gem "chef", "~> 11.14.2"
gem "chef", "~> 11.16.2"
gem "knife-solo", "~> 0.4.1"
gem "librarian-chef", "~> 0.0.4"

gem "test-kitchen"
gem "kitchen-vagrant"
gem "kitchen-digitalocean"
gem "serverspec"
gem "rspec"
86 changes: 83 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
GEM
remote: https://rubygems.org/
specs:
chef (11.14.6)
activesupport (4.1.6)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
addressable (2.3.6)
axiom-types (0.1.1)
descendants_tracker (~> 0.0.4)
ice_nine (~> 0.11.0)
thread_safe (~> 0.3, >= 0.3.1)
chef (11.16.2)
chef-zero (~> 2.1, >= 2.1.4)
diff-lcs (~> 1.2, >= 1.2.4)
erubis (~> 2.7)
Expand All @@ -15,7 +26,7 @@ GEM
mixlib-shellout (~> 1.4)
net-ssh (~> 2.6)
net-ssh-multi (~> 1.1)
ohai (~> 7.2)
ohai (~> 7.4)
plist (~> 3.1.0)
pry (~> 0.9)
rest-client (>= 1.0.4, <= 1.6.7)
Expand All @@ -25,16 +36,35 @@ GEM
mixlib-log (~> 1.3)
rack
coderay (1.1.0)
coercible (1.0.0)
descendants_tracker (~> 0.0.1)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.2.5)
droplet_kit (1.0.1)
kartograph (~> 0.0.5)
resource_kit (~> 0.0.5)
virtus (~> 1.0.3)
equalizer (0.0.9)
erubis (2.7.0)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
ffi (1.9.5)
ffi-yajl (1.1.0)
ffi (~> 1.5)
libyajl2 (~> 1.0)
hashie (2.1.2)
highline (1.6.21)
i18n (0.6.11)
ice_nine (0.11.0)
ipaddress (0.8.0)
json (1.8.1)
kartograph (0.0.8)
kitchen-digitalocean (0.8.0)
droplet_kit (~> 1.0)
test-kitchen (~> 1.2)
kitchen-vagrant (0.15.0)
test-kitchen (~> 1.0)
knife-solo (0.4.2)
chef (>= 10.12)
erubis (~> 2.7.0)
Expand All @@ -50,12 +80,16 @@ GEM
method_source (0.8.2)
mime-types (1.25.1)
minitar (0.5.4)
minitest (5.4.2)
mixlib-authentication (1.3.0)
mixlib-log
mixlib-cli (1.5.0)
mixlib-config (2.1.0)
mixlib-log (1.6.0)
mixlib-shellout (1.4.0)
multipart-post (2.0.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.1)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
Expand All @@ -79,17 +113,63 @@ GEM
method_source (~> 0.8.1)
slop (~> 3.4)
rack (1.5.2)
resource_kit (0.0.5)
activesupport (>= 3.0)
addressable (~> 2.3.6)
faraday
rest-client (1.6.7)
mime-types (>= 1.16)
rspec (3.0.0)
rspec-core (~> 3.0.0)
rspec-expectations (~> 3.0.0)
rspec-mocks (~> 3.0.0)
rspec-core (3.0.4)
rspec-support (~> 3.0.0)
rspec-expectations (3.0.4)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.0.0)
rspec-its (1.0.1)
rspec-core (>= 2.99.0.beta1)
rspec-expectations (>= 2.99.0.beta1)
rspec-mocks (3.0.4)
rspec-support (~> 3.0.0)
rspec-support (3.0.4)
safe_yaml (1.0.4)
serverspec (2.0.1)
rspec (~> 3.0.0)
rspec-its
specinfra (~> 2.0)
slop (3.6.0)
specinfra (2.0.2)
net-scp
net-ssh
systemu (2.6.4)
test-kitchen (1.2.1)
mixlib-shellout (~> 1.2)
net-scp (~> 1.1)
net-ssh (~> 2.7)
safe_yaml (~> 1.0)
thor (~> 0.18)
thor (0.19.1)
thread_safe (0.3.4)
tzinfo (1.2.2)
thread_safe (~> 0.1)
virtus (1.0.3)
axiom-types (~> 0.1)
coercible (~> 1.0)
descendants_tracker (~> 0.0, >= 0.0.3)
equalizer (~> 0.0, >= 0.0.9)
wmi-lite (1.0.0)

PLATFORMS
ruby

DEPENDENCIES
chef (~> 11.14.2)
chef (~> 11.16.2)
kitchen-digitalocean
kitchen-vagrant
knife-solo (~> 0.4.1)
librarian-chef (~> 0.0.4)
rspec
serverspec
test-kitchen
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Intercity Chef Recipes
======================

[ ![Codeship Status for intercity/chef-repo](https://codeship.io/projects/cca718f0-2e65-0132-1079-2a765a227ada/status)](https://codeship.io/projects/39371)

This Chef repository aims at being the easiest way set up and configure your own Rails server
to host one or more Ruby on Rails applications using best
practices from our community.
Expand Down Expand Up @@ -235,6 +237,36 @@ in 5 - 10 minutes**. If something doesn't work or you need more instructions:

**Please!** [Open an issue](https://github.com/intercity/chef-repo/issues) or email [[email protected]](mailto:[email protected]).

## Testing with test-kitchen

### CI testing

Test-kitchen is a tool where you can automatically provision a server with these cookbooks and run the tests for them. The configuration in `.kitchen.yml` works with DigitalOcean.

First you need to obtain a DigitalOcean access token here: https://cloud.digitalocean.com/settings/applications. Then you need to find IDs of the SSH keys you added to your account: https://cloud.digitalocean.com/ssh_keys. You can obtain these IDs with the following command:

```
$ curl -X GET https://api.digitalocean.com/v2/account/keys -H "Authorization: Bearer $DIGITALOCEAN_ACCESS_TOKEN"
```

When you've obtained both your access token and your key IDs you can run the tests like this:

```
$ export DIGITALOCEAN_ACCESS_TOKEN="abcdefg"
$ export DIGITALOCEAN_SSH_KEY_IDS="194173"
$ bin/kitchen test
```

This command boots up a Droplet in your DigitalOcean account, provisions it with Chef, runs the tests and destroys the Droplet.

### Testing while developing

If you want to keep the Droplet running and do testing while making changes you can use the `kitchen verify` command instead of the `kitchen test` command to verify your changes:

```
$ bin/kitchen verify
```

## Resources and original authors

* Most of the cookbooks that are used in this repository are installed from the [Opscode Community Cookbooks](http://community.opscode.com).
Expand Down
16 changes: 16 additions & 0 deletions bin/bundler
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'bundler' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('bundler', 'bundler')
16 changes: 16 additions & 0 deletions bin/chef-apply
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'chef-apply' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('chef', 'chef-apply')
16 changes: 16 additions & 0 deletions bin/chef-client
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'chef-client' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('chef', 'chef-client')
16 changes: 16 additions & 0 deletions bin/chef-service-manager
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'chef-service-manager' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('chef', 'chef-service-manager')
16 changes: 16 additions & 0 deletions bin/chef-shell
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'chef-shell' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('chef', 'chef-shell')
16 changes: 16 additions & 0 deletions bin/chef-solo
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'chef-solo' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('chef', 'chef-solo')
16 changes: 16 additions & 0 deletions bin/chef-zero
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env ruby
#
# This file was generated by Bundler.
#
# The application 'chef-zero' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require 'pathname'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

require 'rubygems'
require 'bundler/setup'

load Gem.bin_path('chef-zero', 'chef-zero')
Loading

0 comments on commit de462dc

Please sign in to comment.