Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Run test-kitchen suites in cloud hosting via Travis #108

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
481bb00
Added DigitalOcean testing for patcon/chef-stash repo.
patcon Jul 9, 2015
2171162
Added inline hint for DigitalOcean SSH key IDs.
patcon Jul 9, 2015
e922cd0
Converted 'empty?' methods in template into booleans.
patcon Jul 9, 2015
67ac33a
Added chef-sugar cookbook for access to #blank? helper.
patcon Jul 9, 2015
fa7125e
Oops. Forgot to add travis kitchen.yml.
patcon Jul 9, 2015
dd38fbd
Installed chef-sugar properly.
patcon Jul 9, 2015
279c221
Make sure java memory settings match digitalocean image's.
patcon Jul 9, 2015
104548c
Build just feature branch for testing.
patcon Jul 10, 2015
6161e7f
Bumped cloud test image size to 1024 mb.
patcon Jul 10, 2015
d054ca3
Fixed up cruft from old mysql cookbook attributes.
patcon Jul 10, 2015
e00fb56
Added more digitalocean memory for testing.
patcon Jul 10, 2015
bc6f3e2
Added paralellism and envvar check to cloud integration tests.
patcon Jul 10, 2015
20d1ee0
Added package manager recipes to local override platforms.
patcon Jul 14, 2015
e298f33
Force apt update at compiletime
patcon Jul 14, 2015
3de36f1
Start using chef_zero provisioner.
patcon Jul 14, 2015
7cdec89
Test against Chef 12.4.1.
patcon Jul 14, 2015
d3c1034
Removed compiletime build-essential, as this is handled by postgresql…
patcon Jul 14, 2015
b010bea
Updated README badge for now.
patcon Jul 14, 2015
984e27c
Output instance listing for failure clarity. [ci skip]
patcon Jul 14, 2015
9ce5df7
Reverted back to using Chef 11 for less verbose logs.
patcon Jul 14, 2015
feff06a
Moved to using an omnibus version that is exists.
patcon Jul 14, 2015
c5041bc
Use minimal formatter on travis cloud tests.
patcon Jul 14, 2015
355f96d
Cleaned up kitchen.yml merging.
patcon Jul 14, 2015
5605969
Simplified kitchen.yml setup.
patcon Jul 14, 2015
3f08d7f
Clean up travis.yml. [ci skip]
patcon Jul 14, 2015
0674296
Added note about node.apt.compile_time_update [ci skip]
patcon Jul 14, 2015
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
14 changes: 14 additions & 0 deletions .kitchen.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
driver:
name: digitalocean
private_networking: false
size: 1gb

provisioner:
client_rb:
formatters:
# Travis CI will cancel job if logs get over 4MB.
- :minimal
attributes:
stash:
jvm:
maximum_memory: 1024m
43 changes: 27 additions & 16 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,72 @@
---
driver:
name: vagrant
require_chef_omnibus: 11.16.2
require_chef_omnibus: 11.18.12

driver_config:
customize:
memory: 1024

provisioner:
name: chef_zero
attributes:
apt:
# Some other cookbook's compile_time nonsense requires this... :/
compile_time_update: true
java:
install_flavor: oracle
java_home: /usr/lib/jvm/java-7-oracle
jdk_version: 7
oracle:
accept_oracle_download_terms: true

platforms:

- name: centos-6
driver_config:
box: chef/centos-6.6
box: chef/centos-6.6 # vagrant
image: centos-6-5-x64 # digitalocean
run_list:
- recipe[yum]

- name: centos-7
driver_config:
box: chef/centos-7.0
image: centos-7-0-x64
run_list:
- recipe[yum]

- name: ubuntu-12.04
driver_config:
box: chef/ubuntu-12.04
image: ubuntu-12-04-x64
run_list:
- recipe[apt]

- name: ubuntu-14.04
driver_config:
box: chef/ubuntu-14.04
image: ubuntu-14-04-x64
run_list:
- recipe[apt]

