Permalink
Browse files

Merge "Add test endpoints for Ruby Blob auto-reconfig"

  • Loading branch information...
2 parents 3937a38 + 4b59fa4 commit d8619cdf8d46d476da41787a56ca572443804dd4 Jennifer Hickey committed with Gerrit Code Review Nov 26, 2012
View
3 rack/app_rack_service_autoconfig/Gemfile
@@ -7,4 +7,5 @@ gem 'redis'
gem 'sinatra'
gem 'json'
gem 'carrot'
-gem 'pg'
+gem 'pg'
+gem 'aws-s3'
View
8 rack/app_rack_service_autoconfig/Gemfile.lock
@@ -1,9 +1,15 @@
GEM
remote: http://rubygems.org/
specs:
+ aws-s3 (0.6.3)
+ builder
+ mime-types
+ xml-simple
bson (1.2.4)
+ builder (3.1.4)
carrot (1.2.0)
json (1.4.6)
+ mime-types (1.19)
mongo (1.2.4)
bson (>= 1.2.4)
mysql2 (0.3.2)
@@ -14,11 +20,13 @@ GEM
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
tilt (1.3)
+ xml-simple (1.1.2)
PLATFORMS
ruby
DEPENDENCIES
+ aws-s3
carrot
json
mongo
View
22 rack/app_rack_service_autoconfig/app.rb
@@ -6,6 +6,7 @@
require 'carrot'
require 'uri'
require 'pg'
+require 'aws/s3'
class RackAutoConfigApp < Sinatra::Base
get '/env' do
@@ -101,6 +102,20 @@ class RackAutoConfigApp < Sinatra::Base
read_from_rabbit(params[:key], client)
end
+post '/service/blob/:object' do
+ load_blob
+ begin
+ AWS::S3::Bucket.create("datavalues")
+ rescue
+ end
+ AWS::S3::S3Object.store(params[:object], request.body, "datavalues")
+end
+
+get '/service/blob/:object' do
+ load_blob
+ AWS::S3::S3Object.value(params[:object], "datavalues")
+end
+
def load_redis
Redis.new({:host => '127.0.0.1', :port => 6379, :password => 'testpw'})
end
@@ -124,6 +139,13 @@ def load_postgresql
client
end
+def load_blob
+ AWS::S3::Base.establish_connection!(
+ :access_key_id => "myid",
+ :secret_access_key => "mypwd"
+ )
+end
+
def rabbit_service
Carrot.new( :host => '127.0.0.1', :port => 12345, :user => 'testuser', :pass => 'testpass', :vhost => 'vhost' )
end
View
3 rails3/app_rails_service_autoconfig/Gemfile
@@ -8,4 +8,5 @@ gem 'redis'
gem 'mongo'
gem 'mongo_mapper'
gem 'carrot'
-gem 'pg'
+gem 'pg'
+gem 'aws-s3'
View
6 rails3/app_rails_service_autoconfig/Gemfile.lock
@@ -29,6 +29,10 @@ GEM
activesupport (= 3.0.6)
activesupport (3.0.6)
arel (2.0.9)
+ aws-s3 (0.6.3)
+ builder
+ mime-types
+ xml-simple
bson (1.2.4)
builder (2.1.2)
carrot (1.2.0)
@@ -84,11 +88,13 @@ GEM
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.26)
+ xml-simple (1.1.2)
PLATFORMS
ruby
DEPENDENCIES
+ aws-s3
carrot
json
mongo
View
8 rails3/app_rails_service_autoconfig/app/controllers/service_controller.rb
@@ -30,6 +30,12 @@ def service
elsif params[:service] == 'rabbitmq'
client = rabbit_service
value = write_to_rabbit(params[:key], value, client)
+ elsif params[:service] == 'blob'
+ begin
+ AWS::S3::Bucket.create("datavalues")
+ rescue
+ end
+ AWS::S3::S3Object.store(params[:key], value, "datavalues")
end
else
if params[:service] == 'redis'
@@ -46,6 +52,8 @@ def service
elsif params[:service] == 'rabbitmq'
client = rabbit_service
value = read_from_rabbit params[:key], client
+ elsif params[:service] == 'blob'
+ value = AWS::S3::S3Object.value(params[:key], "datavalues")
end
end
render :text => value
View
4 rails3/app_rails_service_autoconfig/config/initializers/blob.rb
@@ -0,0 +1,4 @@
+AWS::S3::Base.establish_connection!(
+ :access_key_id => "myid",
+ :secret_access_key => "mypwd"
+)
View
3 sinatra/app_sinatra_service_autoconfig/Gemfile
@@ -7,4 +7,5 @@ gem 'redis'
gem 'sinatra'
gem 'json'
gem 'carrot'
-gem 'pg'
+gem 'pg'
+gem 'aws-s3'
View
8 sinatra/app_sinatra_service_autoconfig/Gemfile.lock
@@ -1,9 +1,15 @@
GEM
remote: http://rubygems.org/
specs:
+ aws-s3 (0.6.3)
+ builder
+ mime-types
+ xml-simple
bson (1.2.4)
+ builder (3.1.4)
carrot (1.2.0)
json (1.4.6)
+ mime-types (1.19)
mongo (1.2.4)
bson (>= 1.2.4)
mysql2 (0.3.2)
@@ -14,11 +20,13 @@ GEM
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
tilt (1.3)
+ xml-simple (1.1.2)
PLATFORMS
ruby
DEPENDENCIES
+ aws-s3
carrot
json
mongo
View
22 sinatra/app_sinatra_service_autoconfig/app.rb
@@ -6,6 +6,7 @@
require 'carrot'
require 'uri'
require 'pg'
+require 'aws/s3'
get '/env' do
ENV['VCAP_SERVICES']
@@ -105,6 +106,20 @@
read_from_rabbit(params[:key], client)
end
+post '/service/blob/:object' do
+ load_blob
+ begin
+ AWS::S3::Bucket.create("datavalues")
+ rescue
+ end
+ AWS::S3::S3Object.store(params[:object], request.body, "datavalues")
+end
+
+get '/service/blob/:object' do
+ load_blob
+ AWS::S3::S3Object.value(params[:object], "datavalues")
+end
+
def load_redis
Redis.new({:host => '127.0.0.1', :port => 6379, :password => 'testpw'})
end
@@ -127,6 +142,13 @@ def load_postgresql
client
end
+def load_blob
+ AWS::S3::Base.establish_connection!(
+ :access_key_id => "myid",
+ :secret_access_key => "mypwd"
+ )
+end
+
def rabbit_service
Carrot.new( :host => '127.0.0.1', :port => 12345, :user => 'testuser', :pass => 'testpass', :vhost => 'vhost' )
end
View
3 standalone/ruby_autoconfig/Gemfile
@@ -7,4 +7,5 @@ gem 'redis'
gem 'sinatra'
gem 'json'
gem 'carrot'
-gem 'pg'
+gem 'pg'
+gem 'aws-s3'
View
8 standalone/ruby_autoconfig/Gemfile.lock
@@ -1,9 +1,15 @@
GEM
remote: http://rubygems.org/
specs:
+ aws-s3 (0.6.3)
+ builder
+ mime-types
+ xml-simple
bson (1.2.4)
+ builder (3.1.4)
carrot (1.2.0)
json (1.4.6)
+ mime-types (1.19)
mongo (1.2.4)
bson (>= 1.2.4)
mysql2 (0.3.2)
@@ -14,11 +20,13 @@ GEM
rack (~> 1.1)
tilt (>= 1.2.2, < 2.0)
tilt (1.3)
+ xml-simple (1.1.2)
PLATFORMS
ruby
DEPENDENCIES
+ aws-s3
carrot
json
mongo
View
22 standalone/ruby_autoconfig/app.rb
@@ -6,6 +6,7 @@
require 'carrot'
require 'uri'
require 'pg'
+require 'aws/s3'
get '/env' do
ENV['VCAP_SERVICES']
@@ -100,6 +101,20 @@
read_from_rabbit(params[:key], client)
end
+post '/service/blob/:object' do
+ load_blob
+ begin
+ AWS::S3::Bucket.create("datavalues")
+ rescue
+ end
+ AWS::S3::S3Object.store(params[:object], request.body, "datavalues")
+end
+
+get '/service/blob/:object' do
+ load_blob
+ AWS::S3::S3Object.value(params[:object], "datavalues")
+end
+
def load_redis
Redis.new({:host => '127.0.0.1', :port => 6379, :password => 'testpw'})
end
@@ -122,6 +137,13 @@ def load_postgresql
client
end
+def load_blob
+ AWS::S3::Base.establish_connection!(
+ :access_key_id => "myid",
+ :secret_access_key => "mypwd"
+ )
+end
+
def rabbit_service
Carrot.new( :host => '127.0.0.1', :port => 12345, :user => 'testuser', :pass => 'testpass', :vhost => 'vhost' )
end

0 comments on commit d8619cd

Please sign in to comment.