Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactor Rake tasks

- created common CI related rake lib
- used the rake lib in: agent client, 
  blobstore client, director, monit api, 
  ruby vim sdk, and simple blobstore server
- still needs to be done in agent, cli, 
  bosh monitor, maybe others?
- removed clover generation since CI now only uses
  Rcov

Cleaned up gem specs
- agent client, blobstore client, cli, monit api, 
  ruby vim sdk

Vendored simple blobstore server

Change-Id: Ib02c1e1f882d881c869e74de2b20d900a0c21cbb
  • Loading branch information...
commit 8572a9acb7628358ee417017c81a4a5b4d6e242f 1 parent f440be4
Vadim Spivak authored
Showing with 571 additions and 882 deletions.
  1. +2 −0  .gitignore
  2. +4 −3 agent_client/Gemfile
  3. +0 −7 agent_client/Gemfile.lock
  4. +23 −25 agent_client/Rakefile
  5. +8 −10 agent_client/agent_client.gemspec
  6. +0 −87 agent_client/spec/Rakefile
  7. +8 −6 agent_client/spec/spec_helper.rb
  8. BIN  agent_client/vendor/cache/rcov-1.0.0.gem
  9. BIN  agent_client/vendor/cache/rcov_analyzer-0.2.gem
  10. BIN  agent_client/vendor/cache/simplecov-clover-0.0.1.gem
  11. +4 −3 blobstore_client/Gemfile
  12. +2 −7 blobstore_client/Gemfile.lock
  13. +25 −33 blobstore_client/Rakefile
  14. +11 −17 blobstore_client/blobstore_client.gemspec
  15. +0 −87 blobstore_client/spec/Rakefile
  16. +6 −6 blobstore_client/spec/spec_helper.rb
  17. BIN  blobstore_client/vendor/cache/json-1.6.5.gem
  18. BIN  blobstore_client/vendor/cache/rcov_analyzer-0.2.gem
  19. BIN  blobstore_client/vendor/cache/simplecov-clover-0.0.1.gem
  20. +9 −11 cli/bosh_cli.gemspec
  21. +82 −85 director/Rakefile
  22. +78 −0 director/migrations.rake
  23. +0 −153 director/spec/Rakefile
  24. +2 −2 director/spec/assets/redis_test.conf
  25. +0 −20 director/spec/spec_helper.rb
  26. +8 −4 monit_api/Gemfile
  27. +9 −4 monit_api/Gemfile.lock
  28. +31 −53 monit_api/Rakefile
  29. +18 −0 monit_api/monit_api.gemspec
  30. +0 −50 monit_api/spec/Rakefile
  31. +8 −6 monit_api/spec/spec_helper.rb
  32. +31 −0 rake/bundler_task.rb
  33. +60 −0 rake/ci_task.rb
  34. +20 −0 rake/simplecov_helper.rb
  35. +10 −5 ruby_vim_sdk/Gemfile
  36. +1 −0  ruby_vim_sdk/README
  37. +33 −27 ruby_vim_sdk/Rakefile
  38. +5 −0 ruby_vim_sdk/lib/ruby_vim_sdk/version.rb
  39. +15 −8 ruby_vim_sdk/ruby_vim_sdk.gemspec
  40. +0 −87 ruby_vim_sdk/spec/Rakefile
  41. +2 −1  ruby_vim_sdk/spec/spec_helper.rb
  42. BIN  ruby_vim_sdk/vendor/cache/simplecov-clover-0.0.1.gem
  43. +11 −4 simple_blobstore_server/Gemfile
  44. +28 −3 simple_blobstore_server/Gemfile.lock
  45. +14 −38 simple_blobstore_server/Rakefile
  46. +3 −30 simple_blobstore_server/spec/spec_helper.rb
  47. BIN  simple_blobstore_server/vendor/cache/archive-tar-minitar-0.5.2.gem
  48. BIN  simple_blobstore_server/vendor/cache/columnize-0.3.6.gem
  49. BIN  simple_blobstore_server/vendor/cache/linecache-0.46.gem
  50. BIN  simple_blobstore_server/vendor/cache/linecache19-0.5.12.gem
  51. BIN  simple_blobstore_server/vendor/cache/rake-0.9.2.2.gem
  52. BIN  simple_blobstore_server/vendor/cache/rbx-require-relative-0.0.5.gem
  53. BIN  simple_blobstore_server/vendor/cache/rcov-1.0.0.gem
  54. BIN  simple_blobstore_server/vendor/cache/ruby-debug-0.10.4.gem
  55. BIN  simple_blobstore_server/vendor/cache/ruby-debug-base-0.10.4.gem
  56. BIN  simple_blobstore_server/vendor/cache/ruby-debug-base19-0.11.25.gem
  57. BIN  simple_blobstore_server/vendor/cache/ruby-debug19-0.11.6.gem
  58. BIN  simple_blobstore_server/vendor/cache/ruby_core_source-0.1.5.gem
  59. BIN  simple_blobstore_server/vendor/cache/simplecov-clover-0.0.1.gem
