foreman 0.47.0 → 0.48.0.pre3
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/bin/taskman +8 -0
- data/data/example/Procfile +4 -3
- data/data/example/spawnee +14 -0
- data/data/example/spawner +7 -0
- data/data/export/bluepill/master.pill.erb +10 -10
- data/data/export/launchd/launchd.plist.erb +3 -3
- data/data/export/runit/log/run.erb +7 -0
- data/data/export/runit/run.erb +2 -2
- data/data/export/supervisord/app.conf.erb +12 -12
- data/data/export/upstart/master.conf.erb +2 -2
- data/data/export/upstart/process.conf.erb +3 -3
- data/lib/foreman/cli.rb +57 -22
- data/lib/foreman/engine/cli.rb +103 -0
- data/lib/foreman/engine.rb +208 -148
- data/lib/foreman/env.rb +27 -0
- data/lib/foreman/export/base.rb +58 -35
- data/lib/foreman/export/bluepill.rb +3 -17
- data/lib/foreman/export/inittab.rb +8 -11
- data/lib/foreman/export/launchd.rb +4 -16
- data/lib/foreman/export/runit.rb +14 -39
- data/lib/foreman/export/supervisord.rb +3 -13
- data/lib/foreman/export/upstart.rb +9 -27
- data/lib/foreman/export.rb +0 -1
- data/lib/foreman/process.rb +56 -67
- data/lib/foreman/procfile.rb +59 -25
- data/lib/foreman/version.rb +1 -1
- data/man/foreman.1 +4 -0
- data/spec/foreman/cli_spec.rb +46 -150
- data/spec/foreman/engine_spec.rb +46 -80
- data/spec/foreman/export/base_spec.rb +4 -7
- data/spec/foreman/export/bluepill_spec.rb +7 -6
- data/spec/foreman/export/inittab_spec.rb +7 -7
- data/spec/foreman/export/launchd_spec.rb +4 -7
- data/spec/foreman/export/runit_spec.rb +12 -17
- data/spec/foreman/export/supervisord_spec.rb +7 -56
- data/spec/foreman/export/upstart_spec.rb +18 -23
- data/spec/foreman/process_spec.rb +27 -124
- data/spec/foreman/procfile_spec.rb +26 -16
- data/spec/resources/Procfile +4 -0
- data/spec/resources/bin/echo +2 -0
- data/spec/resources/bin/env +2 -0
- data/spec/resources/bin/test +2 -0
- data/spec/resources/export/bluepill/app-concurrency.pill +4 -4
- data/spec/resources/export/bluepill/app.pill +4 -4
- data/spec/resources/export/supervisord/app-alpha-1.conf +24 -0
- data/spec/resources/export/supervisord/app-alpha-2.conf +4 -4
- data/spec/spec_helper.rb +58 -6
- metadata +24 -22
- data/data/export/runit/log_run.erb +0 -7
- data/lib/foreman/color.rb +0 -40
- data/lib/foreman/procfile_entry.rb +0 -26
- data/lib/foreman/utils.rb +0 -18
- data/spec/foreman/color_spec.rb +0 -31
- data/spec/foreman/procfile_entry_spec.rb +0 -13
- data/spec/resources/export/supervisord/app-env-with-comma.conf +0 -24
- data/spec/resources/export/supervisord/app-env.conf +0 -21
- data/spec/resources/export/supervisord/app.conf +0 -24
- /data/spec/resources/export/runit/{app-alpha-1-log-run → app-alpha-1/log/run} +0 -0
- /data/spec/resources/export/runit/{app-alpha-1-run → app-alpha-1/run} +0 -0
- /data/spec/resources/export/runit/{app-alpha-2-log-run → app-alpha-2/log/run} +0 -0
- /data/spec/resources/export/runit/{app-alpha-2-run → app-alpha-2/run} +0 -0
- /data/spec/resources/export/runit/{app-bravo-1-log-run → app-bravo-1/log/run} +0 -0
- /data/spec/resources/export/runit/{app-bravo-1-run → app-bravo-1/run} +0 -0
data/spec/foreman/cli_spec.rb
CHANGED
|
@@ -3,188 +3,84 @@ require "foreman/cli"
|
|
|
3
3
|
|
|
4
4
|
describe "Foreman::CLI", :fakefs do
|
|
5
5
|
subject { Foreman::CLI.new }
|
|
6
|
-
let(:engine) { subject.send(:engine) }
|
|
7
|
-
let(:entries) { engine.procfile.entries.inject({}) { |h,e| h.update(e.name => e) } }
|
|
8
6
|
|
|
9
|
-
describe "
|
|
10
|
-
|
|
11
|
-
it "prints an error" do
|
|
12
|
-
mock_error(subject, "Procfile does not exist.") do
|
|
13
|
-
dont_allow.instance_of(Foreman::Engine).start
|
|
14
|
-
subject.start
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe "with a Procfile" do
|
|
20
|
-
before(:each) { write_procfile }
|
|
7
|
+
describe ".foreman" do
|
|
8
|
+
before { File.open(".foreman", "w") { |f| f.puts "formation: alpha=2" } }
|
|
21
9
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
mock.instance_of(Foreman::Engine).start
|
|
25
|
-
subject.start
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "can run a single process" do
|
|
29
|
-
dont_allow(subject).error
|
|
30
|
-
stub(engine).watch_for_output
|
|
31
|
-
stub(engine).watch_for_termination
|
|
32
|
-
mock(entries["alpha"]).spawn(1, is_a(IO), engine.directory, {}, 5000) { [] }
|
|
33
|
-
mock(entries["bravo"]).spawn(0, is_a(IO), engine.directory, {}, 5100) { [] }
|
|
34
|
-
subject.start("alpha")
|
|
35
|
-
end
|
|
10
|
+
it "provides default options" do
|
|
11
|
+
subject.send(:options)["formation"].should == "alpha=2"
|
|
36
12
|
end
|
|
37
13
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
mock(Foreman::Procfile).new("/some/app/Procfile")
|
|
42
|
-
mock.instance_of(Foreman::Engine).start
|
|
43
|
-
foreman %{ start -d /some/app }
|
|
44
|
-
end
|
|
14
|
+
it "is overridden by options at the cli" do
|
|
15
|
+
subject = Foreman::CLI.new([], :formation => "alpha=3")
|
|
16
|
+
subject.send(:options)["formation"].should == "alpha=3"
|
|
45
17
|
end
|
|
46
18
|
end
|
|
47
19
|
|
|
48
|
-
describe "
|
|
49
|
-
describe "
|
|
50
|
-
it "
|
|
51
|
-
write_procfile
|
|
52
|
-
File.open(".foreman", "w") { |f| f.puts "concurrency: alpha=2" }
|
|
53
|
-
mock_export = mock(Foreman::Export::Upstart)
|
|
54
|
-
mock(Foreman::Export::Upstart).new("/upstart", is_a(Foreman::Engine), { "concurrency" => "alpha=2" }) { mock_export }
|
|
55
|
-
mock_export.export
|
|
56
|
-
foreman %{ export upstart /upstart }
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "respects --env" do
|
|
60
|
-
write_procfile
|
|
61
|
-
write_env("envfile")
|
|
62
|
-
mock_export = mock(Foreman::Export::Upstart)
|
|
63
|
-
mock(Foreman::Export::Upstart).new("/upstart", is_a(Foreman::Engine), { "env" => "envfile" }) { mock_export }
|
|
64
|
-
mock_export.export
|
|
65
|
-
foreman %{ export upstart /upstart --env envfile }
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
describe "with a non-existent Procfile" do
|
|
70
|
-
it "prints an error" do
|
|
20
|
+
describe "start" do
|
|
21
|
+
describe "when a Procfile doesnt exist", :fakefs do
|
|
22
|
+
it "displays an error" do
|
|
71
23
|
mock_error(subject, "Procfile does not exist.") do
|
|
72
|
-
dont_allow.instance_of(Foreman::Engine).
|
|
73
|
-
subject.
|
|
24
|
+
dont_allow.instance_of(Foreman::Engine).start
|
|
25
|
+
subject.start
|
|
74
26
|
end
|
|
75
27
|
end
|
|
76
28
|
end
|
|
77
29
|
|
|
78
|
-
describe "with a Procfile" do
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def export
|
|
85
|
-
raise Foreman::Export::Exception.new("foo")
|
|
86
|
-
end
|
|
87
|
-
end }
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it "prints an error" do
|
|
91
|
-
mock_error(subject, "foo") do
|
|
92
|
-
subject.export("errorful")
|
|
93
|
-
end
|
|
30
|
+
describe "with a valid Procfile" do
|
|
31
|
+
it "can run a single command" do
|
|
32
|
+
without_fakefs do
|
|
33
|
+
output = foreman("start env -f #{resource_path("Procfile")}")
|
|
34
|
+
output.should =~ /env.1/
|
|
35
|
+
output.should_not =~ /test.1/
|
|
94
36
|
end
|
|
95
37
|
end
|
|
96
38
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
mock(Foreman::Export::Upstart).new("/tmp/foo", is_a(Foreman::Engine), {}) { mock_export }
|
|
104
|
-
mock_export.export
|
|
105
|
-
subject.export("upstart", "/tmp/foo")
|
|
39
|
+
it "can run all commands" do
|
|
40
|
+
without_fakefs do
|
|
41
|
+
output = foreman("start -f #{resource_path("Procfile")} -e #{resource_path(".env")}")
|
|
42
|
+
output.should =~ /echo.1 \| echoing/
|
|
43
|
+
output.should =~ /env.1 \| bar/
|
|
44
|
+
output.should =~ /test.1 \| testing/
|
|
106
45
|
end
|
|
107
46
|
end
|
|
108
47
|
end
|
|
109
48
|
end
|
|
110
49
|
|
|
111
50
|
describe "check" do
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
it "displays the jobs" do
|
|
116
|
-
mock(subject).puts("valid procfile detected (alpha, bravo)")
|
|
117
|
-
subject.check
|
|
118
|
-
end
|
|
51
|
+
it "with a valid Procfile displays the jobs" do
|
|
52
|
+
write_procfile
|
|
53
|
+
foreman("check").should == "valid procfile detected (alpha, bravo)\n"
|
|
119
54
|
end
|
|
120
55
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it "displays an error" do
|
|
127
|
-
mock_error(subject, "no processes defined") do
|
|
128
|
-
subject.check
|
|
129
|
-
end
|
|
130
|
-
end
|
|
56
|
+
it "with a blank Procfile displays an error" do
|
|
57
|
+
FileUtils.touch "Procfile"
|
|
58
|
+
foreman("check").should == "ERROR: no processes defined\n"
|
|
131
59
|
end
|
|
132
60
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
subject.check
|
|
137
|
-
end
|
|
138
|
-
end
|
|
61
|
+
it "without a Procfile displays an error" do
|
|
62
|
+
FileUtils.rm_f "Procfile"
|
|
63
|
+
foreman("check").should == "ERROR: Procfile does not exist.\n"
|
|
139
64
|
end
|
|
140
65
|
end
|
|
141
66
|
|
|
142
67
|
describe "run" do
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
describe "and a command" do
|
|
147
|
-
let(:command) { ["ls", "-l", "foo bar"] }
|
|
148
|
-
|
|
149
|
-
before(:each) do
|
|
150
|
-
stub(subject).exec
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
it "should load the environment file" do
|
|
154
|
-
write_env
|
|
155
|
-
preserving_env do
|
|
156
|
-
subject.run *command
|
|
157
|
-
ENV["FOO"].should == "bar"
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
ENV["FOO"].should be_nil
|
|
161
|
-
end
|
|
162
|
-
|
|
163
|
-
it "should exec the argument list as a shell command" do
|
|
164
|
-
mock(subject).exec(command.shelljoin)
|
|
165
|
-
subject.run *command
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
describe "and a non-existent command" do
|
|
170
|
-
let(:command) { "iuhtngrglhulhdfg" }
|
|
68
|
+
it "can run a command" do
|
|
69
|
+
forked_foreman("run echo 1").should == "1\n"
|
|
70
|
+
end
|
|
171
71
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
end
|
|
177
|
-
end
|
|
72
|
+
it "includes the environment" do
|
|
73
|
+
forked_foreman("run #{resource_path("bin/env FOO")} -e #{resource_path(".env")}").should == "bar\n"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
178
76
|
|
|
179
|
-
|
|
180
|
-
|
|
77
|
+
describe "version" do
|
|
78
|
+
it "displays gem version" do
|
|
79
|
+
foreman("version").chomp.should == Foreman::VERSION
|
|
80
|
+
end
|
|
181
81
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
subject.run command
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
end
|
|
82
|
+
it "displays gem version on shortcut command" do
|
|
83
|
+
foreman("-v").chomp.should == Foreman::VERSION
|
|
188
84
|
end
|
|
189
85
|
end
|
|
190
86
|
|
data/spec/foreman/engine_spec.rb
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
2
|
require "foreman/engine"
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class Foreman::Engine::Tester < Foreman::Engine
|
|
5
|
+
attr_reader :buffer
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
def startup
|
|
8
|
+
@buffer = ""
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def output(name, data)
|
|
12
|
+
@buffer += "#{name}: #{data}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def shutdown
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "Foreman::Engine", :fakefs do
|
|
20
|
+
subject do
|
|
21
|
+
write_procfile "Procfile"
|
|
22
|
+
Foreman::Engine::Tester.new.load_procfile("Procfile")
|
|
12
23
|
end
|
|
13
24
|
|
|
14
25
|
describe "initialize" do
|
|
@@ -16,65 +27,53 @@ describe "Foreman::Engine", :fakefs do
|
|
|
16
27
|
before { write_procfile }
|
|
17
28
|
|
|
18
29
|
it "reads the processes" do
|
|
19
|
-
subject.
|
|
20
|
-
subject.
|
|
30
|
+
subject.process("alpha").command.should == "./alpha"
|
|
31
|
+
subject.process("bravo").command.should == "./bravo"
|
|
21
32
|
end
|
|
22
33
|
end
|
|
23
34
|
end
|
|
24
35
|
|
|
25
36
|
describe "start" do
|
|
26
37
|
it "forks the processes" do
|
|
27
|
-
|
|
28
|
-
mock
|
|
29
|
-
mock.instance_of(Foreman::Process).run_process(Dir.pwd, "./bravo", is_a(IO))
|
|
38
|
+
mock(subject.process("alpha")).run(anything)
|
|
39
|
+
mock(subject.process("bravo")).run(anything)
|
|
30
40
|
mock(subject).watch_for_output
|
|
31
41
|
mock(subject).watch_for_termination
|
|
32
42
|
subject.start
|
|
33
43
|
end
|
|
34
44
|
|
|
35
45
|
it "handles concurrency" do
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
mock
|
|
39
|
-
mock
|
|
40
|
-
mock(
|
|
41
|
-
|
|
42
|
-
engine.start
|
|
46
|
+
subject.options[:formation] = "alpha=2"
|
|
47
|
+
mock(subject.process("alpha")).run(anything).twice
|
|
48
|
+
mock(subject.process("bravo")).run(anything).never
|
|
49
|
+
mock(subject).watch_for_output
|
|
50
|
+
mock(subject).watch_for_termination
|
|
51
|
+
subject.start
|
|
43
52
|
end
|
|
44
53
|
end
|
|
45
54
|
|
|
46
55
|
describe "directories" do
|
|
47
56
|
it "has the directory default relative to the Procfile" do
|
|
48
57
|
write_procfile "/some/app/Procfile"
|
|
49
|
-
engine = Foreman::Engine.new("/some/app/Procfile")
|
|
50
|
-
engine.
|
|
58
|
+
engine = Foreman::Engine.new.load_procfile("/some/app/Procfile")
|
|
59
|
+
engine.root.should == "/some/app"
|
|
51
60
|
end
|
|
52
61
|
end
|
|
53
62
|
|
|
54
63
|
describe "environment" do
|
|
55
|
-
|
|
56
|
-
write_procfile
|
|
57
|
-
stub(Process).fork
|
|
58
|
-
any_instance_of(Foreman::Engine) do |engine|
|
|
59
|
-
stub(engine).info
|
|
60
|
-
stub(engine).spawn_processes
|
|
61
|
-
stub(engine).watch_for_termination
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it "should read if specified" do
|
|
64
|
+
it "should read env files" do
|
|
66
65
|
File.open("/tmp/env", "w") { |f| f.puts("FOO=baz") }
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
engine.start
|
|
66
|
+
subject.load_env("/tmp/env")
|
|
67
|
+
subject.env["FOO"].should == "baz"
|
|
70
68
|
end
|
|
71
69
|
|
|
72
70
|
it "should read more than one if specified" do
|
|
73
71
|
File.open("/tmp/env1", "w") { |f| f.puts("FOO=bar") }
|
|
74
72
|
File.open("/tmp/env2", "w") { |f| f.puts("BAZ=qux") }
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
73
|
+
subject.load_env "/tmp/env1"
|
|
74
|
+
subject.load_env "/tmp/env2"
|
|
75
|
+
subject.env["FOO"].should == "bar"
|
|
76
|
+
subject.env["BAZ"].should == "qux"
|
|
78
77
|
end
|
|
79
78
|
|
|
80
79
|
it "should handle quoted values" do
|
|
@@ -84,55 +83,22 @@ describe "Foreman::Engine", :fakefs do
|
|
|
84
83
|
f.puts "FRED='barney'"
|
|
85
84
|
f.puts 'OTHER="escaped\"quote"'
|
|
86
85
|
end
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
subject.load_env "/tmp/env"
|
|
87
|
+
subject.env["FOO"].should == "bar"
|
|
88
|
+
subject.env["BAZ"].should == "qux"
|
|
89
|
+
subject.env["FRED"].should == "barney"
|
|
90
|
+
subject.env["OTHER"].should == 'escaped"quote'
|
|
89
91
|
end
|
|
90
92
|
|
|
91
93
|
it "should fail if specified and doesnt exist" do
|
|
92
|
-
|
|
93
|
-
engine = Foreman::Engine.new("Procfile", :env => "/tmp/env")
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "should read .env if none specified" do
|
|
97
|
-
File.open(".env", "w") { |f| f.puts("FOO=qoo") }
|
|
98
|
-
engine = Foreman::Engine.new("Procfile")
|
|
99
|
-
engine.environment.should == {"FOO"=>"qoo"}
|
|
100
|
-
engine.start
|
|
94
|
+
lambda { subject.load_env "/tmp/env" }.should raise_error(Errno::ENOENT)
|
|
101
95
|
end
|
|
102
96
|
|
|
103
97
|
it "should set port from .env if specified" do
|
|
104
|
-
File.open("
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
engine.start
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
it "should be loaded relative to the Procfile" do
|
|
111
|
-
FileUtils.mkdir_p "/some/app"
|
|
112
|
-
File.open("/some/app/.env", "w") { |f| f.puts("FOO=qoo") }
|
|
113
|
-
write_procfile "/some/app/Procfile"
|
|
114
|
-
engine = Foreman::Engine.new("/some/app/Procfile")
|
|
115
|
-
engine.environment.should == {"FOO"=>"qoo"}
|
|
116
|
-
engine.start
|
|
98
|
+
File.open("/tmp/env", "w") { |f| f.puts("PORT=9000") }
|
|
99
|
+
subject.load_env "/tmp/env"
|
|
100
|
+
subject.send(:base_port).should == 9000
|
|
117
101
|
end
|
|
118
102
|
end
|
|
119
103
|
|
|
120
|
-
describe "utf8" do
|
|
121
|
-
before(:each) do
|
|
122
|
-
File.open("Procfile", "w") do |file|
|
|
123
|
-
file.puts "utf8: #{resource_path("bin/utf8")}"
|
|
124
|
-
end
|
|
125
|
-
end
|
|
126
|
-
|
|
127
|
-
it "should spawn" do
|
|
128
|
-
stub(subject).watch_for_output
|
|
129
|
-
stub(subject).watch_for_termination
|
|
130
|
-
subject.start
|
|
131
|
-
Process.waitall
|
|
132
|
-
mock(subject).info(/started with pid \d+/, "utf8.1", anything)
|
|
133
|
-
mock(subject).info("\xff\x03\n", "utf8.1", anything)
|
|
134
|
-
subject.send(:poll_readers)
|
|
135
|
-
subject.send(:poll_readers)
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
104
|
end
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
require "spec_helper"
|
|
2
|
-
require "foreman/
|
|
2
|
+
require "foreman/engine"
|
|
3
|
+
require "foreman/export"
|
|
3
4
|
|
|
4
|
-
describe "Foreman::Export::Base" do
|
|
5
|
+
describe "Foreman::Export::Base", :fakefs do
|
|
5
6
|
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
|
|
6
7
|
let(:location) { "/tmp/init" }
|
|
7
|
-
let(:engine) { Foreman::Engine.new(procfile) }
|
|
8
|
+
let(:engine) { Foreman::Engine.new().load_procfile(procfile) }
|
|
8
9
|
let(:subject) { Foreman::Export::Base.new(location, engine) }
|
|
9
10
|
|
|
10
11
|
it "has a say method for displaying info" do
|
|
@@ -12,10 +13,6 @@ describe "Foreman::Export::Base" do
|
|
|
12
13
|
subject.send(:say, "foo")
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
it "export needs to be overridden" do
|
|
16
|
-
lambda { subject.export }.should raise_error("export method must be overridden")
|
|
17
|
-
end
|
|
18
|
-
|
|
19
16
|
it "raises errors as a Foreman::Export::Exception" do
|
|
20
17
|
lambda { subject.send(:error, "foo") }.should raise_error(Foreman::Export::Exception, "foo")
|
|
21
18
|
end
|
|
@@ -4,10 +4,11 @@ require "foreman/export/bluepill"
|
|
|
4
4
|
require "tmpdir"
|
|
5
5
|
|
|
6
6
|
describe Foreman::Export::Bluepill, :fakefs do
|
|
7
|
-
let(:procfile)
|
|
8
|
-
let(:
|
|
9
|
-
let(:
|
|
10
|
-
let(:
|
|
7
|
+
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
|
|
8
|
+
let(:formation) { nil }
|
|
9
|
+
let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
|
|
10
|
+
let(:options) { Hash.new }
|
|
11
|
+
let(:bluepill) { Foreman::Export::Bluepill.new("/tmp/init", engine, options) }
|
|
11
12
|
|
|
12
13
|
before(:each) { load_export_templates_into_fakefs("bluepill") }
|
|
13
14
|
before(:each) { stub(bluepill).say }
|
|
@@ -24,8 +25,8 @@ describe Foreman::Export::Bluepill, :fakefs do
|
|
|
24
25
|
bluepill.export
|
|
25
26
|
end
|
|
26
27
|
|
|
27
|
-
context
|
|
28
|
-
let(:
|
|
28
|
+
context "with a process formation" do
|
|
29
|
+
let(:formation) { "alpha=2" }
|
|
29
30
|
|
|
30
31
|
it "exports to the filesystem with concurrency" do
|
|
31
32
|
bluepill.export
|
|
@@ -4,12 +4,12 @@ require "foreman/export/inittab"
|
|
|
4
4
|
require "tmpdir"
|
|
5
5
|
|
|
6
6
|
describe Foreman::Export::Inittab, :fakefs do
|
|
7
|
-
let(:
|
|
8
|
-
let(:
|
|
9
|
-
let(:
|
|
10
|
-
let(:engine)
|
|
11
|
-
let(:options)
|
|
12
|
-
let(:inittab)
|
|
7
|
+
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
|
|
8
|
+
let(:location) { "/tmp/inittab" }
|
|
9
|
+
let(:formation) { nil }
|
|
10
|
+
let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
|
|
11
|
+
let(:options) { Hash.new }
|
|
12
|
+
let(:inittab) { Foreman::Export::Inittab.new(location, engine, options) }
|
|
13
13
|
|
|
14
14
|
before(:each) { load_export_templates_into_fakefs("inittab") }
|
|
15
15
|
before(:each) { stub(inittab).say }
|
|
@@ -29,7 +29,7 @@ describe Foreman::Export::Inittab, :fakefs do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
context "with concurrency" do
|
|
32
|
-
let(:
|
|
32
|
+
let(:formation) { "alpha=2" }
|
|
33
33
|
|
|
34
34
|
it "exports to the filesystem with concurrency" do
|
|
35
35
|
inittab.export
|
|
@@ -5,20 +5,17 @@ require "tmpdir"
|
|
|
5
5
|
|
|
6
6
|
describe Foreman::Export::Launchd, :fakefs do
|
|
7
7
|
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
|
|
8
|
-
let(:engine) { Foreman::Engine.new(procfile) }
|
|
9
8
|
let(:options) { Hash.new }
|
|
10
|
-
let(:
|
|
9
|
+
let(:engine) { Foreman::Engine.new().load_procfile(procfile) }
|
|
10
|
+
let(:launchd) { Foreman::Export::Launchd.new("/tmp/init", engine, options) }
|
|
11
11
|
|
|
12
12
|
before(:each) { load_export_templates_into_fakefs("launchd") }
|
|
13
13
|
before(:each) { stub(launchd).say }
|
|
14
14
|
|
|
15
15
|
it "exports to the filesystem" do
|
|
16
16
|
launchd.export
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
normalize_space(File.read("/tmp/init/app-bravo-1.plist")).should == normalize_space(example_export_file("launchd/launchd-b.default"))
|
|
21
|
-
|
|
17
|
+
File.read("/tmp/init/app-alpha-1.plist").should == example_export_file("launchd/launchd-a.default")
|
|
18
|
+
File.read("/tmp/init/app-bravo-1.plist").should == example_export_file("launchd/launchd-b.default")
|
|
22
19
|
end
|
|
23
20
|
|
|
24
21
|
end
|
|
@@ -5,33 +5,28 @@ require "tmpdir"
|
|
|
5
5
|
|
|
6
6
|
describe Foreman::Export::Runit, :fakefs do
|
|
7
7
|
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile", 'bar=baz') }
|
|
8
|
-
let(:engine)
|
|
9
|
-
let(:
|
|
8
|
+
let(:engine) { Foreman::Engine.new(:formation => "alpha=2,bravo=1").load_procfile(procfile) }
|
|
9
|
+
let(:options) { Hash.new }
|
|
10
|
+
let(:runit) { Foreman::Export::Runit.new('/tmp/init', engine, options) }
|
|
10
11
|
|
|
11
12
|
before(:each) { load_export_templates_into_fakefs("runit") }
|
|
12
13
|
before(:each) { stub(runit).say }
|
|
13
14
|
before(:each) { stub(FakeFS::FileUtils).chmod }
|
|
14
15
|
|
|
15
16
|
it "exports to the filesystem" do
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
engine.env["BAR"] = "baz"
|
|
18
18
|
runit.export
|
|
19
19
|
|
|
20
|
-
File.read("/tmp/init/app-alpha-1/run").should
|
|
21
|
-
File.read("/tmp/init/app-alpha-1/log/run").should
|
|
22
|
-
example_export_file('runit/app-alpha-1-log-run')
|
|
20
|
+
File.read("/tmp/init/app-alpha-1/run").should == example_export_file('runit/app-alpha-1/run')
|
|
21
|
+
File.read("/tmp/init/app-alpha-1/log/run").should == example_export_file('runit/app-alpha-1/log/run')
|
|
23
22
|
File.read("/tmp/init/app-alpha-1/env/PORT").should == "5000\n"
|
|
24
|
-
File.read("/tmp/init/app-alpha-1/env/BAR").should
|
|
25
|
-
|
|
26
|
-
File.read("/tmp/init/app-alpha-2/run").should
|
|
27
|
-
File.read("/tmp/init/app-alpha-2/log/run").should ==
|
|
28
|
-
example_export_file('runit/app-alpha-2-log-run')
|
|
23
|
+
File.read("/tmp/init/app-alpha-1/env/BAR").should == "baz\n"
|
|
24
|
+
File.read("/tmp/init/app-alpha-2/run").should == example_export_file('runit/app-alpha-2/run')
|
|
25
|
+
File.read("/tmp/init/app-alpha-2/log/run").should == example_export_file('runit/app-alpha-2/log/run')
|
|
29
26
|
File.read("/tmp/init/app-alpha-2/env/PORT").should == "5001\n"
|
|
30
|
-
File.read("/tmp/init/app-alpha-2/env/BAR").should
|
|
31
|
-
|
|
32
|
-
File.read("/tmp/init/app-bravo-1/run").should
|
|
33
|
-
File.read("/tmp/init/app-bravo-1/log/run").should ==
|
|
34
|
-
example_export_file('runit/app-bravo-1-log-run')
|
|
27
|
+
File.read("/tmp/init/app-alpha-2/env/BAR").should == "baz\n"
|
|
28
|
+
File.read("/tmp/init/app-bravo-1/run").should == example_export_file('runit/app-bravo-1/run')
|
|
29
|
+
File.read("/tmp/init/app-bravo-1/log/run").should == example_export_file('runit/app-bravo-1/log/run')
|
|
35
30
|
File.read("/tmp/init/app-bravo-1/env/PORT").should == "5100\n"
|
|
36
31
|
end
|
|
37
32
|
|