Rakefile in itamae-1.9.11 vs Rakefile in itamae-1.9.12
- old
+ new
@@ -1,46 +1,36 @@
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
require 'tempfile'
require 'net/ssh'
-vagrant_bin = 'vagrant'
-
desc 'Run unit and integration specs.'
task :spec => ['spec:unit', 'spec:integration:all']
namespace :spec do
RSpec::Core::RakeTask.new("unit") do |task|
task.ruby_opts = '-I ./spec/unit'
task.pattern = "./spec/unit{,/*/**}/*_spec.rb"
end
namespace :integration do
- targets = []
- status = `cd spec/integration && #{vagrant_bin} status`
- unless $?.exitstatus == 0
- raise "vagrant status failed.\n#{status}"
- end
+ targets = ["ubuntu:trusty"]
- status.split("\n\n")[1].each_line do |line|
- targets << line.match(/^[^ ]+/)[0]
- end
-
task :all => targets
targets.each do |target|
desc "Run provision and specs to #{target}"
- task target => ["provision:#{target}", "serverspec:#{target}"]
+ task target => ["docker:#{target}", "provision:#{target}", "serverspec:#{target}"]
- namespace :provision do
+ namespace :docker do
task target do
- config = Tempfile.new('', Dir.tmpdir)
- env = {"VAGRANT_CWD" => File.expand_path('./spec/integration')}
- system env, "#{vagrant_bin} up #{target}"
- system env, "#{vagrant_bin} ssh-config #{target} > #{config.path}"
- options = Net::SSH::Config.for(target, [config.path])
+ sh "docker run --privileged -d --name itamae #{target} /sbin/init"
+ end
+ end
+ namespace :provision do
+ task target do
suites = [
[
"spec/integration/recipes/default.rb",
"spec/integration/recipes/default2.rb",
"spec/integration/recipes/redefine.rb",
@@ -49,17 +39,15 @@
"--dry-run",
"spec/integration/recipes/dry_run.rb",
],
]
suites.each do |suite|
- cmd = %w!bundle exec bin/itamae ssh!
- cmd << "-h" << options[:host_name]
- cmd << "-u" << options[:user]
- cmd << "-p" << options[:port].to_s
- cmd << "-i" << options[:keys].first
+ cmd = %w!bundle exec bin/itamae docker!
cmd << "-l" << (ENV['LOG_LEVEL'] || 'debug')
cmd << "-j" << "spec/integration/recipes/node.json"
+ cmd << "--container" << "itamae"
+ cmd << "--tag" << "itamae:latest"
cmd += suite
p cmd
unless system(*cmd)
raise "#{cmd} failed"
@@ -69,10 +57,10 @@
end
namespace :serverspec do
desc "Run serverspec tests to #{target}"
RSpec::Core::RakeTask.new(target.to_sym) do |t|
- ENV['TARGET_HOST'] = target
+ ENV['DOCKER_CONTAINER'] = "itamae"
t.ruby_opts = '-I ./spec/integration'
t.pattern = "spec/integration/*_spec.rb"
end
end
end