Permalink
Browse files

Use system nats instead of nats-util in tests

Now we can pass all the spec tests on dev_setup box by using system nats

Change-Id: I105f0278d6632c95137cb779a858ebc2dd3223f2
  • Loading branch information...
1 parent f2ed7dd commit 2cbeac10975854395bdfc63a6a80e61bc9806170 @EagleChen EagleChen committed Jul 23, 2012
Showing with 32 additions and 4 deletions.
  1. +14 −3 Rakefile
  2. +18 −1 spec/helper/base_spec_helper.rb
View
@@ -43,15 +43,26 @@ namespace "bundler" do
end
namespace "test" do
+ def run_spec
+ Dir.chdir("spec")
+ if `ps ax | grep nats-server | grep -v grep` == ""
+ sh "nats-server &"
+ yield
+ sh "pkill -f nats-server"
+ else
+ yield
+ end
+ end
+
task "spec" do |t|
- sh("cd spec && ../bin/nats-util start && rake spec && ../bin/nats-util stop")
+ run_spec { sh "rake spec" }
end
task "spec:rcov" do |t|
- sh("cd spec && ../bin/nats-util start && rake simcov && ../bin/nats-util stop")
+ run_spec { sh "rake simcov" }
end
task "spec:ci" do |t|
- sh("cd spec && ../bin/nats-util start && rake spec:ci && ../bin/nats-util stop")
+ run_spec { sh "rake spec:ci" }
end
end
@@ -4,8 +4,25 @@ class BaseTests
module Options
+ def self.nats_uri
+ uri = "nats://localhost:4222"
+ if ENV["CLOUD_FOUNDRY_CONFIG_PATH"]
+ config = YAML.load_file(File.join(ENV["CLOUD_FOUNDRY_CONFIG_PATH"],
+ "nats_server", "nats_server.yml"))
+ if config['net']
+ if (auth = config['authorization']) && auth['user']
+ uri = "nats://#{auth['user']}:#{auth['password']}@"\
+ "#{config['net']}:#{config['port']}"
+ else
+ uri = "nats://#{config['net']}:#{config['port']}"
+ end
+ end
+ end
+ uri
+ end
+
LOGGER = Logger.new(STDOUT)
- NATS_URI = "nats://localhost:4222"
+ NATS_URI = nats_uri
IP_ROUTE = "127.0.0.1"
NODE_TIMEOUT = 5
PLAN = "free"

0 comments on commit 2cbeac1

Please sign in to comment.