automateit 0.70923

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data.tar.gz.sig +1 -0
  2. data/CHANGES.txt +100 -0
  3. data/Hoe.rake +35 -0
  4. data/Manifest.txt +111 -0
  5. data/README.txt +44 -0
  6. data/Rakefile +284 -0
  7. data/TESTING.txt +57 -0
  8. data/TODO.txt +26 -0
  9. data/TUTORIAL.txt +390 -0
  10. data/bin/ai +3 -0
  11. data/bin/aifield +82 -0
  12. data/bin/aitag +128 -0
  13. data/bin/automateit +117 -0
  14. data/docs/friendly_errors.txt +50 -0
  15. data/docs/previews.txt +86 -0
  16. data/env.sh +4 -0
  17. data/examples/basic/Rakefile +26 -0
  18. data/examples/basic/config/automateit_env.rb +16 -0
  19. data/examples/basic/config/fields.yml +3 -0
  20. data/examples/basic/config/tags.yml +13 -0
  21. data/examples/basic/dist/README.txt +9 -0
  22. data/examples/basic/dist/myapp_server.erb +30 -0
  23. data/examples/basic/install.log +15 -0
  24. data/examples/basic/lib/README.txt +10 -0
  25. data/examples/basic/recipes/README.txt +4 -0
  26. data/examples/basic/recipes/install.rb +53 -0
  27. data/examples/basic/recipes/uninstall.rb +6 -0
  28. data/gpl.txt +674 -0
  29. data/lib/automateit.rb +66 -0
  30. data/lib/automateit/account_manager.rb +106 -0
  31. data/lib/automateit/account_manager/linux.rb +171 -0
  32. data/lib/automateit/account_manager/passwd.rb +69 -0
  33. data/lib/automateit/account_manager/portable.rb +136 -0
  34. data/lib/automateit/address_manager.rb +165 -0
  35. data/lib/automateit/address_manager/linux.rb +80 -0
  36. data/lib/automateit/address_manager/portable.rb +37 -0
  37. data/lib/automateit/cli.rb +80 -0
  38. data/lib/automateit/common.rb +65 -0
  39. data/lib/automateit/constants.rb +33 -0
  40. data/lib/automateit/edit_manager.rb +292 -0
  41. data/lib/automateit/error.rb +10 -0
  42. data/lib/automateit/field_manager.rb +103 -0
  43. data/lib/automateit/interpreter.rb +641 -0
  44. data/lib/automateit/package_manager.rb +242 -0
  45. data/lib/automateit/package_manager/apt.rb +63 -0
  46. data/lib/automateit/package_manager/egg.rb +64 -0
  47. data/lib/automateit/package_manager/gem.rb +179 -0
  48. data/lib/automateit/package_manager/portage.rb +69 -0
  49. data/lib/automateit/package_manager/yum.rb +65 -0
  50. data/lib/automateit/platform_manager.rb +47 -0
  51. data/lib/automateit/platform_manager/darwin.rb +30 -0
  52. data/lib/automateit/platform_manager/debian.rb +26 -0
  53. data/lib/automateit/platform_manager/freebsd.rb +25 -0
  54. data/lib/automateit/platform_manager/gentoo.rb +26 -0
  55. data/lib/automateit/platform_manager/lsb.rb +40 -0
  56. data/lib/automateit/platform_manager/struct.rb +78 -0
  57. data/lib/automateit/platform_manager/uname.rb +29 -0
  58. data/lib/automateit/platform_manager/windows.rb +33 -0
  59. data/lib/automateit/plugin.rb +7 -0
  60. data/lib/automateit/plugin/base.rb +32 -0
  61. data/lib/automateit/plugin/driver.rb +218 -0
  62. data/lib/automateit/plugin/manager.rb +232 -0
  63. data/lib/automateit/project.rb +460 -0
  64. data/lib/automateit/root.rb +14 -0
  65. data/lib/automateit/service_manager.rb +79 -0
  66. data/lib/automateit/service_manager/chkconfig.rb +39 -0
  67. data/lib/automateit/service_manager/rc_update.rb +37 -0
  68. data/lib/automateit/service_manager/sysv.rb +126 -0
  69. data/lib/automateit/service_manager/update_rcd.rb +35 -0
  70. data/lib/automateit/shell_manager.rb +261 -0
  71. data/lib/automateit/shell_manager/base_link.rb +67 -0
  72. data/lib/automateit/shell_manager/link.rb +24 -0
  73. data/lib/automateit/shell_manager/portable.rb +421 -0
  74. data/lib/automateit/shell_manager/symlink.rb +32 -0
  75. data/lib/automateit/shell_manager/which.rb +25 -0
  76. data/lib/automateit/tag_manager.rb +63 -0
  77. data/lib/automateit/tag_manager/struct.rb +101 -0
  78. data/lib/automateit/tag_manager/tag_parser.rb +91 -0
  79. data/lib/automateit/tag_manager/yaml.rb +29 -0
  80. data/lib/automateit/template_manager.rb +55 -0
  81. data/lib/automateit/template_manager/base.rb +172 -0
  82. data/lib/automateit/template_manager/erb.rb +17 -0
  83. data/lib/ext/metaclass.rb +17 -0
  84. data/lib/ext/object.rb +18 -0
  85. data/lib/hashcache.rb +22 -0
  86. data/lib/helpful_erb.rb +63 -0
  87. data/lib/nested_error.rb +33 -0
  88. data/lib/queued_logger.rb +68 -0
  89. data/lib/tempster.rb +239 -0
  90. data/misc/index_gem_repository.rb +303 -0
  91. data/misc/setup_egg.rb +12 -0
  92. data/misc/setup_gem_dependencies.sh +7 -0
  93. data/misc/setup_rubygems.sh +21 -0
  94. data/misc/which.cmd +6 -0
  95. data/spec/extras/automateit_service_sysv_test +50 -0
  96. data/spec/extras/scratch.rb +15 -0
  97. data/spec/extras/simple_recipe.rb +8 -0
  98. data/spec/integration/account_manager_spec.rb +218 -0
  99. data/spec/integration/address_manager_linux_spec.rb +119 -0
  100. data/spec/integration/address_manager_portable_spec.rb +30 -0
  101. data/spec/integration/cli_spec.rb +215 -0
  102. data/spec/integration/examples_spec.rb +54 -0
  103. data/spec/integration/examples_spec_editor.rb +71 -0
  104. data/spec/integration/package_manager_spec.rb +104 -0
  105. data/spec/integration/platform_manager_spec.rb +69 -0
  106. data/spec/integration/service_manager_sysv_spec.rb +115 -0
  107. data/spec/integration/shell_manager_spec.rb +471 -0
  108. data/spec/integration/template_manager_erb_spec.rb +31 -0
  109. data/spec/spec_helper.rb +23 -0
  110. data/spec/unit/edit_manager_spec.rb +162 -0
  111. data/spec/unit/field_manager_spec.rb +79 -0
  112. data/spec/unit/hashcache_spec.rb +28 -0
  113. data/spec/unit/interpreter_spec.rb +98 -0
  114. data/spec/unit/platform_manager_spec.rb +44 -0
  115. data/spec/unit/plugins_spec.rb +253 -0
  116. data/spec/unit/tag_manager_spec.rb +189 -0
  117. data/spec/unit/template_manager_erb_spec.rb +137 -0
  118. metadata +249 -0
  119. metadata.gz.sig +0 -0
