From bc16de368e21231c0f23bcbd4f9295efb90a22ed Mon Sep 17 00:00:00 2001
From: ormancey <emmanuel.ormancey@cern.ch>
Date: Wed, 13 Oct 2021 10:59:53 +0200
Subject: [PATCH] zz

---
 Python/stress-testing/channel.py        | 8 ++++----
 Python/stress-testing/stress_testing.py | 6 ++++--
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/Python/stress-testing/channel.py b/Python/stress-testing/channel.py
index 273f613..4e51ef2 100644
--- a/Python/stress-testing/channel.py
+++ b/Python/stress-testing/channel.py
@@ -43,8 +43,8 @@ def add_user_to_channel(channel_id, username):
     data = { 'username': username }
     r = requests.put(Config.BACKEND_URL + '/channels/' + channel_id + '/members', json=data, headers=Config.HEADER(), verify=Config.VERIFY)
     if r.status_code != requests.codes.ok:
-        print('error updating channel', r.json())
-        sys.exit(2)
+        #print('error updating channel', r.json())
+        raise FileExistsError("add_user_to_channel", r.json())
     updated_channel = r.json()
 
     return updated_channel['id']
@@ -55,8 +55,8 @@ def add_group_to_channel(channel_id, group):
     data = { 'group': { 'groupIdentifier': group } }
     r = requests.put(Config.BACKEND_URL + '/channels/' + channel_id + '/groups', json=data, headers=Config.HEADER(), verify=Config.VERIFY)
     if r.status_code != requests.codes.ok:
-        print('error updating channel', r.json())
-        sys.exit(2)
+        #print('error updating channel', r.json())
+        raise FileExistsError("add_group_to_channel", r.json())
     updated_channel = r.json()
 
     return updated_channel['id']
diff --git a/Python/stress-testing/stress_testing.py b/Python/stress-testing/stress_testing.py
index 195512a..674c6b3 100644
--- a/Python/stress-testing/stress_testing.py
+++ b/Python/stress-testing/stress_testing.py
@@ -103,8 +103,10 @@ def main(argv):
                 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 Exception:
-                print('error adding, skipping.')
+            except FileExistsError as ex:
+                print("\tGroup or Member already exists")
+                pass
+
             # Add probeXXX users as member
             #for username in Config.PROBE_USERS:
             #   add_user_to_channel(channel_id, username)
-- 
GitLab