furnish 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/lib/furnish/provisioner_group.rb +5 -0
- data/lib/furnish/provisioners/dummy.rb +2 -1
- data/lib/furnish/scheduler.rb +7 -1
- data/lib/furnish/version.rb +1 -1
- data/test/mt_cases.rb +28 -0
- data/test/test_dummy.rb +2 -2
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -65,6 +65,9 @@ module Furnish
|
|
65
65
|
# provisioning halts, effectively creating a chain of responsibility
|
66
66
|
# pattern.
|
67
67
|
#
|
68
|
+
# If a block is provided, will yield self to it for each step through the
|
69
|
+
# group.
|
70
|
+
#
|
68
71
|
def startup(*args)
|
69
72
|
each do |this_prov|
|
70
73
|
unless args = this_prov.startup(args)
|
@@ -74,6 +77,8 @@ module Furnish
|
|
74
77
|
|
75
78
|
raise "Could not provision #{this_prov.name} with provisioner #{this_prov.class.name}"
|
76
79
|
end
|
80
|
+
|
81
|
+
yield self if block_given?
|
77
82
|
end
|
78
83
|
|
79
84
|
return true
|
@@ -46,7 +46,7 @@ module Furnish
|
|
46
46
|
#
|
47
47
|
def report
|
48
48
|
do_delegate(__method__) do
|
49
|
-
[name]
|
49
|
+
[name, @persist]
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
@@ -54,6 +54,7 @@ module Furnish
|
|
54
54
|
# startup shim
|
55
55
|
#
|
56
56
|
def startup(*args)
|
57
|
+
@persist = "floop"
|
57
58
|
do_delegate(__method__) do
|
58
59
|
true
|
59
60
|
end
|
data/lib/furnish/scheduler.rb
CHANGED
@@ -338,7 +338,13 @@ module Furnish
|
|
338
338
|
|
339
339
|
# FIXME maybe a way to specify initial args?
|
340
340
|
args = nil
|
341
|
-
|
341
|
+
|
342
|
+
provisioner.startup do |this_prov|
|
343
|
+
vm.groups[group_name] = this_prov
|
344
|
+
end
|
345
|
+
|
346
|
+
vm.groups[group_name] = provisioner
|
347
|
+
|
342
348
|
@queue << group_name
|
343
349
|
end
|
344
350
|
|
data/lib/furnish/version.rb
CHANGED
data/test/mt_cases.rb
CHANGED
@@ -49,6 +49,34 @@ module Furnish
|
|
49
49
|
assert(provisioner.store[ [name, "shutdown"].join("-") ], "dummy provisioner for #{name} recorded the shutdown run")
|
50
50
|
end
|
51
51
|
|
52
|
+
def test_run_tracking
|
53
|
+
#--
|
54
|
+
# This is a tad convoluted. Dummy's startup method sets an ivar which
|
55
|
+
# should be persisted. Then, we retrieve it by examining the result of
|
56
|
+
# the report method, which regurgitates it.
|
57
|
+
#
|
58
|
+
# This ensures that after startup, the provisioner has had its state
|
59
|
+
# tracked, ensuring the correct state.
|
60
|
+
#++
|
61
|
+
|
62
|
+
assert(sched.schedule_provision('test1', Dummy.new))
|
63
|
+
sched.run
|
64
|
+
sched.wait_for('test1')
|
65
|
+
assert_started('test1')
|
66
|
+
assert_equal("floop", sched.vm.groups['test1'].first.report.last, 'state was stored after provision success')
|
67
|
+
|
68
|
+
assert(sched.schedule_provision('test2', [Dummy.new, StartFailDummy.new], []))
|
69
|
+
|
70
|
+
# the next few lines are an unfortunate necessity, sorry.
|
71
|
+
@monitor.kill rescue nil
|
72
|
+
assert_raises(RuntimeError) do
|
73
|
+
sched.run
|
74
|
+
sleep 0.1 while sched.running?
|
75
|
+
end
|
76
|
+
|
77
|
+
assert_equal("floop", sched.vm.groups['test2'].first.report.last, "provision failed but state is still stored for the provisions that succeeded")
|
78
|
+
end
|
79
|
+
|
52
80
|
def test_provision_cycle
|
53
81
|
machine_names = %w[blarg blarg2 blarg3]
|
54
82
|
|
data/test/test_dummy.rb
CHANGED
@@ -17,7 +17,7 @@ class TestDummy < Furnish::TestCase
|
|
17
17
|
dummy.name = 'dummy_test'
|
18
18
|
assert(dummy.startup, 'startup returns true by default')
|
19
19
|
assert(dummy.shutdown, 'shutdown returns true by default')
|
20
|
-
assert_equal(['dummy_test'], dummy.report, 'report returns boxed name by default')
|
20
|
+
assert_equal(['dummy_test', 'floop'], dummy.report, 'report returns boxed name and ivar by default')
|
21
21
|
|
22
22
|
obj = Palsy::Object.new('dummy')
|
23
23
|
%w[startup shutdown report].each do |meth|
|
@@ -75,7 +75,7 @@ class TestDummy < Furnish::TestCase
|
|
75
75
|
dummy.name = "dummy_marshal_test"
|
76
76
|
assert(dummy.startup)
|
77
77
|
assert(dummy.shutdown)
|
78
|
-
assert_equal([dummy.name], dummy.report)
|
78
|
+
assert_equal([dummy.name, 'floop'], dummy.report)
|
79
79
|
|
80
80
|
obj = Palsy::Object.new('dummy')
|
81
81
|
%w[startup shutdown report].each do |meth|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: furnish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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-03-
|
12
|
+
date: 2013-03-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: palsy
|