Permalink
Browse files

Initial commit for marketplace code

 - Refactored original code by Monica (mwilkinson@vmware.com) to separate base marketplace and appdirect code
 - TODO:
   -- FIX: gateway specs commented out as app initialized asynchronously causing the spec to run and fail
   -- REWRITE: app direct helper specs to be rewritten using webmock

 - Update Rakefile to include marketplace in gem update scripts

Change-Id: I85caf61f0a51177df2f7f4828a72a6abbca82fe5
  • Loading branch information...
1 parent 3771022 commit b77b9da61b56bb18fe3404d0c86975943a642d1a Harshawardhan Gadgil committed Aug 23, 2012
Showing with 1,994 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +1 −1 Rakefile
  3. +30 −0 marketplace/Gemfile
  4. +230 −0 marketplace/Gemfile.lock
  5. +44 −0 marketplace/README.md
  6. +52 −0 marketplace/Rakefile
  7. +58 −0 marketplace/bin/marketplace_gateway
  8. +16 −0 marketplace/config/appdirect.yml
  9. +15 −0 marketplace/config/marketplace_gateway.yml
  10. +12 −0 marketplace/lib/base/common.rb
  11. +268 −0 marketplace/lib/base/marketplace_async_gateway.rb
  12. +39 −0 marketplace/lib/base/marketplace_base.rb
  13. +17 −0 marketplace/lib/marketplaces/appdirect/appdirect_error.rb
  14. +209 −0 marketplace/lib/marketplaces/appdirect/appdirect_helper.rb
  15. +186 −0 marketplace/lib/marketplaces/appdirect/appdirect_marketplace.rb
  16. +49 −0 marketplace/spec/Rakefile
  17. +92 −0 marketplace/spec/appdirect/appdirect_gateway_spec.rb
  18. +158 −0 marketplace/spec/appdirect/appdirect_helper_spec.rb
  19. +82 −0 marketplace/spec/appdirect/fixtures/asms_dev/custom/cloudfoundry/v1/offerings/get_response.json
  20. +16 −0 marketplace/spec/appdirect/fixtures/asms_dev/custom/cloudfoundry/v1/services/post_request.json
  21. +21 −0 marketplace/spec/appdirect/fixtures/asms_dev/custom/cloudfoundry/v1/services/post_response.json
  22. +75 −0 marketplace/spec/appdirect/fixtures/mongolab/custom/cloudfoundry/v1/offerings/get_response.json
  23. +5 −0 ...ace/spec/appdirect/fixtures/mongolab/custom/cloudfoundry/v1/services/2/bindings/post_request.json
  24. +8 −0 ...ce/spec/appdirect/fixtures/mongolab/custom/cloudfoundry/v1/services/2/bindings/post_response.json
  25. +5 −0 ...b/custom/cloudfoundry/v1/services/60ea08ec-a4d4-4f69-9f70-14db951ddd2d/bindings/post_request.json
  26. +8 −0 .../custom/cloudfoundry/v1/services/60ea08ec-a4d4-4f69-9f70-14db951ddd2d/bindings/post_response.json
  27. +17 −0 marketplace/spec/appdirect/fixtures/mongolab/custom/cloudfoundry/v1/services/post_request.json
  28. +26 −0 marketplace/spec/appdirect/fixtures/mongolab/custom/cloudfoundry/v1/services/post_response.json
  29. +55 −0 marketplace/spec/appdirect/fixtures/newrelic/custom/cloudfoundry/v1/offerings/get_response.json
  30. +9 −0 ...place/spec/appdirect/fixtures/urbanairship/cloudfoundry/services/v1/offerings/post_request_0.json
  31. +8 −0 ...place/spec/appdirect/fixtures/urbanairship/cloudfoundry/services/v1/offerings/post_request_1.json
  32. +57 −0 marketplace/spec/appdirect/fixtures/urbanairship/custom/cloudfoundry/v1/offerings/get_response.json
  33. +20 −0 marketplace/spec/appdirect/fixtures/urbanairship/custom/cloudfoundry/v1/services/post_response.json
  34. +105 −0 marketplace/spec/appdirect/spec_helper.rb
