Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit f80e43e

Browse files
sethboylesAakash Shah
andcommitted
Add script to generate a user with many roles
* for performance testing cloudfoundry#1618 [#172968474] Co-authored-by: Seth Boyles <sboyles@pivotal.io> Co-authored-by: Aakash Shah <ashah@pivotal.io>
1 parent 0a4ff67 commit f80e43e

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

scripts/seed_roles.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# For creating a few users with many roles
2+
# 1 users; 20 orgs; 10 spaces per org
3+
# usage: pipe this script into bin/console on the api vm
4+
5+
NUM_ORGS = 20
6+
NUM_SPACES = 10
7+
8+
org_roles = %w/manager auditor billing_manager/
9+
space_roles = %w/developer manager auditor/
10+
11+
user = User.find_or_create(guid: 'seed-role-user')
12+
13+
NUM_ORGS.times do |i|
14+
org = VCAP::CloudController::Organization.find_or_create(
15+
name: "seed-role-org-#{i}",
16+
status: Organization::ACTIVE,
17+
)
18+
org_roles.each do |org_role|
19+
org.add_user(user)
20+
org.send("add_#{org_role}", user)
21+
end
22+
NUM_SPACES.times do |j|
23+
space = VCAP::CloudController::Space.find_or_create(name: "seed-role-space-#{j}", organization: org)
24+
25+
space_roles.each do |space_role|
26+
space.send("add_#{space_role}", user)
27+
end
28+
end
29+
end
30+
31+
# User.where(admin: false).all.map(&:destroy)

0 commit comments

Comments
 (0)