daptiv-chef-ci 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/daptiv-chef-ci.gemspec
CHANGED
@@ -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.
|
46
|
+
gem.version = '0.0.6'
|
47
47
|
|
48
48
|
gem.add_runtime_dependency "log4r", "~> 1.1.10"
|
49
49
|
gem.add_runtime_dependency "mixlib-shellout", "~> 1.2.0"
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'log4r'
|
2
|
+
require 'mixlib/shellout/exceptions'
|
2
3
|
require_relative 'shell'
|
3
4
|
|
4
5
|
module DaptivChefCI
|
@@ -12,24 +13,60 @@ module DaptivChefCI
|
|
12
13
|
@shell = shell
|
13
14
|
end
|
14
15
|
|
15
|
-
def destroy()
|
16
|
-
|
16
|
+
def destroy(opts={})
|
17
|
+
opts = {
|
18
|
+
:cmd_timeout_in_seconds => 180,
|
19
|
+
:retry_attempts => 2,
|
20
|
+
:retry_wait_in_seconds => 20
|
21
|
+
}.merge(opts)
|
22
|
+
exec_cmd_with_retry('vagrant destroy -f', opts)
|
17
23
|
end
|
18
24
|
|
19
|
-
def halt()
|
20
|
-
|
25
|
+
def halt(opts={})
|
26
|
+
opts = {
|
27
|
+
:cmd_timeout_in_seconds => 180,
|
28
|
+
:retry_attempts => 2,
|
29
|
+
:retry_wait_in_seconds => 20
|
30
|
+
}.merge(opts)
|
31
|
+
exec_cmd_with_retry('vagrant halt', opts)
|
21
32
|
end
|
22
33
|
|
23
|
-
def up(
|
24
|
-
|
34
|
+
def up(opts={})
|
35
|
+
opts = {
|
36
|
+
:cmd_timeout_in_seconds => 7200,
|
37
|
+
:retry_attempts => 0
|
38
|
+
}.merge(opts)
|
39
|
+
exec_cmd_with_retry('vagrant up', opts)
|
25
40
|
end
|
26
41
|
|
27
|
-
def provision(
|
28
|
-
|
42
|
+
def provision(opts={})
|
43
|
+
opts = {
|
44
|
+
:cmd_timeout_in_seconds => 7200,
|
45
|
+
:retry_attempts => 0
|
46
|
+
}.merge(opts)
|
47
|
+
exec_cmd_with_retry('vagrant provision', opts)
|
29
48
|
end
|
30
49
|
|
31
|
-
def reload()
|
32
|
-
|
50
|
+
def reload(opts={})
|
51
|
+
opts = {
|
52
|
+
:cmd_timeout_in_seconds => 180,
|
53
|
+
:retry_attempts => 0
|
54
|
+
}.merge(opts)
|
55
|
+
exec_cmd_with_retry('vagrant reload', opts)
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def exec_cmd_with_retry(cmd, opts)
|
62
|
+
attempt ||= 1
|
63
|
+
@shell.exec_cmd(cmd, opts[:cmd_timeout_in_seconds] || 600)
|
64
|
+
rescue Mixlib::ShellOut::ShellCommandFailed => e
|
65
|
+
@logger.warn("#{cmd} failed with error: #{e.message}")
|
66
|
+
raise if attempt > (opts[:retry_attempts] || 0)
|
67
|
+
attempt += 1
|
68
|
+
sleep(opts[:retry_wait_in_seconds] || 10)
|
69
|
+
retry
|
33
70
|
end
|
34
71
|
|
35
72
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'mocha/api'
|
2
|
+
require 'mixlib/shellout/exceptions'
|
2
3
|
require 'daptiv-chef-ci/vagrant_driver'
|
3
4
|
require 'daptiv-chef-ci/logger'
|
4
5
|
|
@@ -25,6 +26,18 @@ describe DaptivChefCI::VagrantDriver, :unit => true do
|
|
25
26
|
end
|
26
27
|
@vagrant.halt()
|
27
28
|
end
|
29
|
+
|
30
|
+
it 'should retry when exec fails' do
|
31
|
+
# 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
|
+
@vagrant.halt({ :retry_wait_in_seconds => 0 })
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should fail after retrying twice' do
|
37
|
+
# shell always fails, vagrant.halt should fail after a couple retries
|
38
|
+
@shell.stubs(:exec_cmd).raises(Mixlib::ShellOut::ShellCommandFailed, 'There was an error')
|
39
|
+
expect { @vagrant.halt({ :retry_wait_in_seconds => 0 }) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed)
|
40
|
+
end
|
28
41
|
end
|
29
42
|
|
30
43
|
describe 'up' do
|
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.
|
4
|
+
version: 0.0.6
|
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-
|
12
|
+
date: 2013-10-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: log4r
|
@@ -157,6 +157,7 @@ files:
|
|
157
157
|
- pkg/daptiv-chef-ci-0.0.2.gem
|
158
158
|
- pkg/daptiv-chef-ci-0.0.3.gem
|
159
159
|
- pkg/daptiv-chef-ci-0.0.4.gem
|
160
|
+
- pkg/daptiv-chef-ci-0.0.5.gem
|
160
161
|
- Rakefile
|
161
162
|
- README.md
|
162
163
|
- spec/daptiv-chef-ci/logger_spec.rb
|
@@ -178,7 +179,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
178
179
|
version: '0'
|
179
180
|
segments:
|
180
181
|
- 0
|
181
|
-
hash:
|
182
|
+
hash: -3011568715703408744
|
182
183
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
184
|
none: false
|
184
185
|
requirements:
|
@@ -187,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
187
188
|
version: '0'
|
188
189
|
segments:
|
189
190
|
- 0
|
190
|
-
hash:
|
191
|
+
hash: -3011568715703408744
|
191
192
|
requirements: []
|
192
193
|
rubyforge_project:
|
193
194
|
rubygems_version: 1.8.23
|