From 511cae7d7f49912316ea106691dc1bf173e5a869 Mon Sep 17 00:00:00 2001
From: Slavek Kabrda <bkabrda@redhat.com>
Date: Mar 13 2018 13:55:53 +0000
Subject: [PATCH 1/2] Reconnect to stomp broker if connection gets lost


---

diff --git a/pagure/lib/notify.py b/pagure/lib/notify.py
index 1498ac1..8aa5044 100644
--- a/pagure/lib/notify.py
+++ b/pagure/lib/notify.py
@@ -72,7 +72,7 @@ def stomp_publish(topic, message):
     try:
         import stomp
         global stomp_conn
-        if not stomp_conn:
+        if not stomp_conn or not stomp_conn.is_connected():
             stomp_conn = stomp.Connection12(pagure_config['STOMP_BROKERS'])
             if pagure_config.get('STOMP_SSL'):
                 stomp_conn.set_ssl(

From c8fc0da771bb3cf006f45189130375c15cbf86c7 Mon Sep 17 00:00:00 2001
From: Slavek Kabrda <bkabrda@redhat.com>
Date: Mar 13 2018 14:16:53 +0000
Subject: [PATCH 2/2] Fix tests broken by stomp integration


---

diff --git a/tests/test_pagure_flask_api_group.py b/tests/test_pagure_flask_api_group.py
index 972955e..5a87a2e 100644
--- a/tests/test_pagure_flask_api_group.py
+++ b/tests/test_pagure_flask_api_group.py
@@ -325,7 +325,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest):
                         "project_documentation": False,
                         "pull_request_access_only": False,
                         "pull_requests": True,
-                        "roadmap_on_issues_page": False
+                        "roadmap_on_issues_page": False,
+                        "stomp_notifications": True,
                     },
                     "tags": [],
                     "url_path": "test2",
@@ -418,7 +419,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest):
                         "project_documentation": False,
                         "pull_request_access_only": False,
                         "pull_requests": True,
-                        "roadmap_on_issues_page": False
+                        "roadmap_on_issues_page": False,
+                        "stomp_notifications": True,
                     },
                     "tags": [],
                     "url_path": "test2",
@@ -507,7 +509,8 @@ class PagureFlaskApiGroupTests(tests.SimplePagureTest):
                         "project_documentation": False,
                         "pull_request_access_only": False,
                         "pull_requests": True,
-                        "roadmap_on_issues_page": False
+                        "roadmap_on_issues_page": False,
+                        "stomp_notifications": True,
                     },
                     "tags": [],
                     "url_path": "test2",
diff --git a/tests/test_pagure_flask_api_user.py b/tests/test_pagure_flask_api_user.py
index cfae42d..3208523 100644
--- a/tests/test_pagure_flask_api_user.py
+++ b/tests/test_pagure_flask_api_user.py
@@ -136,7 +136,8 @@ class PagureFlaskApiUSertests(tests.Modeltests):
                         "pull_request_access_only": False,
                         "project_documentation": False,
                         "pull_requests": True,
-                        "roadmap_on_issues_page": False
+                        "roadmap_on_issues_page": False,
+                        "stomp_notifications": True,
                     },
                     "tags": [],
                     "user": {
@@ -188,7 +189,8 @@ class PagureFlaskApiUSertests(tests.Modeltests):
                         "pull_request_access_only": False,
                         "project_documentation": False,
                         "pull_requests": True,
-                        "roadmap_on_issues_page": False
+                        "roadmap_on_issues_page": False,
+                        "stomp_notifications": True,
                     },
                     "tags": [],
                     "user": {
@@ -239,7 +241,8 @@ class PagureFlaskApiUSertests(tests.Modeltests):
                         "project_documentation": False,
                         "pull_request_access_only": False,
                         "pull_requests": True,
-                        "roadmap_on_issues_page": False
+                        "roadmap_on_issues_page": False,
+                        "stomp_notifications": True,
                     },
                     "tags": [],
                     "user": {
diff --git a/tests/test_pagure_lib.py b/tests/test_pagure_lib.py
index b1ab9b8..7085b0e 100644
--- a/tests/test_pagure_lib.py
+++ b/tests/test_pagure_lib.py
@@ -1931,6 +1931,7 @@ class PagureLibtests(tests.Modeltests):
                 'always_merge': False,
                 'issues_default_to_private': False,
                 'fedmsg_notifications': True,
+                'stomp_notifications': True,
                 'pull_request_access_only': False,
             },
             user='pingou',
@@ -1954,6 +1955,7 @@ class PagureLibtests(tests.Modeltests):
                 'Enforce_signed-off_commits_in_pull-request': False,
                 'issues_default_to_private': False,
                 'fedmsg_notifications': True,
+                'stomp_notifications': True,
                 'pull_request_access_only': False,
             },
             user='pingou',
@@ -1972,6 +1974,7 @@ class PagureLibtests(tests.Modeltests):
                 'Enforce_signed-off_commits_in_pull-request': False,
                 'issues_default_to_private': False,
                 'fedmsg_notifications': True,
+                'stomp_notifications': True,
                 'pull_request_access_only': False,
             },
             user='pingou',
diff --git a/tests/test_pagure_lib_git.py b/tests/test_pagure_lib_git.py
index 2f70756..f4764a7 100644
--- a/tests/test_pagure_lib_git.py
+++ b/tests/test_pagure_lib_git.py
@@ -1850,7 +1850,7 @@ new file mode 100644
 index 0000000..60f7480
 --- /dev/null
 +++ b/456
-@@ -0,0 +1,137 @@
+@@ -0,0 +1,139 @@
 +{
 +    "assignee": null,
 +    "branch": "master",
@@ -1905,7 +1905,8 @@ index 0000000..60f7480
 +            "project_documentation": false,
 +            "pull_request_access_only": false,
 +            "pull_requests": true,
-+            "roadmap_on_issues_page": false
++            "roadmap_on_issues_page": false,
++            "stomp_notifications": true
 +        },
 +        "tags": [],
 +        "url_path": "test_ticket_repo",
@@ -1960,7 +1961,8 @@ index 0000000..60f7480
 +            "project_documentation": false,
 +            "pull_request_access_only": false,
 +            "pull_requests": true,
-+            "roadmap_on_issues_page": false
++            "roadmap_on_issues_page": false,
++            "stomp_notifications": true
 +        },
 +        "tags": [],
 +        "url_path": "test_ticket_repo",

