Skip to content

Commit

Permalink
Add script to generate a user with many roles
Browse files Browse the repository at this point in the history
* for performance testing cloudfoundry#1618

[#172968474]

Co-authored-by: Seth Boyles <[email protected]>
Co-authored-by: Aakash Shah <[email protected]>
  • Loading branch information
sethboyles and Aakash Shah committed May 21, 2020
1 parent 0a4ff67 commit f80e43e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions scripts/seed_roles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# For creating a few users with many roles
# 1 users; 20 orgs; 10 spaces per org
# usage: pipe this script into bin/console on the api vm

NUM_ORGS = 20
NUM_SPACES = 10

org_roles = %w/manager auditor billing_manager/
space_roles = %w/developer manager auditor/

user = User.find_or_create(guid: 'seed-role-user')

NUM_ORGS.times do |i|
org = VCAP::CloudController::Organization.find_or_create(
name: "seed-role-org-#{i}",
status: Organization::ACTIVE,
)
org_roles.each do |org_role|
org.add_user(user)
org.send("add_#{org_role}", user)
end
NUM_SPACES.times do |j|
space = VCAP::CloudController::Space.find_or_create(name: "seed-role-space-#{j}", organization: org)

space_roles.each do |space_role|
space.send("add_#{space_role}", user)
end
end
end

# User.where(admin: false).all.map(&:destroy)

0 comments on commit f80e43e

Please sign in to comment.