Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bump yetis to latest cfoundry; remove uaac

+ don't set 'production' flag
  • Loading branch information...
commit 889b7504ed80c5f4775ef81e66bf62eafe2f971c 1 parent 9739c78
Alex Suraci, Dmitriy Kalinin and Mark Rushakoff authored
View
13 Gemfile
@@ -12,18 +12,13 @@ gem "yajl-ruby"
gem "nokogiri"
group :vcap do
- # Used to create users in CCNGUserHelper
- gem "cf-uaac", "= 1.3.3"
gem "vcap_logging", ">= 1.0"
- # Specific version of cfoundry is needed to be
- # compatible with deps from cf-uaas. Update with care!
gem "cfoundry", {
- :github => "cloudfoundry/vmc-lib",
- :ref => "e11ddf5d",
- :submodules => true,
+ :github => "cloudfoundry/cfoundry",
+ :submodules => true,
}
- gem "tunnel-vmc-plugin", :github => "cloudfoundry/tunnel-vmc-plugin"
- gem "console-vmc-plugin", :github => "cloudfoundry/console-vmc-plugin"
+ gem "tunnel-cf-plugin", :github => "cloudfoundry/tunnel-cf-plugin"
+ gem "console-cf-plugin", :github => "cloudfoundry/console-cf-plugin"
end
View
108 Gemfile.lock
@@ -1,87 +1,64 @@
GIT
- remote: git://github.com/cloudfoundry/console-vmc-plugin.git
- revision: 1b281d0a74dc50de34c736b4945fd7bdc3d53331
+ remote: git://github.com/cloudfoundry/cfoundry.git
+ revision: 87c192a714fd6b21bb7bceade789424a9bf779e1
+ submodules: true
+ specs:
+ cfoundry (0.6.1.rc3)
+ cf-uaa-lib (~> 1.3.10)
+ multi_json (~> 1.3)
+ multipart-post (~> 1.1)
+ rubyzip (~> 0.9)
+
+GIT
+ remote: git://github.com/cloudfoundry/console-cf-plugin.git
+ revision: a165f4cade721edd637df97d64488560c5913933
specs:
- console-vmc-plugin (0.1.1)
- tunnel-vmc-plugin (~> 0.2.0)
+ console-cf-plugin (0.2.0)
+ tunnel-cf-plugin (~> 0.3.0)
GIT
- remote: git://github.com/cloudfoundry/tunnel-vmc-plugin.git
- revision: d61318c67165d56ad4662294f661802ecfdd398c
+ remote: git://github.com/cloudfoundry/tunnel-cf-plugin.git
+ revision: 3800e057d9a6c191e036fb2cad7fdfaaa8fb7432
specs:
- tunnel-vmc-plugin (0.2.1.rc1)
+ tunnel-cf-plugin (0.3.0)
addressable (~> 2.2)
caldecott-client (~> 0.0.2)
- cfoundry (~> 0.5.0)
+ cfoundry (>= 0.6.1.rc2, < 0.7)
rest-client (~> 1.6)
uuidtools (~> 2.1)
-GIT
- remote: git://github.com/cloudfoundry/vmc-lib.git
- revision: e11ddf5d7e9fce165a1f917bd4a9dbd4ecb0739f
- ref: e11ddf5d
- submodules: true
- specs:
- cfoundry (0.5.1.rc2)
- cf-uaa-lib (~> 1.3.3)
- multi_json (~> 1.3)
- multipart-post (~> 1.1)
- rubyzip (~> 0.9)
-
GEM
remote: http://rubygems.org/
specs:
- activesupport (3.2.9)
- i18n (~> 0.6)
- multi_json (~> 1.0)
- addressable (2.2.8)
- bson (1.8.0)
- activesupport
- bson_ext (1.8.0)
- bson (~> 1.8.0)
+ addressable (2.3.3)
+ bson (1.8.4)
+ bson_ext (1.8.4)
+ bson (~> 1.8.4)
caldecott-client (0.0.2)
multi_json (~> 1.3)
- cf-uaa-lib (1.3.3)
+ cf-uaa-lib (1.3.10)
multi_json
- cf-uaac (1.3.3)
- cf-uaa-lib (>= 1.3.3, <= 1.3.3)
- em-http-request (= 0.3.0)
- eventmachine
- highline
- json_pure
- launchy
- diff-lcs (1.1.3)
- em-http-request (0.3.0)
- addressable (>= 2.0.0)
- escape_utils
- eventmachine (>= 0.12.9)
- escape_utils (0.3.2)
- eventmachine (1.0.3)
- highline (1.6.16)
- i18n (0.6.1)
- json_pure (1.7.7)
- launchy (2.1.0)
- addressable (~> 2.2.6)
- mime-types (1.20.1)
- mongo (1.8.0)
- bson (~> 1.8.0)
- multi_json (1.7.1)
+ diff-lcs (1.2.2)
+ mime-types (1.22)
+ mongo (1.8.4)
+ bson (~> 1.8.4)
+ multi_json (1.7.2)
multipart-post (1.2.0)
- nokogiri (1.5.5)
- parallel (0.6.2)
+ nokogiri (1.5.9)
+ parallel (0.6.4)
parallel_tests (0.10.4)
parallel
- rake (10.0.2)
+ rake (10.0.4)
rest-client (1.6.7)
mime-types (>= 1.16)
- rspec (2.12.0)
- rspec-core (~> 2.12.0)
- rspec-expectations (~> 2.12.0)
- rspec-mocks (~> 2.12.0)
- rspec-core (2.12.1)
- rspec-expectations (2.12.0)
- diff-lcs (~> 1.1.3)
- rspec-mocks (2.12.0)
+ rspec (2.13.0)
+ rspec-core (~> 2.13.0)
+ rspec-expectations (~> 2.13.0)
+ rspec-mocks (~> 2.13.0)
+ rspec-core (2.13.1)
+ rspec-expectations (2.13.0)
+ diff-lcs (>= 1.1.3, < 2.0)
+ rspec-mocks (2.13.0)
rubyzip (0.9.9)
uuidtools (2.1.3)
vcap_logging (1.0.0)
@@ -93,15 +70,14 @@ PLATFORMS
DEPENDENCIES
bson_ext
- cf-uaac (= 1.3.3)
cfoundry!
- console-vmc-plugin!
+ console-cf-plugin!
mongo
nokogiri
parallel_tests
rake
rest-client
rspec
- tunnel-vmc-plugin!
+ tunnel-cf-plugin!
vcap_logging (>= 1.0)
yajl-ruby
View
9 lib/harness/app.rb
@@ -573,15 +573,6 @@ def sync_app(app, path)
app.command = command
end
- if @session.v2?
- production = @manifest['plan'] ? true : false
-
- if production != app.production
- diff[:production] = [app.production, production]
- app.production = production
- end
- end
-
unless diff.empty?
diff.each do |name, change|
old, new = change
View
136 lib/harness/ccng_user_helper.rb
@@ -1,119 +1,59 @@
module BVT::Harness
- module CCNGUserHelper
+ class CCNGUserHelper
+ attr_reader :target, :admin_user
- def create_user(uaa_url, uaa_cc_secret, cc_url, cc_admin_email, cc_admin_password, email, password, org_name, space_name)
- with_uaa_target(uaa_url) do
- user_guid = create_uaa_user(uaa_cc_secret, email, password)
- token = auth_token(cc_admin_email, cc_admin_password)
- quota_guid = get_paid_quota_guid(cc_url, token)
- create_cc_user(cc_url, token, user_guid)
- org_guid = create_cc_org(cc_url, token, org_name, user_guid, quota_guid)
- space_guid = create_cc_space(cc_url, token, space_name, org_guid, user_guid)
- end
+ def initialize(target, admin_user, admin_password)
+ @target = target
+ @admin_user = admin_user
+ @admin_password = admin_password
end
- def create_uaa_user(uaa_cc_secret, email, password)
- with_cc_uaa_client(uaa_cc_secret) do
- output = run "uaac user add #{email} --email #{email} --given_name yeti --family_name testuser -p #{password}"
- error("Could not create uaa user: #{output}") unless output =~ /added/
- uaa_uid(email)
+ def setup_user(email, password, org_name, space_name)
+ create_user(client, email, password).tap do |user|
+ org = create_org(client, user, org_name, "yeti")
+ space = create_space(client, user, org, space_name)
end
end
- def create_cc_user(cc_url, token, guid)
- auth_header = {"AUTHORIZATION" => token}
- response = RestClient.post("#{cc_url}/v2/users", {"guid" => guid}.to_json, auth_header)
- output = response.to_str
- cc_guid = output[/"guid": "([^"]*)/, 1]
- error "could not extract user guid" unless guid
- error "cc guid did not match uaa guid" unless cc_guid == guid
- guid
- end
+ private
- def get_paid_quota_guid(cc_url, token)
- auth_header = {"AUTHORIZATION" => token}
- response = RestClient.get("#{cc_url}/v2/quota_definitions", auth_header)
- output = response.to_str
- output_hash = Yajl::Parser.parse(output)
- resource = output_hash["resources"].select do |r|
- r["entity"]["name"] == "paid"
- end
- error "could not find paid quota" unless resource
- resource.first["metadata"]["guid"]
+ def create_user(client, email, password)
+ client.register(email, password)
end
- def create_cc_org(cc_url, token, name, user_guid, quota_guid)
- auth_header = {"AUTHORIZATION" => token}
- data = { "name" => name,
- "user_guids" => [user_guid],
- "manager_guids" => [user_guid],
- "quota_definition_guid" => quota_guid }
- response = RestClient.post("#{cc_url}/v2/organizations", data.to_json, auth_header)
- output = response.to_str
- guid = output[/"guid": "([^"]*)/, 1]
- error "could not extract space guid" unless guid
- RestClient.put("#{cc_url}/v2/organizations/#{guid}", {"billing_enabled" => true}.to_json, auth_header)
- guid
- end
+ def create_org(client, user, org_name, quota_name)
+ quota = client.quota_definition_by_name(quota_name)
- def create_cc_space(cc_url, token, name, org_guid, user_guid)
- auth_header = {"AUTHORIZATION" => token}
- data = { "name" => name,
- "organization_guid" => org_guid,
- "manager_guids" => [user_guid],
- "developer_guids" => [user_guid] }
- response = RestClient.post("#{cc_url}/v2/spaces", data.to_json, auth_header)
- output = response.to_str
- guid = output[/"guid": "([^"]*)/, 1]
- error "could not extract org guid" unless guid
- guid
- end
-
- def run(cmd)
- `#{cmd}`
- end
+ client.organization.tap do |o|
+ o.name = org_name
+ o.users = [user]
+ o.managers = [user]
+ o.billing_managers = [user]
+ o.auditors = [user]
+ o.quota_definition = quota
+ o.create!
- def error(str)
- abort "Error: #{str}"
- end
-
- def with_uaa_target(uaa_url)
- output = run "uaac target"
- orig_target = output[/target set to ([^,]*)?/, 1]
- output = run "uaac target #{uaa_url}"
- error("Could not target: #{output}") unless output =~ /target set to/
- begin
- yield if block_given?
- ensure
- if orig_target
- run "uaac target #{orig_target}"
- end
+ o.billing_enabled = true
+ o.update!
end
end
- def with_cc_uaa_client(uaa_cc_secret)
- output = run "uaac token client get cloud_controller -s #{uaa_cc_secret}"
- error "Error while creating user: #{output}" if output =~ /error/
- begin
- yield if block_given?
- ensure
- run "uaac token delete cloud_controller"
+ def create_space(client, user, org, space_name)
+ client.space.tap do |s|
+ s.organization = org
+ s.name = space_name
+ s.developers = [user]
+ s.managers = [user]
+ s.auditors = [user]
+ s.create!
end
end
- def uaa_uid(email)
- # cmdline copied from a previous bash script, hence the grep/sed
- output = run "uaac user get #{email} | grep ' id: ' | sed 's/ *id: //'"
- output.chomp
- end
-
- def auth_token(email, password)
- output = run "uaac token get #{email} #{password}"
- error("Could not get auth token: #{output}") if output =~ /failed/
- output = run "uaac context | grep access_token | sed 's/ *access_token: //'"
- "bearer #{output.chomp}"
+ def client
+ @client ||= CFoundry::V2::Client.new(@target).tap do |c|
+ c.trace = !!ENV["VCAP_BVT_TRACE"]
+ c.login(@admin_user, @admin_password)
+ end
end
-
- extend self
end
end
View
4 lib/harness/cfconsole_monkey_patch.rb
@@ -1,5 +1,5 @@
-require 'tunnel-vmc-plugin/tunnel'
-require 'console-vmc-plugin/console'
+require 'tunnel-cf-plugin/tunnel'
+require 'console-cf-plugin/console'
class CFConsole < CFTunnel
View
4 lib/harness/console_helper.rb
@@ -1,10 +1,10 @@
-require 'console-vmc-plugin/console'
+require 'console-cf-plugin/console'
module BVT::Harness
module ConsoleHelpers
def init_console(client, app, port = 10000)
- console = CFConsole.new(client, app)
+ console = CFConsole.new(client, app)
console.pick_port!(port)
console_open(console)
View
64 lib/harness/rake_helper.rb
@@ -1,6 +1,7 @@
require "yaml"
require "harness"
require "tempfile"
+require "securerandom"
module BVT::Harness
module RakeHelper
@@ -150,54 +151,41 @@ def get_user_passwd
end
def create_parallel_users(user_number)
- puts "Using admin account to create parallel users:"
get_admin_user
get_admin_user_passwd
- @config['parallel'] = []
- session = BVT::Harness::CFSession.new(
- :admin => true,
- :email => @config['admin']['email'],
- :passwd => @config['admin']['passwd'],
- :target => @config['target']
+ user_creator = CCNGUserHelper.new(
+ @config["target"],
+ @config["admin"]["email"],
+ @config["admin"]["passwd"],
)
- passwd = 'aZ_x13YcIa4nhl' #parallel user secret
+ puts "Using admin account to create parallel users"
+ puts " ('#{user_creator.target}' with '#{user_creator.admin_user}'):"
- (1..user_number).to_a.each do |index|
- config = {}
-
- if session.v2?
- uaa_url = @config['target'].gsub(/\/\/\w+/, '//uaa')
- email = "#{session.namespace}#{index}-test_user@vmware.com"
- org_name = "#{session.namespace}yeti_test_org-#{index}"
- space_name = "yeti_test_space"
-
- CCNGUserHelper.create_user(
- uaa_url, get_uaa_cc_secret,
- @config['target'],
- @config['admin']['email'],
- @config['admin']['passwd'],
- email, passwd,
- org_name, space_name
- )
- config['email'] = email
- else
- email = "#{index}-test_user@vmware.com"
- user = session.user(email)
- user.create(passwd)
- config['email'] = user.email
- end
+ namespace = SecureRandom.uuid.gsub("-", "")
+ passwd = "password"
+ @config["parallel"] = []
- config['passwd'] = passwd
- puts " - #{config['email']}"
+ (1..user_number).to_a.each do |index|
+ @config["parallel"] << config = {
+ "email" => "#{namespace}-#{index}-test_user@vmware.com",
+ "passwd" => passwd,
+ }
+
+ user_creator.setup_user(
+ config["email"],
+ config["passwd"],
+ "#{namespace}-yeti_test_org-#{index}",
+ "yeti_test_space",
+ )
+
+ puts " - #{config["email"]}"
$stdout.flush
-
- @config['parallel'] << config
end
- @config['admin'].delete('passwd')
- @config['parallel']
+ @config["admin"].delete("passwd")
+ @config["parallel"]
end
def get_parallel_users(check_first_user=false)
Please sign in to comment.
Something went wrong with that request. Please try again.