populate_db: Add option to specify max no of topics to create.

This will help us create more topics per stream than we currently do
by default.
This commit is contained in:
Aman Agrawal 2020-05-01 23:00:05 +05:30 committed by Tim Abbott
parent 87ddd73dcb
commit b25f2ed5b3
2 changed files with 13 additions and 1 deletions

View File

@ -33,6 +33,7 @@ create_zulip_test
# This next line can be simplified to "-n0" once we fix our app (and tests) with 0 messages.
./manage.py populate_db --test-suite -n30 --threads=1 \
--max-topics=3 \
--huddles=0 --personals=0 --percent-huddles=0 --percent-personals=0
./manage.py dumpdata \

View File

@ -134,6 +134,12 @@ class Command(BaseCommand):
default=0,
help='The number of extra streams to create')
parser.add_argument('--max-topics',
dest='max_topics',
type=int,
default=None,
help='The number of maximum topics to create')
parser.add_argument('--huddles',
dest='num_huddles',
type=int,
@ -191,6 +197,11 @@ class Command(BaseCommand):
if options["test_suite"]:
random.seed(0)
# If max_topics is not set, we set it proportional to the
# number of messages.
if options["max_topics"] is None:
options["max_topics"] = 1 + options["num_messages"] // 100
if options["delete"]:
# Start by clearing all the data in our database
clear_database()
@ -682,7 +693,7 @@ def generate_and_send_messages(data: Tuple[int, Sequence[Sequence[int]], Mapping
# Pick a random subscriber to the stream
message.sender = random.choice(Subscription.objects.filter(
recipient=message.recipient)).user_profile
message.subject = stream.name + str(random.randint(1, 3))
message.subject = stream.name + str(random.randint(1, options["max_topics"]))
saved_data['subject'] = message.subject
message.date_sent = choose_date_sent(num_messages, tot_messages, options['threads'])