daptiv-chef-ci 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,7 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in my_gem.gemspec
4
4
  gemspec
5
-
6
- group :development do
7
- gem "mocha", :require => false
8
- end
data/Rakefile CHANGED
@@ -15,6 +15,12 @@ RSpec::Core::RakeTask.new do |task|
15
15
  task.rspec_opts << '-tunit'
16
16
  end
17
17
 
18
+ # Run the integration test suite
19
+ RSpec::Core::RakeTask.new(:integration) do |task|
20
+ task.pattern = "spec/**/*_spec.rb"
21
+ task.rspec_opts = [ '--color', '-f documentation' ]
22
+ end
23
+
18
24
  # Default task is to run tests
19
25
  task :default => "spec"
20
26
 
@@ -43,7 +43,7 @@ Gem::Specification.new do |gem|
43
43
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
44
44
  gem.name = "daptiv-chef-ci"
45
45
  gem.require_paths = ["lib"]
46
- gem.version = '0.0.6'
46
+ gem.version = '0.0.7'
47
47
 
48
48
  gem.add_runtime_dependency "log4r", "~> 1.1.10"
49
49
  gem.add_runtime_dependency "mixlib-shellout", "~> 1.2.0"
@@ -52,6 +52,4 @@ Gem::Specification.new do |gem|
52
52
  gem.add_development_dependency "rspec-core", "~> 2.12.2"
53
53
  gem.add_development_dependency "rspec-expectations", "~> 2.12.1"
54
54
  gem.add_development_dependency "rspec-mocks", "~> 2.12.1"
55
- gem.add_development_dependency "simplecov"
56
- gem.add_development_dependency "mocha", "~> 0.14.0"
57
55
  end
@@ -0,0 +1,19 @@
1
+ require 'log4r'
2
+ require_relative 'shell'
3
+ require_relative 'vmware_basebox_builder'
4
+ require_relative 'virtualbox_basebox_builder'
5
+
6
+ module DaptivChefCI
7
+
8
+ # Abstract factory to produce base box builder instances based off the specified provider
9
+ class BaseBoxBuilderFactory
10
+
11
+ # Creates a new base box builder instance
12
+ def create(shell, provider, base_dir)
13
+ provider == :vmware_fusion ?
14
+ DaptivChefCI::VMwareBaseBoxBuilder.new(base_dir) :
15
+ DaptivChefCI::VirtualBoxBaseBoxBuilder.new(base_dir, shell)
16
+ end
17
+
18
+ end
19
+ end
@@ -8,9 +8,13 @@ module DaptivChefCI
8
8
  # Constructs a new Vagrant management instance
9
9
  #
10
10
  # @param [Shell] The CLI
11
- def initialize(shell)
11
+ # @param [BaseBoxBuilderFactory] The base box builder factory instance
12
+ # @param [String] The name of the Vagrant virtualization provider: virtualbox, vmware_fusion
13
+ def initialize(shell, basebox_builder_factory, provider = :virtualbox)
12
14
  @logger = Log4r::Logger.new("daptiv_chef_ci::vagrant")
13
15
  @shell = shell
16
+ @basebox_builder_factory = basebox_builder_factory
17
+ @provider = provider
14
18
  end
15
19
 
16
20
  def destroy(opts={})
@@ -36,7 +40,9 @@ module DaptivChefCI
36
40
  :cmd_timeout_in_seconds => 7200,
37
41
  :retry_attempts => 0
38
42
  }.merge(opts)
39
- exec_cmd_with_retry('vagrant up', opts)
43
+ cmd = 'vagrant up'
44
+ cmd += ' --provider=' + @provider.to_s if @provider != :virtualbox
45
+ exec_cmd_with_retry(cmd, opts)
40
46
  end
41
47
 
42
48
  def provision(opts={})
@@ -55,6 +61,15 @@ module DaptivChefCI
55
61
  exec_cmd_with_retry('vagrant reload', opts)
56
62
  end
57
63
 
64
+ def package(opts={})
65
+ base_dir = opts[:base_dir] || Dir.pwd
66
+ box_name = opts[:box_name] || File.basename(base_dir)
67
+ box_name += '.box' unless box_name.end_with?('.box')
68
+
69
+ builder = @basebox_builder_factory.create(@shell, @provider, base_dir)
70
+ builder.build(box_name)
71
+ end
72
+
58
73
 
59
74
  private
60
75
 
@@ -2,6 +2,7 @@ require 'rake'
2
2
  require 'rake/tasklib'
3
3
  require_relative 'vagrant_driver'
4
4
  require_relative 'virtualbox_driver'
5
+ require_relative 'basebox_builder_factory'
5
6
  require_relative 'shell'
6
7
  require_relative 'logger'
7
8
 
@@ -15,14 +16,43 @@ DaptivChefCI::Logger.init()
15
16
 
16
17
  class Vagrant
17
18
 
19
+ # Example usage, creates a vmware base box:
20
+ #
21
+ # Vagrant::RakeTask.new 'vagrant_fusion' do |t|
22
+ # t.provider = :vmware_fusion
23
+ # t.create_box = true
24
+ # t.box_name = 'windows-server-vmwarefusion.box'
25
+ # t.up_timeout_in_seconds = 3600
26
+ # end
27
+ #
18
28
  # This class lets you define Rake tasks to drive Vagrant.
19
29
  class RakeTask < ::Rake::TaskLib
20
30
  include ::Rake::DSL if defined? ::Rake::DSL
21
31
 
32
+ attr_accessor :provider
33
+ attr_accessor :create_box
34
+ attr_accessor :vagrantfile_dir
35
+ attr_accessor :box_name
36
+ attr_accessor :up_timeout_in_seconds
37
+ attr_accessor :halt_timeout_in_seconds
38
+ attr_accessor :destroy_timeout_in_seconds
39
+ attr_accessor :destroy_retry_attempts
40
+ attr_accessor :halt_retry_attempts
41
+
22
42
  # @param [String] name The task name.
23
43
  # @param [String] desc Description of the task.
44
+ # @param [String] provider vagrant provider to use if other than the default virtualbox provider
24
45
  def initialize(name = 'vagrant', desc = 'Daptiv Vagrant Tasks')
25
46
  @name, @desc = name, desc
47
+ @provider = :virtualbox
48
+ @create_box = false
49
+ @vagrantfile_dir = Dir.pwd
50
+ @box_name = nil
51
+ @up_timeout_in_seconds = 7200
52
+ @halt_timeout_in_seconds = 180
53
+ @destroy_timeout_in_seconds = 180
54
+ @destroy_retry_attempts = 2
55
+ @halt_retry_attempts = 2
26
56
  yield self if block_given?
27
57
  define_task
28
58
  end
@@ -32,7 +62,9 @@ class Vagrant
32
62
  def define_task
33
63
  desc @desc
34
64
  task @name do
35
- vagrant = DaptivChefCI::VagrantDriver.new(DaptivChefCI::Shell.new())
65
+ shell = DaptivChefCI::Shell.new()
66
+ basebox_builder_factory = DaptivChefCI::BaseBoxBuilderFactory.new()
67
+ vagrant = DaptivChefCI::VagrantDriver.new(shell, basebox_builder_factory, @provider)
36
68
  execute_vagrant_run(vagrant)
37
69
  end
38
70
  end
@@ -44,7 +76,7 @@ class Vagrant
44
76
 
45
77
  def try_destroy_before_vagrant_up(vagrant)
46
78
  begin
47
- vagrant.destroy()
79
+ destroy(vagrant)
48
80
  rescue SystemExit => ex
49
81
  exit(ex.status)
50
82
  rescue Exception => ex
@@ -54,18 +86,36 @@ class Vagrant
54
86
 
55
87
  def try_vagrant_up(vagrant)
56
88
  begin
