Permalink
Browse files

-removed exclusion from unit test.

-updated package cache client name references.
-fixed bug in run code.

Change-Id: I18d1bbb4bbd18b0ba16aec43e07ec312e7a05190
  • Loading branch information...
Tal Garfinkel
Tal Garfinkel committed Jan 25, 2012
1 parent 8e6e196 commit 18cc1e20e881af8e73cc0a7ae0b55bab529a8a92
Showing with 32 additions and 33 deletions.
  1. +13 −6 package_cache/Gemfile.lock
  2. +8 −18 package_cache/lib/vcap/package_cache/run.rb
  3. +1 −1 package_cache/package_cache.gemspec
  4. +1 −1 package_cache/spec/unit/gem_builder_spec.rb
  5. +1 −1 package_cache/spec/unit/inbox_spec.rb
  6. +1 −1 package_cache/tests/e2e_test
  7. +5 −3 package_cache/tests/load_test
  8. BIN package_cache/vendor/cache/daemons-1.1.5.gem
  9. BIN package_cache/vendor/cache/daemons-1.1.6.gem
  10. BIN package_cache/vendor/cache/json_pure-1.6.4.gem
  11. BIN package_cache/vendor/cache/json_pure-1.6.5.gem
  12. BIN package_cache/vendor/cache/logging-1.6.1.gem
  13. BIN package_cache/vendor/cache/logging-1.6.2.gem
  14. BIN package_cache/vendor/cache/nats-0.4.22.beta.4.gem
  15. BIN package_cache/vendor/cache/nats-0.4.22.beta.8.gem
  16. BIN package_cache/vendor/cache/rack-1.4.0.gem
  17. BIN package_cache/vendor/cache/rack-1.4.1.gem
  18. BIN package_cache/vendor/cache/vcap_package_cache-client-0.1.8.gem
  19. BIN package_cache/vendor/cache/vcap_package_cache_client-0.1.8.gem
  20. 0 package_cache_client/lib/vcap/{package_cache-client → package_cache_client}/cache_client.rb
  21. 0 package_cache_client/lib/vcap/{package_cache-client → package_cache_client}/client.rb
  22. 0 package_cache_client/lib/vcap/{package_cache-client → package_cache_client}/config.rb
  23. 0 package_cache_client/lib/vcap/{package_cache-client → package_cache_client}/errors.rb
  24. 0 package_cache_client/lib/vcap/{package_cache-client → package_cache_client}/inbox_client.rb
  25. 0 package_cache_client/lib/vcap/{package_cache-client → package_cache_client}/pkg_util.rb
  26. 0 package_cache_client/lib/vcap/{package_cache-client → package_cache_client}/version.rb
  27. +1 −1 package_cache_client/package_cache_client.gemspec
  28. +1 −1 package_cache_client/spec/spec_helper.rb
