-
Notifications
You must be signed in to change notification settings - Fork 31
[CDSK-815] Create a script which populates a database with random builds and user #337
[CDSK-815] Create a script which populates a database with random builds and user #337
Conversation
master/buildbot/db/builds.py
Outdated
except Exception as e: | ||
print("Exception occurs during create new build", e) | ||
transaction.rollback() | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return True | False
looks weird to me in Python.
Why not just re-raise the exception after rollback?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved 👍
from buildbot.util import datetime2epoch | ||
from buildbot.status import results | ||
|
||
MAX_UNIQUE_USER_COUNT = 5494 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm maybe you have right. I've got this number because I've added rows from https://github.com/treyhunner/names/blob/master/names/dist.female.first and https://github.com/treyhunner/names/blob/master/names/dist.male.first. But honestly, I have no idea what can be easily done in code to replace it. Maybe it will be enough to add a comment why exactly this number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you just put those two files in a set, and pop
to get an unique name?
Would save you the trouble with the while
unique checking thing...
results.DEPENDENCY_FAILURE, | ||
results.MERGED, | ||
results.INTERRUPTED, | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't duplicate this list, perhaps you could create an ALL_RESULTS in results.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved 👍
master/setup.py
Outdated
@@ -203,6 +203,7 @@ def make_release_tree(self, base_dir, files): | |||
'psutil == 4.3.0', | |||
'jsonschema == 2.6.0', | |||
'freezegun == 0.3.9', | |||
'names == 0.3.0', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a development requirement, not runtime (as long as you are careful with the imports).
Perhaps remove it from setup.py
and create a requirements-dev.txt
in the repo?
percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total))) | ||
filled_length = int(length * iteration // total) | ||
bar = fill * filled_length + '-' * (length - filled_length) | ||
print('\r%s |%s| %s%% %s' % (prefix, bar, percent, suffix), end='\r') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good job. But Python has a package for this: https://pypi.python.org/pypi/progress_bar/8
We can add this package do requirements-dev (as Diogo suggests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved 👍
0bd8bc0
to
cb63808
Compare
The script
buildbot populate-database
create random data in the database.It can be parametrized by few flags
-u NUMBER
or--users=NUMBER
- means how many users the script should create in the database-b NUMBER
or--builds=NUMBER
- means how many builds (with the related objects) the script should create in the database-s NUMBER
or--seed=NUMBER
- if a developer wants to have the same data every time, he or she can set this parameter to constant-q
- be quiet, does not display any information on std input