View
@@ -13,3 +13,4 @@ ci-working-dir
.rvmrc
nats-server.pid
base/pkg
+coverage
View
@@ -1,6 +1,6 @@
require 'tmpdir'
-SERVICES_DIR = %w(atmos couchdb echo elasticsearch filesystem memcached mongodb mysql neo4j postgresql rabbit redis service_broker vblob tools/backup/manager)
+SERVICES_DIR = %w(atmos couchdb echo elasticsearch filesystem memcached mongodb mysql neo4j postgresql rabbit redis service_broker vblob tools/backup/manager marketplace)
desc "Run integration tests."
task "tests" do |t|
View
@@ -0,0 +1,30 @@
+source :rubygems
+
+gem 'eventmachine', :git => 'git://github.com/cloudfoundry/eventmachine.git', :branch => 'release-0.12.11-cf'
+gem "em-http-request"
+gem "ruby-hmac"
+gem "uuidtools"
+gem "datamapper", "~> 1.1.0"
+gem "dm-core", "= 1.1.0"
+gem "do_sqlite3"
+gem "dm-sqlite-adapter"
+gem "sinatra", "~> 1.2.3"
+gem "oauth"
+gem "json", "~> 1.4.6"
+gem "nats"
+
+gem 'vcap_common', :require => ['vcap/common', 'vcap/component'], :git => 'git://github.com/cloudfoundry/vcap-common.git', :ref => 'fd6b6d91'
+gem 'vcap_logging', :require => ['vcap/logging'], :git => 'git://github.com/cloudfoundry/common.git', :ref => 'b96ec1192'
+gem 'vcap_services_base', :git => 'git://github.com/cloudfoundry/vcap-services-base.git', :ref => 'e54a821c'
+gem 'warden-client', :require => ['warden/client'], :git => 'git://github.com/cloudfoundry/warden.git', :ref => '21f9a32ab50'
+gem 'warden-protocol', :require => ['warden/protocol'], :git => 'git://github.com/cloudfoundry/warden.git', :ref => '21f9a32ab50'
+
+group :test do
+ #gem "webmock"
+ gem "rake"
+ gem "rack-test"
+ gem "rspec"
+ gem "simplecov"
+ gem "simplecov-rcov"
+ gem "ci_reporter"
+end
View
@@ -0,0 +1,230 @@
+GIT
+ remote: git://github.com/cloudfoundry/common.git
+ revision: b96ec1192d961925d91e17ca3831f8547489d918
+ ref: b96ec1192
+ specs:
+ vcap_logging (1.0.2)
+ rake
+
+GIT
+ remote: git://github.com/cloudfoundry/eventmachine.git
+ revision: 2806c630d8631d5dcf9fb2555f665b829052aabe
+ branch: release-0.12.11-cf
+ specs:
+ eventmachine (0.12.11.cloudfoundry.3)
+
+GIT
+ remote: git://github.com/cloudfoundry/vcap-common.git
+ revision: fd6b6d91b19c551cf5091c8469595df923dd2612
+ ref: fd6b6d91
+ specs:
+ vcap_common (2.0.7)
+ em-http-request (~> 1.0.0.beta3)
+ eventmachine
+ httpclient
+ membrane (~> 0.0.2)
+ mime-types
+ multipart-post
+ nats (~> 0.4.24)
+ posix-spawn (~> 0.3.6)
+ thin
+ yajl-ruby (~> 0.8.3)
+
+GIT
+ remote: git://github.com/cloudfoundry/vcap-services-base.git
+ revision: e54a821c72f1733a333442c7b123a17941c8ed1e
+ ref: e54a821c
+ specs:
+ vcap_services_base (0.1.14)
+ curb (~> 0.7.16)
+ datamapper (~> 1.1.0)
+ do_sqlite3 (~> 0.10.3)
+ em-http-request (~> 1.0.0.beta.3)
+ eventmachine (~> 0.12.11.cloudfoundry.3)
+ eventmachine_httpserver (~> 0.2.1)
+ json (~> 1.4.6)
+ nats (~> 0.4.22.beta.8)
+ resque (~> 1.20)
+ resque-status (~> 0.3.2)
+ ruby-hmac (~> 0.4.0)
+ rubyzip (~> 0.9.8)
+ sinatra (~> 1.2.3)
+ thin (~> 1.3.1)
+ uuidtools (~> 2.1.2)
+ vcap_common (>= 1.0.8)
+ vcap_logging (>= 1.0.2)
+ warden-client (~> 0.0.6)
+ warden-protocol (~> 0.0.5)
+
+GIT
+ remote: git://github.com/cloudfoundry/warden.git
+ revision: 21f9a32ab501a6485c9a4e7aff4f9b6f40e31e3c
+ ref: 21f9a32ab50
+ specs:
+ warden-client (0.0.6)
+ warden-protocol
+ warden-protocol (0.0.5)
+ beefcake
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ addressable (2.2.8)
+ bcrypt-ruby (2.1.4)
+ beefcake (0.3.7)
+ builder (3.0.0)
+ ci_reporter (1.7.0)
+ builder (>= 2.1.2)
+ curb (0.7.18)
+ daemons (1.1.8)
+ data_objects (0.10.8)
+ addressable (~> 2.1)
+ datamapper (1.1.0)
+ dm-aggregates (= 1.1.0)
+ dm-constraints (= 1.1.0)
+ dm-core (= 1.1.0)
+ dm-migrations (= 1.1.0)
+ dm-serializer (= 1.1.0)
+ dm-timestamps (= 1.1.0)
+ dm-transactions (= 1.1.0)
+ dm-types (= 1.1.0)
+ dm-validations (= 1.1.0)
+ diff-lcs (1.1.3)
+ dm-aggregates (1.1.0)
+ dm-core (~> 1.1.0)
+ dm-constraints (1.1.0)
+ dm-core (~> 1.1.0)
+ dm-core (1.1.0)
+ addressable (~> 2.2.4)
+ dm-do-adapter (1.1.0)
+ data_objects (~> 0.10.2)
+ dm-core (~> 1.1.0)
+ dm-migrations (1.1.0)
+ dm-core (~> 1.1.0)
+ dm-serializer (1.1.0)
+ dm-core (~> 1.1.0)
+ fastercsv (~> 1.5.4)
+ json (~> 1.4.6)
+ dm-sqlite-adapter (1.1.0)
+ dm-do-adapter (~> 1.1.0)
+ do_sqlite3 (~> 0.10.2)
+ dm-timestamps (1.1.0)
+ dm-core (~> 1.1.0)
+ dm-transactions (1.1.0)
+ dm-core (~> 1.1.0)
+ dm-types (1.1.0)
+ bcrypt-ruby (~> 2.1.4)
+ dm-core (~> 1.1.0)
+ fastercsv (~> 1.5.4)
+ json (~> 1.4.6)
+ stringex (~> 1.2.0)
+ uuidtools (~> 2.1.2)
+ dm-validations (1.1.0)
+ dm-core (~> 1.1.0)
+ do_sqlite3 (0.10.8)
+ data_objects (= 0.10.8)
+ em-http-request (1.0.0.beta.3)
+ addressable (>= 2.2.3)
+ em-socksify
+ eventmachine
+ http_parser.rb (>= 0.5.1)
+ em-socksify (0.1.0)
+ eventmachine
+ eventmachine_httpserver (0.2.1)
+ fastercsv (1.5.5)
+ http_parser.rb (0.5.3)
+ httpclient (2.2.7)
+ json (1.4.6)
+ json_pure (1.7.4)
+ macaddr (1.6.1)
+ systemu (~> 2.5.0)
+ membrane (0.0.2)
+ mime-types (1.19)
+ multi_json (1.3.6)
+ multipart-post (1.1.5)
+ nats (0.4.24)
+ daemons (>= 1.1.5)
+ eventmachine (>= 0.12.10)
+ json_pure (>= 1.7.3)
+ thin (>= 1.3.1)
+ oauth (0.4.6)
+ posix-spawn (0.3.6)
+ rack (1.4.1)
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rake (0.9.2.2)
+ redis (3.0.1)
+ redis-namespace (1.2.1)
+ redis (~> 3.0.0)
+ redisk (0.2.2)
+ redis (>= 0.1.1)
+ redis-namespace (>= 0.1.0)
+ resque (1.22.0)
+ multi_json (~> 1.0)
+ redis-namespace (~> 1.0)
+ sinatra (>= 0.9.2)
+ vegas (~> 0.1.2)
+ resque-status (0.3.3)
+ redisk (>= 0.2.1)
+ resque (~> 1.19)
+ uuid (~> 2.3)
+ rspec (2.11.0)
+ rspec-core (~> 2.11.0)
+ rspec-expectations (~> 2.11.0)
+ rspec-mocks (~> 2.11.0)
+ rspec-core (2.11.1)
+ rspec-expectations (2.11.2)
+ diff-lcs (~> 1.1.3)
+ rspec-mocks (2.11.1)
+ ruby-hmac (0.4.0)
+ rubyzip (0.9.9)
+ simplecov (0.6.4)
+ multi_json (~> 1.0)
+ simplecov-html (~> 0.5.3)
+ simplecov-html (0.5.3)
+ simplecov-rcov (0.2.3)
+ simplecov (>= 0.4.1)
+ sinatra (1.2.8)
+ rack (~> 1.1)
+ tilt (>= 1.2.2, < 2.0)
+ stringex (1.2.2)
+ systemu (2.5.2)
+ thin (1.3.1)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
+ tilt (1.3.3)
+ uuid (2.3.5)
+ macaddr (~> 1.0)
+ uuidtools (2.1.3)
+ vegas (0.1.11)
+ rack (>= 1.0.0)
+ yajl-ruby (0.8.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ ci_reporter
+ datamapper (~> 1.1.0)
+ dm-core (= 1.1.0)
+ dm-sqlite-adapter
+ do_sqlite3
+ em-http-request
+ eventmachine!
+ json (~> 1.4.6)
+ nats
+ oauth
+ rack-test
+ rake
+ rspec
+ ruby-hmac
+ simplecov
+ simplecov-rcov
+ sinatra (~> 1.2.3)
+ uuidtools
+ vcap_common!
+ vcap_logging!
+ vcap_services_base!
+ warden-client!
+ warden-protocol!
View
@@ -0,0 +1,44 @@
+## Overview
+
+This AppDirect Gateway acts as a proxy between the Cloud Controller and App Direct to list and provision services.
+
+## Functionality
+
+### On startup
+
+- Reads the list of services available in App Direct and the list of services available in Cloud Controller
+ - See https://wiki.springsource.com/display/ACDEV/VCAP+Service+Gateway+API+Document for how to read from CC the list of services
+- Adds, updates or removes(deactivates) AppDirect services listed in Cloud Controller
+- This behavior is repeated on a periodic basis
+
+### On create-service, delete-service, bind-service, unbind-service
+
+- Maps and forwards the requests to and from AppDirect
+
+### Requirements to run tests
+
+- Access to the internet for rubygems, github, appdirect
+- Ruby 1.9.3p125
+
+### Testing
+
+``` bash
+
+$ bundle install
+$ rspec spec
+
+```
+
+
+### Runnning standalone
+
+```bash
+$ ./bin/appdirect_gateway
+
+ ```
+
+### Running in dev_setup
+
+
+### Running on bosh
+
View
@@ -0,0 +1,52 @@
+require 'rake'
+
+desc "Run specs"
+task "spec" => ["test:spec"]
+
+desc "Run specs using SimpleCov"
+task "spec:rcov" => ["test:spec:rcov"]
+
+desc "Run ci using SimpleCov"
+task "spec:ci" => ["test:spec:ci"]
+
+namespace "bundler" do
+ desc "Install gems"
+ task "install" do
+ sh("bundle install")
+ end
+
+ desc "Install gems for test"
+ task "install:test" do
+ sh("bundle install --without development production")
+ end
+
+ desc "Install gems for production"
+ task "install:production" do
+ sh("bundle install --without development test")
+ end
+
+ desc "Install gems for development"
+ task "install:development" do
+ sh("bundle install --without test production")
+ end
+end
+
+namespace "test" do
+ def run_spec
+ sh "nats-server &"
+ Dir.chdir("spec"){ yield }
+ sh "pkill -f nats-server"
+ end
+
+ task "spec" do |t|
+ run_spec{ sh "rake spec" }
+ end
+
+ task "spec:rcov" do |t|
+ run_spec{ sh "rake simcov" }
+ end
+
+ task "spec:ci" do |t|
+ run_spec{ sh "rake spec:ci" }
+ end
+end
Oops, something went wrong.

0 comments on commit b77b9da

Please sign in to comment.