forked from dblock/heroku-forward
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3198c58
commit 5a050b8
Showing
4 changed files
with
136 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,93 @@ | ||
require 'spec_helper' | ||
require 'heroku/forward/backends/thin' | ||
unless RUBY_PLATFORM == "java" | ||
require 'spec_helper' | ||
require 'heroku/forward/backends/thin' | ||
|
||
describe Heroku::Forward::Backends::Thin do | ||
|
||
describe "without ssl" do | ||
let(:backend) do | ||
Heroku::Forward::Backends::Thin.new | ||
end | ||
|
||
after do | ||
backend.terminate! | ||
end | ||
|
||
it "#spawned?" do | ||
backend.spawned?.should be_false | ||
end | ||
|
||
it "doesn't generate socket file" do | ||
File.exists?(backend.socket).should_not be_true | ||
end | ||
describe Heroku::Forward::Backends::Thin do | ||
describe "without ssl" do | ||
let(:backend) do | ||
Heroku::Forward::Backends::Thin.new | ||
end | ||
|
||
context "checks" do | ||
it "checks for application" do | ||
expect { | ||
backend.spawn! | ||
}.to raise_error Heroku::Forward::Errors::MissingBackendOptionError | ||
after do | ||
backend.terminate! | ||
end | ||
|
||
it "checks that the application file exists" do | ||
expect { | ||
backend.application = 'spec/foobar' | ||
backend.spawn! | ||
}.to raise_error Heroku::Forward::Errors::MissingBackendApplicationError | ||
it "#spawned?" do | ||
backend.spawned?.should be_false | ||
end | ||
|
||
end | ||
|
||
describe "#spawn!" do | ||
before do | ||
backend.application = "spec/support/app.ru" | ||
it "doesn't generate socket file" do | ||
File.exists?(backend.socket).should_not be_true | ||
end | ||
|
||
it "starts successfully" do | ||
backend.spawn!.should_not == 0 | ||
sleep 2 | ||
backend.terminate!.should be_true | ||
|
||
context "checks" do | ||
it "checks for application" do | ||
expect { | ||
backend.spawn! | ||
}.to raise_error Heroku::Forward::Errors::MissingBackendOptionError | ||
end | ||
|
||
it "checks that the application file exists" do | ||
expect { | ||
backend.application = 'spec/foobar' | ||
backend.spawn! | ||
}.to raise_error Heroku::Forward::Errors::MissingBackendApplicationError | ||
end | ||
|
||
end | ||
|
||
it "generates socket file that outlives garbage-collection" do | ||
backend.spawn! | ||
sleep 2 | ||
lambda { GC.start }.should_not raise_error | ||
File.exists?(backend.socket).should be_true | ||
|
||
describe "#spawn!" do | ||
before do | ||
backend.application = "spec/support/app.ru" | ||
end | ||
|
||
it "starts successfully" do | ||
backend.spawn!.should_not == 0 | ||
sleep 2 | ||
backend.terminate!.should be_true | ||
end | ||
|
||
it "generates socket file that outlives garbage-collection" do | ||
backend.spawn! | ||
sleep 2 | ||
lambda { GC.start }.should_not raise_error | ||
File.exists?(backend.socket).should be_true | ||
end | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
describe "with SSL" do | ||
let(:application) { "spec/support/app.ru" } | ||
let(:mock_ssl_cert_file) { "foo" } | ||
let(:mock_ssl_key_file) { "bar" } | ||
let(:socket) { "foobar" } | ||
describe "with SSL" do | ||
let(:application) { "spec/support/app.ru" } | ||
let(:mock_ssl_cert_file) { "foo" } | ||
let(:mock_ssl_key_file) { "bar" } | ||
let(:socket) { "foobar" } | ||
|
||
let(:backend) do | ||
Heroku::Forward::Backends::Thin.new({ | ||
:application => application, | ||
:socket => socket, | ||
:ssl => true, | ||
:ssl_verify => true, | ||
:ssl_key_file => mock_ssl_key_file, | ||
:ssl_cert_file => mock_ssl_cert_file | ||
}) | ||
end | ||
let(:backend) do | ||
Heroku::Forward::Backends::Thin.new({ | ||
:application => application, | ||
:socket => socket, | ||
:ssl => true, | ||
:ssl_verify => true, | ||
:ssl_key_file => mock_ssl_key_file, | ||
:ssl_cert_file => mock_ssl_cert_file | ||
}) | ||
end | ||
|
||
it "forward SSL arguments on spawning" do | ||
cmd = [] | ||
cmd.push "thin" | ||
cmd.push "start" | ||
cmd.push "-R", application | ||
cmd.push "--socket", socket | ||
cmd.push "-e", "development" | ||
cmd.push "--ssl" | ||
cmd.push "--ssl-key-file", mock_ssl_key_file | ||
cmd.push "--ssl-cert-file", mock_ssl_cert_file | ||
cmd.push "--ssl-verify" | ||
Spoon.should_receive(:spawnp).with(* cmd).and_return(0) | ||
backend.spawn! | ||
it "forward SSL arguments on spawning" do | ||
cmd = [] | ||
cmd.push "thin" | ||
cmd.push "start" | ||
cmd.push "-R", application | ||
cmd.push "--socket", socket | ||
cmd.push "-e", "development" | ||
cmd.push "--ssl" | ||
cmd.push "--ssl-key-file", mock_ssl_key_file | ||
cmd.push "--ssl-cert-file", mock_ssl_cert_file | ||
cmd.push "--ssl-verify" | ||
Spoon.should_receive(:spawnp).with(* cmd).and_return(0) | ||
backend.spawn! | ||
end | ||
end | ||
|
||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
require 'spec_helper' | ||
require 'heroku/forward/backends/unicorn' | ||
unless RUBY_PLATFORM == "java" | ||
require 'spec_helper' | ||
require 'heroku/forward/backends/unicorn' | ||
|
||
describe Heroku::Forward::Backends::Unicorn do | ||
describe Heroku::Forward::Backends::Unicorn do | ||
|
||
describe "with defaults" do | ||
let(:backend) do | ||
Heroku::Forward::Backends::Unicorn.new | ||
end | ||
|
||
after do | ||
backend.terminate! | ||
end | ||
describe "with defaults" do | ||
let(:backend) do | ||
Heroku::Forward::Backends::Unicorn.new | ||
end | ||
|
||
it "#spawned?" do | ||
backend.spawned?.should be_false | ||
end | ||
after do | ||
backend.terminate! | ||
end | ||
|
||
context "checks" do | ||
it "checks for application" do | ||
expect { | ||
backend.spawn! | ||
}.to raise_error Heroku::Forward::Errors::MissingBackendOptionError | ||
it "#spawned?" do | ||
backend.spawned?.should be_false | ||
end | ||
|
||
it "checks that the application file exists" do | ||
expect { | ||
backend.application = 'spec/foobar' | ||
backend.spawn! | ||
}.to raise_error Heroku::Forward::Errors::MissingBackendApplicationError | ||
context "checks" do | ||
it "checks for application" do | ||
expect { | ||
backend.spawn! | ||
}.to raise_error Heroku::Forward::Errors::MissingBackendOptionError | ||
end | ||
|
||
it "checks that the application file exists" do | ||
expect { | ||
backend.application = 'spec/foobar' | ||
backend.spawn! | ||
}.to raise_error Heroku::Forward::Errors::MissingBackendApplicationError | ||
end | ||
|
||
end | ||
|
||
it "#spawn!" do | ||
backend.application = "spec/support/app.ru" | ||
backend.spawn!.should_not == 0 | ||
sleep 2 | ||
backend.terminate!.should be_true | ||
end | ||
end | ||
|
||
it "#spawn!" do | ||
backend.application = "spec/support/app.ru" | ||
backend.spawn!.should_not == 0 | ||
sleep 2 | ||
backend.terminate!.should be_true | ||
end | ||
end | ||
|
||
context "constructs command" do | ||
|
||
let(:backend) do | ||
Heroku::Forward::Backends::Unicorn.new( | ||
:application => 'spec/support/app.ru', | ||
:env => 'test', | ||
:socket => '/tmp/unicorn.sock', | ||
:config_file => 'spec/support/unicorn.rb' | ||
) | ||
end | ||
context "constructs command" do | ||
|
||
it "forwards arguments to spawner" do | ||
Spoon.should_receive(:spawnp).with(*%w{unicorn --env test --config-file spec/support/unicorn.rb --listen /tmp/unicorn.sock spec/support/app.ru}).and_return(0) | ||
backend.spawn! | ||
end | ||
let(:backend) do | ||
Heroku::Forward::Backends::Unicorn.new( | ||
:application => 'spec/support/app.ru', | ||
:env => 'test', | ||
:socket => '/tmp/unicorn.sock', | ||
:config_file => 'spec/support/unicorn.rb' | ||
) | ||
end | ||
|
||
it "forwards arguments to spawner" do | ||
Spoon.should_receive(:spawnp).with(*%w{unicorn --env test --config-file spec/support/unicorn.rb --listen /tmp/unicorn.sock spec/support/app.ru}).and_return(0) | ||
backend.spawn! | ||
end | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5a050b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am looking forward to a pull request :)
5a050b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5a050b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had looked at the EM code a while ago, there's quite a bit to write to get unix socket support into that. You should open an issue in em-proxy with whatever detail you have so far, someone will surely want the challenge if you're not already on it.
5a050b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened igrigorik/em-proxy#39 actually, wanted to reference it in README.