Permalink
Browse files

Add cfruntime-tests

Change-Id: Ia7f728bda3392e3a6a940575b004035d7f164d7e
  • Loading branch information...
Jennifer Hickey
Jennifer Hickey committed Dec 15, 2011
1 parent af46612 commit f7cfcb5c2b2352bc39dd78a2db92c1c7a7bc69bb
@@ -2,4 +2,4 @@ Gemfile.lock
.build
*.gem
.DS_Store
-**/spec/spec
+spec/spec
@@ -32,7 +32,7 @@ class Connection
end
end
else
- puts "Auto-reconfiguration not supported for this Redis version. " +
+ puts "Auto-reconfiguration not supported for this Mongo version. " +
"Found: #{Mongo::VERSION}. Required: #{AutoReconfiguration::SUPPORTED_MONGO_VERSION} or higher."
end
rescue LoadError
@@ -0,0 +1,4 @@
+.build
+*.gem
+.DS_Store
+**/spec/spec
View
@@ -0,0 +1,7 @@
+source "http://rubygems.org"
+gem "rake", "~> 0.9.2"
+gem "rcov", "~> 0.9.10"
+gem "rspec", "~> 2.6.0"
+gem "ci_reporter", "~> 1.6.5"
+gem "vmc"
+gem "curb"
@@ -0,0 +1,46 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ addressable (2.2.6)
+ builder (3.0.0)
+ ci_reporter (1.6.8)
+ builder (>= 2.1.2)
+ curb (0.7.16)
+ diff-lcs (1.1.3)
+ interact (0.3)
+ json_pure (1.5.4)
+ spruz (~> 0.2.8)
+ mime-types (1.17.2)
+ rake (0.9.2.2)
+ rcov (0.9.11)
+ rest-client (1.6.7)
+ mime-types (>= 1.16)
+ rspec (2.6.0)
+ rspec-core (~> 2.6.0)
+ rspec-expectations (~> 2.6.0)
+ rspec-mocks (~> 2.6.0)
+ rspec-core (2.6.4)
+ rspec-expectations (2.6.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.6.0)
+ rubyzip2 (2.0.2)
+ spruz (0.2.13)
+ terminal-table (1.4.4)
+ vmc (0.3.14)
+ addressable (~> 2.2.6)
+ interact (~> 0.3.0)
+ json_pure (~> 1.5.1)
+ rest-client (>= 1.6.1, < 1.7.0)
+ rubyzip2 (~> 2.0.1)
+ terminal-table (~> 1.4.2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ ci_reporter (~> 1.6.5)
+ curb
+ rake (~> 0.9.2)
+ rcov (~> 0.9.10)
+ rspec (~> 2.6.0)
+ vmc
View
@@ -0,0 +1,25 @@
+require 'rake'
+require 'ci/reporter/rake/rspec'
+
+desc "Run specs"
+task "spec" => ["test:spec"]
+
+desc "Run specs using RCov"
+task "spec:rcov" => ["test:spec:rcov"]
+
+desc "Run specs producing results for CI"
+task "ci" => ["ci:spec"]
+
+namespace "test" do
+ task "spec" do |t|
+ sh("cd spec && rake spec")
+ end
+
+ task "spec:rcov" do |t|
+ sh("cd spec && rake spec:rcov")
+ end
+end
+
+namespace :ci do
+ task "spec" => ["ci:setup:rspec", "^spec"]
+end
@@ -0,0 +1,26 @@
+require 'tempfile'
+
+require 'rubygems'
+require 'bundler/setup'
+Bundler.require(:default, :test)
+
+require 'rake'
+require 'rspec'
+require 'rspec/core/rake_task'
+
+coverage_dir = File.expand_path(File.join(File.dirname(__FILE__), "coverage"))
+
+ignore_pattern = 'spec,[.]bundle,[/]gems[/]'
+
+RSpec::Core::RakeTask.new do |t|
+ t.pattern = "**/*_spec.rb"
+ t.rspec_opts = ["--format", "documentation", "--colour"]
+end
+
+desc "Run specs using RCov"
+RSpec::Core::RakeTask.new("spec:rcov") do |t|
+ t.pattern = "**/*_spec.rb"
+ t.rspec_opts = []
+ t.rcov = true
+ t.rcov_opts = %W{--exclude osx\/objc,gems\/,spec\/,features\/ -o "#{coverage_dir}"}
+end
@@ -0,0 +1,7 @@
+source "http://rubygems.org"
+# Without any bound services, app runs on sqlite3
+#.. but may also be staged with mysql
+gem 'sinatra'
+gem 'json_pure'
+gem 'amqp'
+gem 'cf-runtime'
@@ -0,0 +1,33 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ amq-client (0.8.7)
+ amq-protocol (>= 0.8.4)
+ eventmachine
+ amq-protocol (0.8.4)
+ amqp (0.8.4)
+ amq-client (~> 0.8.7)
+ amq-protocol (~> 0.8.4)
+ eventmachine
+ cf-runtime (0.0.1)
+ crack (~> 0.3.1)
+ crack (0.3.1)
+ eventmachine (0.12.10)
+ json_pure (1.6.3)
+ rack (1.3.5)
+ rack-protection (1.1.4)
+ rack
+ sinatra (1.3.1)
+ rack (~> 1.3, >= 1.3.4)
+ rack-protection (~> 1.1, >= 1.1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ tilt (1.3.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ amqp
+ cf-runtime
+ json_pure
+ sinatra
@@ -0,0 +1,41 @@
+require 'sinatra'
+require 'json/pure'
+require 'uri'
+require 'amqp'
+require 'cfruntime'
+
+get '/env' do
+ ENV['VMC_SERVICES']
+end
+
+get '/' do
+ 'hello from sinatra'
+end
+
+not_found do
+ 'This is nowhere to be found.'
+end
+
+post '/service/amqp/:key' do
+ value = request.env["rack.input"].read
+ write_to_rabbit(params[:key], value)
+end
+
+get '/service/amqp/:key' do
+ options.amqp_option_msg
+end
+
+def write_to_rabbit(key, value)
+ EventMachine.run do
+ connection = CFRuntime::AMQPClient.create_from_svc('test-cfruntime-svc-test-rabbit')
+ channel = AMQP::Channel.new(connection)
+ queue = channel.queue(key, :auto_delete => true)
+ exchange = channel.default_exchange
+ queue.subscribe do |payload|
+ puts "Received a message: #{payload}. Disconnecting..."
+ set :amqp_option_msg, payload
+ connection.close { EventMachine.stop }
+ end
+ exchange.publish value, :routing_key => queue.name, :app_id => "Hello world"
+ end
+end
@@ -0,0 +1,7 @@
+source "http://rubygems.org"
+# Without any bound services, app runs on sqlite3
+#.. but may also be staged with mysql
+gem 'sinatra'
+gem 'json_pure'
+gem 'amqp'
+gem 'cf-runtime'
@@ -0,0 +1,33 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ amq-client (0.8.7)
+ amq-protocol (>= 0.8.4)
+ eventmachine
+ amq-protocol (0.8.4)
+ amqp (0.8.4)
+ amq-client (~> 0.8.7)
+ amq-protocol (~> 0.8.4)
+ eventmachine
+ cf-runtime (0.0.1)
+ crack (~> 0.3.1)
+ crack (0.3.1)
+ eventmachine (0.12.10)
+ json_pure (1.6.3)
+ rack (1.3.5)
+ rack-protection (1.1.4)
+ rack
+ sinatra (1.3.1)
+ rack (~> 1.3, >= 1.3.4)
+ rack-protection (~> 1.1, >= 1.1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ tilt (1.3.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ amqp
+ cf-runtime
+ json_pure
+ sinatra
@@ -0,0 +1,41 @@
+require 'sinatra'
+require 'json/pure'
+require 'uri'
+require 'amqp'
+require 'cfruntime'
+
+get '/env' do
+ ENV['VMC_SERVICES']
+end
+
+get '/' do
+ 'hello from sinatra'
+end
+
+not_found do
+ 'This is nowhere to be found.'
+end
+
+post '/service/amqp/:key' do
+ value = request.env["rack.input"].read
+ write_to_rabbit(params[:key], value)
+end
+
+get '/service/amqp/:key' do
+ options.amqp_option_msg
+end
+
+def write_to_rabbit(key, value)
+ EventMachine.run do
+ connection = CFRuntime::AMQPClient.create
+ channel = AMQP::Channel.new(connection)
+ queue = channel.queue(key, :auto_delete => true)
+ exchange = channel.default_exchange
+ queue.subscribe do |payload|
+ puts "Received a message: #{payload}. Disconnecting..."
+ set :amqp_option_msg, payload
+ connection.close { EventMachine.stop }
+ end
+ exchange.publish value, :routing_key => queue.name, :app_id => "Hello world"
+ end
+end
@@ -0,0 +1,9 @@
+source "http://rubygems.org"
+gem 'mysql2'
+gem 'mongo'
+gem 'redis'
+gem 'sinatra'
+gem 'json'
+gem 'carrot'
+gem 'pg',"~> 0.11.0"
+gem 'cf-runtime'
@@ -0,0 +1,35 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ bson (1.5.2)
+ carrot (1.2.0)
+ cf-runtime (0.0.1)
+ crack (~> 0.3.1)
+ crack (0.3.1)
+ json (1.6.3)
+ mongo (1.5.2)
+ bson (= 1.5.2)
+ mysql2 (0.3.11)
+ pg (0.11.0)
+ rack (1.3.5)
+ rack-protection (1.1.4)
+ rack
+ redis (2.2.2)
+ sinatra (1.3.1)
+ rack (~> 1.3, >= 1.3.4)
+ rack-protection (~> 1.1, >= 1.1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ tilt (1.3.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ carrot
+ cf-runtime
+ json
+ mongo
+ mysql2
+ pg (~> 0.11.0)
+ redis
+ sinatra
Oops, something went wrong.

0 comments on commit f7cfcb5

Please sign in to comment.