View
2  .gitignore
@@ -11,6 +11,7 @@ spec.log
*.rbc
*.swp
.rvmrc
+.DS_Store
spec/assets/*.pid
spec/assets/*.db
spec/assets/**/*.pid
@@ -26,3 +27,4 @@ spec/assets/test_release/config/final.yml
director/director.db
micro/tmp
health_monitor/spec/assets/dev*.yml
+ci_result/
View
7 agent_client/Gemfile
@@ -5,12 +5,13 @@ gem "rake"
group :test do
gem "ci_reporter"
- gem "rcov", :platforms => :ruby_18
- gem "rcov_analyzer", ">= 0.2", :platforms => :ruby_18
gem "rspec"
+
gem "ruby-debug", :platforms => :ruby_18
gem "ruby-debug19", :platforms => :ruby_19
+
+ gem "rcov", :platforms => :ruby_18
+
gem "simplecov", :platforms => :ruby_19
- gem "simplecov-clover", :platforms => :ruby_19
gem "simplecov-rcov", :platforms => :ruby_19
end
View
7 agent_client/Gemfile.lock
@@ -23,9 +23,6 @@ GEM
rake (0.9.2.2)
rbx-require-relative (0.0.5)
rcov (1.0.0)
- rcov_analyzer (0.2)
- builder
- rcov
rspec (2.8.0)
rspec-core (~> 2.8.0)
rspec-expectations (~> 2.8.0)
@@ -52,8 +49,6 @@ GEM
simplecov (0.5.4)
multi_json (~> 1.0.3)
simplecov-html (~> 0.5.3)
- simplecov-clover (0.0.1)
- simplecov (>= 0.4.1)
simplecov-html (0.5.3)
simplecov-rcov (0.2.3)
simplecov (>= 0.4.1)
@@ -67,10 +62,8 @@ DEPENDENCIES
ci_reporter
rake
rcov
- rcov_analyzer (>= 0.2)
rspec
ruby-debug
ruby-debug19
simplecov
- simplecov-clover
simplecov-rcov
View
48 agent_client/Rakefile
@@ -1,14 +1,18 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+$:.unshift(File.expand_path("../../rake", __FILE__))
+
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
+
require "rubygems"
require "bundler"
+Bundler.setup(:default, :test)
-desc "Run specs"
-task "spec" => [ "bundler:install:test", "test:spec" ]
-
-desc "Run specs for CI"
-task "spec:ci" => ["bundler:install:test", "test:spec:ci"]
+require "rake"
+require "rspec/core/rake_task"
-desc "Run specs w/coverage"
-task "spec:rcov" => ["bundler:install:test", "test:spec:rcov"]
+require "bundler_task"
+require "ci_task"
gem_helper = Bundler::GemHelper.new(Dir.pwd)
@@ -23,26 +27,20 @@ task "install" do
gem_helper.install_gem
end
-namespace "bundler" do
- desc "Install gems"
- task "install" do
- sh("bundle install")
- end
-
- environments = %w(test development production)
+BundlerTask.new
- environments.each do |env|
- desc "Install gems for #{env}"
- task "install:#{env}" do
- sh("bundle install --local --without #{(environments - [env]).join(' ')}")
- end
+namespace :spec do
+ desc "Run Unit Tests"
+ rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
+ t.gemfile = "Gemfile"
+ t.pattern = "spec/unit/**/*_spec.rb"
+ t.rspec_opts = %w(--format progress --colour)
end
-end
-namespace "test" do
- ["spec", "spec:rcov", "spec:ci" ].each do |task_name|
- task task_name do
- sh("cd spec && rake #{task_name}")
- end
+ CiTask.new do |task|
+ task.rspec_task = rspec_task
end
end
+
+desc "Install dependencies and run tests"
+task :spec => %w(bundler:install:test spec:unit)
View
18 agent_client/agent_client.gemspec
@@ -1,21 +1,19 @@
-libdir = File.join(File.dirname(__FILE__), "lib")
-$:.unshift(libdir) unless $:.include?(libdir)
+require File.dirname(__FILE__) + "/lib/agent_client/version"
-require "agent_client/version"
-
-gemspec = Gem::Specification.new do |s|
+Gem::Specification.new do |s|
s.name = "agent_client"
s.version = Bosh::Agent::Client::VERSION
s.platform = Gem::Platform::RUBY
s.summary = "Bosh agent client"
s.description = s.summary
- s.authors = [ "Bosh eng" ]
- s.homepage = "http://vmware.com"
+ s.author = "VMware"
+ s.email = "support@vmware.com"
+ s.homepage = "http://www.vmware.com"
+
+ s.files = `git ls-files -- lib/*`.split("\n") + %w(README Rakefile)
+ s.test_files = `git ls-files -- spec/*`.split("\n")
s.require_path = "lib"
- s.files = %w(README Rakefile) + Dir.glob("{lib}/**/*")
s.add_dependency "httpclient"
s.add_dependency "yajl-ruby"
-
- s.add_development_dependency "rspec"
end
View
87 agent_client/spec/Rakefile
@@ -1,87 +0,0 @@
-require "tempfile"
-require "rake"
-
-APP_DIR = File.expand_path(File.join("..", ".."), __FILE__)
-ENV["BUNDLE_GEMFILE"] ||= File.join(APP_DIR, "Gemfile")
-require "rubygems"
-require "bundler"
-Bundler.setup(:default, :test)
-
-require "rspec/core/rake_task"
-require "ci/reporter/rake/rspec"
-
-desc "Run all examples"
-RSpec::Core::RakeTask.new(:spec) do |t|
- t.pattern = "**/*_spec.rb"
- t.rspec_opts = %w[--color]
-end
-
-task :default => [:spec]
-
-coverage_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_coverage"))
-reports_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_reports"))
-dump_file = File.join(Dir.tmpdir, "bosh-agent-client.rcov")
-
-ENV["CI_REPORTS"] = reports_dir
-
-namespace "spec" do
- gemfile = "../Gemfile"
- spec_opts = ["--format", "documentation", "--colour"]
-
- if RUBY_VERSION < "1.9"
- desc "Run specs for ci"
- task "ci" => [ "ci:setup:rspec", "spec:rcov", "convert_rcov_to_clover" ]
-
- desc "Run spec with coverage"
- RSpec::Core::RakeTask.new("rcov") do |t|
- FileUtils.rm_rf(dump_file)
- t.gemfile = gemfile
- t.pattern = "**/*_spec.rb"
- t.rspec_opts = ["--format", "progress", "--colour"]
- t.rcov = true
- t.rcov_opts = %W{--aggregate #{dump_file} --exclude osx\/objc,gems\/,spec\/,unit\/,features\/ -o "#{coverage_dir}"}
- end
-
- task "convert_rcov_to_clover" do |t|
- ignore_pattern = "spec,[.]bundle,[/]gems[/]"
- clover_output = File.join(coverage_dir, "clover.xml")
-
- sh("bundle exec rcov_analyzer #{dump_file} #{ignore_pattern} > #{clover_output}")
- FileUtils.rm_rf(dump_file)
- end
-
- else
- desc "Run specs for ci"
- task "ci" => [ "ci:setup:rspec", "spec:rcov" ]
-
- desc "Run spec with coverage"
- task :rcov => :cleanup_coverage do
- require "simplecov"
- require "simplecov-rcov"
- require "simplecov-clover"
-
- class SimpleCov::Formatter::CombinedFormatter
- def format(result)
- SimpleCov::Formatter::CloverFormatter.new.format(result)
- SimpleCov::Formatter::RcovFormatter.new.format(result)
- end
- end
-
- SimpleCov.formatter = SimpleCov::Formatter::CombinedFormatter
- SimpleCov.root('..')
- SimpleCov.coverage_dir('cov')
- SimpleCov.start do
- require "rspec/core"
- add_filter "/spec/"
- spec_dir = File.expand_path("..", __FILE__)
- RSpec::Core::Runner.disable_autorun!
- RSpec::Core::Runner.run([spec_dir], STDERR, STDOUT)
- end
- end
- end
-
- task "cleanup_coverage" do
- rm_rf "cov"
- end
-
-end
View
14 agent_client/spec/spec_helper.rb
@@ -1,8 +1,10 @@
-require 'rspec/core'
+# Copyright (c) 2009-2012 VMware, Inc.
-$:.unshift(File.expand_path("../../lib", __FILE__))
-require 'agent_client'
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
-RSpec.configure do |c|
- c.color_enabled = true
-end
+require "rubygems"
+require "bundler"
+Bundler.setup(:default, :test)
+
+require "rspec"
+require "agent_client"
View
BIN  agent_client/vendor/cache/rcov-1.0.0.gem
Binary file not shown
View
BIN  agent_client/vendor/cache/rcov_analyzer-0.2.gem
Binary file not shown
View
BIN  agent_client/vendor/cache/simplecov-clover-0.0.1.gem
Binary file not shown
View
7 blobstore_client/Gemfile
@@ -5,13 +5,14 @@ gem "rake"
group :test do
gem "ci_reporter"
- gem "rcov", :platforms => :ruby_18
- gem "rcov_analyzer", ">= 0.2", :platforms => :ruby_18
gem "rspec"
+
gem "ruby-debug", :platforms => :ruby_18
gem "ruby-debug19", :platforms => :ruby_19
+
+ gem "rcov", :platforms => :ruby_18
+
gem "simplecov", :platforms => :ruby_19
- gem "simplecov-clover", :platforms => :ruby_19
gem "simplecov-rcov", :platforms => :ruby_19
end
View
9 blobstore_client/Gemfile.lock
@@ -4,6 +4,7 @@ PATH
blobstore_client (0.3.9)
aws-s3
httpclient
+ json
ruby-atmos-pure (>= 1.0.5)
uuidtools
@@ -21,6 +22,7 @@ GEM
columnize (0.3.3)
diff-lcs (1.1.2)
httpclient (2.2.4)
+ json (1.6.5)
linecache (0.46)
rbx-require-relative (> 0.0.4)
linecache19 (0.5.12)
@@ -30,9 +32,6 @@ GEM
rake (0.8.7)
rbx-require-relative (0.0.5)
rcov (0.9.9)
- rcov_analyzer (0.2)
- builder
- rcov
rspec (2.3.0)
rspec-core (~> 2.3.0)
rspec-expectations (~> 2.3.0)
@@ -62,8 +61,6 @@ GEM
archive-tar-minitar (>= 0.5.2)
simplecov (0.4.2)
simplecov-html (~> 0.4.4)
- simplecov-clover (0.0.1)
- simplecov (>= 0.4.1)
simplecov-html (0.4.5)
simplecov-rcov (0.2.3)
simplecov (>= 0.4.1)
@@ -78,10 +75,8 @@ DEPENDENCIES
ci_reporter
rake
rcov
- rcov_analyzer (>= 0.2)
rspec
ruby-debug
ruby-debug19
simplecov
- simplecov-clover
simplecov-rcov
View
58 blobstore_client/Rakefile
@@ -1,54 +1,46 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+$:.unshift(File.expand_path("../../rake", __FILE__))
+
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
+
require "rubygems"
require "bundler"
+Bundler.setup(:default, :test)
-desc "Run specs"
-task "spec" => [ "bundler:install:test", "test:spec" ]
-
-desc "Run specs for CI"
-task "spec:ci" => ["bundler:install:test", "test:spec:ci"]
+require "rake"
+require "rspec/core/rake_task"
-desc "Run specs w/coverage"
-task "spec:rcov" => ["bundler:install:test", "test:spec:rcov"]
+require "bundler_task"
+require "ci_task"
gem_helper = Bundler::GemHelper.new(Dir.pwd)
-desc "Build Bosh CLI gem into the pkg directory"
+desc "Build Blobstore Client gem into the pkg directory"
task "build" do
gem_helper.build_gem
end
-desc "Build and install Bosh CLI into system gems"
+desc "Build and install Blobstore Client into system gems"
task "install" do
sh("bundle install --local --without test development")
gem_helper.install_gem
end
-namespace "bundler" do
- desc "Install gems"
- task "install" do
- sh("bundle install")
- end
+BundlerTask.new
- environments = %w(test development production)
-
- environments.each do |env|
- desc "Install gems for #{env}"
- task "install:#{env}" do
- Bundler.with_clean_env do
- if ENV.has_key? 'RUBYOPT'
- ENV['RUBYOPT'] = ENV['RUBYOPT'].sub '-rbundler/setup', ''
- ENV['RUBYOPT'] = ENV['RUBYOPT'].sub "-I#{File.expand_path('..', __FILE__)}", ''
- end
- sh("bundle install --without #{(environments - [env]).join(' ')}")
- end
- end
+namespace :spec do
+ desc "Run Unit Tests"
+ rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
+ t.gemfile = "Gemfile"
+ t.pattern = "spec/unit/**/*_spec.rb"
+ t.rspec_opts = %w(--format progress --colour)
end
-end
-namespace "test" do
- ["spec", "spec:rcov", "spec:ci" ].each do |task_name|
- task task_name do
- sh("cd spec && rake #{task_name}")
- end
+ CiTask.new do |task|
+ task.rspec_task = rspec_task
end
end
+
+desc "Install dependencies and run tests"
+task :spec => %w(bundler:install:test spec:unit)
View
28 blobstore_client/blobstore_client.gemspec
@@ -1,28 +1,22 @@
-libdir = File.join(File.dirname(__FILE__), "lib")
-$:.unshift(libdir) unless $:.include?(libdir)
+require File.dirname(__FILE__) + "/lib/blobstore_client/version"
-require "blobstore_client/version"
-
-gemspec = Gem::Specification.new do |s|
+Gem::Specification.new do |s|
s.name = "blobstore_client"
s.version = Bosh::Blobstore::Client::VERSION
s.platform = Gem::Platform::RUBY
s.summary = "Bosh blobstore client"
s.description = s.summary
- s.authors = [ "Vadim Spivak", "Oleg Shaldybin" ]
- s.email = "vspivak@vmware.com"
- s.homepage = "http://vmware.com"
+ s.author = "VMware"
+ s.email = "support@vmware.com"
+ s.homepage = "http://www.vmware.com"
+
+ s.files = `git ls-files -- lib/*`.split("\n") + %w(README Rakefile)
+ s.test_files = `git ls-files -- spec/*`.split("\n")
s.require_path = "lib"
- s.files = %w(README Rakefile) + Dir.glob("{lib}/**/*")
- s.add_dependency "httpclient"
s.add_dependency "aws-s3"
- s.add_dependency "uuidtools"
+ s.add_dependency "httpclient"
+ s.add_dependency "json"
s.add_dependency "ruby-atmos-pure", ">= 1.0.5"
-
- if Gem::Version.new(RUBY_VERSION.dup) <= Gem::Version.new("1.8.7")
- s.add_dependency "json"
- end
-
- s.add_development_dependency "rspec"
+ s.add_dependency "uuidtools"
end
View
87 blobstore_client/spec/Rakefile
@@ -1,87 +0,0 @@
-require "tempfile"
-require "rake"
-
-APP_DIR = File.expand_path(File.join("..", ".."), __FILE__)
-ENV["BUNDLE_GEMFILE"] ||= File.join(APP_DIR, "Gemfile")
-require "rubygems"
-require "bundler"
-Bundler.setup(:default, :test)
-
-require "rspec/core/rake_task"
-require "ci/reporter/rake/rspec"
-
-desc "Run all examples"
-RSpec::Core::RakeTask.new(:spec) do |t|
- t.pattern = "**/*_spec.rb"
- t.rspec_opts = %w[--color]
-end
-
-task :default => [:spec]
-
-coverage_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_coverage"))
-reports_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_reports"))
-dump_file = File.join(Dir.tmpdir, "bosh-blobstore-client.rcov")
-
-ENV["CI_REPORTS"] = reports_dir
-
-namespace "spec" do
- gemfile = "../Gemfile"
- spec_opts = ["--format", "documentation", "--colour"]
-
- if RUBY_VERSION < "1.9"
- desc "Run specs for ci"
- task "ci" => [ "ci:setup:rspec", "spec:rcov", "convert_rcov_to_clover" ]
-
- desc "Run spec with coverage"
- RSpec::Core::RakeTask.new("rcov") do |t|
- FileUtils.rm_rf(dump_file)
- t.gemfile = gemfile
- t.pattern = "**/*_spec.rb"
- t.rspec_opts = ["--format", "progress", "--colour"]
- t.rcov = true
- t.rcov_opts = %W{--aggregate #{dump_file} --exclude osx\/objc,gems\/,spec\/,unit\/,features\/ -o "#{coverage_dir}"}
- end
-
- task "convert_rcov_to_clover" do |t|
- ignore_pattern = "spec,[.]bundle,[/]gems[/]"
- clover_output = File.join(coverage_dir, "clover.xml")
-
- sh("bundle exec rcov_analyzer #{dump_file} #{ignore_pattern} > #{clover_output}")
- FileUtils.rm_rf(dump_file)
- end
-
- else
- desc "Run specs for ci"
- task "ci" => [ "ci:setup:rspec", "spec:rcov" ]
-
- desc "Run spec with coverage"
- task :rcov => :cleanup_coverage do
- require "simplecov"
- require "simplecov-rcov"
- require "simplecov-clover"
-
- class SimpleCov::Formatter::CombinedFormatter
- def format(result)
- SimpleCov::Formatter::CloverFormatter.new.format(result)
- SimpleCov::Formatter::RcovFormatter.new.format(result)
- end
- end
-
- SimpleCov.formatter = SimpleCov::Formatter::CombinedFormatter
- SimpleCov.root('..')
- SimpleCov.coverage_dir('cov')
- SimpleCov.start do
- require "rspec/core"
- add_filter "/spec/"
- spec_dir = File.expand_path("..", __FILE__)
- RSpec::Core::Runner.disable_autorun!
- RSpec::Core::Runner.run([spec_dir], STDERR, STDOUT)
- end
- end
- end
-
- task "cleanup_coverage" do
- rm_rf "cov"
- end
-
-end
View
12 blobstore_client/spec/spec_helper.rb
@@ -1,8 +1,8 @@
-require 'rspec/core'
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
-$:.unshift(File.expand_path("../../lib", __FILE__))
-require 'blobstore_client'
+require "rubygems"
+require "bundler"
+Bundler.setup(:default, :test)
-RSpec.configure do |c|
- c.color_enabled = true
-end
+require "rspec"
+require "blobstore_client"
View
BIN  blobstore_client/vendor/cache/json-1.6.5.gem
Binary file not shown
View
BIN  blobstore_client/vendor/cache/rcov_analyzer-0.2.gem
Binary file not shown
View
BIN  blobstore_client/vendor/cache/simplecov-clover-0.0.1.gem
Binary file not shown
View
20 cli/bosh_cli.gemspec
@@ -1,6 +1,4 @@
-libdir = File.expand_path("../lib", __FILE__)
-$:.unshift(libdir) unless $:.include?(libdir)
-require "cli/version"
+require File.dirname(__FILE__) + "/lib/cli/version"
Gem::Specification.new do |s|
s.name = "bosh_cli"
@@ -8,13 +6,15 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.summary = "Bosh CLI"
s.description = "Bosh command-line tool for release engineering and deployment"
- s.authors = [ "Oleg Shaldybin" ]
- s.email = "olegs@vmware.com"
- s.homepage = "http://vmware.com"
- s.executables = %w(bosh)
- s.files = %w(README Rakefile) + Dir.glob("{bin,lib}/**/*")
- s.bindir = "bin"
+ s.author = "VMware"
+ s.email = "support@vmware.com"
+ s.homepage = "http://www.vmware.com"
+
+ s.files = `git ls-files -- {bin,lib}/*`.split("\n") + %w(README Rakefile)
+ s.test_files = `git ls-files -- {spec}/*`.split("\n")
s.require_path = "lib"
+ s.bindir = "bin"
+ s.executables = %w(bosh)
s.add_dependency "json_pure", "~>1.6.1"
s.add_dependency "highline", "~>1.6.2"
@@ -25,6 +25,4 @@ Gem::Specification.new do |s|
s.add_dependency "net-ssh", "~>2.2.1"
s.add_dependency "net-ssh-gateway", "~>1.1.0"
s.add_dependency "net-scp", "~>1.0.4"
-
- s.add_development_dependency "rspec"
end
View
167 director/Rakefile
@@ -1,113 +1,110 @@
-require 'rake'
-require 'fileutils'
-
-desc "Run specs"
-task "spec" => %W(bundler:install:test test:spec)
-
-desc "Run functional tests"
-task "spec:unit" => %W(bundler:install:test test:spec:unit)
-
-desc "Run functional tests"
-task "spec:functional" => %W(bundler:install:test test:spec:functional)
-
-desc "Run CPI integration tests"
-task "spec:cpi" => %W(bundler:install:test test:spec:cpi)
-
-namespace "migration" do
- desc "Generate new migration"
- task "new", :type, :name do |task, args|
- type = args[:type]
- if type.nil?
- puts "Please provide migration type: rake #{task.name}[<type>, <name>]"
- exit(1)
- elsif !File.directory?("db/migrations/#{type}")
- Dir.chdir("db/migrations")
- valid_types = Dir["*"].select {|file| File.directory?(file)}
- puts "Invalid type: '#{type}', must be one of: #{valid_types.join(", ")}"
- exit(1)
- end
+# Copyright (c) 2009-2012 VMware, Inc.
- name = args[:name]
- if name.nil?
- puts "Please provide migration name: rake #{task.name}[<type>, <name>]"
- exit(1)
- end
+$:.unshift(File.expand_path("../../rake", __FILE__))
- timestamp = Time.new.getutc.strftime("%Y%m%d%H%M%S")
- filename = "db/migrations/#{type}/#{timestamp}_#{name}.rb"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
- puts "Creating #{filename}"
- FileUtils.touch(filename)
- end
+require "rubygems"
+require "bundler"
+Bundler.setup(:default, :test)
- desc "Run migrations"
- task "run", :config do |task, args|
- config_file = args[:config]
- if config_file.nil?
- abort("Please provide a path to the config file: rake #{task.name}[<path to config file>]")
- elsif !File.file?(config_file)
- abort("Invalid config file '#{config_file}'")
- end
+require "rake"
+require "rspec/core/rake_task"
- config = YAML.load_file(config_file)
- abort ("Director database config missing from config file") unless config["db"] && config["db"]["database"]
+require "bundler_task"
+require "ci_task"
- migrate(config["db"]["database"], nil, "db/migrations/director")
- migrate(config["db"]["database"], "vsphere_cpi_schema", "db/migrations/vsphere_cpi")
+BundlerTask.new
- if config["dns"] && config["dns"]["db"]
- migrate(config["dns"]["db"]["database"], "dns_schema", "db/migrations/dns")
- end
- end
+import "migrations.rake"
- task "manual", :type, :db, :schema do |task, args|
- migrate(args[:db], args[:schema], "db/migrations/#{args[:type]}")
- end
+namespace "redis" do
+ REDIS_DIR = File.join(File.dirname(__FILE__), "spec/assets")
+ REDIS_CNF = File.join(REDIS_DIR, "redis_test.conf")
+ REDIS_PID = File.join(REDIS_DIR, "redis_db/redis.pid")
- def migrate(database, schema_table, dir, target = nil)
- dir = "\"#{dir}\""
- schema_table = schema_table ? "\"#{schema_table}\"" : "nil"
- target = target ? "\"#{target}\"" : "nil"
+ task :start do
+ redis_running = false
- script=<<-EOS
- Sequel.extension :migration
- Sequel::TimestampMigrator.new(DB, #{dir}, :table => #{schema_table}, :target => #{target}).run
- EOS
+ begin
+ redis_running = File.exists?(REDIS_PID) &&
+ Process.kill(0, File.read(REDIS_PID).to_i)
+ rescue Errno::ESRCH
+ FileUtils.rm REDIS_PID
+ false
+ end
- IO.popen("bundle exec sequel '#{database}'", :mode => "r+") do |io|
- io.write(script)
- io.close_write
- puts io.read
+ unless redis_running
+ output = `redis-server "#{REDIS_CNF}"`
+ unless $?.exitstatus == 0
+ puts("Can't start redis-server: \n#{output}")
+ exit(1)
+ end
end
+ end
- exit(1) unless $?.exitstatus == 0
+ task :stop do
+ if File.exists?(REDIS_PID)
+ Process.kill "INT", File.read(REDIS_PID).to_i
+ FileUtils.rm REDIS_PID
+ end
end
end
-namespace "bundler" do
+namespace :spec do
+ SPEC_OPTS = %w(--format progress --colour)
- desc "Install gems"
- task "install" do
- sh("bundle install")
+ desc "Run Unit Tests"
+ unit_rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
+ t.gemfile = "Gemfile"
+ t.pattern = "spec/unit/**/*_spec.rb"
+ t.rspec_opts = SPEC_OPTS
end
- environments = %w(test development production)
+ CiTask.new do |task|
+ task.rspec_task = unit_rspec_task
+ end
- environments.each do |env|
- desc "Install gems for #{env}"
- task "install:#{env}" do
- sh("bundle install --local --without #{(environments - [env]).join(' ')}")
- end
+ desc ""
+ fn_rspec_task = RSpec::Core::RakeTask.new(:run_fn) do |t|
+ t.gemfile = "Gemfile"
+ t.pattern = "spec/functional/**/*_spec.rb"
+ t.rspec_opts = SPEC_OPTS
end
-end
+ CiTask.new do |task|
+ task.rspec_task = fn_rspec_task
+ end
+
+ desc "Run CPI Tests"
+ cpi_rspec_task = RSpec::Core::RakeTask.new(:cpi) do |t|
+ t.gemfile = "Gemfile"
+ t.pattern = "spec/cpi/**/*_spec.rb"
+ t.rspec_opts = SPEC_OPTS
+ end
-namespace "test" do
+ CiTask.new do |task|
+ task.rspec_task = cpi_rspec_task
+ end
+
+ desc "Run Functional Tests"
+ task "functional" => %w(redis:start spec:run_fn redis:stop)
+
+ desc "Run Functional Tests for CI"
+ task "functional:ci" => %w(redis:start spec:run_fn:ci redis:stop)
- %W(spec spec:unit spec:functional spec:cpi).each do |task_name|
- task task_name do
- sh("cd spec && rake #{task_name}")
+ namespace :combined do
+ task :run => %w(redis:start spec:combined:tests redis:stop)
+
+ desc ""
+ RSpec::Core::RakeTask.new(:tests) do |task|
+ task.gemfile = "Gemfile"
+ task.rspec_opts = SPEC_OPTS
+ task.pattern = "spec/{unit,functional}/**/*_spec.rb"
end
end
end
+
+desc "Install dependencies and run tests"
+task :spec => %w(bundler:install:test spec:combined:run)
View
78 director/migrations.rake
@@ -0,0 +1,78 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+namespace "migration" do
+ desc "Generate new migration"
+ task "new", :type, :name do |task, args|
+ type = args[:type]
+ if type.nil?
+ puts "Please provide migration type: rake #{task.name}[<type>, <name>]"
+ exit(1)
+ elsif !File.directory?("db/migrations/#{type}")
+ Dir.chdir("db/migrations")
+ valid_types = Dir["*"].select {|file| File.directory?(file)}
+ puts "Invalid type: '#{type}', must be one of: #{valid_types.join(", ")}"
+ exit(1)
+ end
+
+ name = args[:name]
+ if name.nil?
+ puts "Please provide migration name: rake #{task.name}[<type>, <name>]"
+ exit(1)
+ end
+
+ timestamp = Time.new.getutc.strftime("%Y%m%d%H%M%S")
+ filename = "db/migrations/#{type}/#{timestamp}_#{name}.rb"
+
+ puts "Creating #{filename}"
+ FileUtils.touch(filename)
+ end
+
+ desc "Run migrations"
+ task "run", :config do |task, args|
+ config_file = args[:config]
+ if config_file.nil?
+ abort("Please provide a path to the config file: " +
+ "rake #{task.name}[<path to config file>]")
+ elsif !File.file?(config_file)
+ abort("Invalid config file '#{config_file}'")
+ end
+
+ config = YAML.load_file(config_file)
+ unless config["db"] && config["db"]["database"]
+ abort ("Director database config missing from config file")
+ end
+
+ migrate(config["db"]["database"], nil, "db/migrations/director")
+ migrate(config["db"]["database"], "vsphere_cpi_schema",
+ "db/migrations/vsphere_cpi")
+
+ if config["dns"] && config["dns"]["db"]
+ migrate(config["dns"]["db"]["database"], "dns_schema",
+ "db/migrations/dns")
+ end
+ end
+
+ task "manual", :type, :db, :schema do |task, args|
+ migrate(args[:db], args[:schema], "db/migrations/#{args[:type]}")
+ end
+
+ def migrate(database, schema_table, dir, target = nil)
+ dir = "\"#{dir}\""
+ schema_table = schema_table ? "\"#{schema_table}\"" : "nil"
+ target = target ? "\"#{target}\"" : "nil"
+
+ script=<<-EOS
+ Sequel.extension :migration
+ Sequel::TimestampMigrator.new(DB, #{dir}, :table => #{schema_table},
+ :target => #{target}).run
+ EOS
+
+ IO.popen("bundle exec sequel '#{database}'", :mode => "r+") do |io|
+ io.write(script)
+ io.close_write
+ puts io.read
+ end
+
+ exit(1) unless $?.exitstatus == 0
+ end
+end
View
153 director/spec/Rakefile
@@ -1,153 +0,0 @@
-# Copyright (c) 2009-2012 VMware, Inc.
-
-if RUBY_VERSION < "1.9"
- puts("BOSH Director requires Ruby 1.9+")
- exit(1)
-end
-
-ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
-
-require "tempfile"
-
-require "rubygems"
-require "bundler"
-Bundler.setup(:default, :test)
-
-require "rake"
-require "rspec/core/rake_task"
-require "ci/reporter/rake/rspec"
-
-coverage_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_coverage"))
-reports_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_reports"))
-
-ENV["CI_REPORTS"] = reports_dir
-
-namespace "redis" do
-
- REDIS_DIR = File.join(File.dirname(__FILE__), "assets")
- REDIS_CNF = File.join(REDIS_DIR, "redis_test.conf")
- REDIS_PID = File.join(REDIS_DIR, "redis_db/redis.pid")
-
- task :start do
- redis_running = false
-
- begin
- redis_running = File.exists?(REDIS_PID) && Process.kill(0, File.read(REDIS_PID).to_i)
- rescue Errno::ESRCH
- FileUtils.rm REDIS_PID
- false
- end
-
- unless redis_running
- output = `redis-server "#{REDIS_CNF}"`
- unless $?.exitstatus == 0
- puts("Can't start redis-server: \n#{output}")
- exit(1)
- end
- end
- end
-
- task :stop do
- if File.exists?(REDIS_PID)
- Process.kill "INT", File.read(REDIS_PID).to_i
- FileUtils.rm REDIS_PID
- end
- end
-
-end
-
-desc "Run Director functional and unit tests"
-task :spec => %W(spec:smoke:run)
-
-namespace :spec do
- gemfile = "../Gemfile"
- spec_opts = %W(--format documentation --colour)
-
- desc "Run Director unit tests"
- task :unit => %W(spec:unit:run)
-
- task :cleanup_cov do
- FileUtils.rm_rf(coverage_dir)
- end
-
- task :cleanup_reports do
- FileUtils.rm_rf(reports_dir)
- end
-
- namespace :unit do
- desc ""
- RSpec::Core::RakeTask.new(:run) do |task|
- task.gemfile = gemfile
- task.rspec_opts = spec_opts
- task.pattern = "unit/**/*_spec.rb"
- end
-
- desc "Run Director unit tests with code coverage"
- task :cov do
- ENV["SIMPLECOV"] = "1"
- Rake::Task["spec:cleanup_cov"].invoke
- Rake::Task["spec:unit:run"].invoke
- end
-
- desc "Run Director unit tests for CI"
- task :ci => %W(ci:setup:rspec spec:cleanup_reports spec:unit:cov)
- end
-
- desc "Run Director functional tests"
- task :functional => %W(spec:functional:run)
-
- namespace :functional do
- task :run => %W(redis:start spec:functional:tests redis:stop)
-
- desc ""
- RSpec::Core::RakeTask.new(:tests) do |task|
- task.gemfile = gemfile
- task.rspec_opts = spec_opts
- task.pattern = "functional/**/*_spec.rb"
- end
-
- desc "Run Director functional tests with code coverage"
- task :cov do
- ENV["SIMPLECOV"] = "1"
- Rake::Task["spec:cleanup_cov"].invoke
- Rake::Task["spec:functional:run"].invoke
- end
-
- desc "Run Director functional tests for CI"
- task :ci => %W(ci:setup:rspec spec:cleanup_reports spec:functional:cov)
- end
-
- namespace :smoke do
- task :run => %W(redis:start spec:smoke:tests redis:stop)
-
- desc ""
- RSpec::Core::RakeTask.new(:tests) do |task|
- task.gemfile = gemfile
- task.rspec_opts = spec_opts
- task.pattern = "{unit,functional}/**/*_spec.rb"
- end
- end
-
- desc "Run Director CPI tests"
- task :cpi => %W(spec:cpi:run)
-
- namespace :cpi do
- desc ""
- RSpec::Core::RakeTask.new(:run) do |task|
- task.gemfile = gemfile
- task.rspec_opts = spec_opts
- task.pattern = "cpi/**/*_spec.rb"
- end
-
- desc "Run Director CPI tests with code coverage"
- task :cov do
- ENV["SIMPLECOV"] = "1"
- Rake::Task["spec:cleanup_cov"].invoke
- Rake::Task["spec:cpi:run"].invoke
- end
-
- desc "Run Director CPI tests for CI"
- task :ci => %W(ci:setup:rspec spec:cleanup_reports spec:cpi:cov)
- end
-
-end
View
4 director/spec/assets/redis_test.conf
@@ -1,5 +1,5 @@
-dir ./assets/redis_db
-pidfile ./redis.pid
+dir ./spec/assets/redis_db
+pidfile ./spec/redis.pid
port 63790
timeout 300
loglevel debug
View
20 director/spec/spec_helper.rb
@@ -26,7 +26,6 @@ class << self
def init
ENV["RACK_ENV"] = "test"
- enable_simplecov if ENV["SIMPLECOV"]
configure_logging
configure_temp_dir
@@ -38,25 +37,6 @@ def init
require "blueprints"
end
- def enable_simplecov
- require "simplecov"
- require "simplecov-rcov"
- require "simplecov-clover"
-
- SimpleCov.formatter = Class.new do
- def format(result)
- SimpleCov::Formatter::CloverFormatter.new.format(result)
- SimpleCov::Formatter::RcovFormatter.new.format(result)
- end
- end
-
- SimpleCov.root(File.expand_path("../..", __FILE__))
- SimpleCov.add_filter("spec")
- SimpleCov.add_filter("vendor")
- SimpleCov.coverage_dir(ENV["SIMPLECOV_DIR"] || "spec_coverage")
- SimpleCov.start
- end
-
def configure_logging
if ENV["DEBUG"]
@logger = Logger.new(STDOUT)
View
12 monit_api/Gemfile
@@ -5,9 +5,13 @@ gem "crack"
group :test do
gem "ci_reporter"
- gem "rcov"
- gem "rcov_analyzer"
gem "rspec"
- gem "ruby-debug", :platform => :ruby_18
- gem "ruby-debug19", :platform => :ruby_19
+
+ gem "ruby-debug", :platforms => :ruby_18
+ gem "ruby-debug19", :platforms => :ruby_19
+
+ gem "rcov", :platforms => :ruby_18
+
+ gem "simplecov", :platforms => :ruby_19
+ gem "simplecov-rcov", :platforms => :ruby_19
end
View
13 monit_api/Gemfile.lock
@@ -11,11 +11,9 @@ GEM
linecache (0.43)
linecache19 (0.5.12)
ruby_core_source (>= 0.1.4)
+ multi_json (1.0.4)
rake (0.8.7)
rcov (0.9.9)
- rcov_analyzer (0.2)
- builder
- rcov
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
@@ -39,6 +37,12 @@ GEM
ruby-debug-base19 (>= 0.11.19)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
+ simplecov (0.5.4)
+ multi_json (~> 1.0.3)
+ simplecov-html (~> 0.5.3)
+ simplecov-html (0.5.3)
+ simplecov-rcov (0.2.3)
+ simplecov (>= 0.4.1)
PLATFORMS
ruby
@@ -48,7 +52,8 @@ DEPENDENCIES
crack
rake
rcov
- rcov_analyzer
rspec
ruby-debug
ruby-debug19
+ simplecov
+ simplecov-rcov
View
84 monit_api/Rakefile
@@ -1,68 +1,46 @@
-require "rubygems"
-require "rubygems/package_task"
-
-$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "lib"))
-require "monit_api/version"
+# Copyright (c) 2009-2012 VMware, Inc.
-GEM = "monit_api"
-GEM_VERSION = MonitApi::VERSION
+$:.unshift(File.expand_path("../../rake", __FILE__))
-gemspec = Gem::Specification.new do |s|
- s.name = GEM
- s.version = GEM_VERSION
- s.platform = Gem::Platform::RUBY
- s.summary = "Monit API Client"
- s.description = s.summary
- s.authors = [ "Vadim Spivak" ]
- s.email = "vspivak@vmware.com"
- s.homepage = "http://vmware.com"
- s.require_path = "lib"
- s.files = %w(README Rakefile) + Dir.glob("{lib,spec}/**/*")
-
- s.add_dependency "crack"
-end
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
-Gem::PackageTask.new(gemspec) do |pkg|
- pkg.gem_spec = gemspec
-end
+require "rubygems"
+require "bundler"
+Bundler.setup(:default, :test)
-task :install => [ :package ] do
- sh "gem install pkg/#{GEM}-#{GEM_VERSION}"
-end
+require "rake"
+require "rspec/core/rake_task"
-desc "Run specs"
-task :spec => [ "bundler:install:test", "test:spec" ]
+require "bundler_task"
+require "ci_task"
-desc "Run specs for CI"
-task "spec:ci" => ["bundler:install:test", "test:spec:ci"]
+gem_helper = Bundler::GemHelper.new(Dir.pwd)
-desc "Run specs w/coverage"
-task "spec:rcov" => ["bundler:install:test", "test:spec:rcov"]
+desc "Build Monit API Client gem into the pkg directory"
+task "build" do
+ gem_helper.build_gem
+end
-environments = %w(test development production)
+desc "Build and install Monit API Client into system gems"
+task "install" do
+ sh("bundle install --local --without test development")
+ gem_helper.install_gem
+end
-namespace "bundler" do
+BundlerTask.new
- desc "Install gems"
- task "install" do
- sh("bundle install")
+namespace :spec do
+ desc "Run Unit Tests"
+ rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
+ t.gemfile = "Gemfile"
+ t.pattern = "spec/unit/**/*_spec.rb"
+ t.rspec_opts = %w(--format progress --colour)
end
- environments = %w(test development production)
-
- environments.each do |env|
- desc "Install gems for #{env}"
- task "install:#{env}" do
- sh("bundle install --local --without #{(environments - [env]).join(' ')}")
- end
+ CiTask.new do |task|
+ task.rspec_task = rspec_task
end
-
end
-namespace "test" do
- ["spec", "spec:rcov", "spec:ci" ].each do |task_name|
- task task_name do
- sh("cd spec && rake #{task_name}")
- end
- end
-end
+desc "Install dependencies and run tests"
+task :spec => %w(bundler:install:test spec:unit)
View
18 monit_api/monit_api.gemspec
@@ -0,0 +1,18 @@
+require File.dirname(__FILE__) + "/lib/monit_api/version"
+
+Gem::Specification.new do |s|
+ s.name = "monit_api"
+ s.version = MonitApi::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.summary = "Bosh Monit API client"
+ s.description = s.summary
+ s.author = "VMware"
+ s.email = "support@vmware.com"
+ s.homepage = "http://www.vmware.com"
+
+ s.files = `git ls-files -- lib/*`.split("\n") + %w(README Rakefile)
+ s.test_files = `git ls-files -- spec/*`.split("\n")
+ s.require_path = "lib"
+
+ s.add_dependency "crack"
+end
View
50 monit_api/spec/Rakefile
@@ -1,50 +0,0 @@
-require "tempfile"
-require "rake"
-
-APP_DIR = File.expand_path(File.join("..", ".."), __FILE__)
-ENV["BUNDLE_GEMFILE"] ||= File.join(APP_DIR, "Gemfile")
-require "rubygems"
-require "bundler"
-Bundler.setup(:default, :test)
-
-require "rspec/core/rake_task"
-require "ci/reporter/rake/rspec"
-
-desc "Run all examples"
-RSpec::Core::RakeTask.new(:spec) do |t|
- t.pattern = "**/*_spec.rb"
- t.rspec_opts = %w[--color]
-end
-
-task :default => [:spec]
-
-coverage_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_coverage"))
-reports_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_reports"))
-dump_file = File.join(Dir.tmpdir, "monit-api.rcov")
-
-ENV["CI_REPORTS"] = reports_dir
-
-namespace "spec" do
- gemfile = "../Gemfile"
-
- desc "Run specs for ci"
- task "ci" => [ "ci:setup:rspec", "spec:rcov", "convert_rcov_to_clover" ]
-
- RSpec::Core::RakeTask.new("rcov") do |t|
- FileUtils.rm_rf(dump_file)
- t.gemfile = gemfile
- t.pattern = "**/*_spec.rb"
- t.rspec_opts = ["--format", "progress", "--colour"]
- t.rcov = true
- t.rcov_opts = %W{--aggregate #{dump_file} --exclude osx\/objc,gems\/,spec\/,unit\/,features\/ -o "#{coverage_dir}"}
- end
-
- task "convert_rcov_to_clover" do |t|
- ignore_pattern = "spec,[.]bundle,[/]gems[/]"
- clover_output = File.join(coverage_dir, "clover.xml")
-
- sh("bundle exec rcov_analyzer #{dump_file} #{ignore_pattern} > #{clover_output}")
- FileUtils.rm_rf(dump_file)
- end
-
-end
View
14 monit_api/spec/spec_helper.rb
@@ -1,8 +1,10 @@
-require "rspec/core"
+# Copyright (c) 2009-2012 VMware, Inc.
-$:.unshift(File.expand_path("../../lib", __FILE__))
-require "monit_api"
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
+
+require "rubygems"
+require "bundler"
+Bundler.setup(:default, :test)
-RSpec.configure do |c|
- c.color_enabled = true
-end
+require "rspec"
+require "monit_api"
View
31 rake/bundler_task.rb
@@ -0,0 +1,31 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+require "rake/tasklib"
+
+class BundlerTask < ::Rake::TaskLib
+ def initialize
+ namespace "bundler" do
+ desc "Install gems"
+ task "install" do
+ sh("bundle install")
+ end
+
+ environments = %w(test development production)
+
+ environments.each do |env|
+ desc "Install gems for #{env}"
+ task "install:#{env}" do
+ Bundler.with_clean_env do
+ if ENV.has_key? "RUBYOPT"
+ ENV["RUBYOPT"] = ENV["RUBYOPT"].sub("-rbundler/setup", "")
+ ENV["RUBYOPT"] = ENV["RUBYOPT"].sub(
+ "-I#{File.expand_path("..", __FILE__)}", "")
+ end
+
+ sh("bundle install --without #{(environments - [env]).join(" ")}")
+ end
+ end
+ end
+ end
+ end
+end
View
60 rake/ci_task.rb
@@ -0,0 +1,60 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+require "pathname"
+require "rake/tasklib"
+
+class CiTask < ::Rake::TaskLib
+ attr_accessor :rspec_task
+ attr_accessor :test_reports_dir
+ attr_accessor :coverage_dir
+ attr_accessor :root_dir
+
+ def initialize
+ yield self
+
+ @root_dir ||= Dir.pwd
+ @test_reports_dir ||= File.join(@root_dir, "ci_result/reports")
+ @coverage_dir ||= File.join(@root_dir, "ci_result/coverage")
+
+ # TODO remove once CI is reconfigured
+ legacy_spec_coverage = File.join(@root_dir, "spec_coverage")
+ legacy_spec_reports = File.join(@root_dir, "spec_reports")
+
+ actual_rspec_task = Rake.application.lookup(@rspec_task.name)
+ rspec_task_description = actual_rspec_task.comment
+
+ if rspec_task_description && !rspec_task_description.empty?
+ desc("#{rspec_task_description} for CIs")
+ end
+ task("#{@rspec_task.name}:ci") do |task|
+ rm_rf(legacy_spec_coverage)
+ rm_rf(legacy_spec_reports)
+
+ rm_rf(@test_reports_dir)
+ rm_rf(@coverage_dir)
+
+ require "ci/reporter/rake/rspec"
+ ENV["CI_REPORTS"] = @test_reports_dir
+ Rake::Task["ci:setup:rspec"].execute
+
+ if RUBY_VERSION < "1.9"
+ @rspec_task.rcov = true
+ @rspec_task.rcov_opts =
+ %W{--exclude spec\/,vendor\/ -o "#{@coverage_dir}/rcov"}
+ actual_rspec_task.invoke
+ else
+ simple_cov_helper = File.expand_path("../simplecov_helper", __FILE__)
+ ENV["SPEC_OPTS"] = "#{ENV['SPEC_OPTS']} --require #{simple_cov_helper}"
+ ENV["SIMPLECOV"] = "1"
+ ENV["SIMPLECOV_ROOT"] = @root_dir
+ ENV["SIMPLECOV_EXCLUDE"] = "spec, vendor"
+ ENV["SIMPLECOV_DIR"] = Pathname.new(@coverage_dir).relative_path_from(
+ Pathname.new(root_dir)).to_s
+ actual_rspec_task.invoke
+ end
+
+ ln_s(@test_reports_dir, legacy_spec_reports)
+ ln_s(@coverage_dir, legacy_spec_coverage)
+ end
+ end
+end
View
20 rake/simplecov_helper.rb
@@ -0,0 +1,20 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+require "rubygems"
+require "bundler"
+Bundler.setup(:default, :test)
+
+if ENV["SIMPLECOV"]
+ require "simplecov"
+ require "simplecov-rcov"
+
+ SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
+ SimpleCov.root(ENV["SIMPLECOV_ROOT"])
+ if ENV["SIMPLECOV_EXCLUDE"]
+ ENV["SIMPLECOV_EXCLUDE"].split(",").each do |filter|
+ SimpleCov.add_filter(filter.strip)
+ end
+ end
+ SimpleCov.coverage_dir(ENV["SIMPLECOV_DIR"]) if ENV["SIMPLECOV_DIR"]
+ SimpleCov.start
+end
View
15 ruby_vim_sdk/Gemfile
@@ -2,12 +2,17 @@ source :rubygems
gemspec
+gem "rake"
+
group :test do
gem "ci_reporter"
- gem "rake"
gem "rspec"
- gem "ruby-debug19"
- gem "simplecov"
- gem "simplecov-clover"
- gem "simplecov-rcov"
+
+ gem "ruby-debug", :platforms => :ruby_18
+ gem "ruby-debug19", :platforms => :ruby_19
+
+ gem "rcov", :platforms => :ruby_18
+
+ gem "simplecov", :platforms => :ruby_19
+ gem "simplecov-rcov", :platforms => :ruby_19
end
View
1  ruby_vim_sdk/README
@@ -0,0 +1 @@
+Ruby VIM SDK is a gem to simplify making vSphere API calls.
View
60 ruby_vim_sdk/Rakefile
@@ -1,40 +1,46 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+$:.unshift(File.expand_path("../../rake", __FILE__))
+
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
+
require "rubygems"
require "bundler"
-Bundler::GemHelper.install_tasks
+Bundler.setup(:default, :test)
-desc "Run specs"
-task :spec => [ "bundler:install:test", "test:spec" ]
+require "rake"
+require "rspec/core/rake_task"
-desc "Run specs for CI"
-task "spec:ci" => ["bundler:install:test", "test:spec:ci"]
+require "bundler_task"
+require "ci_task"
-desc "Run specs w/coverage"
-task "spec:rcov" => ["bundler:install:test", "test:spec:rcov"]
+gem_helper = Bundler::GemHelper.new(Dir.pwd)
-environments = %w(test development production)
-
-namespace "bundler" do
+desc "Build Ruby VIM Client gem into the pkg directory"
+task "build" do
+ gem_helper.build_gem
+end
- desc "Install gems"
- task "install" do
- sh("bundle install")
- end
+desc "Build and install Ruby VIM Client into system gems"
+task "install" do
+ sh("bundle install --local --without test development")
+ gem_helper.install_gem
+end
- environments = %w(test development production)
+BundlerTask.new
- environments.each do |env|
- desc "Install gems for #{env}"
- task "install:#{env}" do
- sh("bundle install --local --without #{(environments - [env]).join(' ')}")
- end
+namespace :spec do
+ desc "Run Unit Tests"
+ rspec_task = RSpec::Core::RakeTask.new(:unit) do |t|
+ t.gemfile = "Gemfile"
+ t.pattern = "spec/unit/**/*_spec.rb"
+ t.rspec_opts = %w(--format progress --colour)
end
-end
-
-namespace "test" do
- ["spec", "spec:rcov", "spec:ci" ].each do |task_name|
- task task_name do
- sh("cd spec && rake #{task_name}")
- end
+ CiTask.new do |task|
+ task.rspec_task = rspec_task
end
end
+
+desc "Install dependencies and run tests"
+task :spec => %w(bundler:install:test spec:unit)
View
5 ruby_vim_sdk/lib/ruby_vim_sdk/version.rb
@@ -0,0 +1,5 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
+module VimSdk
+ VERSION = "0.0.2"
+end
View
23 ruby_vim_sdk/ruby_vim_sdk.gemspec
@@ -1,15 +1,22 @@
-$:.push File.expand_path("../lib", __FILE__)
+$:.unshift(File.expand_path("../lib", __FILE__))
+
+require "ruby_vim_sdk/version"
Gem::Specification.new do |s|
- s.name = "ruby_vim_sdk"
- s.version = "0.0.2"
- s.platform = Gem::Platform::RUBY
- s.summary = %q{VMware VIM Binding for Ruby}
+ s.name = "ruby_vim_sdk"
+ s.version = VimSdk::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.summary = "Bosh vSphere API client"
+ s.description = s.summary
+ s.author = "VMware"
+ s.email = "support@vmware.com"
+ s.homepage = "http://www.vmware.com"
- s.files = %w(Rakefile) + `git ls-files -- lib/*`.split("\n")
- s.require_paths = ["lib"]
+ s.files = `git ls-files -- lib/*`.split("\n") + %w(README Rakefile)
+ s.test_files = `git ls-files -- spec/*`.split("\n")
+ s.require_path = "lib"
s.add_dependency("builder")
- s.add_dependency("nokogiri")
s.add_dependency("httpclient")
+ s.add_dependency("nokogiri")
end
View
87 ruby_vim_sdk/spec/Rakefile
@@ -1,87 +0,0 @@
-require "rake"
-require "tempfile"
-
-APP_DIR = File.expand_path(File.join("..", ".."), __FILE__)
-ENV["BUNDLE_GEMFILE"] ||= File.join(APP_DIR, "Gemfile")
-require "rubygems"
-require "bundler"
-Bundler.setup(:default, :test)
-
-require "rspec/core/rake_task"
-require "ci/reporter/rake/rspec"
-
-desc "Run all examples"
-RSpec::Core::RakeTask.new(:spec) do |t|
- t.pattern = "**/*_spec.rb"
- t.rspec_opts = %w[--color]
-end
-
-task :default => [:spec]
-
-coverage_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_coverage"))
-reports_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_reports"))
-dump_file = File.join(Dir.tmpdir, "bosh-ruby-vim-sdk.rcov")
-
-ENV["CI_REPORTS"] = reports_dir
-
-namespace "spec" do
- gemfile = "../Gemfile"
- spec_opts = ["--format", "documentation", "--colour"]
-
- if RUBY_VERSION < "1.9"
- desc "Run specs for ci"
- task "ci" => [ "ci:setup:rspec", "spec:rcov", "convert_rcov_to_clover" ]
-
- desc "Run spec with coverage"
- RSpec::Core::RakeTask.new("rcov") do |t|
- FileUtils.rm_rf(dump_file)
- t.gemfile = gemfile
- t.pattern = "unit/**/*_spec.rb"
- t.rspec_opts = ["--format", "progress", "--colour"]
- t.rcov = true
- t.rcov_opts = %W{--aggregate #{dump_file} --exclude osx\/objc,gems\/,spec\/,unit\/,features\/ -o "#{coverage_dir}"}
- end
-
- task "convert_rcov_to_clover" do |t|
- ignore_pattern = "spec,[.]bundle,[/]gems[/]"
- clover_output = File.join(coverage_dir, "clover.xml")
-
- sh("bundle exec rcov_analyzer #{dump_file} #{ignore_pattern} > #{clover_output}")
- FileUtils.rm_rf(dump_file)
- end
-
- else
- desc "Run specs for ci"
- task "ci" => [ "ci:setup:rspec", "spec:rcov" ]
-
- desc "Run spec with coverage"
- task :rcov => :cleanup_coverage do
- require "simplecov"
- require "simplecov-rcov"
- require "simplecov-clover"
-
- class SimpleCov::Formatter::CombinedFormatter
- def format(result)
- SimpleCov::Formatter::CloverFormatter.new.format(result)
- SimpleCov::Formatter::RcovFormatter.new.format(result)
- end
- end
-
- SimpleCov.formatter = SimpleCov::Formatter::CombinedFormatter
- SimpleCov.root('..')
- SimpleCov.coverage_dir('cov')
- SimpleCov.start do
- require "rspec/core"
- add_filter "/spec/"
- spec_dir = File.expand_path("..", __FILE__)
- RSpec::Core::Runner.disable_autorun!
- RSpec::Core::Runner.run([spec_dir], STDERR, STDOUT)
- end
- end
- end
-
- task "cleanup_coverage" do
- rm_rf "cov"
- end
-
-end
View
3  ruby_vim_sdk/spec/spec_helper.rb
@@ -1,6 +1,7 @@
-$:.unshift(File.expand_path("../../lib", __FILE__))
+# Copyright (c) 2009-2012 VMware, Inc.
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
+
require "rubygems"
require "bundler"
Bundler.setup(:default, :test)
View
BIN  ruby_vim_sdk/vendor/cache/simplecov-clover-0.0.1.gem
Binary file not shown
View
15 simple_blobstore_server/Gemfile
@@ -1,14 +1,21 @@
source :rubygems
+gem "rake"
gem "sinatra"
gem "thin"
gem "uuidtools"
group :test do
gem "rack-test"
- gem "rspec"
- gem "simplecov"
- gem "simplecov-clover"
- gem "simplecov-rcov"
+
gem "ci_reporter"
+ gem "rspec"
+
+ gem "ruby-debug", :platforms => :ruby_18
+ gem "ruby-debug19", :platforms => :ruby_19
+
+ gem "rcov", :platforms => :ruby_18
+
+ gem "simplecov", :platforms => :ruby_19
+ gem "simplecov-rcov", :platforms => :ruby_19
end
View
31 simple_blobstore_server/Gemfile.lock
@@ -1,15 +1,24 @@
GEM
remote: http://rubygems.org/
specs:
+ archive-tar-minitar (0.5.2)
builder (3.0.0)
ci_reporter (1.6.4)
builder (>= 2.1.2)
+ columnize (0.3.6)
daemons (1.1.5)
diff-lcs (1.1.2)
eventmachine (0.12.10)
+ linecache (0.46)
+ rbx-require-relative (> 0.0.4)
+ linecache19 (0.5.12)
+ ruby_core_source (>= 0.1.4)
rack (1.4.0)
rack-test (0.5.7)
rack (>= 1.0)
+ rake (0.9.2.2)
+ rbx-require-relative (0.0.5)
+ rcov (1.0.0)
rspec (2.5.0)
rspec-core (~> 2.5.0)
rspec-expectations (~> 2.5.0)
@@ -18,10 +27,23 @@ GEM
rspec-expectations (2.5.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.5.0)
+ ruby-debug (0.10.4)
+ columnize (>= 0.1)
+ ruby-debug-base (~> 0.10.4.0)
+ ruby-debug-base (0.10.4)
+ linecache (>= 0.3)
+ ruby-debug-base19 (0.11.25)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby_core_source (>= 0.1.4)
+ ruby-debug19 (0.11.6)
+ columnize (>= 0.3.1)
+ linecache19 (>= 0.5.11)
+ ruby-debug-base19 (>= 0.11.19)
+ ruby_core_source (0.1.5)
+ archive-tar-minitar (>= 0.5.2)
simplecov (0.4.2)
simplecov-html (~> 0.4.4)
- simplecov-clover (0.0.1)
- simplecov (>= 0.4.1)
simplecov-html (0.4.5)
simplecov-rcov (0.2.3)
simplecov (>= 0.4.1)
@@ -41,9 +63,12 @@ PLATFORMS
DEPENDENCIES
ci_reporter
rack-test
+ rake
+ rcov
rspec
+ ruby-debug
+ ruby-debug19
simplecov
- simplecov-clover
simplecov-rcov
sinatra
thin
View
52 simple_blobstore_server/Rakefile
@@ -1,9 +1,6 @@
# Copyright (c) 2009-2012 VMware, Inc.
-if RUBY_VERSION < "1.9"
- puts("BOSH Director requires Ruby 1.9+")
- exit(1)
-end
+$:.unshift(File.expand_path("../../rake", __FILE__))
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __FILE__)
@@ -13,45 +10,24 @@ Bundler.setup(:default, :test)
require "rake"
require "rspec/core/rake_task"
-require "ci/reporter/rake/rspec"
-coverage_dir = File.expand_path("../spec_coverage", __FILE__)
-reports_dir = File.expand_path("../spec_reports", __FILE__)
+require "bundler_task"
+require "ci_task"
-ENV["CI_REPORTS"] = reports_dir
+BundlerTask.new
namespace :spec do
- gemfile = "Gemfile"
- spec_opts = %W(--format documentation --colour)
-
- task :cleanup_cov do
- FileUtils.rm_rf(coverage_dir)
+ desc "Run Functional Tests"
+ rspec_task = RSpec::Core::RakeTask.new(:functional) do |t|
+ t.gemfile = "Gemfile"
+ t.pattern = "spec/functional/**/*_spec.rb"
+ t.rspec_opts = %w(--format progress --colour)
end
- task :cleanup_reports do
- FileUtils.rm_rf(reports_dir)
- end
-
- desc "Run Blobstore Server functional tests"
- task :functional => %W(spec:functional:run)
-
- namespace :functional do
-
- desc ""
- RSpec::Core::RakeTask.new(:run) do |task|
- task.gemfile = gemfile
- task.rspec_opts = spec_opts
- task.pattern = "spec/functional/**/*_spec.rb"
- end
-
- desc "Run Blobstore Server functional tests with code coverage"
- task :cov do
- ENV["SIMPLECOV"] = "1"
- Rake::Task["spec:cleanup_cov"].invoke
- Rake::Task["spec:functional:run"].invoke
- end
-
- desc "Run Blobstore Server functional tests for CI"
- task :ci => %W(ci:setup:rspec spec:cleanup_reports spec:functional:cov)
+ CiTask.new do |task|
+ task.rspec_task = rspec_task
end
end
+
+desc "Install dependencies and run tests"
+task :spec => %w(bundler:install:test spec:functional)
View
33 simple_blobstore_server/spec/spec_helper.rb
@@ -1,27 +1,11 @@
+# Copyright (c) 2009-2012 VMware, Inc.
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__)
require "rubygems"
Bundler.setup(:default, :test)
-if ENV["SIMPLECOV"]
- require "simplecov"
- require "simplecov-rcov"
- require "simplecov-clover"
-
- SimpleCov.formatter = Class.new do
- def format(result)
- SimpleCov::Formatter::CloverFormatter.new.format(result)
- SimpleCov::Formatter::RcovFormatter.new.format(result)
- end
- end
-
- SimpleCov.root(File.expand_path("../..", __FILE__))
- SimpleCov.add_filter("spec")
- SimpleCov.add_filter("vendor")
- SimpleCov.coverage_dir(ENV["SIMPLECOV_DIR"] || "spec_coverage")
- SimpleCov.start
-end
-
+require "rspec"
require "rack/test"
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/../lib")
@@ -29,14 +13,3 @@ def format(result)
ENV["RACK_ENV"] = "test"
require "simple_blobstore_server"
-
-Rspec.configure do |rspec_config|
- rspec_config.before(:each) do
- end
-
- rspec_config.after(:each) do
- end
-
- rspec_config.after(:all) do
- end
-end
View
BIN  simple_blobstore_server/vendor/cache/archive-tar-minitar-0.5.2.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/columnize-0.3.6.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/linecache-0.46.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/linecache19-0.5.12.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/rake-0.9.2.2.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/rbx-require-relative-0.0.5.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/rcov-1.0.0.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/ruby-debug-0.10.4.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/ruby-debug-base-0.10.4.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/ruby-debug-base19-0.11.25.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/ruby-debug19-0.11.6.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/ruby_core_source-0.1.5.gem
Binary file not shown
View
BIN  simple_blobstore_server/vendor/cache/simplecov-clover-0.0.1.gem
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.