@@ -0,0 +1,119 @@
1
+ require File.join(File.dirname(File.expand_path(__FILE__)), "/../spec_helper.rb")
2
+
3
+ if not INTERPRETER.euid?
4
+ puts "NOTE: Can't check 'euid' on this platform, #{__FILE__}"
5
+ elsif not INTERPRETER.superuser?
6
+ puts "NOTE: Must be root to check #{__FILE__}"
7
+ elsif not INTERPRETER.address_manager[:linux].available?
8
+ puts "NOTE: Can't check AddressManager::Linux on this platform, #{__FILE__}"
9
+ else
10
+ describe "AutomateIt::AddressManager::Linux" do
11
+ before(:all) do
12
+ @a = AutomateIt.new(:verbosity => Logger::WARN)
13
+ @m = @a.address_manager
14
+
15
+ @properties = {
16
+ :device => "eth0",
17
+ :label => "xxxx",
18
+ :address => "10.0.0.249",
19
+ :mask => "24",
20
+ :announcements => 1,
21
+ }
22
+
23
+ @device_and_label = @properties[:device]+":"+@properties[:label]
24
+
25
+ if @m.interfaces.include?(@device_and_label) \
26
+ or @m.addresses.include?(@properties[:address])
27
+ raise "ERROR: This computer already has the device/address used for testing! Either disable #{@device_and_label} and #{@properties[:address]}, or change the spec to test using different properties."
28
+ end
29
+ end
30
+
31
+ after(:all) do
32
+ @m.remove(@properties)
33
+ end
34
+
35
+ it "should find interfaces for top-level device" do
36
+ @m.interfaces.should include(@properties[:device])
37
+ end
38
+
39
+ it "should not find non-existent device-label" do
40
+ @m.interfaces.should_not include(@device_and_label)
41
+ end
42
+
43
+ it "should not find non-existant IP address" do
44
+ @m.addresses.should_not include(@properties[:address])
45
+ end
46
+
47
+ it "should not have non-existent address bundles" do
48
+ @m.has?(@properties).should be_false
49
+ end
50
+
51
+ it "should add an address" do
52
+ @m.add(@properties).should be_true
53
+ # Leaves active interface behind for other tests
54
+ end
55
+
56
+ it "should find added interface" do
57
+ # Depends on active interface being created by earlier test
58
+ @m.interfaces.should include(@device_and_label)
59
+ end
60
+
61
+ it "should find added IP address" do
62
+ # Depends on active interface being created by earlier test
63
+ @m.addresses.should include(@properties[:address])
64
+ end
65
+
66
+ it "should find added address using a properties bundle" do
67
+ # Depends on user to be created by previous tests
68
+ @m.has?(@properties).should be_true
69
+ end
70
+
71
+ it "should find added address using the IP address" do
72
+ # Depends on user to be created by previous tests
73
+ @m.has?(:address => @properties[:address]).should be_true
74
+ end
75
+
76
+ it "should find added address using device and label" do
77
+ # Depends on user to be created by previous tests
78
+ @m.has?(:device => @properties[:device], :label => @properties[:label]).should be_true
79
+ end
80
+
81
+ it "should remove an address" do
82
+ # Depends on active interface being created by earlier test
83
+ @m.remove(@properties).should be_true
84
+ end
85
+
86
+ it "should not have an interface after removing it" do
87
+ @m.interfaces.should_not include(@device_and_label)
88
+ end
89
+
90
+ it "should not have an address after removing it" do
91
+ @m.addresses.should_not include(@properties[:address])
92
+ end
93
+
94
+ it "should not have an address match a properties bundle after removing it" do
95
+ @m.has?(@properties).should be_false
96
+ end
97
+
98
+ it "should not remove a non-existant address" do
99
+ @m.remove(@properties).should be_false
100
+ end
101
+
102
+ it "should not re-add an existing address" do
103
+ @m.add(@properties).should be_true
104
+ @m.add(@properties).should be_false
105
+
106
+ # Cleanup
107
+ @m.remove(@properties).should be_true
108
+ end
109
+
110
+ it "should have hostnames" do
111
+ @m.addresses.size.should >= 1
112
+ end
113
+
114
+ it "should be able to infer hostname variants" do
115
+ @m.hostnames_for("kagami.lucky-channel").should == ["kagami", "kagami.lucky-channel"]
116
+ @m.hostnames_for("kagami").should == ["kagami"]
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(File.expand_path(__FILE__)), "/../spec_helper.rb")
2
+
3
+ describe "AutomateIt::AddressManager::Portable" do
4
+ before :all do
5
+ @a = AutomateIt.new(:verbosity => Logger::WARN)
6
+ @d = @a.address_manager[:portable]
7
+ end
8
+
9
+ it "should have hostnames" do
10
+ @d.hostnames.should_not be_empty
11
+ end
12
+
13
+ it "should have localhost in hostnames" do
14
+ @d.hostnames.should include("localhost")
15
+ @d.has?("localhost").should be_true
16
+ end
17
+
18
+ it "should have machine's hostname in hostnames" do
19
+ @d.hostnames.should include(Socket.gethostname)
20
+ @d.has?(Socket.gethostname).should be_true
21
+ end
22
+
23
+ it "should have addresses" do
24
+ @d.addresses.should_not be_empty
25
+ end
26
+
27
+ it "should have 127.0.0.1 in addresses" do
28
+ @d.addresses.should include("127.0.0.1")
29
+ end
30
+ end
@@ -0,0 +1,215 @@
1
+ require File.join(File.dirname(File.expand_path(__FILE__)), "/../spec_helper.rb")
2
+
3
+ describe AutomateIt::CLI, " stand-alone" do# {{{
4
+ it "should eval code" do
5
+ AutomateIt::CLI.run(:eval => "42").should == 42
6
+ end
7
+
8
+ it "should invoke a recipe" do
9
+ INTERPRETER.mktemp do |filename|
10
+ File.open(filename, "w+") {|h| h.write("42")}
11
+ AutomateIt::CLI.run(:recipe => filename).should == 42
12
+ end
13
+ end
14
+ end# }}}
15
+
16
+ describe AutomateIt::CLI, " without a project" do# {{{
17
+ def on_recipe(opts={})
18
+ INTERPRETER.mktempdircd do
19
+ recipe = "recipe.rb"
20
+ File.open(recipe, "w+"){|h| h.write("42")}
21
+ args = [recipe]
22
+ args << opts unless opts.blank?
23
+ return AutomateIt::CLI.run(*args)
24
+ end
25
+ end
26
+
27
+ it "should run recipe with a guessed but non-existent project path" do
28
+ on_recipe().should == 42
29
+ end
30
+ it "should fail to run recipe with explicit but non-existent project path" do
31
+ lambda{ on_recipe(:project => "not_a_real_project") }.should raise_error(ArgumentError)
32
+ end
33
+ end# }}}
34
+
35
+ describe AutomateIt::CLI, " with a project" do# {{{
36
+ def with_project(&block)
37
+ INTERPRETER.mktempdircd do
38
+ project = "myproject"
39
+ AutomateIt::CLI.run(:create => project, :verbosity => Logger::WARN)
40
+
41
+ INTERPRETER.cd project do
42
+ block.call(project)
43
+ end
44
+ end
45
+ end
46
+
47
+ it "should create a project" do
48
+ with_project do
49
+ File.exists?("config/tags.yml").should be_true
50
+ end
51
+ end
52
+
53
+ it "should invoke a project recipe that can access a dist directory" do
54
+ with_project do
55
+ recipe = "recipes/recipe.rb"
56
+ write_to(recipe, "dist")
57
+
58
+ path = AutomateIt::CLI.run(:recipe => recipe)
59
+ File.expand_path(path).should == File.expand_path("./dist")
60
+ end
61
+ end
62
+
63
+ it "should load custom driver" do
64
+ with_project do
65
+ recipe = "recipes/recipe.rb"
66
+ driver = "lib/custom_driver.rb"
67
+
68
+ write_to(driver, <<-HERE)
69
+ class ::AutomateIt::PackageManager::MyDriver < ::AutomateIt::PackageManager::BaseDriver
70
+ depends_on :nothing
71
+
72
+ def suitability(method, *args) # :nodoc:
73
+ # Never select as default driver
74
+ return 0
75
+ end
76
+ end
77
+ HERE
78
+
79
+ write_to(recipe, <<-HERE)
80
+ package_manager.drivers.keys.include?(:my_driver)
81
+ HERE
82
+
83
+ AutomateIt::CLI.run(:recipe => recipe).should be_true
84
+ end
85
+ end
86
+
87
+ it "should load custom driver with a different namespace than its manager" do
88
+ with_project do
89
+ recipe = "recipes/recipe.rb"
90
+ driver = "lib/custom_driver.rb"
91
+
92
+ # Keep this in sync with rdoc example in: lib/automateit/plugins/driver.rb
93
+ write_to(driver, <<-HERE)
94
+ class MyOtherDriver < ::AutomateIt::PackageManager::BaseDriver
95
+ depends_on :nothing
96
+
97
+ def suitability(method, *args) # :nodoc:
98
+ # Never select as default driver
99
+ return 0
100
+ end
101
+ end
102
+ HERE
103
+
104
+ write_to(recipe, <<-HERE)
105
+ package_manager.drivers.keys.include?(:my_other_driver)
106
+ HERE
107
+
108
+ AutomateIt::CLI.run(:recipe => recipe).should be_true
109
+ end
110
+ end
111
+
112
+ it "should load tags in a project" do
113
+ with_project do
114
+ recipe = "recipes/recipe.rb"
115
+ tags_yml = "config/tags.yml"
116
+
117
+ write_to(tags_yml, <<-HERE)
118
+ all_servers:
119
+ - localhost
120
+ all_groups:
121
+ - @all_servers
122
+ no_servers:
123
+ - !localhost
124
+ no_groups:
125
+ - !@all_servers
126
+ HERE
127
+
128
+ write_to(recipe, <<-HERE)
129
+ result = true
130
+ result &= tagged?("localhost")
131
+ result &= tagged?("all_servers")
132
+ result &= tagged?("all_groups")
133
+ result &= ! tagged?("no_servers")
134
+ result &= ! tagged?("no_groups")
135
+
136
+ result
137
+ HERE
138
+
139
+ AutomateIt::CLI.run(:recipe => recipe).should be_true
140
+ end
141
+ end
142
+
143
+ it "should load fields in a project" do
144
+ with_project do
145
+ recipe = "recipes/recipe.rb"
146
+ fields = "config/fields.yml"
147
+
148
+ write_to(fields, <<-HERE)
149
+ <%="key"%>: value
150
+ hash:
151
+ leafkey: leafvalue
152
+ branchkey:
153
+ deepleafkey: deepleafvalue
154
+ HERE
155
+
156
+ write_to(recipe, <<-HERE)
157
+ lookup("*")
158
+ lookup("key")
159
+ lookup("hash")
160
+ lookup("hash")["leafkey"]
161
+ lookup("hash#leafkey")
162
+ lookup("hash#branchkey#deepleafkey")
163
+ lookup("asdf") rescue IndexError
164
+ true
165
+ HERE
166
+
167
+ AutomateIt::CLI.run(:recipe => recipe).should be_true
168
+ end
169
+ end
170
+
171
+ it "should let recipes invoke other recipes" do
172
+ with_project do
173
+ first = "recipes/first.rb"
174
+ second = "recipes/second.rb"
175
+
176
+ write_to(first, "invoke 'second'")
177
+ write_to(second, "42")
178
+
179
+ AutomateIt::CLI.run(first).should == 42
180
+ end
181
+ end
182
+
183
+ it "should be able to run default project" do
184
+ with_project do
185
+ # XXX How to determine which rake to use!?
186
+ rake = RUBY_PLATFORM =~ /mswin/i ? "rake.bat" : "rake"
187
+ output = `#{rake} -I #{AutomateIt_Lib} preview hello`
188
+ output.should match(/I'm in preview mode/)
189
+ end
190
+ end
191
+ end# }}}
192
+
193
+ describe AutomateIt::CLI, " with an interactive shell" do# {{{
194
+ it "should provide an interactive shell" do
195
+ # FIXME this seems to break IRB somehow for breakpoints, why?!
196
+ # Mock IRB to run shell and return it to unmocked state when done
197
+ begin
198
+ $irb_under_test = true
199
+ require 'irb'
200
+ IRB::Irb.class_eval do
201
+ def initialize_with_test(*args)
202
+ return initialize_without_test(*args) unless $irb_under_test
203
+
204
+ require 'spec'
205
+ @context = Spec::Mocks::Mock.new("asdf", :null_object => true)
206
+ self.instance_eval { def eval_input; 42; end }
207
+ end
208
+ alias_method_chain :initialize, :test
209
+ end
210
+ AutomateIt::CLI.run(:verbosity => Logger::WARN).should == 42
211
+ ensure
212
+ $irb_under_test = false
213
+ end
214
+ end
215
+ end# }}}
@@ -0,0 +1,54 @@
1
+ require File.join(File.dirname(File.expand_path(__FILE__)), "/../spec_helper.rb")
2
+
3
+ # This spec runs the ruby interpreter directly. This makes it possible to silently run the recipes, without editing them. Unfortunately, this is evil and brittle because it relies on being able to run the interpreter again. The alternative is "spec/integration/examples_spec_editor.rb", which edits the recipes so they're silent and uses the internal invoke method to run them. What's a reasonable way to do this?
4
+
5
+ if not INTERPRETER.euid?
6
+ puts "NOTE: Can't check 'euid' on this platform, #{__FILE__}"
7
+ elsif not INTERPRETER.superuser?
8
+ puts "NOTE: Must be root to check #{__FILE__}"
9
+ else
10
+ describe "Examples" do
11
+ params = {
12
+ :project => "examples/basic",
13
+ :installer => "examples/basic/recipes/install.rb",
14
+ :uninstaller => "examples/basic/recipes/uninstall.rb",
15
+ }
16
+ INTERPRETER.params = params
17
+
18
+ # Get the fully qualified filename for the interpreter.
19
+ # XXX What bad things will this do if, say, running with JRuby?
20
+ ruby = begin
21
+ c = ::Config::CONFIG
22
+ File::join(c['bindir'], c['ruby_install_name']) << c['EXEEXT']
23
+ end
24
+
25
+ begin
26
+ # Preview examples to cause a NotImplemented error on unsupported platforms
27
+ AutomateIt::invoke(params[:installer], :verbosity => Logger::WARN, :preview => true, :friendly_exceptions => false)
28
+
29
+ it "should install the example" do
30
+ INTERPRETER.instance_eval do
31
+ log.silence(Logger::WARN) do
32
+ sh("#{ruby} bin/automateit #{params[:installer]} > /dev/null 2>&1")
33
+ File.exists?("/etc/init.d/myapp_server").should be_true
34
+ File.directory?("/tmp/myapp_server").should be_true
35
+ service_manager.started?("myapp_server", :wait => 5).should be_true
36
+ end
37
+ end
38
+ end
39
+
40
+ it "should uninstall the example" do
41
+ INTERPRETER.instance_eval do
42
+ log.silence(Logger::WARN) do
43
+ sh("#{ruby} bin/automateit #{params[:uninstaller]} > /dev/null 2>&1")
44
+ File.exists?("/etc/init.d/myapp_server").should be_false
45
+ File.directory?("/tmp/myapp_server").should be_false
46
+ service_manager.stopped?("myapp_server", :wait => 5).should be_true
47
+ end
48
+ end
49
+ end
50
+ rescue NotImplementedError => e
51
+ puts "NOTE: Can't check examples on this platform, #{__FILE__}"
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,71 @@
1
+ require File.join(File.dirname(File.expand_path(__FILE__)), "/../spec_helper.rb")
2
+
3
+ # This spec edits the recipes to make them run silently when used with an internal invoke. Although this is faster and more portable, it's also evil and brittle because it can't run the recipes as they are.
4
+
5
+ if not INTERPRETER.euid?
6
+ puts "NOTE: Can't check 'euid' on this platform, #{__FILE__}"
7
+ elsif not INTERPRETER.superuser?
8
+ puts "NOTE: Must be root to check #{__FILE__}"
9
+ else
10
+ describe "Examples" do
11
+ params = {
12
+ :project => "examples/basic",
13
+ :installer => "examples/basic/recipes/install.rb",
14
+ :uninstaller => "examples/basic/recipes/uninstall.rb",
15
+ }
16
+ INTERPRETER.params = params
17
+
18
+ begin
19
+ # Preview examples to cause a NotImplemented error on unsupported platforms
20
+ AutomateIt::invoke(params[:installer], :verbosity => Logger::WARN, :preview => true)
21
+
22
+ it "should install the example" do
23
+ INTERPRETER.instance_eval do
24
+ mktemp do |recipe|
25
+ log.silence(Logger::WARN) do
26
+ cp(params[:installer], recipe)
27
+ edit(:file => recipe) do
28
+ replace 'service_manager.start\("myapp_server"\)$',
29
+ 'service_manager.start "myapp_server", :silent => true'
30
+ replace 'sh\("rails --database=sqlite3 . > /dev/null"\)',
31
+ 'sh("rails --database=sqlite3 . > /dev/null 2>&1")'
32
+ replace 'sh\("rake db:migrate"\)',
33
+ 'sh("rake db:migrate > /dev/null 2>&1")'
34
+ end or raise "couldn't edit installer"
35
+ # cp recipe, "/tmp/installer.rb"
36
+
37
+ AutomateIt::invoke(recipe, :project => params[:project],
38
+ :verbosity => Logger::WARN)
39
+ File.exists?("/etc/init.d/myapp_server").should be_true
40
+ File.directory?("/tmp/myapp_server").should be_true
41
+ service_manager.started?("myapp_server", :wait => 5).should be_true
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ it "should uninstall the example" do
48
+ INTERPRETER.instance_eval do
49
+ mktemp do |recipe|
50
+ log.silence(Logger::WARN) do
51
+ cp(params[:uninstaller], recipe)
52
+ edit(:file => recipe) do
53
+ replace 'service_manager.stop "myapp_server"$',
54
+ 'service_manager.stop "myapp_server", :silent => true'
55
+ end or raise "couldn't edit uninstaller"
56
+ ### cp recipe, "/tmp/uninstaller.rb"
57
+
58
+ AutomateIt::invoke(recipe, :project => params[:project],
59
+ :verbosity => Logger::WARN)
60
+ File.exists?("/etc/init.d/myapp_server").should be_false
61
+ File.directory?("/tmp/myapp_server").should be_false
62
+ service_manager.stopped?("myapp_server", :wait => 5).should be_true
63
+ end
64
+ end
65
+ end
66
+ end
67
+ rescue NotImplementedError
68
+ puts "NOTE: Can't check examples on this platform, #{__FILE__}"
69
+ end
70
+ end
71
+ end