From f18c5f03963245ce2f211cd8fed7feededf4e1db Mon Sep 17 00:00:00 2001
From: ormancey <emmanuel.ormancey@cern.ch>
Date: Wed, 13 Oct 2021 16:48:14 +0200
Subject: [PATCH] updates

---
 .gitignore                              | 17 ++++++++++++++++
 Python/stress-testing/config.py         |  3 +++
 Python/stress-testing/stress_testing.py | 27 ++++++++++++++++---------
 3 files changed, 38 insertions(+), 9 deletions(-)
 create mode 100644 .gitignore

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..29e42e6
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,17 @@
+# Python
+*.egg-info/
+*.egg
+*__pycache__
+dist
+.pycharm*
+pycharm*
+
+# IDE
+.vscode
+.idea
+
+# Others
+*.DS_Store
+
+# Env
+.env.local
diff --git a/Python/stress-testing/config.py b/Python/stress-testing/config.py
index f97b653..4dddec6 100644
--- a/Python/stress-testing/config.py
+++ b/Python/stress-testing/config.py
@@ -38,6 +38,9 @@ class Config:
     # 5 Grappa groups created, containing 10 notiftestxx users each
     NOTIFTEST_GROUPS = ['group-notiftest' + f"{i:02d}" for i in range(1, 6)]
 
+    # Random 'unverified email users' to add more members
+    UNVERIFIED_USERS = ['bill.gates.vaccines.5G.' + f"{i:05d}" + '@ffp.club' for i in range(1, 40000)]
+
     PROBE_USERS = [
         "probe000@cern.ch",
         "probe001@cern.ch",
diff --git a/Python/stress-testing/stress_testing.py b/Python/stress-testing/stress_testing.py
index 674c6b3..b53d611 100644
--- a/Python/stress-testing/stress_testing.py
+++ b/Python/stress-testing/stress_testing.py
@@ -44,8 +44,8 @@ def main(argv):
             countnotifications = int(arg)
         elif opt in ("-u", "--users"):
             countusers = int(arg)
-            if countusers > len(Config.NOTIFTEST_USERS):
-                countusers = len(Config.NOTIFTEST_USERS)
+            if countusers > (len(Config.NOTIFTEST_USERS) + len(Config.UNVERIFIED_USERS)):
+                countusers = (len(Config.NOTIFTEST_USERS) + len(Config.UNVERIFIED_USERS))
         elif opt in ("-d", "--delete"):
             delete_test_channels = True
 
@@ -91,22 +91,31 @@ def main(argv):
     if countusers > 0:
         cnt = 0
         for channel_id in channel_ids:
+            print("Processing channel", channel_id)
             # Renew token
             if (cnt % 100) == 99:
                 Config.renew()
-            if (cnt % 1000) == 999:
-                print("Processed", cnt, "channels")
+            if (cnt % 100) == 99:
+                print("================= Processed", cnt, "channels =================")
             # Add one grappa gourp as member
             try:
                 add_group_to_channel(channel_id, Config.NOTIFTEST_GROUPS[cnt % len(Config.NOTIFTEST_GROUPS)])
-                # Add notiftest users as member, except the ones in the group added above
-                for ucpt in range(0, countusers):
-                    if (int(ucpt / 10)) != (cnt % len(Config.NOTIFTEST_GROUPS)): 
-                        add_user_to_channel(channel_id, Config.NOTIFTEST_USERS[ucpt])
             except FileExistsError as ex:
-                print("\tGroup or Member already exists")
+                print("\tGroup already exists")
                 pass
 
+            # Add notiftest users as member, except the ones in the group added above
+            for ucpt in range(0, countusers):
+                try:
+                    if ucpt < len(Config.NOTIFTEST_USERS):
+                        if (int(ucpt / 10)) != (cnt % len(Config.NOTIFTEST_GROUPS)): 
+                            add_user_to_channel(channel_id, Config.NOTIFTEST_USERS[ucpt])
+                    else:
+                        add_user_to_channel(channel_id, Config.UNVERIFIED_USERS[ucpt - len(Config.NOTIFTEST_USERS)])
+                except FileExistsError as ex:
+                    print("\tUser already exists")
+                    pass
+
             # Add probeXXX users as member
             #for username in Config.PROBE_USERS:
             #   add_user_to_channel(channel_id, username)
-- 
GitLab