forked from cloudfoundry-attic/vcap-tools
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
periodically (given the router.start message) announce the routes
- Loading branch information
Gregg Van Hove and Sarah Chandler
committed
Jun 26, 2013
1 parent
5e9e431
commit 120b5ba
Showing
48 changed files
with
281 additions
and
79 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
source :rubygems | ||
source 'https://rubygems.org' | ||
|
||
gem "eventmachine" | ||
gem "nats" | ||
gem "vcap_logging" | ||
gem "yajl-ruby" | ||
gem "yajl-ruby" | ||
gem "vcap-concurrency", :git => "https://github.com/cloudfoundry/vcap-concurrency.git" | ||
gem "cf-message-bus", :github => "cloudfoundry/cf-message-bus" | ||
|
||
group :development, :test do | ||
gem "rspec" | ||
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,21 +1,56 @@ | ||
GIT | ||
remote: git://github.com/cloudfoundry/cf-message-bus.git | ||
revision: 88a9fc0fa75fca29a8fd1fb47c6504a252020a0f | ||
specs: | ||
cf-message-bus (0.0.1) | ||
eventmachine (~> 1.0.0) | ||
nats (= 0.4.26) | ||
vcap-concurrency | ||
yajl-ruby | ||
|
||
GIT | ||
remote: https://github.com/cloudfoundry/vcap-concurrency.git | ||
revision: dfddfb0bc0e599b94390ef8c026f71c4ddc323f7 | ||
specs: | ||
vcap-concurrency (0.1.0) | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
remote: https://rubygems.org/ | ||
specs: | ||
daemons (1.1.4) | ||
eventmachine (0.12.10) | ||
json_pure (1.5.3) | ||
nats (0.4.10) | ||
daemons (>= 1.1.0) | ||
daemons (1.1.9) | ||
diff-lcs (1.2.4) | ||
eventmachine (1.0.3) | ||
json_pure (1.8.0) | ||
nats (0.4.26) | ||
daemons (>= 1.1.5) | ||
eventmachine (>= 0.12.10) | ||
json_pure (>= 1.5.1) | ||
vcap_logging (0.1.0) | ||
yajl-ruby (0.8.2) | ||
json_pure (>= 1.7.3) | ||
thin (>= 1.4.1) | ||
rack (1.5.2) | ||
rake (10.1.0) | ||
rspec (2.13.0) | ||
rspec-core (~> 2.13.0) | ||
rspec-expectations (~> 2.13.0) | ||
rspec-mocks (~> 2.13.0) | ||
rspec-core (2.13.1) | ||
rspec-expectations (2.13.0) | ||
diff-lcs (>= 1.1.3, < 2.0) | ||
rspec-mocks (2.13.1) | ||
thin (1.5.1) | ||
daemons (>= 1.0.9) | ||
eventmachine (>= 0.12.6) | ||
rack (>= 1.0.0) | ||
vcap_logging (0.1.4) | ||
rake | ||
yajl-ruby (1.1.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
cf-message-bus! | ||
eventmachine | ||
nats | ||
rspec | ||
vcap-concurrency! | ||
vcap_logging | ||
yajl-ruby |
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require_relative '../lib/router_registrar' | ||
require 'cf_message_bus/mock_message_bus' | ||
|
||
module RouterRegistrar | ||
describe RouterRegistrar do | ||
let(:message_bus) { CfMessageBus::MockMessageBus.new } | ||
let(:bus_uri) { "a message bus uri" } | ||
let(:config) do | ||
{ | ||
'mbus' => bus_uri, | ||
'host' => 'registrar.host', | ||
'port' => 98765, | ||
'uri' => 'fancyuri', | ||
'tags' => 'taggy goodness', | ||
'logging' => {} | ||
} | ||
end | ||
before do | ||
EM.stub(:add_periodic_timer) | ||
EM.stub(:cancel_timer) | ||
Config.configure(config) | ||
Config.stub(:logger).and_return(double(:logger, info: nil, error: nil, debug: nil)) | ||
CfMessageBus::MessageBus.stub(:new).with(uri: bus_uri).and_return(message_bus) | ||
end | ||
|
||
describe "#register_with_router" do | ||
let(:registration_message) do | ||
{ | ||
host: config['host'], | ||
port: config['port'], | ||
uris: Array(config['uri']), | ||
tags: config['tags'] | ||
} | ||
end | ||
|
||
before do | ||
subject | ||
end | ||
|
||
it 'should register routes immediately' do | ||
expect(message_bus).to have_published_with_message("router.register", registration_message) | ||
end | ||
|
||
it 'should registers upon a router.start message' do | ||
message_bus.clear_published_messages | ||
message_bus.publish("router.start", {minimumRegisterIntervalInSeconds: 33}) | ||
|
||
expect(message_bus).to have_published_with_message("router.register", registration_message) | ||
end | ||
|
||
it 'should periodically register with the router' do | ||
EM.should_receive(:add_periodic_timer).with(33).and_return(:periodic_timer) | ||
message_bus.publish("router.start", {minimumRegisterIntervalInSeconds: 33}) | ||
end | ||
|
||
it 'should clear an existing timer when registering a new one' do | ||
EM.should_receive(:add_periodic_timer).with(33).and_return(:periodic_timer) | ||
message_bus.publish("router.start", {minimumRegisterIntervalInSeconds: 33}) | ||
|
||
EM.should_receive(:cancel_timer).with(:periodic_timer) | ||
EM.should_receive(:add_periodic_timer).with(24) | ||
message_bus.publish("router.start", {minimumRegisterIntervalInSeconds: 24}) | ||
end | ||
end | ||
end | ||
end |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,6 +1,11 @@ | ||
source :rubygems | ||
source 'https://rubygems.org' | ||
|
||
gem "eventmachine" | ||
gem "nats" | ||
gem "vcap_logging" | ||
gem "yajl-ruby" | ||
gem "vcap-concurrency", :git => "https://github.com/cloudfoundry/vcap-concurrency.git" | ||
gem "cf-message-bus", :github => "cloudfoundry/cf-message-bus" | ||
|
||
group :development, :test do | ||
gem "rspec" | ||
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,21 +1,56 @@ | ||
GIT | ||
remote: git://github.com/cloudfoundry/cf-message-bus.git | ||
revision: 88a9fc0fa75fca29a8fd1fb47c6504a252020a0f | ||
specs: | ||
cf-message-bus (0.0.1) | ||
eventmachine (~> 1.0.0) | ||
nats (= 0.4.26) | ||
vcap-concurrency | ||
yajl-ruby | ||
|
||
GIT | ||
remote: https://github.com/cloudfoundry/vcap-concurrency.git | ||
revision: dfddfb0bc0e599b94390ef8c026f71c4ddc323f7 | ||
specs: | ||
vcap-concurrency (0.1.0) | ||
|
||
GEM | ||
remote: http://rubygems.org/ | ||
remote: https://rubygems.org/ | ||
specs: | ||
daemons (1.1.4) | ||
eventmachine (0.12.10) | ||
json_pure (1.5.3) | ||
nats (0.4.10) | ||
daemons (>= 1.1.0) | ||
daemons (1.1.9) | ||
diff-lcs (1.2.4) | ||
eventmachine (1.0.3) | ||
json_pure (1.8.0) | ||
nats (0.4.26) | ||
daemons (>= 1.1.5) | ||
eventmachine (>= 0.12.10) | ||
json_pure (>= 1.5.1) | ||
vcap_logging (0.1.0) | ||
yajl-ruby (0.8.2) | ||
json_pure (>= 1.7.3) | ||
thin (>= 1.4.1) | ||
rack (1.5.2) | ||
rake (10.1.0) | ||
rspec (2.13.0) | ||
rspec-core (~> 2.13.0) | ||
rspec-expectations (~> 2.13.0) | ||
rspec-mocks (~> 2.13.0) | ||
rspec-core (2.13.1) | ||
rspec-expectations (2.13.0) | ||
diff-lcs (>= 1.1.3, < 2.0) | ||
rspec-mocks (2.13.1) | ||
thin (1.5.1) | ||
daemons (>= 1.0.9) | ||
eventmachine (>= 0.12.6) | ||
rack (>= 1.0.0) | ||
vcap_logging (0.1.4) | ||
rake | ||
yajl-ruby (1.1.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
cf-message-bus! | ||
eventmachine | ||
nats | ||
rspec | ||
vcap-concurrency! | ||
vcap_logging | ||
yajl-ruby |
Oops, something went wrong.