57
- vagrant.up()
89
+ up(vagrant)
90
+ halt(vagrant)
91
+ package(vagrant) if @create_box
58
92
  rescue SystemExit => ex
59
93
  exit(ex.status)
60
94
  rescue Exception => ex
61
95
  print_err(ex)
62
96
  exit(1)
63
97
  ensure
64
- vagrant.halt()
65
- vagrant.destroy()
98
+ halt(vagrant)
99
+ destroy(vagrant)
66
100
  end
67
101
  end
68
102
 
103
+ def up(vagrant)
104
+ vagrant.up({ :cmd_timeout_in_seconds => @up_timeout_in_seconds })
105
+ end
106
+
107
+ def package(vagrant)
108
+ vagrant.package({ :base_dir => @vagrantfile_dir, :box_name => @box_name })
109
+ end
110
+
111
+ def destroy(vagrant)
112
+ vagrant.destroy({ :cmd_timeout_in_seconds => @destroy_timeout_in_seconds, :retry_attempts => @destroy_retry_attempts })
113
+ end
114
+
115
+ def halt(vagrant)
116
+ vagrant.halt({ :cmd_timeout_in_seconds => @halt_timeout_in_seconds, :retry_attempts => @halt_retry_attempts })
117
+ end
118
+
69
119
  def print_err(ex)
70
120
  STDERR.puts("#{ex.message} (#{ex.class})")
71
121
  STDERR.puts(ex.backtrace.join("\n"))