default_attributes: &DEFAULT_ATTRIBUTES
java:
install_flavor: oracle
java_home: /usr/lib/jvm/java-7-oracle
jdk_version: 7
oracle:
accept_oracle_download_terms: true

suites:
- name: mysql # default
run_list:
- recipe[test-helper]
- recipe[java]
- recipe[stash]
attributes:
<<: *DEFAULT_ATTRIBUTES
mysql:
server_root_password: iloverandompasswordsbutthiswilldo
server_repl_password: iloverandompasswordsbutthiswilldo
server_debian_password: iloverandompasswordsbutthiswilldo
stash:
database:
password: iloverandompasswordsbutthiswilldo

- name: postgresql
run_list:
- recipe[test-helper]
- recipe[java]
- recipe[stash]
attributes:
<<: *DEFAULT_ATTRIBUTES
stash:
database:
type: postgresql
Expand Down
41 changes: 36 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,41 @@
language: ruby
bundler_args: --without integration

cache: bundler
sudo: false

rvm:
- 2.0.0
- 2.0.0

env:
global:
# Uses public key of private keypair set up in `before_install` task.
# Hint: Inspect SSH key edit buttons in DigitalOcean web interface for IDs.
- DIGITALOCEAN_SSH_KEY_IDS="970381"
# DIGITALOCEAN_ACCESS_TOKEN
- secure: "LYbpXAi9+TuzF4kuMiJTXKbgqnPGkokdX0dm+REduODCzORbPlmcfhdJNSpbYOE+PAM9uqjtAlHiuZQ5dvHdP7HgELcFFOhFEvjCWGypxBBMCNbBp6BCMX2wkUPgATqdkyEMsznCQEDbtK61OuJAMT082X7DQVo1qwWnsEmx8cAsIy9hw1c6yXGMDM8nv3ymSwu9FyQ6Vje8d0ZzLy06OkRs8T60LekzZBBus5wESRf0E8wy4I51qLZbndkCgLA/WyAKpK5rczJP3Ve5DNbMBJHyyYILYN7vKyb0JlOdI97juqa6bJYcsBA2EmpYISfWEzTW4hd5hPModqzjHxHPGada4y7rE7w6FEAXO4N/flxJe/tFe2/fHs8sLO3b8awh3YWVJ0FMP/gl8biXAc42DSiF9flMRc9eM0bqDqijOmK+LLL3FoIP7nRnvF2evcZ6bdLkNH9MnkomCliAovPfaDfD4UQXkRN5Nl5HwcIhCvve3j6Uq7o633r409R6Qc5k1ri63FIya/Iyddo4jHYperSv6/ISgwdfGGeRBpP7cZJ/ZA+tCRdQFjELwjG91Pen4im59qjc2IkVV+XrKhde7Hpl4PgiRDeWW230v8obS4Y31iL/usMm1c1UIgW2azrS7TaFdMJBmLOaO68eRJpyyqz5pGZ5tSgWMNaogD/Am5M="

before_install:
# Decrypt pre-generated private key
# See: http://docs.travis-ci.com/user/encrypting-files/
- openssl aes-256-cbc -K $encrypted_370ffe2e34a2_key -iv $encrypted_370ffe2e34a2_iv -in test/support/travis_id_rsa.key.enc -out ~/.ssh/id_rsa -d
- chmod 600 ~/.ssh/id_rsa
# Re-generate public key from private
- ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub

before_script:
- bundle exec berks install
- cp .kitchen.travis.yml .kitchen.local.yml

script:
- bundle exec rake travis
- bundle exec rake style:ruby
- bundle exec rake style:chef
- '[ "${TRAVIS_SECURE_ENV_VARS}" = "true" ] && bundle exec kitchen test --parallel'

after_script:
- bundle exec kitchen list
- bundle exec kitchen destroy

branches:
only:
- feature/108-test-kitchen-cloud

