Skip to content
This repository has been archived by the owner on May 24, 2018. It is now read-only.

[CDSK-815] Create a script which populates a database with random builds and user #337

Merged
merged 8 commits into from
Apr 11, 2018

Conversation

Mowinski
Copy link

@Mowinski Mowinski commented Mar 2, 2018

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

populate

@Mowinski Mowinski self-assigned this Mar 2, 2018
@coveralls
Copy link

coveralls commented Mar 2, 2018

Coverage Status

Coverage decreased (-0.2%) to 68.376% when pulling 8183c8c on cdsk-815-populate-database-with-sample-data into 68ced0e on staging.

@Mowinski Mowinski changed the title [WIP] [CDSK-815] Sample runner [WIP] [CDSK-815] Create a script which populate database with random builds and user Mar 20, 2018
@Mowinski Mowinski changed the title [WIP] [CDSK-815] Create a script which populate database with random builds and user [CDSK-815] Create a script which populate database with random builds and user Mar 21, 2018
except Exception as e:
print("Exception occurs during create new build", e)
transaction.rollback()
return False
Copy link
Member

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?

Copy link
Author

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number?

Copy link
Author

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?

Copy link
Member

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,
]
Copy link
Member

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.

Copy link
Author

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',
Copy link
Member

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')

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)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solved 👍

@Mowinski Mowinski force-pushed the cdsk-815-populate-database-with-sample-data branch from 0bd8bc0 to cb63808 Compare March 22, 2018 10:52
@Mowinski Mowinski changed the title [CDSK-815] Create a script which populate database with random builds and user [CDSK-815] Create a script which populates a database with random builds and user Apr 10, 2018
@Mowinski Mowinski merged commit a86c294 into staging Apr 11, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants