Commit e4568fdb authored by Christopher Huhn's avatar Christopher Huhn
Browse files

Add test suite

parent dd36d724
---
driver:
name: vagrant
box_check_update: true
customize:
cpus: 1
memory: 1024
box_check_update: true
provisioner:
require_chef_omnibus: false
install_strategy: skip
log_level: warn
#name: chef-solo
#chef_solo_path: /usr/bin/chef-solo
name: chef_zero
require_chef_omnibus: 12
chef_client_path: /usr/bin/chef-client
data_bags_path: test/integration/data_bags
verifier:
name: busser
ruby_bindir: /usr/bin
platforms:
- name: stretch64
driver:
box: debian/stretch64
provider: libvirt
provision: true
vagrantfiles:
- vagrant.rb
suites:
- name: fai
data_bags_path: test/integration/data_bags
run_list:
run_list:
- recipe[fai]
- recipe[fai::flavors]
attributes:
fai:
flavors:
default:
codename: stretch
arch: amd64
stretch-amd64-createmenot:
config_only: true
begin
require 'rubocop/rake_task'
RuboCop::RakeTask.new do |task|
task.options = ['--lint']
end
rescue LoadError
desc 'rubocop rake task not available'
task :rubocop do
abort 'Rubocop rake task is not available. Be sure to install rubocop'
end
end
begin
require 'foodcritic'
FoodCritic::Rake::LintTask.new do |task|
task.options = {
:exclude_paths => ['example_config/**/*']
}
end
rescue LoadError
desc 'foodcritic rake task not available'
task :foodcritic do
abort 'Foodcritic rake task is not available. Be sure to install foodcritic'
end
end
begin
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:chefspec) do |task|
task.pattern = 'test/unit/**/*_spec.rb'
task.rspec_opts = '--backtrace --color --format documentation --require spec_helper --default-path test/unit'
end
rescue LoadError
desc 'chefspec rake task not available'
task :chefspec do
abort 'Chefspec rake task is not available. Be sure to install chefspec'
end
end
begin
require 'kitchen/rake_tasks'
Kitchen::RakeTasks.new do
Kitchen.logger = Kitchen.default_logger
end
rescue LoadError
desc 'kitchen rake task not available'
task :kitchen do
abort 'kitchen rake task is not available. Be sure to install test-kitchen'
end
end
begin
require 'yard'
YARD::Config.load_plugin 'chef'
YARD::Rake::YardocTask.new do |t|
t.files = ['**/*.rb']
t.options = ['--debug']
end
rescue LoadError
desc 'yard rake task not available'
task :yard do
abort 'yard rake task is not available. Be sure to install yard and yard-chef'
end
end
task default: %w[rubocop foodcritic chefspec kitchen:all]
require 'spec_helper'
# should be created
describe file('/etc/fai/flavors/default/') do
it { should exist }
it { should be_directory }
end
# should be created
describe file('/srv/fai/nfsroot-default/') do
it { should exist }
it { should be_directory }
end
# should be created
describe file('/etc/fai/flavors/stretch-amd64-createmenot/') do
it { should exist }
it { should be_directory }
end
# should not be created
describe file('/srv/fai/nfsroot-stretch-amd64-createmenot/') do
it { should_not exist }
end
require 'serverspec'
set :backend, :exec
require 'chefspec'
ChefSpec::Coverage.start!
RSpec.configure do |config|
# Specify the path for Chef Solo to find cookbooks (default: [inferred from
# the location of the calling spec file])
config.cookbook_path = File.expand_path("#{File.dirname(__FILE__)}/../../../")
# Specify the path for Chef Solo to find roles (default: [ascending search])
#config.role_path = '/var/roles'
# Specify the Chef log_level (default: :warn)
#config.log_level = :debug
# Specify the path to a local JSON file with Ohai data (default: nil)
#config.path = 'ohai.json'
# Specify the operating platform to mock Ohai data from (default: nil)
config.platform = 'debian'
# Specify the operating version to mock Ohai data from (default: nil)
config.version = '9.2'
end
Vagrant.configure(2) do |config|
# install the Debian-provided Chef package
config.vm.provision "shell", inline: <<-SHELL
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install chef
SHELL
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment