traffic_replay: Assign users to groups by default
authorTim Beale <timbeale@catalyst.net.nz>
Wed, 10 Apr 2019 00:55:26 +0000 (12:55 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 30 Apr 2019 23:18:28 +0000 (23:18 +0000)
The traffic_replay script has a myriad of options, but by default when
it creates user accounts it does not assign these users to any groups
(you have to specify extra options to do that). This isn't really a fair
test of samba performance, because it's unlikely that real world setups
will have users that are in no groups (other than the default ones).

This patch changes the default behaviour so that it will assign the new
users to groups automatically, if no other group options were
specified.

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
script/traffic_replay

index fab9a8ded2631e97354638ddababce392e5b1d37..0d06d1c861dc5ea76ad49c798d57e96da43439c8 100755 (executable)
@@ -114,7 +114,7 @@ def main():
                               'the traffic')
     user_gen_group.add_option('-n', '--number-of-users', type='int', default=0,
                               help='Total number of test users to create')
-    user_gen_group.add_option('--number-of-groups', type='int', default=0,
+    user_gen_group.add_option('--number-of-groups', type='int', default=None,
                               help='Create this many groups')
     user_gen_group.add_option('--average-groups-per-user',
                               type='int', default=0,
@@ -301,6 +301,10 @@ def main():
         sys.exit(1)
 
     number_of_users = max(opts.number_of_users, len(conversations))
+
+    if opts.number_of_groups is None:
+        opts.number_of_groups = max(int(number_of_users / 10), 1)
+
     max_memberships = number_of_users * opts.number_of_groups
 
     if not opts.group_memberships and opts.average_groups_per_user:
@@ -317,6 +321,11 @@ def main():
                          opts.number_of_groups)))
         sys.exit(1)
 
+    # if no groups were specified by the user, then make sure we create some
+    # group memberships (otherwise it's not really a fair test)
+    if not opts.group_memberships and not opts.average_groups_per_user:
+        opts.group_memberships = min(number_of_users * 5, max_memberships)
+
     # Get an LDB connection.
     try:
         # if we're only adding users, then it's OK to pass a sam.ldb filepath