Fill-database
Review Request #2104 — Created Feb. 6, 2011 and submitted
Here is the fully functioning fill-database script. Command and arguments take the form of: ./reviewboard/manage.py fill-database --users=N1 --review-requests=N2:N3 --diffs=N4:N5 --reviews=N6:N7 --diff-comments=N8:N9 Added: a password can now be set for all users created using --password=TEXT fill-database --users=10 --password=custom1 For instance: ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=1 --diff-comments=1 or ./reviewboard/manage.py fill-database --users=1 --review-requests=1:10 --diffs=1:5 --reviews=1:5 --diff-comments=1:5
Testing for fill-database March 20, 2011 tests added: Tested missing diff directory, missing diff files, & missing repo directory Tested causing error cases where try/except clauses were changed March 13, 2011 Tests added: Tested running exceptions, where path files could not be found Tested adding the password parameter (--password=test5) Tested adding random lorem ipsum wording to summary & description In the cases below where the database is empty a superuser has been created Test adding only one user on empty database ./reviewboard/manage.py fill-database --users=1 Test adding many users on an empty database ./reviewboard/manage.py fill-database --users=100 ./reviewboard/manage.py fill-database --users=1000 Test adding large num of users ./reviewboard/manage.py fill-database --users=10000 Test adding users and arguments other than review-request (shouldn't add anything but users) ./reviewboard/manage.py fill-database --users=5 --diffs=1 ./reviewboard/manage.py fill-database --users=5 --reviews=1 ./reviewboard/manage.py fill-database --users=5 --diffs=1 --reviews=1 ./reviewboard/manage.py fill-database --users=5 --diff-comments=1 ./reviewboard/manage.py fill-database --users=5 --diffs=1 --reviews=1 --diff-comments=1 Test adding users and review-requests to emtpy database ./reviewboard/manage.py fill-database --users=1 --review-requests=1 ./reviewboard/manage.py fill-database --users=1 --review-requests=1:10 ./reviewboard/manage.py fill-database --users=100 --review-requests=1:10 Test adding arguments other than diffs (shouldn't add anything but users & review-requests) ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --reviews=100 ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diff-comments=100 ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --reviews=100 --diff-comments=100 Test adding users, review-requests, and diffs to empty database ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=1:10 --diffs=0:10 Test adding users, requests, diffs, and arguments other than reviews (shouldn't add anything but users, requests & diffs) ./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:10 --diff-comments=10 Test adding users, requests, diffs, and reviews to empty database ./reviewboard/manage.py fill-database --users=1 --review-requests=1:5 --diffs=1 --reviews=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=0:5 --diffs=0:5 --reviews=0:5 Test adding users, requests, diffs, reviews, and comments to empty database ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=1 --diff-comments=1 Test adding additional information to existing database ./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:5 --reviews=1:10 --diff-comments=1:10 Test adding lots of information ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=100 --diff-comments=1 ./reviewboard/manage.py fill-database --users=5 --review-requests=5 --diffs=10 --reviews=100 --diff-comments=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=10 --diffs=10 --reviews=10 --diff-comments=10 [unfortunately while this last test does work, I ran it for 24hour without it completing the task entirely] Test some params at 0, shouldn't execute following parameters ./reviewboard/manage.py fill-database --users=5 --review-requests=0 --diffs=1:5 --reviews=1:5 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=0 --reviews=1:5 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=2 --reviews=0 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=2 --reviews=2 --diff-comments=0 Additional quantity-based tests: ./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:10 --reviews=1:10 --diff-comments=1:10 ./reviewboard/manage.py fill-database --users=100 --review-requests=100 ./reviewboard/manage.py fill-database --users=100 --review-requests=50 --diffs=20 ./reviewboard/manage.py fill-database --users=100 --review-requests=30 --diffs=10 ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=50 ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=20 ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=10 ./reviewboard/manage.py fill-database --users=100 --review-requests=10 --diffs=5 --reviews=10 --diff-comments=10
- Summary:
-
Updated add users command to add as many users as requested, also added the initial number of review requests to be added as part of the generated output. Also option for adding custom password.Here is a sneak peak at the fill-database script
- Description:
-
~ Updated add users command to add as many users as requested, also added the initial number of review requests to be added as part of the generated output. Also option for adding custom password.
~ Here is a sneak-peak at the fill-database.py script.
~ ~ So far, it takes the command --users=N, where N is any positive integer, and creates a list of users based on that argument.
~ Added filling user and profile contents to the database
~ Each user is created with the username test+i (where i is the value from 1 to and including the maximum number given (N).
~ ~ The password for each user is set to 'test1' but can be customized by uncommenting the appropriate area.
~ Looks like a working prototype to me :), just to fill the db now
~ The other parameters have been included but do not yet function.
- - - - Setup a good framework for command line arguments
- - - - Pilot test for creating the command line args, still trying things out
- - - - Import valid_prefs_required.
- - Time to slow down it seems.
- - Fix @valid_prefs_required and add it to the dashboard view.
- - The implementation had a bad variable reference in it, and it wasn't even being
- called from the dashboard, which is the first thing new users would see. - - Merge branch 'release-1.5.x'
- - - - Fix a syntax error.
- - Missed this in review.
- - Remove the deprecated webapi.
- - We'll have had a fairly long run of 1.5 with the deprecated webapi, and it
- doesn't support some of our new features like local site partitions. We've - broken all our dependencies on it now that rbtools and the web UI speak the REST - API, so we can remove it. - - Merge branch 'release-1.5.x'
- - - - Search Index setting in Admin UI doesn't perform validation for absolute paths
- - - Check is path is absolute
- - Check is path exists
- - Check is path writable
- - Fixes bug 1831.
- Reviewed at http://reviews.reviewboard.org/r/1940/ - - Remove some spurious print statements.
- - mod_wsgi gets cranky if a webapp tries to write to stdout. This can be avoided
- with an apache configuration, but we really shouldn't be printing from backend - code anyway. - - Fixes bug 1952
- - Merge branch 'release-1.5.x'
- - - - Turn on debugging if $DEBUG_RBSSH is 1.
- - - - Fail more gracefully if encountering an error during connecting.
- - We now log the error (if debug is on) and exit with a status of 1.
- - Suppor the -l login_name parameter with rbssh.
- - CVS makes use of the ssh -l parameter for specifying the username to log in
- as. rbssh wasn't supporting this, breaking cvs. We now support it, and it will - be used as the fallback if a username is not specified in the URL. - - Add release notes for RBTools 0.3.
- - - - Fix tabs-vs-spaces
- - - - Bug Fix 1508: Search includes change number
- - Made changes to index.py so now the search function also searches for change
- number. - - Testing done: Did some manual testing and it worked perfectly fine.
- Reviewed at http://reviews.reviewboard.org/r/2065/ - Fixes bug 1508 - - Return 404 if the local site name doesn't exist.
- - I noticed the other day that accessing the dashboard with a local site name that
- didn't exist showed me a dashboard page. This was happening because we used - get_object_or_none for the local site in a lot of places, which meant that said - views were showing the root data instead of 404. - - Fix the unit tests.
- - Apparently the django docs' suggestion of hooking up to User's post_save signal
- in order to create the Profile wasn't actually a good idea. Since we already - wrap things in valid_prefs_required, and that implementation wasn't actually - good anymore anyway, we'll just repurpose it to create the profile object. - - Add first and last names to the sign-up form, turn off interruption.
- - It seems a little annoying to have to fill these in from the preferences form
- after you've already signed up. In addition, we would interrupt users asking - them to join groups even if there were no groups. - - I've turned off the first-time-setup screen and message entirely for now, and
- intend to repurpose it to show a "what now" screen with some help and basic - instructions. - - Display local site names in the user group membership UI
- - This change fixes the "My Account" form to show all groups across local sites,
- and prefixes them with the local site name (if applicable). This way people will - be able to join groups even before I finish up the change to the group - membership UI to put it in the datagrid. - - Fix validation issues with the Repository.
- - This fixes another validation issue where the repository was also processing
- fields in the wrong order. We now validate users and groups in clean(). - - This fix uncovered another problem, which is that if no entries were available
- (say, no invite-only groups), our validation checks would raise an exception, - as the field wouldn't be in cleaned_data. We now default to an empty list in - these cases. - - Fix validation issues with the new LocalSite checks in admin forms.
- - The LocalSite checks were assuming that local_site would be "cleaned" prior
- to validating the fields that depend on them. That was clearly a bad idea. - Validation consisting of multiple fields should be done in clean(), so I've - moved the calls to there. Nothing changed with the actual validation logic. - The calls are just in one place now. - - Simplify RepositoryForm and add LocalSite validation.
- - This greatly simplifies RepositoryForm. We now tell the underlying ModelForm
- that this is a form for the Repository model, and ModelForm handles most of - the fields we care about based on the Model. This required moving some - information to the Model, which is a better place for it anyway. - - It also adds validation to check that the associated groups and users have
- a valid LocalSite given the LocalSite of the Repository. - - The validation logic is the same across all models that need it. They've been
- moved to new validate_users and validate_review_groups functions in - reviewboard.site.validation. - - Reviewed at http://reviews.reviewboard.org/r/2045/
- - Use display_id in the Comment admin.
- - We were using the wrong ID to show review request IDs in the Comment admin
- pages. We now use display_id instead, which should be the correct one. - - Fix "View Diff" links in notification emails
- - The HTML email for a review request update was using the pk instead of the
- display_id, which meant that the link was broken for review requests in a local - site. - - Add LocalSite validation for Group's list of users.
- - This introduces new validation for Group that ensures the users selected
- are actually part of the LocalSite, if the Group is a part of one. - - This makes use of the same user validation logic as DefaultReviewer. The
- checks have been split out into a _validate_users function, which both - can access. - - Unit tests have been added to ensure that validation works how we expect.
- - Reviewed at http://reviews.reviewboard.org/r/2041/
- - Make DefaultReviewer aware of LocalSites.
- - DefaultReviewer wasn't tied to a LocalSite, making it impossible to see
- which ones exist when not bound to a Repository or Group. It now stores the - LocalSite, and the DefaultReviewerForm performs validation to ensure that - the repositories, users and groups selected match the LocalSite in order to - prevent people or code from linking to objects on other LocalSites. - - Reviewed at http://reviews.reviewboard.org/r/2040/
- - Add Plastic SCM support
- - Implemented support for the Plastic SCM server. http://www.codicesoftware.com
- Supports changesets, and branch diffs. Tested (with post-review generating the - diff file) against the latest version of Plastic SCM; also with post-review - directly. - - Don't error out when creating a LocalSiteProfile during a star operation.
- - It's unlikely that we'll hit this case, since LocalSiteProfile will probably get
- created earlier on, but just in case, when we create this object, we need to - include the Profile object in addition to the User. - Branch:
-
fill-database
-
-
According to PEP-8 (the python style guide), imports should be separated into three groups, with a blank line in between each of those groups. Standard library (os, random, optparse) Other 3rd party modules (django) Package imports (reviewboard) Within each of these three sections, please alphabetize the import lines.
-
-
The help text here is a little repetitive. I'd get rid of "Specifies the" from each, and provide examples of what the input should look like, especially for the range items. I think these would be more helpful: "The number of users to add" "The number of review requests per user [min:max]" "The number of diffs per user [min:max]" I also think that "diffs" should be per review request, and "diff-comments" should be per diff. Also your last help text (for diff-comments) is incorrect.
-
It might be nice to let people either specify a single number or a range (you can parse that fairly easily). These might also be nicer to store as tuples instead of separate variables for min and max.
-
I know that a lot of this kind of output is probably temporary and for debug purposes, but chances are pretty good that the user knows what they entered. The output should inform about the progress and communicate how long the user has to wait before long-running operations are done.
-
-
This can be much shorter: return (int(item.strip()) for item in com_string.split(':')) Also note that we wrap lines to 80 characters.
-
Since this is an error message, please print it to stderr. print >> sys.stderr, "..." Also wrap to 80 characters.
- Change Summary:
-
Made the corrections that David has spelled out below. In this iteration the diffs are able to be uploaded from a specified directory.
- Change Summary:
-
Here is the first completely working version of fill-database
- Description:
-
~ Here is a sneak-peak at the fill-database.py script.
~ Here is the fully functioning fill-database script.
~ So far, it takes the command --users=N, where N is any positive integer, and creates a list of users based on that argument.
~ Command and arguments take the form of:
+ ./reviewboard/manage.py fill-database --users=N1 --review-requests=N2:N3 --diffs=N4:N5 --reviews=N6:N7 --diff-comments=N8:N9 ~ Each user is created with the username test+i (where i is the value from 1 to and including the maximum number given (N).
~ For instance:
+ ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=1 --diff-comments=1 ~ The password for each user is set to 'test1' but can be customized by uncommenting the appropriate area.
~ or
~ The other parameters have been included but do not yet function.
~ ./reviewboard/manage.py fill-database --users=1 --review-requests=1:10 --diffs=1:5 --reviews=1:5 --diff-comments=1:5
- Testing Done:
-
+ Testing for fill-database
+ + In the cases below where the database is empty a superuser has been created
+ + Test adding only one user on empty database
+ ./reviewboard/manage.py fill-database --users=1 + + Test adding many users on an empty database
+ ./reviewboard/manage.py fill-database --users=100 + ./reviewboard/manage.py fill-database --users=1000 + + Test adding large num of users
+ ./reviewboard/manage.py fill-database --users=10000 + + Test adding users and arguments other than review-request
+ (shouldn't add anything but users) + ./reviewboard/manage.py fill-database --users=5 --diffs=1 + ./reviewboard/manage.py fill-database --users=5 --reviews=1 + ./reviewboard/manage.py fill-database --users=5 --diffs=1 --reviews=1 + ./reviewboard/manage.py fill-database --users=5 --diff-comments=1 + ./reviewboard/manage.py fill-database --users=5 --diffs=1 --reviews=1 --diff-comments=1 + + Test adding users and review-requests to emtpy database
+ ./reviewboard/manage.py fill-database --users=1 --review-requests=1 + ./reviewboard/manage.py fill-database --users=1 --review-requests=1:10 + ./reviewboard/manage.py fill-database --users=100 --review-requests=1:10 + + Test adding arguments other than diffs
+ (shouldn't add anything but users & review-requests) + ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --reviews=100 + ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diff-comments=100 + ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --reviews=100 --diff-comments=100 + + Test adding users, review-requests, and diffs to empty database
+ ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 + ./reviewboard/manage.py fill-database --users=100 --review-requests=1:10 --diffs=0:10 + + Test adding users, requests, diffs, and arguments other than reviews
+ (shouldn't add anything but users, requests & diffs) + ./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:10 --diff-comments=10 + + Test adding users, requests, diffs, and reviews to empty database
+ ./reviewboard/manage.py fill-database --users=1 --review-requests=1:5 --diffs=1 --reviews=1 + ./reviewboard/manage.py fill-database --users=100 --review-requests=0:5 --diffs=0:5 --reviews=0:5 + + Test adding users, requests, diffs, reviews, and comments to empty database
+ ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=1 --diff-comments=1 + + Test adding additional information to existing database
+ ./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:5 --reviews=1:10 --diff-comments=1:10 + + Test adding lots of information
+ ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=100 --diff-comments=1 + ./reviewboard/manage.py fill-database --users=5 --review-requests=5 --diffs=10 --reviews=100 --diff-comments=1 + ./reviewboard/manage.py fill-database --users=100 --review-requests=10 --diffs=10 --reviews=10 --diff-comments=10 + [unfortunately while this last test does work, I ran it for 24hour without it completing the task entirely] + + Test some params at 0, shouldn't execute following parameters
+ ./reviewboard/manage.py fill-database --users=5 --review-requests=0 --diffs=1:5 --reviews=1:5 --diff-comments=1:5 + ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=0 --reviews=1:5 --diff-comments=1:5 + ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=2 --reviews=0 --diff-comments=1:5 + ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=2 --reviews=2 --diff-comments=0
- Change Summary:
-
Updated title & test cases
- Summary:
-
Here is a sneak peak at the fill-database scriptFill-database version 1.0
- Testing Done:
-
Testing for fill-database
In the cases below where the database is empty a superuser has been created
Test adding only one user on empty database
./reviewboard/manage.py fill-database --users=1 Test adding many users on an empty database
./reviewboard/manage.py fill-database --users=100 ./reviewboard/manage.py fill-database --users=1000 Test adding large num of users
./reviewboard/manage.py fill-database --users=10000 Test adding users and arguments other than review-request
(shouldn't add anything but users) ./reviewboard/manage.py fill-database --users=5 --diffs=1 ./reviewboard/manage.py fill-database --users=5 --reviews=1 ./reviewboard/manage.py fill-database --users=5 --diffs=1 --reviews=1 ./reviewboard/manage.py fill-database --users=5 --diff-comments=1 ./reviewboard/manage.py fill-database --users=5 --diffs=1 --reviews=1 --diff-comments=1 Test adding users and review-requests to emtpy database
./reviewboard/manage.py fill-database --users=1 --review-requests=1 ./reviewboard/manage.py fill-database --users=1 --review-requests=1:10 ./reviewboard/manage.py fill-database --users=100 --review-requests=1:10 Test adding arguments other than diffs
(shouldn't add anything but users & review-requests) ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --reviews=100 ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diff-comments=100 ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --reviews=100 --diff-comments=100 Test adding users, review-requests, and diffs to empty database
./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=1:10 --diffs=0:10 Test adding users, requests, diffs, and arguments other than reviews
(shouldn't add anything but users, requests & diffs) ./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:10 --diff-comments=10 Test adding users, requests, diffs, and reviews to empty database
./reviewboard/manage.py fill-database --users=1 --review-requests=1:5 --diffs=1 --reviews=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=0:5 --diffs=0:5 --reviews=0:5 Test adding users, requests, diffs, reviews, and comments to empty database
./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=1 --diff-comments=1 Test adding additional information to existing database
./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:5 --reviews=1:10 --diff-comments=1:10 Test adding lots of information
./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=100 --diff-comments=1 ./reviewboard/manage.py fill-database --users=5 --review-requests=5 --diffs=10 --reviews=100 --diff-comments=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=10 --diffs=10 --reviews=10 --diff-comments=10 [unfortunately while this last test does work, I ran it for 24hour without it completing the task entirely] Test some params at 0, shouldn't execute following parameters
./reviewboard/manage.py fill-database --users=5 --review-requests=0 --diffs=1:5 --reviews=1:5 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=0 --reviews=1:5 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=2 --reviews=0 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=2 --reviews=2 --diff-comments=0 + + Additional quantity-based tests:
+ ./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:10 --reviews=1:10 --diff-comments=1:10 + ./reviewboard/manage.py fill-database --users=100 --review-requests=100 + ./reviewboard/manage.py fill-database --users=100 --review-requests=50 --diffs=20 + ./reviewboard/manage.py fill-database --users=100 --review-requests=30 --diffs=10 + ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=50 + ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=20 + ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=10 + ./reviewboard/manage.py fill-database --users=100 --review-requests=10 --diffs=5 --reviews=10 --diff-comments=10
-
Steve: Good work on this. There are a few minor style things - a sweep with the pep8 script (http://pypi.python.org/pypi/pep8) will help you nail them all. Some other concerns: 1) Shouldn't we create the reviews/management/diffs folder, instead of asking users to create it on their own? 2) Shouldn't we include some .diff files, instead of asking users to create them on their own? 3) According to the Django documentation, @transaction.commit_on_success only rolls back if we throw an exception. In some cases, you're exiting on a failure, which means that the database commits the transaction at that point - even though we've failed. This can leave the database in a tricky state (I got this error after not having any .diff files, and it wouldn't go away until I reverted by DB manually: http://www.pastie.org/1667934). Better to throw exceptions, and rollback the DB on failure. So those are my comments. Thanks for your work, -Mike
-
-
-
Why is manage.py here? I think you can just have "/../scmtools/testdata/git_repo" and get the same effect.
-
-
Hold up - so we need to add a new folder called "diffs" under "reviews/management/commands/diffs"? That should probably be part of this review request too, then. Git generally ignores empty folders, but you can get it to pay attention by putting an empty .gitignore in it.
-
-
-
Since you're using @transaction.commit_on_success, you'll probably want to throw exceptions to ensure that the db gets rolled back.
-
-
-
-
Space on either side of "=" operator. There are a bunch of these, but I'll just mention it this one time.
-
I think these should be different for each review request - it'll give a better sense of variety when looking at the dashboard, instead of seeing the same summary/descriptions all over the place. Maybe some Lorem Ipsum would be appropriate here.
-
-
-
So you just want the most recent one? file_diff = cur_diff.files.order_by('timestamp')[0] oughta do the trick, unless I misunderstand what you're trying to do. Also, two spaces before inline comment, space after "#".
-
-
Hm. We should guarantee that the diffs we provide (if we're providing diffs) have more than 220 lines. Or, like you say, we need to detect that per diff. Hrm. Is there no diffviewer util for this?
-
-
-
Hm. NameError is for when a local or global variable is not defined. Both output and req_val *should* be defined here...not sure why you need to catch this one, nor pass it silently.
-
-
-
More concise / neater option: return ''.join(random.choice(string.ascii_lowercase) for x in range(5, 8))
-
I'd prefer failing early, like: if not value: return 0 if len(value) == 1: return value[0] return random.randrange(value[0], value[1])
- Change Summary:
-
Fixed issues and added suggestions listed by Mike in previous review
- Summary:
-
Fill-database version 1.0Fill-database version 1.1
- Testing Done:
-
Testing for fill-database
+ March 13, 2011 Tests added:
+ Tested running exceptions, where path files could not be found + Tested adding the password parameter (--password=test5) + Tested adding random lorem ipsum wording to summary & description + In the cases below where the database is empty a superuser has been created
Test adding only one user on empty database
./reviewboard/manage.py fill-database --users=1 Test adding many users on an empty database
./reviewboard/manage.py fill-database --users=100 ./reviewboard/manage.py fill-database --users=1000 Test adding large num of users
./reviewboard/manage.py fill-database --users=10000 Test adding users and arguments other than review-request
(shouldn't add anything but users) ./reviewboard/manage.py fill-database --users=5 --diffs=1 ./reviewboard/manage.py fill-database --users=5 --reviews=1 ./reviewboard/manage.py fill-database --users=5 --diffs=1 --reviews=1 ./reviewboard/manage.py fill-database --users=5 --diff-comments=1 ./reviewboard/manage.py fill-database --users=5 --diffs=1 --reviews=1 --diff-comments=1 Test adding users and review-requests to emtpy database
./reviewboard/manage.py fill-database --users=1 --review-requests=1 ./reviewboard/manage.py fill-database --users=1 --review-requests=1:10 ./reviewboard/manage.py fill-database --users=100 --review-requests=1:10 Test adding arguments other than diffs
(shouldn't add anything but users & review-requests) ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --reviews=100 ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diff-comments=100 ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --reviews=100 --diff-comments=100 Test adding users, review-requests, and diffs to empty database
./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=1:10 --diffs=0:10 Test adding users, requests, diffs, and arguments other than reviews
(shouldn't add anything but users, requests & diffs) ./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:10 --diff-comments=10 Test adding users, requests, diffs, and reviews to empty database
./reviewboard/manage.py fill-database --users=1 --review-requests=1:5 --diffs=1 --reviews=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=0:5 --diffs=0:5 --reviews=0:5 Test adding users, requests, diffs, reviews, and comments to empty database
./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=1 --diff-comments=1 Test adding additional information to existing database
./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:5 --reviews=1:10 --diff-comments=1:10 Test adding lots of information
./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=100 --diff-comments=1 ./reviewboard/manage.py fill-database --users=5 --review-requests=5 --diffs=10 --reviews=100 --diff-comments=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=10 --diffs=10 --reviews=10 --diff-comments=10 [unfortunately while this last test does work, I ran it for 24hour without it completing the task entirely] Test some params at 0, shouldn't execute following parameters
./reviewboard/manage.py fill-database --users=5 --review-requests=0 --diffs=1:5 --reviews=1:5 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=0 --reviews=1:5 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=2 --reviews=0 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=2 --reviews=2 --diff-comments=0 Additional quantity-based tests:
./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:10 --reviews=1:10 --diff-comments=1:10 ./reviewboard/manage.py fill-database --users=100 --review-requests=100 ./reviewboard/manage.py fill-database --users=100 --review-requests=50 --diffs=20 ./reviewboard/manage.py fill-database --users=100 --review-requests=30 --diffs=10 ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=50 ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=20 ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=10 ./reviewboard/manage.py fill-database --users=100 --review-requests=10 --diffs=5 --reviews=10 --diff-comments=10 - Diff:
-
Revision 6 (+26220 -1)
- Change Summary:
-
Updated description to include password changes
- Description:
-
Here is the fully functioning fill-database script.
Command and arguments take the form of:
./reviewboard/manage.py fill-database --users=N1 --review-requests=N2:N3 --diffs=N4:N5 --reviews=N6:N7 --diff-comments=N8:N9 + Added: a password can now be set for all users created using --password=TEXT
+ fill-database --users=10 --password=custom1 + For instance:
./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=1 --diff-comments=1 or
./reviewboard/manage.py fill-database --users=1 --review-requests=1:10 --diffs=1:5 --reviews=1:5 --diff-comments=1:5
-
-
-
-
You probably should do: def handle_noargs(self, users=None, review_requests=None, ....., **options):
-
Most management commands will take a verbosity parameter. That should probably be used. That way things can be done from scripts.
-
-
Use os.path.join: repo_dir = os.path.join(os.path.abspath(sys.argv[0]), "..", "scmtools", "testdata", "git_repo") This ensures it works across platforms.
-
This is an odd way to do it. I don't really think oyu need to throw an exception and then catch it immediately. Just do the if statement and then print the error.
-
This should actually be: raise CommandError('...') No trailing \n. Also, that lets you get rid of the exit() below. It means that other commands can wrap this and not terminate early.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Rather than this, we should always use set_password. The SHA1 isn't good enough, because it depends on the SECRET_KEY.
-
-
-
-
Should use print, and one per actual line. Also, instead of casting to strings and concatenating, use Python format strings.
-
-
-
-
User.objects.get(pk=1) Actually, we're doing this in a loop, so let's only fetch this one time throughout the whole lifetime of this program. It'll speed things up a bit.
-
-
-
-
-
-
-
-
-
-
-
-
-
Descriptions of functions should be in python docstring format: def parseCommand(...) """One line summary""" or: """One line summary Optional description. """
-
-
-
-
We're going to create this every single time this is called, which will be slow. Define it as a constant at the top of the file.
-
- Change Summary:
-
Fixed corrections noted by Christian
- Summary:
-
Fill-database version 1.1Fill-database version 1.2
- Testing Done:
-
~ Testing for fill-database
~ Testing for fill-database
+ March 20, 2011 tests added: + Tested missing diff directory, missing diff files, & missing repo directory + Tested causing error cases where try/except clauses were changed March 13, 2011 Tests added:
Tested running exceptions, where path files could not be found Tested adding the password parameter (--password=test5) Tested adding random lorem ipsum wording to summary & description In the cases below where the database is empty a superuser has been created
Test adding only one user on empty database
./reviewboard/manage.py fill-database --users=1 Test adding many users on an empty database
./reviewboard/manage.py fill-database --users=100 ./reviewboard/manage.py fill-database --users=1000 Test adding large num of users
./reviewboard/manage.py fill-database --users=10000 Test adding users and arguments other than review-request
(shouldn't add anything but users) ./reviewboard/manage.py fill-database --users=5 --diffs=1 ./reviewboard/manage.py fill-database --users=5 --reviews=1 ./reviewboard/manage.py fill-database --users=5 --diffs=1 --reviews=1 ./reviewboard/manage.py fill-database --users=5 --diff-comments=1 ./reviewboard/manage.py fill-database --users=5 --diffs=1 --reviews=1 --diff-comments=1 Test adding users and review-requests to emtpy database
./reviewboard/manage.py fill-database --users=1 --review-requests=1 ./reviewboard/manage.py fill-database --users=1 --review-requests=1:10 ./reviewboard/manage.py fill-database --users=100 --review-requests=1:10 Test adding arguments other than diffs
(shouldn't add anything but users & review-requests) ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --reviews=100 ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diff-comments=100 ./reviewboard/manage.py fill-database --users=1 --review-requests=1 --reviews=100 --diff-comments=100 Test adding users, review-requests, and diffs to empty database
./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=1:10 --diffs=0:10 Test adding users, requests, diffs, and arguments other than reviews
(shouldn't add anything but users, requests & diffs) ./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:10 --diff-comments=10 Test adding users, requests, diffs, and reviews to empty database
./reviewboard/manage.py fill-database --users=1 --review-requests=1:5 --diffs=1 --reviews=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=0:5 --diffs=0:5 --reviews=0:5 Test adding users, requests, diffs, reviews, and comments to empty database
./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=1 --diff-comments=1 Test adding additional information to existing database
./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:5 --reviews=1:10 --diff-comments=1:10 Test adding lots of information
./reviewboard/manage.py fill-database --users=1 --review-requests=1 --diffs=1 --reviews=100 --diff-comments=1 ./reviewboard/manage.py fill-database --users=5 --review-requests=5 --diffs=10 --reviews=100 --diff-comments=1 ./reviewboard/manage.py fill-database --users=100 --review-requests=10 --diffs=10 --reviews=10 --diff-comments=10 [unfortunately while this last test does work, I ran it for 24hour without it completing the task entirely] Test some params at 0, shouldn't execute following parameters
./reviewboard/manage.py fill-database --users=5 --review-requests=0 --diffs=1:5 --reviews=1:5 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=0 --reviews=1:5 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=2 --reviews=0 --diff-comments=1:5 ./reviewboard/manage.py fill-database --users=5 --review-requests=2 --diffs=2 --reviews=2 --diff-comments=0 Additional quantity-based tests:
./reviewboard/manage.py fill-database --users=5 --review-requests=1:5 --diffs=1:10 --reviews=1:10 --diff-comments=1:10 ./reviewboard/manage.py fill-database --users=100 --review-requests=100 ./reviewboard/manage.py fill-database --users=100 --review-requests=50 --diffs=20 ./reviewboard/manage.py fill-database --users=100 --review-requests=30 --diffs=10 ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=50 ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=20 ./reviewboard/manage.py fill-database --users=100 --review-requests=20 --diffs=5 --reviews=10 ./reviewboard/manage.py fill-database --users=100 --review-requests=10 --diffs=5 --reviews=10 --diff-comments=10 - Diff:
-
Revision 7 (+26231 -12)
-
Make sure master is merged in and references were fetched from origin. I'm seeing stray changes in here. Also, best to keep this just "Fill-database script" or something in the summary. Things shouldn't have a version number until they're officially in, and changing the summary breaks the threading in my e-mail client :) Once this is updated with master, I'll do another review.
- Change Summary:
-
re-rebased with master
- Summary:
-
Fill-database version 1.2Fill-database
- Diff:
-
Revision 8 (+26246 -15)
- Change Summary:
-
At last, a version that is up-to-date with the lastest version of reviewboard as of March 21, 2011: 9:46pm (PST)
- Diff:
-
Revision 9 (+26214 -1)
- Change Summary:
-
Forgot to do a search for trailing whitespace. Now updated with no trailing whitespace.
- Diff:
-
Revision 10 (+26214 -1)