@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add "--force" and "--quickly" flags to `bin/lipsum`

Summary:
Ref T12319.

- Lipsum can trash an install by creating a lot of junk that's hard to get rid of, so we're cautious about letting you run it. Add a `--force` flag if you're sure you know what you're doing. This makes the edit/test cycle a bit easier when actually writing Lipsum generators.
- Lipsum normally sleeps for a second before creating objects, to give users more control over how much stuff they create and limit the amount of damage caused by mistakes. Sometimes, you want to generate a LOT of stuff because you want to reproduce a performance/scale issue (like T12319). Add a `--quickly` flag to generate objects as fast as possible.
- When loading random users (used as authors, assignees, etc), also load user settings so we can `ConduitCall` with them.
- Allow generators to return a PHID instead of an actual object (more convenient for Conduit-based generators).

Test Plan:
- With next change, ran `lipsum generate badges --force --quickly`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12319

Differential Revision: https://secure.phabricator.com/D17421

+40 -18
+1 -1
src/applications/lipsum/generator/PhabricatorTestDataGenerator.php
··· 45 45 $user = id(new PhabricatorPeopleQuery()) 46 46 ->setViewer($viewer) 47 47 ->withPHIDs(array($user_phid)) 48 + ->needUserSettings(true) 48 49 ->executeOne(); 49 50 } 50 51 ··· 114 115 public function loadPhabricatorUser() { 115 116 return $this->loadOneRandom('PhabricatorUser'); 116 117 } 117 - 118 118 119 119 }
+39 -17
src/applications/lipsum/management/PhabricatorLipsumGenerateWorkflow.php
··· 11 11 ->setArguments( 12 12 array( 13 13 array( 14 + 'name' => 'force', 15 + 'short' => 'f', 16 + 'help' => pht( 17 + 'Generate objects without prompting for confirmation.'), 18 + ), 19 + array( 20 + 'name' => 'quickly', 21 + 'help' => pht( 22 + 'Generate objects as quickly as possible.'), 23 + ), 24 + array( 14 25 'name' => 'args', 15 26 'wildcard' => true, 16 27 ), ··· 34 45 ->execute(); 35 46 36 47 $argv = $args->getArg('args'); 48 + $is_force = $args->getArg('force'); 49 + $is_quickly = $args->getArg('quickly'); 50 + 37 51 $all = 'all'; 38 52 39 53 if (isset($all_generators[$all])) { ··· 125 139 'Selected generators: %s.', 126 140 implode(', ', mpull($generators, 'getGeneratorName')))); 127 141 128 - echo tsprintf( 129 - "**<bg:yellow> %s </bg>** %s\n", 130 - pht('WARNING'), 131 - pht( 132 - 'This command generates synthetic test data, including user '. 133 - 'accounts. It is intended for use in development environments '. 134 - 'so you can test features more easily. There is no easy way to '. 135 - 'delete this data or undo the effects of this command. If you run '. 136 - 'it in a production environment, it will pollute your data with '. 137 - 'large amounts of meaningless garbage that you can not get rid of.')); 142 + if (!$is_force) { 143 + echo tsprintf( 144 + "**<bg:yellow> %s </bg>** %s\n", 145 + pht('WARNING'), 146 + pht( 147 + 'This command generates synthetic test data, including user '. 148 + 'accounts. It is intended for use in development environments so '. 149 + 'you can test features more easily. There is no easy way to delete '. 150 + 'this data or undo the effects of this command. If you run it in a '. 151 + 'production environment, it will pollute your data with large '. 152 + 'amounts of meaningless garbage that you can not get rid of.')); 138 153 139 - $prompt = pht('Are you sure you want to generate piles of garbage?'); 140 - if (!phutil_console_confirm($prompt, true)) { 141 - return; 154 + $prompt = pht('Are you sure you want to generate piles of garbage?'); 155 + if (!phutil_console_confirm($prompt, true)) { 156 + return; 157 + } 142 158 } 143 159 144 160 echo tsprintf( ··· 148 164 'Generating synthetic test objects forever. '. 149 165 'Use ^C to stop when satisfied.')); 150 166 151 - $this->generate($generators); 167 + $this->generate($generators, $is_quickly); 152 168 } 153 169 154 - protected function generate(array $generators) { 170 + protected function generate(array $generators, $is_quickly) { 155 171 $viewer = $this->getViewer(); 156 172 157 173 foreach ($generators as $generator) { ··· 178 194 continue; 179 195 } 180 196 181 - $object_phid = $object->getPHID(); 197 + if (is_string($object)) { 198 + $object_phid = $object; 199 + } else { 200 + $object_phid = $object->getPHID(); 201 + } 182 202 183 203 $handles = $viewer->loadHandles(array($object_phid)); 184 204 ··· 189 209 $handles[$object_phid]->getTypeName(), 190 210 $handles[$object_phid]->getFullName())); 191 211 192 - sleep(1); 212 + if (!$is_quickly) { 213 + sleep(1); 214 + } 193 215 } 194 216 } 195 217