View
@@ -7,28 +7,31 @@ PATH
thin (= 1.3.1)
vcap_common (~> 1.0.3)
vcap_logging (>= 0.1.1)
- vcap_package_cache-client (= 0.1.8)
+ vcap_package_cache_client (= 0.1.8)
GEM
remote: http://rubygems.org/
specs:
- daemons (1.1.5)
+ daemons (1.1.6)
diff-lcs (1.1.3)
eventmachine (0.12.11.cloudfoundry.3)
- json_pure (1.6.4)
+ json_pure (1.6.5)
little-plugger (1.1.3)
logging (1.6.2)
little-plugger (>= 1.1.3)
- nats (0.4.22.beta.4)
+ mime-types (1.17.2)
+ nats (0.4.22.beta.8)
daemons (>= 1.1.4)
eventmachine (>= 0.12.10)
json_pure (>= 1.6.1)
thin (>= 1.3.1)
posix-spawn (0.3.6)
- rack (1.4.0)
+ rack (1.4.1)
rack-protection (1.2.0)
rack
rake (0.9.2.2)
+ rest-client (1.6.3)
+ mime-types (>= 1.16)
rspec (2.7.0)
rspec-core (~> 2.7.0)
rspec-expectations (~> 2.7.0)
@@ -54,7 +57,11 @@ GEM
thin (~> 1.3.1)
yajl-ruby (~> 0.8.3)
vcap_logging (0.1.3)
- vcap_package_cache-client (0.1.8)
+ vcap_package_cache_client (0.1.8)
+ rake (= 0.9.2.2)
+ rest-client (= 1.6.3)
+ vcap_common (~> 1.0.3)
+ vcap_logging (>= 0.1.1)
yajl-ruby (0.8.3)
PLATFORMS
@@ -38,10 +38,6 @@ def chown(uid, gid, path)
run_sudo("chown +#{uid}:+#{gid} #{path}") if @secure_mode
end
- def chown_r(uid, gid, path)
- run_sudo("chown -R +#{uid}:+#{gid} #{path}") if @secure_mode
- end
-
def run_cmd(cmd, expected_result = 0)
cmd_str = "#{cmd} 2>&1"
stdout = `#{cmd_str}`
@@ -52,25 +48,19 @@ def run_cmd(cmd, expected_result = 0)
return stdout, result
end
- def transfer_ownership(path, user)
- chown_r(user[:uid], user[:gid], path)
- end
-
- def recover_ownership(path)
- chown_r(Process.uid, Process.gid, path)
- end
-
def run_restricted(run_dir, user, cmd)
- Dir.chdir(run_dir) {
- transfer_ownership(run_dir, user)
+ #transfer_ownership(run_dir, user)
+ chdir_cmd = "cd #{run_dir}"
+ pass_ownership = "sudo chown -R +#{user[:uid]}:+#{user[:gid]} #{run_dir}"
+ run_as_cmd = "sudo -n -u #{user[:user_name]} #{cmd}"
+ recover_ownership = "sudo -n chown -R +#{Process.uid}:+#{Process.gid} #{run_dir}"
if @secure_mode
- stdout, result = run_sudo("-u #{user[:user_name]} #{cmd}")
+ stdout, result = run_cmd(
+ "#{chdir_cmd} ; #{pass_ownership}; #{run_as_cmd}; #{recover_ownership}")
else
- stdout, result = run_cmd(cmd)
+ stdout, result = run_cmd("cd #{run_dir}; #{cmd}")
end
- recover_ownership(run_dir)
return stdout, result
- }
end
end
end
@@ -23,6 +23,6 @@ Gem::Specification.new do |s|
s.add_dependency('sinatra', '1.3.2')
s.add_dependency('vcap_common', '~> 1.0.3')
s.add_dependency('vcap_logging', '>= 0.1.1')
- s.add_dependency('vcap_package_cache-client', '0.1.8')
+ s.add_dependency('vcap_package_cache_client', '0.1.8')
end
@@ -12,7 +12,7 @@ def uid_to_name(uid)
Etc.getpwuid(uid).name
end
-describe VCAP::PackageCache::GemBuilder, :needs_sudo => true do
+describe VCAP::PackageCache::GemBuilder do
before(:all) do
enter_test_root
@build_dir = 'build'
@@ -2,7 +2,7 @@
require 'spec_helper'
require 'fileutils'
require 'inbox'
-require 'vcap/package_cache-client/inbox_client'
+require 'vcap/package_cache_client/inbox_client'
describe VCAP::PackageCache::Inbox do
before(:all) do
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../lib/vcap/package_cache')))
-require 'vcap/package_cache-client/client'
+require 'vcap/package_cache_client/client'
require 'fileutils'
LOCAL_GEM_PATH = '../spec/fixtures/yajl-ruby-0.8.2.gem'
@@ -5,13 +5,15 @@ require 'rubygems'
require 'optparse'
require 'logger'
-require 'client'
+require 'vcap/package_cache_client/client'
+
+TEST_RUNTIME = :ruby18
class RemoteLoadTester
attr_accessor :gem_list
def initialize
@logger = Logger.new(STDOUT)
- @client = VCAP::PackageCache::Client.new
+ @client = VCAP::PackageCacheClient::Client.new
end
def load_gem_list(path)
@@ -39,7 +41,7 @@ class RemoteLoadTester
Thread.current['start_time'] = Time.now
puts "adding #{gem_name}"
begin
- @client.add_package(:remote, :gem, gem_name)
+ @client.add_package(:remote, :gem, gem_name, TEST_RUNTIME)
rescue => e
puts e.to_s
end
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
require "vcap/package_cache-client/version"
Gem::Specification.new do |s|
- s.name = 'vcap_package_cache-client'
+ s.name = 'vcap_package_cache_client'
s.version = VCAP::PackageCacheClient::VERSION
s.platform = Gem::Platform::RUBY
s.summary = 'client driver for package_cache'
@@ -1,4 +1,4 @@
-$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../lib/vcap/package_cache-client')))
+$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../lib/vcap/package_cache_client')))
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '../../common/lib')))
require 'rubygems'
require 'fileutils'

0 comments on commit 18cc1e2

Please sign in to comment.