add circus support

This commit is contained in:
Andrews Medina
2012-11-29 00:15:01 -02:00
parent 8fe86e98c8
commit 9325f2ca6d
5 changed files with 137 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
require "spec_helper"
require "foreman/engine"
require "foreman/export/circus"
require "tmpdir"
describe Foreman::Export::Circus, :fakefs do
let(:procfile) { FileUtils.mkdir_p("/tmp/app"); write_procfile("/tmp/app/Procfile") }
let(:formation) { nil }
let(:engine) { Foreman::Engine.new(:formation => formation).load_procfile(procfile) }
let(:options) { Hash.new }
let(:circus) { Foreman::Export::Circus.new("/tmp/init", engine, options) }
before(:each) { load_export_templates_into_fakefs("circus") }
before(:each) { stub(circus).say }
it "exports to the filesystem" do
circus.export
File.read("/tmp/init/app.ini").should == example_export_file("circus/app-alpha-1.ini")
end
it "cleans up if exporting into an existing dir" do
mock(FileUtils).rm("/tmp/init/app.ini")
circus.export
circus.export
end
context "with concurrency" do
let(:formation) { "alpha=2" }
it "exports to the filesystem with concurrency" do
circus.export
File.read("/tmp/init/app.ini").should == example_export_file("circus/app-alpha-2.ini")
end
end
end
@@ -0,0 +1,30 @@
[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
[watcher:app-alpha-1]
cmd = ./alpha
working_dir = /tmp/app
uid = app
stdout_stream.class = FileStream
stdout_stream.filename = /var/log/app/alpha-1.log
stderr_stream.class = FileStream
stderr_stream.filename = /var/log/app/alpha-1.error.log
copy_env = True
[env:app-alpha-1]
PORT = 5000
[watcher:app-bravo-1]
cmd = ./bravo
working_dir = /tmp/app
uid = app
stdout_stream.class = FileStream
stdout_stream.filename = /var/log/app/bravo-1.log
stderr_stream.class = FileStream
stderr_stream.filename = /var/log/app/bravo-1.error.log
copy_env = True
[env:app-bravo-1]
PORT = 5100
@@ -0,0 +1,30 @@
[circus]
check_delay = 5
endpoint = tcp://127.0.0.1:5555
[watcher:app-alpha-1]
cmd = ./alpha
working_dir = /tmp/app
uid = app
stdout_stream.class = FileStream
stdout_stream.filename = /var/log/app/alpha-1.log
stderr_stream.class = FileStream
stderr_stream.filename = /var/log/app/alpha-1.error.log
copy_env = True
[env:app-alpha-1]
PORT = 5000
[watcher:app-alpha-2]
cmd = ./alpha
working_dir = /tmp/app
uid = app
stdout_stream.class = FileStream
stdout_stream.filename = /var/log/app/alpha-2.log
stderr_stream.class = FileStream
stderr_stream.filename = /var/log/app/alpha-2.error.log
copy_env = True
[env:app-alpha-2]
PORT = 5001