notifications:
email: false
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ group :test do
end

group :integration do
gem 'kitchen-digitalocean'
gem 'busser-serverspec', '~> 0.2.6'
gem 'kitchen-vagrant', '~> 0.15'
gem 'test-kitchen', '~> 1.3'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# chef-stash [![Build Status](https://secure.travis-ci.org/bflad/chef-stash.png?branch=master)](http://travis-ci.org/bflad/chef-stash)
# chef-stash [![Build Status](https://secure.travis-ci.org/patcon/chef-stash.png?branch=feature/108-test-kitchen-cloud)](http://travis-ci.org/patcon/chef-stash)

##![](https://assets-cdn.github.com/images/icons/emoji/unicode/2757.png) We are preparing for 4.0.0 release which makes the git repo not stable for now. Please use cookbook from [Supermarket](https://supermarket.chef.io/cookbooks/stash/) for the time being.

Expand Down
2 changes: 0 additions & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
set['build_essential']['compiletime'] = true

default['stash']['home_path'] = '/var/atlassian/application-data/stash'
default['stash']['install_path'] = '/opt/atlassian'
default['stash']['install_type'] = 'standalone'
Expand Down
1 change: 1 addition & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

depends 'apache2'
depends 'ark'
depends 'chef-sugar', '> 1.3.0'
depends 'cron'
depends 'database'
depends 'git'
Expand Down
5 changes: 2 additions & 3 deletions recipes/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
bind_address settings['database']['host']
# See: https://github.com/chef-cookbooks/mysql/pull/361
port settings['database']['port'].to_s
data_dir node['mysql']['data_dir'] if node['mysql']['data_dir']
initial_root_password node['mysql']['server_root_password']
initial_root_password settings['database']['password']
action [:create, :start]
end

database_connection.merge!(:username => 'root', :password => node['mysql']['server_root_password'])
database_connection.merge!(:username => 'root', :password => settings['database']['password'])

mysql_database settings['database']['name'] do
connection database_connection
Expand Down
3 changes: 3 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
end
include_recipe 'perl'

include_recipe 'chef-sugar::default'
require 'chef/sugar/core_extensions'

include_recipe 'stash::database' if settings['database']['host'] == '127.0.0.1'
include_recipe "stash::#{platform}_#{node['stash']['install_type']}"
include_recipe 'stash::configuration'
Expand Down
18 changes: 9 additions & 9 deletions templates/default/web_app.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
# Local modifications will be overwritten by Chef.
#
<VirtualHost *:<%= node['stash']['apache2']['port'] %>>
<% unless node['stash']['apache2']['virtual_host_name'].empty? -%>
<% unless node['stash']['apache2']['virtual_host_name'].blank? -%>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, DigitalOcean images don't have an FQDN (from which this is set in attributes), so it's nil and there's not #empty?. Realized we probably shouldn't be using this method anyhow, so swapped it out.

If we really want something robust (I'm not sure it's an edgecase worth pandering to) then we could perhaps use #blank? from chef-sugar cookbook:
https://github.com/sethvargo/chef-sugar#core-extensions

I don't think that's worth it though -- a blank string shouldn't be set for any of these anyhow.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. Seems we are using blank strings for some of this stuff in attributes/default.rb... what are your thoughts here @linc01n? Using nil for unset things seems more sensible to me. Or we could mix-and-match approaches in this template, and just assume nil is the blank value for the virtual_host_* attrs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And just confirmed that chef-sugar would resolve this. That cookbook is pretty established and has lots of other things that wemight benefit from using, so perhaps we could add it?

https://github.com/sethvargo/chef-sugar/blob/bd65556f7c101d9fa8cd68d6a7ded2a1daf6525b/lib/chef/sugar/core_extensions/object.rb#L21

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding chef-sugar is ok i think.

