David Ostrovsky | 2b5fe09 | 2021-03-03 11:52:30 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 2 | # Copyright (C) 2016 The Android Open Source Project |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | """ |
| 17 | This script will populate an empty standard Gerrit instance with some |
| 18 | data for local testing. |
| 19 | |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 20 | TODO(hiesel): Make real git commits instead of empty changes |
| 21 | TODO(hiesel): Add comments |
| 22 | """ |
| 23 | |
Chad Horohoe | bc8eca1 | 2018-05-09 20:24:15 -0700 | [diff] [blame] | 24 | from __future__ import print_function |
Paladox none | f262d68 | 2020-02-02 01:40:48 +0000 | [diff] [blame] | 25 | import argparse |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 26 | import atexit |
| 27 | import json |
| 28 | import os |
| 29 | import random |
| 30 | import shutil |
| 31 | import subprocess |
| 32 | import tempfile |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 33 | import requests |
| 34 | import requests.auth |
| 35 | |
| 36 | DEFAULT_TMP_PATH = "/tmp" |
| 37 | TMP_PATH = "" |
Han-Wen Nienhuys | 6c51586 | 2018-02-22 15:38:57 +0100 | [diff] [blame] | 38 | BASE_URL = "http://localhost:%d/a/" |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 39 | |
Changcheng Xiao | 7b1264e | 2017-04-20 18:14:52 +0200 | [diff] [blame] | 40 | ADMIN_BASIC_AUTH = requests.auth.HTTPBasicAuth("admin", "secret") |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 41 | |
| 42 | # GROUP_ADMIN stores a GroupInfo for the admin group (see Gerrit rest docs) |
| 43 | # In addition, GROUP_ADMIN["name"] stores the admin group"s name. |
| 44 | GROUP_ADMIN = {} |
| 45 | |
| 46 | HEADERS = {"Content-Type": "application/json", "charset": "UTF-8"} |
| 47 | |
| 48 | # Random names from US Census Data |
| 49 | FIRST_NAMES = [ |
Chad Horohoe | 6914232 | 2018-05-17 10:19:22 -0700 | [diff] [blame] | 50 | "Casey", "Yesenia", "Shirley", "Tara", "Wanda", "Sheryl", "Jaime", |
| 51 | "Elaine", "Charlotte", "Carly", "Bonnie", "Kirsten", "Kathryn", "Carla", |
| 52 | "Katrina", "Melody", "Suzanne", "Sandy", "Joann", "Kristie", "Sally", |
| 53 | "Emma", "Susan", "Amanda", "Alyssa", "Patty", "Angie", "Dominique", |
| 54 | "Cynthia", "Jennifer", "Theresa", "Desiree", "Kaylee", "Maureen", |
| 55 | "Jeanne", "Kellie", "Valerie", "Nina", "Judy", "Diamond", "Anita", |
| 56 | "Rebekah", "Stefanie", "Kendra", "Erin", "Tammie", "Tracey", "Bridget", |
| 57 | "Krystal", "Jasmin", "Sonia", "Meghan", "Rebecca", "Jeanette", "Meredith", |
| 58 | "Beverly", "Natasha", "Chloe", "Selena", "Teresa", "Sheena", "Cassandra", |
| 59 | "Rhonda", "Tami", "Jodi", "Shelly", "Angela", "Kimberly", "Terry", |
| 60 | "Joanna", "Isabella", "Lindsey", "Loretta", "Dana", "Veronica", "Carolyn", |
| 61 | "Laura", "Karen", "Dawn", "Alejandra", "Cassie", "Lorraine", "Yolanda", |
| 62 | "Kerry", "Stephanie", "Caitlin", "Melanie", "Kerri", "Doris", "Sandra", |
| 63 | "Beth", "Carol", "Vicki", "Shelia", "Bethany", "Rachael", "Donna", |
| 64 | "Alexandra", "Barbara", "Ana", "Jillian", "Ann", "Rachel", "Lauren", |
| 65 | "Hayley", "Misty", "Brianna", "Tanya", "Danielle", "Courtney", |
| 66 | "Jacqueline", "Becky", "Christy", "Alisha", "Phyllis", "Faith", "Jocelyn", |
| 67 | "Nancy", "Gloria", "Kristen", "Evelyn", "Julie", "Julia", "Kara", |
| 68 | "Chelsey", "Cassidy", "Jean", "Chelsea", "Jenny", "Diana", "Haley", |
| 69 | "Kristine", "Kristina", "Erika", "Jenna", "Alison", "Deanna", "Abigail", |
| 70 | "Melissa", "Sierra", "Linda", "Monica", "Tasha", "Traci", "Yvonne", |
| 71 | "Tracy", "Marie", "Maria", "Michaela", "Stacie", "April", "Morgan", |
| 72 | "Cathy", "Darlene", "Cristina", "Emily" "Ian", "Russell", "Phillip", "Jay", |
| 73 | "Barry", "Brad", "Frederick", "Fernando", "Timothy", "Ricardo", "Bernard", |
| 74 | "Daniel", "Ruben", "Alexis", "Kyle", "Malik", "Norman", "Kent", "Melvin", |
| 75 | "Stephen", "Daryl", "Kurt", "Greg", "Alex", "Mario", "Riley", "Marvin", |
| 76 | "Dan", "Steven", "Roberto", "Lucas", "Leroy", "Preston", "Drew", "Fred", |
| 77 | "Casey", "Wesley", "Elijah", "Reginald", "Joel", "Christopher", "Jacob", |
| 78 | "Luis", "Philip", "Mark", "Rickey", "Todd", "Scott", "Terrence", "Jim", |
| 79 | "Stanley", "Bobby", "Thomas", "Gabriel", "Tracy", "Marcus", "Peter", |
| 80 | "Michael", "Calvin", "Herbert", "Darryl", "Billy", "Ross", "Dustin", |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 81 | "Jaime", "Adam", "Henry", "Xavier", "Dominic", "Lonnie", "Danny", "Victor", |
| 82 | "Glen", "Perry", "Jackson", "Grant", "Gerald", "Garrett", "Alejandro", |
| 83 | "Eddie", "Alan", "Ronnie", "Mathew", "Dave", "Wayne", "Joe", "Craig", |
| 84 | "Terry", "Chris", "Randall", "Parker", "Francis", "Keith", "Neil", "Caleb", |
| 85 | "Jon", "Earl", "Taylor", "Bryce", "Brady", "Max", "Sergio", "Leon", "Gene", |
Chad Horohoe | 6914232 | 2018-05-17 10:19:22 -0700 | [diff] [blame] | 86 | "Darin", "Bill", "Edgar", "Antonio", "Dalton", "Arthur", "Austin", |
| 87 | "Cristian", "Kevin", "Omar", "Kelly", "Aaron", "Ethan", "Tom", "Isaac", |
| 88 | "Maurice", "Gilbert", "Hunter", "Willie", "Harry", "Dale", "Darius", |
| 89 | "Jerome", "Jason", "Harold", "Kerry", "Clarence", "Gregg", "Shane", |
| 90 | "Eduardo", "Micheal", "Howard", "Vernon", "Rodney", "Anthony", "Levi", |
| 91 | "Larry", "Franklin", "Jimmy", "Jonathon", "Carl", |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 92 | ] |
| 93 | |
| 94 | LAST_NAMES = [ |
Chad Horohoe | 6914232 | 2018-05-17 10:19:22 -0700 | [diff] [blame] | 95 | "Savage", "Hendrix", "Moon", "Larsen", "Rocha", "Burgess", "Bailey", |
| 96 | "Farley", "Moses", "Schmidt", "Brown", "Hoover", "Klein", "Jennings", |
| 97 | "Braun", "Rangel", "Casey", "Dougherty", "Hancock", "Wolf", "Henry", |
| 98 | "Thomas", "Bentley", "Barnett", "Kline", "Pitts", "Rojas", "Sosa", "Paul", |
| 99 | "Hess", "Chase", "Mckay", "Bender", "Colins", "Montoya", "Townsend", |
| 100 | "Potts", "Ayala", "Avery", "Sherman", "Tapia", "Hamilton", "Ferguson", |
| 101 | "Huang", "Hooper", "Zamora", "Logan", "Lloyd", "Quinn", "Monroe", "Brock", |
| 102 | "Ibarra", "Fowler", "Weiss", "Montgomery", "Diaz", "Dixon", "Olson", |
| 103 | "Robertson", "Arias", "Benjamin", "Abbott", "Stein", "Schroeder", "Beck", |
| 104 | "Velasquez", "Barber", "Nichols", "Ortiz", "Burns", "Moody", "Stokes", |
| 105 | "Wilcox", "Rush", "Michael", "Kidd", "Rowland", "Mclean", "Saunders", |
| 106 | "Chung", "Newton", "Potter", "Hickman", "Ray", "Larson", "Figueroa", |
| 107 | "Duncan", "Sparks", "Rose", "Hodge", "Huynh", "Joseph", "Morales", |
| 108 | "Beasley", "Mora", "Fry", "Ross", "Novak", "Hahn", "Wise", "Knight", |
| 109 | "Frederick", "Heath", "Pollard", "Vega", "Mcclain", "Buckley", "Conrad", |
| 110 | "Cantrell", "Bond", "Mejia", "Wang", "Lewis", "Johns", "Mcknight", |
| 111 | "Callahan", "Reynolds", "Norris", "Burnett", "Carey", "Jacobson", "Oneill", |
| 112 | "Oconnor", "Leonard", "Mckenzie", "Hale", "Delgado", "Spence", "Brandt", |
| 113 | "Obrien", "Bowman", "James", "Avila", "Roberts", "Barker", "Cohen", |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 114 | "Bradley", "Prince", "Warren", "Summers", "Little", "Caldwell", "Garrett", |
| 115 | "Hughes", "Norton", "Burke", "Holden", "Merritt", "Lee", "Frank", "Wiley", |
| 116 | "Ho", "Weber", "Keith", "Winters", "Gray", "Watts", "Brady", "Aguilar", |
| 117 | "Nicholson", "David", "Pace", "Cervantes", "Davis", "Baxter", "Sanchez", |
Chad Horohoe | 6914232 | 2018-05-17 10:19:22 -0700 | [diff] [blame] | 118 | "Singleton", "Taylor", "Strickland", "Glenn", "Valentine", "Roy", |
| 119 | "Cameron", "Beard", "Norman", "Fritz", "Anthony", "Koch", "Parrish", |
| 120 | "Herman", "Hines", "Sutton", "Gallegos", "Stephenson", "Lozano", |
| 121 | "Franklin", "Howe", "Bauer", "Love", "Ali", "Ellison", "Lester", "Guzman", |
| 122 | "Jarvis", "Espinoza", "Fletcher", "Burton", "Woodard", "Peterson", |
| 123 | "Barajas", "Richard", "Bryan", "Goodman", "Cline", "Rowe", "Faulkner", |
| 124 | "Crawford", "Mueller", "Patterson", "Hull", "Walton", "Wu", "Flores", |
| 125 | "York", "Dickson", "Barnes", "Fisher", "Strong", "Juarez", "Fitzgerald", |
| 126 | "Schmitt", "Blevins", "Villa", "Sullivan", "Velazquez", "Horton", |
| 127 | "Meadows", "Riley", "Barrera", "Neal", "Mendez", "Mcdonald", "Floyd", |
| 128 | "Lynch", "Mcdowell", "Benson", "Hebert", "Livingston", "Davies", |
| 129 | "Richardson", "Vincent", "Davenport", "Osborn", "Mckee", "Marshall", |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 130 | "Ferrell", "Martinez", "Melton", "Mercer", "Yoder", "Jacobs", "Mcdaniel", |
| 131 | "Mcmillan", "Peters", "Atkinson", "Wood", "Briggs", "Valencia", "Chandler", |
| 132 | "Rios", "Hunter", "Bean", "Hicks", "Hays", "Lucero", "Malone", "Waller", |
| 133 | "Banks", "Myers", "Mitchell", "Grimes", "Houston", "Hampton", "Trujillo", |
| 134 | "Perkins", "Moran", "Welch", "Contreras", "Montes", "Ayers", "Hayden", |
| 135 | "Daniel", "Weeks", "Porter", "Gill", "Mullen", "Nolan", "Dorsey", "Crane", |
| 136 | "Estes", "Lam", "Wells", "Cisneros", "Giles", "Watson", "Vang", "Scott", |
| 137 | "Knox", "Hanna", "Fields", |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 138 | ] |
| 139 | |
| 140 | |
| 141 | def clean(json_string): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 142 | # Strip JSON XSS Tag |
| 143 | json_string = json_string.strip() |
| 144 | if json_string.startswith(")]}'"): |
| 145 | return json_string[5:] |
| 146 | return json_string |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 147 | |
| 148 | |
Changcheng Xiao | 7b1264e | 2017-04-20 18:14:52 +0200 | [diff] [blame] | 149 | def basic_auth(user): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 150 | return requests.auth.HTTPBasicAuth(user["username"], user["http_password"]) |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 151 | |
| 152 | |
| 153 | def fetch_admin_group(): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 154 | global GROUP_ADMIN |
| 155 | # Get admin group |
Chad Horohoe | 6914232 | 2018-05-17 10:19:22 -0700 | [diff] [blame] | 156 | r = json.loads(clean(requests.get( |
| 157 | BASE_URL + "groups/?suggest=ad&p=All-Projects", |
| 158 | headers=HEADERS, |
| 159 | auth=ADMIN_BASIC_AUTH).text)) |
Ilmari Lauhakangas | 695d9f7 | 2021-03-01 17:13:53 +0000 | [diff] [blame] | 160 | admin_group_name = list(r.keys())[0] |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 161 | GROUP_ADMIN = r[admin_group_name] |
| 162 | GROUP_ADMIN["name"] = admin_group_name |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 163 | |
| 164 | |
| 165 | def generate_random_text(): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 166 | return " ".join([random.choice("lorem ipsum " |
| 167 | "doleret delendam " |
Chad Horohoe | 6914232 | 2018-05-17 10:19:22 -0700 | [diff] [blame] | 168 | "\n esse".split(" ")) for _ in range(1, |
| 169 | 100)]) |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 170 | |
| 171 | |
| 172 | def set_up(): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 173 | global TMP_PATH |
| 174 | TMP_PATH = tempfile.mkdtemp() |
| 175 | atexit.register(clean_up) |
| 176 | os.makedirs(TMP_PATH + "/ssh") |
| 177 | os.makedirs(TMP_PATH + "/repos") |
| 178 | fetch_admin_group() |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 179 | |
| 180 | |
| 181 | def get_random_users(num_users): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 182 | users = random.sample([(f, l) for f in FIRST_NAMES for l in LAST_NAMES], |
| 183 | num_users) |
| 184 | names = [] |
| 185 | for u in users: |
| 186 | names.append({"firstname": u[0], |
| 187 | "lastname": u[1], |
| 188 | "name": u[0] + " " + u[1], |
| 189 | "username": u[0] + u[1], |
| 190 | "email": u[0] + "." + u[1] + "@gerritcodereview.com", |
| 191 | "http_password": "secret", |
| 192 | "groups": []}) |
| 193 | return names |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 194 | |
| 195 | |
| 196 | def generate_ssh_keys(gerrit_users): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 197 | for user in gerrit_users: |
| 198 | key_file = TMP_PATH + "/ssh/" + user["username"] + ".key" |
| 199 | subprocess.check_output(["ssh-keygen", "-f", key_file, "-N", ""]) |
| 200 | with open(key_file + ".pub", "r") as f: |
| 201 | user["ssh_key"] = f.read() |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 202 | |
| 203 | |
| 204 | def create_gerrit_groups(): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 205 | groups = [ |
| 206 | {"name": "iOS-Maintainers", "description": "iOS Maintainers", |
| 207 | "visible_to_all": True, "owner": GROUP_ADMIN["name"], |
| 208 | "owner_id": GROUP_ADMIN["id"]}, |
| 209 | {"name": "Android-Maintainers", "description": "Android Maintainers", |
| 210 | "visible_to_all": True, "owner": GROUP_ADMIN["name"], |
| 211 | "owner_id": GROUP_ADMIN["id"]}, |
| 212 | {"name": "Backend-Maintainers", "description": "Backend Maintainers", |
| 213 | "visible_to_all": True, "owner": GROUP_ADMIN["name"], |
| 214 | "owner_id": GROUP_ADMIN["id"]}, |
| 215 | {"name": "Script-Maintainers", "description": "Script Maintainers", |
| 216 | "visible_to_all": True, "owner": GROUP_ADMIN["name"], |
| 217 | "owner_id": GROUP_ADMIN["id"]}, |
| 218 | {"name": "Security-Team", "description": "Sec Team", |
| 219 | "visible_to_all": False, "owner": GROUP_ADMIN["name"], |
| 220 | "owner_id": GROUP_ADMIN["id"]}] |
| 221 | for g in groups: |
| 222 | requests.put(BASE_URL + "groups/" + g["name"], |
| 223 | json.dumps(g), |
| 224 | headers=HEADERS, |
| 225 | auth=ADMIN_BASIC_AUTH) |
| 226 | return [g["name"] for g in groups] |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 227 | |
| 228 | |
| 229 | def create_gerrit_projects(owner_groups): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 230 | projects = [ |
| 231 | {"id": "android", "name": "Android", "parent": "All-Projects", |
| 232 | "branches": ["master"], "description": "Our android app.", |
| 233 | "owners": [owner_groups[0]], "create_empty_commit": True}, |
| 234 | {"id": "ios", "name": "iOS", "parent": "All-Projects", |
| 235 | "branches": ["master"], "description": "Our ios app.", |
| 236 | "owners": [owner_groups[1]], "create_empty_commit": True}, |
| 237 | {"id": "backend", "name": "Backend", "parent": "All-Projects", |
| 238 | "branches": ["master"], "description": "Our awesome backend.", |
| 239 | "owners": [owner_groups[2]], "create_empty_commit": True}, |
| 240 | {"id": "scripts", "name": "Scripts", "parent": "All-Projects", |
| 241 | "branches": ["master"], "description": "some small scripts.", |
| 242 | "owners": [owner_groups[3]], "create_empty_commit": True}] |
| 243 | for p in projects: |
| 244 | requests.put(BASE_URL + "projects/" + p["name"], |
| 245 | json.dumps(p), |
| 246 | headers=HEADERS, |
| 247 | auth=ADMIN_BASIC_AUTH) |
| 248 | return [p["name"] for p in projects] |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 249 | |
| 250 | |
| 251 | def create_gerrit_users(gerrit_users): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 252 | for user in gerrit_users: |
| 253 | requests.put(BASE_URL + "accounts/" + user["username"], |
| 254 | json.dumps(user), |
| 255 | headers=HEADERS, |
| 256 | auth=ADMIN_BASIC_AUTH) |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 257 | |
| 258 | |
| 259 | def create_change(user, project_name): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 260 | random_commit_message = generate_random_text() |
| 261 | change = { |
| 262 | "project": project_name, |
| 263 | "subject": random_commit_message.split("\n")[0], |
| 264 | "branch": "master", |
| 265 | "status": "NEW", |
| 266 | } |
| 267 | requests.post(BASE_URL + "changes/", |
| 268 | json.dumps(change), |
| 269 | headers=HEADERS, |
| 270 | auth=basic_auth(user)) |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 271 | |
| 272 | |
| 273 | def clean_up(): |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 274 | shutil.rmtree(TMP_PATH) |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 275 | |
| 276 | |
| 277 | def main(): |
Paladox none | f262d68 | 2020-02-02 01:40:48 +0000 | [diff] [blame] | 278 | p = argparse.ArgumentParser() |
| 279 | p.add_argument("-u", "--user_count", action="store", |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 280 | default=100, |
Paladox none | f262d68 | 2020-02-02 01:40:48 +0000 | [diff] [blame] | 281 | type=int, |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 282 | help="number of users to generate") |
Paladox none | f262d68 | 2020-02-02 01:40:48 +0000 | [diff] [blame] | 283 | p.add_argument("-p", "--port", action="store", |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 284 | default=8080, |
Paladox none | f262d68 | 2020-02-02 01:40:48 +0000 | [diff] [blame] | 285 | type=int, |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 286 | help="port of server") |
Paladox none | f262d68 | 2020-02-02 01:40:48 +0000 | [diff] [blame] | 287 | args = p.parse_args() |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 288 | global BASE_URL |
Paladox none | f262d68 | 2020-02-02 01:40:48 +0000 | [diff] [blame] | 289 | BASE_URL = BASE_URL % args.port |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 290 | print(BASE_URL) |
| 291 | |
| 292 | set_up() |
Paladox none | f262d68 | 2020-02-02 01:40:48 +0000 | [diff] [blame] | 293 | gerrit_users = get_random_users(args.user_count) |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 294 | |
| 295 | group_names = create_gerrit_groups() |
| 296 | for idx, u in enumerate(gerrit_users): |
| 297 | u["groups"].append(group_names[idx % len(group_names)]) |
| 298 | if idx % 5 == 0: |
| 299 | # Also add to security group |
| 300 | u["groups"].append(group_names[4]) |
| 301 | |
| 302 | generate_ssh_keys(gerrit_users) |
| 303 | create_gerrit_users(gerrit_users) |
| 304 | |
| 305 | project_names = create_gerrit_projects(group_names) |
| 306 | |
| 307 | for idx, u in enumerate(gerrit_users): |
Ilmari Lauhakangas | 695d9f7 | 2021-03-01 17:13:53 +0000 | [diff] [blame] | 308 | for _ in range(random.randint(1, 5)): |
| 309 | create_change(u, project_names[4 * idx // len(gerrit_users)]) |
Chad Horohoe | dd22470 | 2018-05-16 22:33:06 -0400 | [diff] [blame] | 310 | |
Patrick Hiesel | c8076c3 | 2016-05-02 11:18:51 +0200 | [diff] [blame] | 311 | main() |