Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
use first parallel user if VCAP_BVT_USER* is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitriy Kalinin and Mark Rushakoff committed Mar 27, 2013
1 parent 22625f2 commit dcbec97
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ run tests:
bundle exec rspec
bundle exec rspec spec/apps/ruby_spec.rb

Tip: If you do not want to set `VCAP_BVT_USER` and `VCAP_BVT_USER_PASSWD`
you can run `rake prepare` (task used with parallel set up) once
and after that tests will just use first parallel user.

## Parallel

Tests require several environment variables to be set:
Expand Down
22 changes: 19 additions & 3 deletions lib/harness/rake_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ def get_admin_user_passwd
def get_user
get_config unless @config
@config['user'] ||= {}
@config['user']['email'] = require_env!("VCAP_BVT_USER")
@config['user']['email'] = \
require_env!("VCAP_BVT_USER", first_parallel_user)
end

def get_user_passwd
get_config unless @config
@config['user'] ||= {}
@config['user']['passwd'] = require_env!("VCAP_BVT_USER_PASSWD")
@config['user']['passwd'] = \
require_env!("VCAP_BVT_USER_PASSWD", first_parallel_user_passwd)
end

def create_parallel_users(user_number)
Expand Down Expand Up @@ -241,6 +243,18 @@ def format_target(str)

private

def first_parallel_user
return unless users = get_parallel_users
return unless user = users[0]
user['email']
end

def first_parallel_user_passwd
return unless users = get_parallel_users
return unless user = users[0]
user['passwd']
end

def get_uaa_cc_secret
require_env!("VCAP_BVT_UAA_CC_SECRET")
end
Expand All @@ -259,9 +273,11 @@ def parallel_run_number
ENV["TEST_ENV_NUMBER"].to_i
end

def require_env!(var_name)
def require_env!(var_name, default_value=nil)
if value = ENV[var_name]
value
elsif default_value
default_value
else
abort("Please specify #{var_name}")
end
Expand Down

0 comments on commit dcbec97

Please sign in to comment.