@@ -0,0 +1,33 @@
1
+ require 'log4r'
2
+ require 'fileutils'
3
+ require_relative 'shell'
4
+
5
+ module DaptivChefCI
6
+
7
+ # This class builds VBox Vagrant boxes
8
+ class VirtualBoxBaseBoxBuilder
9
+
10
+ # Creates a new box builder instance
11
+ #
12
+ # @param [String] The full path to the directory where the Vagrantfile exists
13
+ # of the box we want to package, i.e. /Users/admin/src/dotnetframework
14
+ # @param [Shell] A shell instance
15
+ def initialize(base_dir, shell)
16
+ @shell = shell
17
+ @base_dir = base_dir
18
+ @logger = Log4r::Logger.new("daptiv_chef_ci::vmware_base_box_builder")
19
+ end
20
+
21
+ # Packages a VBox Vagrant box. This can take 15 minutes or so.
22
+ #
23
+ # @param [String] base box file name, i.e. 'windows-server-2008.box'
24
+ def build(box_file)
25
+ Dir.chdir(@base_dir) {
26
+ @logger.info("Packaging box #{box_file}")
27
+ FileUtils.rm(box_file) if File.exists?(box_file)
28
+ @shell.exec_cmd("vagrant package --output #{box_file}", 1800)
29
+ }
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,103 @@
1
+ require 'log4r'
2
+ require 'fileutils'
3
+ require_relative 'shell'
4
+
5
+ module DaptivChefCI
6
+
7
+ # This class builds VMware Fusion 6 Vagrant boxes on OS X
8
+ #
9
+ # NOTE - This class makes a lot of assumptions that hopefully won't break until
10
+ # after Vagrant natively supports packaging VMware Fusion boxes.
11
+ class VMwareBaseBoxBuilder
12
+
13
+ # Creates a new box builder instance
14
+ #
15
+ # @param [String] The full path to the directory where the Vagrantfile exists
16
+ # of the box we want to package, i.e. /Users/admin/src/dotnetframework
17
+ def initialize(base_dir)
18
+ @base_dir = base_dir
19
+ @logger = Log4r::Logger.new("daptiv_chef_ci::vmware_base_box_builder")
20
+ end
21
+
22
+ # Packages a VMware Fusion Vagrant box. This can take 15 minutes or so.
23
+ #
24
+ # @param [String] base box file name, i.e. 'windows-server-2008.box'
25
+ def build(box_file)
26
+ # /Users/admin/src/mybox/.vagrant/machines/default/vmware_fusion/0f721388-a327-4ba3-b203-c09f69016b43/
27
+ box_root_path = "#{@base_dir}/.vagrant/machines/default/vmware_fusion"
28
+
29
+ sub_dir = Dir["#{box_root_path}/*/"]
30
+ .map { |d| File.basename(d) }
31
+ .find { |d| d =~ /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ }
32
+
33
+ box_path = "#{box_root_path}/#{sub_dir}"
34
+ @logger.debug("box_path: #{box_path}")
35
+
36
+ build_box(box_path, box_file)
37
+ end
38
+
39
+
40
+ protected
41
+
42
+ def build_box(box_path, box_file)
43
+ tar_list_path = "#{box_path}/boxfilelist.txt"
44
+ completed_box_path = "#{@base_dir}/#{box_file}"
45
+
46
+ @logger.debug("tar_list_path: #{tar_list_path}")
47
+ @logger.debug("completed_box_path: #{completed_box_path}")
48
+
49
+ Dir.chdir(box_path) {
50
+ vmdk_file = File.expand_path(Dir.glob("*.vmdk").first())
51
+
52
+ args = [vdiskmanager_path]
53
+ args << '-d'
54
+ args << vmdk_file
55
+ @logger.info("Defragging #{vmdk_file}")
56
+ system(*args)
57
+
58
+ args = [vdiskmanager_path]
59
+ args << '-k'
60
+ args << vmdk_file
61
+ @logger.info("Shrinking #{vmdk_file}")
62
+ system(*args)
63
+
64
+ create_json_manifest(box_path)
65
+ create_tar_manifest(tar_list_path)
66
+
67
+ @logger.info("Packaging box #{box_file}")
68
+ tar_cmd = "tar -czvf #{box_file} -T #{tar_list_path}"
69
+ %x[#{tar_cmd}]
70
+ FileUtils.rm(completed_box_path) if File.exists?(completed_box_path)
71
+ FileUtils.mv(box_file, completed_box_path)
72
+ }
73
+
74
+ @logger.info("Done creating box #{completed_box_path}")
75
+ end
76
+
77
+ def create_tar_manifest(tar_list_path)
78
+ @logger.debug("Creating manifest #{tar_list_path}")
79
+
80
+ files = Dir.glob("*.{vmdk,nvram,plist,vmsd,vmx,vmxf,json}").join("\n")
81
+ @logger.debug("Found the following files to pack: #{files}")
82
+
83
+ FileUtils.rm(tar_list_path) if File.exists?(tar_list_path)
84
+ IO.write(tar_list_path, files)
85
+ end
86
+
87
+ def create_json_manifest(box_path)
88
+ json_manifest_path = File.join(box_path, "metadata.json")
89
+ FileUtils.rm(json_manifest_path) if File.exists?(json_manifest_path)
90
+ manifest = <<-EOH
91
+ {
92
+ "provider":"vmware_fusion"
93
+ }
94
+ EOH
95
+ IO.write(json_manifest_path, manifest)
96
+ end
97
+
98
+ def vdiskmanager_path
99
+ '/Applications/VMware Fusion.app/Contents/Library/vmware-vdiskmanager'
100
+ end
101
+
102
+ end
103
+ end
@@ -0,0 +1,25 @@
1
+ require 'daptiv-chef-ci/basebox_builder_factory'
2
+ require 'daptiv-chef-ci/virtualbox_basebox_builder'
3
+ require 'daptiv-chef-ci/vmware_basebox_builder'
4
+
5
+ describe DaptivChefCI::BaseBoxBuilderFactory, :unit => true do
6
+
7
+ before(:each) do
8
+ @shell = stub()
9
+ @factory = DaptivChefCI::BaseBoxBuilderFactory.new()
10
+ end
11
+
12
+ describe 'create' do
13
+
14
+ it 'should create VMware builder when provider is vmware_fusion' do
15
+ builder = @factory.create(@shell, :vmware_fusion, Dir.pwd)
16
+ expect(builder).to be_an_instance_of(DaptivChefCI::VMwareBaseBoxBuilder)
17
+ end
18
+
19
+ it 'should create VMware builder when provider is virtualbox' do
20
+ builder = @factory.create(@shell, :virtualbox, Dir.pwd)
21
+ expect(builder).to be_an_instance_of(DaptivChefCI::VirtualBoxBaseBoxBuilder)
22
+ end
23
+
24
+ end
25
+ end
@@ -1,4 +1,3 @@
1
- require 'mocha/api'
2
1
  require 'daptiv-chef-ci/logger'
3
2
  require 'log4r'
4
3
 
@@ -1,4 +1,3 @@
1
- require 'mocha/api'
2
1
  require 'daptiv-chef-ci/virtualbox_driver'
3
2
  require 'daptiv-chef-ci/logger'
4
3
  require 'mixlib/shellout/exceptions'
@@ -1,4 +1,3 @@
1
- require 'mocha/api'
2
1
  require 'mixlib/shellout/exceptions'
3
2
  require 'daptiv-chef-ci/vagrant_driver'
4
3
  require 'daptiv-chef-ci/logger'
@@ -7,64 +6,97 @@ describe DaptivChefCI::VagrantDriver, :unit => true do
7
6
 
8
7
  before(:each) do
9
8
  @shell = mock()
10
- @vagrant = DaptivChefCI::VagrantDriver.new(@shell)
9
+ @basebox_builder_factory = stub()
10
+ @vagrant = DaptivChefCI::VagrantDriver.new(@shell, @basebox_builder_factory)
11
11
  end
12
12
 
13
13
  describe 'destroy' do
14
- it 'should force shutdown vagrant' do
15
- @shell.expects(:exec_cmd).with do |cmd|
16
- expect(cmd).to eq('vagrant destroy -f')
17
- end
14
+ it 'should force shutdown vagrant with a timeout of 180 seconds' do
15
+ @shell.should_receive(:exec_cmd).with('vagrant destroy -f', 180)
18
16
  @vagrant.destroy()
19
17
  end
20
18
  end
21
19
 
22
20
  describe 'halt' do
23
- it 'should halt vagrant' do
24
- @shell.expects(:exec_cmd).with do |cmd|
25
- expect(cmd).to eq('vagrant halt')
26
- end
21
+ it 'should halt vagrant with a timeout of 180 seconds' do
22
+ @shell.should_receive(:exec_cmd).with('vagrant halt', 180)
27
23
  @vagrant.halt()
28
24
  end
29
25
 
30
26
  it 'should retry when exec fails' do
27
+ @shell.should_receive(:exec_cmd).and_raise(Mixlib::ShellOut::ShellCommandFailed)
28
+ @shell.should_receive(:exec_cmd).and_return('success')
31
29
  # shell cmd fails then succeeds, the vagrant.halt should succeed overall
32
- @shell.stubs(:exec_cmd).raises(Mixlib::ShellOut::ShellCommandFailed, 'There was an error').then.returns('success')
33
30
  @vagrant.halt({ :retry_wait_in_seconds => 0 })
34
31
  end
35
32
 
36
33
  it 'should fail after retrying twice' do
37
34
  # shell always fails, vagrant.halt should fail after a couple retries
38
- @shell.stubs(:exec_cmd).raises(Mixlib::ShellOut::ShellCommandFailed, 'There was an error')
35
+ @shell.should_receive(:exec_cmd).exactly(3).times.and_raise(Mixlib::ShellOut::ShellCommandFailed)
39
36
  expect { @vagrant.halt({ :retry_wait_in_seconds => 0 }) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
40
37
  end
41
38
  end
42
39
 
43
40
  describe 'up' do
44
- it 'should up vagrant' do
45
- @shell.expects(:exec_cmd).with do |cmd|
46
- expect(cmd).to eq('vagrant up')
47
- end
41
+ it 'should up vagrant with a timeout of 7200 seconds' do
42
+ @shell.should_receive(:exec_cmd).with('vagrant up', 7200)
43
+ @vagrant.up()
44
+ end
45
+
46
+ it 'should up vagrant and specify the provider if not virtualbox' do
47
+ @vagrant = DaptivChefCI::VagrantDriver.new(@shell, @basebox_builder_factory, :my_custom_provider)
48
+ @shell.should_receive(:exec_cmd).with('vagrant up --provider=my_custom_provider', 7200)
48
49
  @vagrant.up()
49
50
  end
50
51
  end
51
-
52
+
52
53
  describe 'provision' do
53
- it 'should provision vagrant' do
54
- @shell.expects(:exec_cmd).with do |cmd|
55
- expect(cmd).to eq('vagrant provision')
56
- end
54
+ it 'should provision vagrant with a timeout of 7200 seconds' do
55
+ @shell.should_receive(:exec_cmd).with('vagrant provision', 7200)
57
56
  @vagrant.provision()
58
57
  end
59
58
  end
60
59
 
61
60
  describe 'reload' do
62
- it 'should reload vagrant' do
63
- @shell.expects(:exec_cmd).with do |cmd|
64
- expect(cmd).to eq('vagrant reload')
65
- end
61
+ it 'should reload vagrant with a timeout of 180 seconds' do
62
+ @shell.should_receive(:exec_cmd).with('vagrant reload', 180)
66
63
  @vagrant.reload()
67
64
  end
68
65
  end
69
66
 
67
+ describe 'package' do
68
+ it 'should default to virtualbox and base_dir to current working dir' do
69
+ builder = double('builder').as_null_object
70
+ @basebox_builder_factory.should_receive(:create).with(@shell, :virtualbox, Dir.pwd).and_return(builder)
71
+ @vagrant.package()
72
+ end
73
+
74
+ it 'should use the specified provider' do
75
+ builder = double('builder').as_null_object
76
+ @vagrant = DaptivChefCI::VagrantDriver.new(@shell, @basebox_builder_factory, :vmware_fusion)
77
+ @basebox_builder_factory.should_receive(:create).with(@shell, :vmware_fusion, Dir.pwd).and_return(builder)
78
+ @vagrant.package()
79
+ end
80
+
81
+ it 'should use the specified base_dir' do
82
+ builder = double('builder').as_null_object
83
+ @basebox_builder_factory.should_receive(:create).with(@shell, :virtualbox, '/Users/admin/mybox').and_return(builder)
84
+ @vagrant.package({ :base_dir => '/Users/admin/mybox' })
85
+ end
86
+
87
+ it 'should default box_name to directory name' do
88
+ builder = mock('builder')
89
+ builder.should_receive(:build).with('mybox.box')
90
+ @basebox_builder_factory.stub(:create).and_return(builder)
91
+ @vagrant.package({ :base_dir => '/Users/admin/mybox' })
92
+ end
93
+
94
+ it 'should ensure box name ends with .box' do
95
+ builder = mock('builder')
96
+ builder.should_receive(:build).with('mybox.box')
97
+ @basebox_builder_factory.stub(:create).and_return(builder)
98
+ @vagrant.package({ :box_name => 'mybox' })
99
+ end
100
+ end
101
+
70
102
  end
@@ -0,0 +1,20 @@
1
+ require 'daptiv-chef-ci/virtualbox_basebox_builder'
2
+ require 'daptiv-chef-ci/logger'
3
+
4
+ describe DaptivChefCI::VirtualBoxBaseBoxBuilder, :integration => true do
5
+
6
+ #Note- This test requires you have
7
+ # 1. the dotnetframework cookbook cloned to ~/src/dotnetframework
8
+ # 2. From ~/src/dotnetframework previously ran: vagrant up
9
+ # 3. vagrant halt
10
+
11
+ describe 'build' do
12
+ it 'should build a VBox Vagrant base box' do
13
+ base_dir = "#{ENV['HOME']}/src/dotnetframework"
14
+ builder = DaptivChefCI::VirtualBoxBaseBoxBuilder.new(base_dir, DaptivChefCI::Shell.new())
15
+ builder.build('dotnettest-vbox.box')
16
+ expect(File.exists?("#{base_dir}/dotnettest-vbox.box"))
17
+ end
18
+ end
19
+
20
+ end
@@ -1,4 +1,3 @@
1
- require 'mocha/api'
2
1
  require 'daptiv-chef-ci/virtualbox_driver'
3
2
  require 'daptiv-chef-ci/logger'
4
3
 
@@ -14,16 +13,16 @@ describe DaptivChefCI::VirtualBoxDriver, :unit => true do
14
13
  @shell = mock()
15
14
  @vbox = DaptivChefCI::VirtualBoxDriver.new(@shell)
16
15
 
17
- @shell.expects(:exec_cmd).with('vboxmanage list runningvms').returns(boxes)
16
+ @shell.should_receive(:exec_cmd).with('vboxmanage list runningvms').and_return(boxes)
18
17
 
19
- @shell.expects(:exec_cmd).with('vboxmanage controlvm "aspnet_1372120179" poweroff').once()
20
- @shell.expects(:exec_cmd).with('vboxmanage unregistervm "aspnet_1372120179"').once()
18
+ @shell.should_receive(:exec_cmd).with('vboxmanage controlvm "aspnet_1372120179" poweroff').once()
19
+ @shell.should_receive(:exec_cmd).with('vboxmanage unregistervm "aspnet_1372120179"').once()
21
20
 
22
- @shell.expects(:exec_cmd).with('vboxmanage controlvm "aspnet_1379346156" poweroff').once()
23
- @shell.expects(:exec_cmd).with('vboxmanage unregistervm "aspnet_1379346156"').once()
21
+ @shell.should_receive(:exec_cmd).with('vboxmanage controlvm "aspnet_1379346156" poweroff').once()
22
+ @shell.should_receive(:exec_cmd).with('vboxmanage unregistervm "aspnet_1379346156"').once()
24
23
 
25
- @shell.expects(:exec_cmd).with('vboxmanage controlvm "python_1372120178" poweroff').never()
26
- @shell.expects(:exec_cmd).with('vboxmanage unregistervm "python_1372120178"').never()
24
+ @shell.should_receive(:exec_cmd).with('vboxmanage controlvm "python_1372120178" poweroff').never()
25
+ @shell.should_receive(:exec_cmd).with('vboxmanage unregistervm "python_1372120178"').never()
27
26
 
28
27
  @vbox.cleanup_vms('aspnet')
29
28
  end
@@ -0,0 +1,20 @@
1
+ require 'daptiv-chef-ci/vmware_basebox_builder'
2
+ require 'daptiv-chef-ci/logger'
3
+
4
+ describe DaptivChefCI::VMwareBaseBoxBuilder, :integration => true do
5
+
6
+ #Note- This test requires you have
7
+ # 1. the dotnetframework cookbook cloned to ~/src/dotnetframework
8
+ # 2. From ~/src/dotnetframework previously ran: vagrant up --provider vmware_fusion
9
+ # 3. vagrant halt
10
+
11
+ describe 'build' do
12
+ it 'should build a VMware Vagrant base box' do
13
+ base_dir = "#{ENV['HOME']}/src/dotnetframework"
14
+ builder = DaptivChefCI::VMwareBaseBoxBuilder.new(base_dir)
15
+ builder.build('dotnettest-vmware.box')
16
+ expect(File.exists?("#{base_dir}/dotnettest-vmware.box"))
17
+ end
18
+ end
19
+
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daptiv-chef-ci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-27 00:00:00.000000000 Z
12
+ date: 2013-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: log4r
@@ -107,38 +107,6 @@ dependencies:
107
107
  - - ~>
108
108
  - !ruby/object:Gem::Version
109
109
  version: 2.12.1
110
- - !ruby/object:Gem::Dependency
111
- name: simplecov
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ! '>='
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
- requirements:
123
- - - ! '>='
124
- - !ruby/object:Gem::Version
125
- version: '0'
126
- - !ruby/object:Gem::Dependency
127
- name: mocha
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ~>
132
- - !ruby/object:Gem::Version
133
- version: 0.14.0
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
- requirements:
139
- - - ~>
140
- - !ruby/object:Gem::Version
141
- version: 0.14.0
142
110
  description: Vagrant automation for CI
143
111
  email:
144
112
  - sneal@daptiv.com
@@ -148,22 +116,29 @@ extra_rdoc_files: []
148
116
  files:
149
117
  - daptiv-chef-ci.gemspec
150
118
  - Gemfile
119
+ - lib/daptiv-chef-ci/basebox_builder_factory.rb
151
120
  - lib/daptiv-chef-ci/logger.rb
152
121
  - lib/daptiv-chef-ci/shell.rb
153
122
  - lib/daptiv-chef-ci/vagrant_driver.rb
154
123
  - lib/daptiv-chef-ci/vagrant_task.rb
124
+ - lib/daptiv-chef-ci/virtualbox_basebox_builder.rb
155
125
  - lib/daptiv-chef-ci/virtualbox_driver.rb
126
+ - lib/daptiv-chef-ci/vmware_basebox_builder.rb
156
127
  - pkg/daptiv-chef-ci-0.0.1.gem
157
128
  - pkg/daptiv-chef-ci-0.0.2.gem
158
129
  - pkg/daptiv-chef-ci-0.0.3.gem
159
130
  - pkg/daptiv-chef-ci-0.0.4.gem
160
131
  - pkg/daptiv-chef-ci-0.0.5.gem
132
+ - pkg/daptiv-chef-ci-0.0.6.gem
161
133
  - Rakefile
162
134
  - README.md
135
+ - spec/daptiv-chef-ci/basebox_builder_factory_spec.rb
163
136
  - spec/daptiv-chef-ci/logger_spec.rb
164
137
  - spec/daptiv-chef-ci/shell_spec.rb
165
138
  - spec/daptiv-chef-ci/vagrant_driver_spec.rb
139
+ - spec/daptiv-chef-ci/virtualbox_basebox_builder_spec.rb
166
140
  - spec/daptiv-chef-ci/virtualbox_driver_spec.rb
141
+ - spec/daptiv-chef-ci/vmware_basebox_builder_spec.rb
167
142
  - .gitignore
168
143
  homepage: ''
169
144
  licenses: []
@@ -179,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
154
  version: '0'
180
155
  segments:
181
156
  - 0
182
- hash: -3011568715703408744
157
+ hash: -97595725804922558
183
158
  required_rubygems_version: !ruby/object:Gem::Requirement
184
159
  none: false
185
160
  requirements:
@@ -188,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
188
163
  version: '0'
189
164
  segments:
190
165
  - 0
191
- hash: -3011568715703408744
166
+ hash: -97595725804922558
192
167
  requirements: []
193
168
  rubyforge_project:
194
169
  rubygems_version: 1.8.23
@@ -196,7 +171,10 @@ signing_key:
196
171
  specification_version: 3
197
172
  summary: A small gem to reduce Rake duplication
198
173
  test_files:
174
+ - spec/daptiv-chef-ci/basebox_builder_factory_spec.rb
199
175
  - spec/daptiv-chef-ci/logger_spec.rb
200
176
  - spec/daptiv-chef-ci/shell_spec.rb
201
177
  - spec/daptiv-chef-ci/vagrant_driver_spec.rb
178
+ - spec/daptiv-chef-ci/virtualbox_basebox_builder_spec.rb
202
179
  - spec/daptiv-chef-ci/virtualbox_driver_spec.rb
180
+ - spec/daptiv-chef-ci/vmware_basebox_builder_spec.rb