furnish 0.0.1 → 0.0.2
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/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/furnish/test.rb +99 -0
- data/lib/furnish/version.rb +1 -1
- data/test/mt_cases.rb +2 -38
- data/test/test_scheduler_serial.rb +1 -1
- data/test/test_scheduler_threaded.rb +1 -1
- metadata +4 -8
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -41,7 +41,7 @@ Or install it yourself as:
|
|
41
41
|
```ruby
|
42
42
|
Furnish.init("state.db")
|
43
43
|
# set a logger if you want -- See Furnish::Logger for more info
|
44
|
-
Furnish.logger = File.open('log', 'w')
|
44
|
+
Furnish.logger = Furnish::Logger.new(File.open('log', 'w'))
|
45
45
|
# start a scheduler and start spinning
|
46
46
|
scheduler = Furnish::Scheduler.new
|
47
47
|
scheduler.run # returns immediately
|
data/lib/furnish/test.rb
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'minitest/unit'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'furnish'
|
4
|
+
|
5
|
+
module Furnish
|
6
|
+
#
|
7
|
+
# Furnish::TestCase is a test harness for testing things with furnish, like
|
8
|
+
# provisioner libraries. It is intended to be consumed by other libraries.
|
9
|
+
#
|
10
|
+
# There are few others, such as SchedulerTestCase and
|
11
|
+
# RunningSchedulerTestCase which are tuned to specific scenarios, but inherit
|
12
|
+
# from this class.
|
13
|
+
#
|
14
|
+
# The basic case initializes furnish and the logger in a safe way in setup,
|
15
|
+
# and cleans up in teardown.
|
16
|
+
#
|
17
|
+
class TestCase < MiniTest::Unit::TestCase
|
18
|
+
def setup # :nodoc:
|
19
|
+
@tempfiles ||= []
|
20
|
+
file = Tempfile.new('furnish_db')
|
21
|
+
@tempfiles.push(file)
|
22
|
+
logfile = Tempfile.new('furnish_log')
|
23
|
+
@tempfiles.push(logfile)
|
24
|
+
Furnish.logger = Furnish::Logger.new(logfile, 3)
|
25
|
+
Furnish.init(file.path)
|
26
|
+
return file
|
27
|
+
end
|
28
|
+
|
29
|
+
def teardown # :nodoc:
|
30
|
+
Furnish.logger.close
|
31
|
+
Furnish.shutdown
|
32
|
+
@tempfiles.each do |file|
|
33
|
+
file.unlink
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# SchedulerTestCase inherits from Furnish::TestCase and configures a threaded
|
40
|
+
# scheduler, but does not attempt to start it. It's intended to be a
|
41
|
+
# primitive for cases where you might create a number of schedulers.
|
42
|
+
#
|
43
|
+
# If the scheduler throws an exception for any reason, the test suite will
|
44
|
+
# abort.
|
45
|
+
#
|
46
|
+
# RunningSchedulerTestCase deals with managing a running scheduler for you.
|
47
|
+
#
|
48
|
+
class SchedulerTestCase < TestCase
|
49
|
+
##
|
50
|
+
# Furnish::Scheduler object.
|
51
|
+
attr_reader :sched
|
52
|
+
|
53
|
+
def setup # :nodoc:
|
54
|
+
super
|
55
|
+
@sched = Furnish::Scheduler.new
|
56
|
+
@monitor = Thread.new { loop { @sched.running?; sleep 1 } }
|
57
|
+
@monitor.abort_on_exception = true
|
58
|
+
end
|
59
|
+
|
60
|
+
def teardown # :nodoc:
|
61
|
+
@monitor.kill rescue nil
|
62
|
+
super
|
63
|
+
end
|
64
|
+
|
65
|
+
##
|
66
|
+
#
|
67
|
+
# Assert the named group is solved, as far as the scheduler's concerned.
|
68
|
+
#
|
69
|
+
def assert_solved(name)
|
70
|
+
assert_includes(sched.vm.solved, name, "#{name} is solved in the scheduler")
|
71
|
+
end
|
72
|
+
|
73
|
+
##
|
74
|
+
#
|
75
|
+
# Refute the named group is solved, as far as the scheduler's concerned.
|
76
|
+
#
|
77
|
+
def refute_solved(name)
|
78
|
+
refute_includes(sched.vm.solved, name, "#{name} is solved in the scheduler")
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
#
|
84
|
+
# Inherits from SchedulerTestCase and manages a running scheduler in
|
85
|
+
# conjunction with all the other features.
|
86
|
+
#
|
87
|
+
class RunningSchedulerTestCase < SchedulerTestCase
|
88
|
+
def setup # :nodoc:
|
89
|
+
super
|
90
|
+
@sched.run
|
91
|
+
end
|
92
|
+
|
93
|
+
def teardown # :nodoc:
|
94
|
+
@sched.stop
|
95
|
+
sleep 0.3 while @sched.running?
|
96
|
+
super
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/furnish/version.rb
CHANGED
data/test/mt_cases.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'furnish/provisioners/dummy'
|
2
|
+
require 'furnish/test'
|
2
3
|
|
3
4
|
Dummy = Furnish::Provisioner::Dummy unless defined? Dummy
|
4
5
|
|
@@ -31,44 +32,7 @@ class StopExceptionDummy < Dummy
|
|
31
32
|
end
|
32
33
|
|
33
34
|
module Furnish
|
34
|
-
class
|
35
|
-
def setup
|
36
|
-
@tempfiles ||= []
|
37
|
-
file = Tempfile.new('furnish_db')
|
38
|
-
@tempfiles.push(file)
|
39
|
-
logfile = Tempfile.new('furnish_log')
|
40
|
-
@tempfiles.push(logfile)
|
41
|
-
Furnish.logger = Furnish::Logger.new(logfile, 3)
|
42
|
-
Furnish.init(file.path)
|
43
|
-
return file
|
44
|
-
end
|
45
|
-
|
46
|
-
def teardown
|
47
|
-
Furnish.logger.close
|
48
|
-
Furnish.shutdown
|
49
|
-
@tempfiles.each do |file|
|
50
|
-
file.unlink
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
class SchedulerTestCase < TestCase
|
56
|
-
attr_reader :sched
|
57
|
-
|
58
|
-
def setup
|
59
|
-
super
|
60
|
-
@sched = Furnish::Scheduler.new
|
61
|
-
@monitor = Thread.new { loop { @sched.running?; sleep 1 } }
|
62
|
-
@monitor.abort_on_exception = true
|
63
|
-
end
|
64
|
-
|
65
|
-
def teardown
|
66
|
-
@monitor.kill rescue nil
|
67
|
-
super
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
class RunningSchedulerTestCase < SchedulerTestCase
|
35
|
+
class RestartingSchedulerTestCase < SchedulerTestCase
|
72
36
|
def teardown
|
73
37
|
sched.stop
|
74
38
|
super
|
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.2
|
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-
|
12
|
+
date: 2013-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: palsy
|
@@ -147,6 +147,7 @@ extensions: []
|
|
147
147
|
extra_rdoc_files: []
|
148
148
|
files:
|
149
149
|
- .gitignore
|
150
|
+
- CHANGELOG.md
|
150
151
|
- Gemfile
|
151
152
|
- Guardfile
|
152
153
|
- LICENSE.txt
|
@@ -159,6 +160,7 @@ files:
|
|
159
160
|
- lib/furnish/provisioner_group.rb
|
160
161
|
- lib/furnish/provisioners/dummy.rb
|
161
162
|
- lib/furnish/scheduler.rb
|
163
|
+
- lib/furnish/test.rb
|
162
164
|
- lib/furnish/version.rb
|
163
165
|
- lib/furnish/vm.rb
|
164
166
|
- test/helper.rb
|
@@ -182,18 +184,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
182
184
|
- - ! '>='
|
183
185
|
- !ruby/object:Gem::Version
|
184
186
|
version: '0'
|
185
|
-
segments:
|
186
|
-
- 0
|
187
|
-
hash: 799210686028845944
|
188
187
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
189
188
|
none: false
|
190
189
|
requirements:
|
191
190
|
- - ! '>='
|
192
191
|
- !ruby/object:Gem::Version
|
193
192
|
version: '0'
|
194
|
-
segments:
|
195
|
-
- 0
|
196
|
-
hash: 799210686028845944
|
197
193
|
requirements: []
|
198
194
|
rubyforge_project:
|
199
195
|
rubygems_version: 1.8.25
|