ServerName <%= node['stash']['apache2']['virtual_host_name'] %>
<% end -%>
<% unless node['stash']['apache2']['virtual_host_alias'].empty? -%>
<% unless node['stash']['apache2']['virtual_host_alias'].blank? -%>
<% virtual_host_aliases = node['stash']['apache2']['virtual_host_alias'].kind_of?(Array) ? node['stash']['apache2']['virtual_host_alias'] : [ node['stash']['apache2']['virtual_host_alias'] ] -%>
<% virtual_host_aliases.each do |virtual_host_alias| -%>
ServerAlias <%= virtual_host_alias %>
<% end -%>
<% end -%>
DocumentRoot <%= node['stash']['install_path'] %>

CustomLog <%= node['stash']['apache2']['access_log'].empty? ? node['apache']['log_dir']+"/stash-access.log" : node['stash']['apache2']['access_log'] %> combined
ErrorLog <%= node['stash']['apache2']['error_log'].empty? ? node['apache']['log_dir']+"/stash-error.log" : node['stash']['apache2']['error_log'] %>
CustomLog <%= node['stash']['apache2']['access_log'].blank? ? node['apache']['log_dir']+"/stash-access.log" : node['stash']['apache2']['access_log'] %> combined
ErrorLog <%= node['stash']['apache2']['error_log'].blank? ? node['apache']['log_dir']+"/stash-error.log" : node['stash']['apache2']['error_log'] %>
LogLevel warn

<Proxy *>
Expand All @@ -31,19 +31,19 @@
</VirtualHost>

<VirtualHost *:<%= node['stash']['apache2']['ssl']['port'] %>>
<% unless node['stash']['apache2']['virtual_host_name'].empty? -%>
<% unless node['stash']['apache2']['virtual_host_name'].blank? -%>
ServerName <%= node['stash']['apache2']['virtual_host_name'] %>
<% end -%>
<% unless node['stash']['apache2']['virtual_host_alias'].empty? -%>
<% unless node['stash']['apache2']['virtual_host_alias'].blank? -%>
<% virtual_host_aliases = node['stash']['apache2']['virtual_host_alias'].kind_of?(Array) ? node['stash']['apache2']['virtual_host_alias'] : [ node['stash']['apache2']['virtual_host_alias'] ] -%>
<% virtual_host_aliases.each do |virtual_host_alias| -%>
ServerAlias <%= virtual_host_alias %>
<% end -%>
<% end -%>
DocumentRoot <%= node['stash']['install_path'] %>

CustomLog <%= node['stash']['apache2']['ssl']['access_log'].empty? ? node['apache']['log_dir']+"/stash-ssl-access.log" : node['stash']['apache2']['ssl']['access_log'] %> combined
ErrorLog <%= node['stash']['apache2']['ssl']['error_log'].empty? ? node['apache']['log_dir']+"/stash-ssl-error.log" : node['stash']['apache2']['ssl']['error_log'] %>
CustomLog <%= node['stash']['apache2']['ssl']['access_log'].blank? ? node['apache']['log_dir']+"/stash-ssl-access.log" : node['stash']['apache2']['ssl']['access_log'] %> combined
ErrorLog <%= node['stash']['apache2']['ssl']['error_log'].blank? ? node['apache']['log_dir']+"/stash-ssl-error.log" : node['stash']['apache2']['ssl']['error_log'] %>
LogLevel warn

<Proxy *>
Expand All @@ -60,7 +60,7 @@
SSLEngine on
SSLCertificateFile <%= node['stash']['apache2']['ssl']['certificate_file'] %>
SSLCertificateKeyFile <%= node['stash']['apache2']['ssl']['key_file'] %>
<% unless node['stash']['apache2']['ssl']['chain_file'].empty? -%>
<% unless node['stash']['apache2']['ssl']['chain_file'].blank? -%>
SSLCertificateChainFile <%= node['stash']['apache2']['ssl']['chain_file'] %>
<% end -%>
</VirtualHost>
Binary file added test/support/travis_id_rsa.key.enc
Binary file not shown.