#316 Drop fedmsg for publishing events
Merged 4 years ago by lsedlar. Opened 4 years ago by lsedlar.
lsedlar/odcs drop-fedmsg-sender  into  master

file modified
+2 -2
@@ -197,9 +197,9 @@ 

  

  ### Waiting until the compose is generated

  

- There are two ways how to wait for the compose generation. The preferred one is listening on fedmsg bus for `odcs.state.change` message with `done` or `failed` state and another one is using HTTP polling implemented in `wait_for_compose(...)` method.

+ There are two ways how to wait for the compose generation. The preferred one is listening on Fedora messaging bus for `odcs.state.change` message with `done` or `failed` state and another one is using HTTP polling implemented in `wait_for_compose(...)` method.

  

- If your application does not allow listening on fedmsg bus for some reason, you can use `wait_for_compose(...)` method like this:

+ If your application does not allow listening on the bus for some reason, you can use `wait_for_compose(...)` method like this:

  

  ```

  compose = odcs.new_compose(sources, source_type)

file modified
+1 -1
@@ -341,7 +341,7 @@ 

          in given time limit, raises RuntimeError.

  

          NOTE: It is advised to use this method only in situations where the

-         caller is not able to listen on fedmsg bus or UMB bus for the

+         caller is not able to listen on Fedora messaging bus or UMB bus for the

          odcs.state.change messages which can inform the caller about the

          compose state change without the polling.

  

file modified
+1 -1
@@ -109,7 +109,7 @@ 

  

      # Select backend where message will be sent to. Currently, umb is supported

      # which means the Unified Message Bus.

-     MESSAGING_BACKEND = ''  # fedmsg or umb

+     MESSAGING_BACKEND = ''  # fedora-messaging or umb

  

      # List of broker URLs. Each of them is a string consisting of domain and

      # optiona port.

file modified
+1 -1
@@ -221,7 +221,7 @@ 

          'messaging_backend': {

              'type': str,

              'default': '',

-             'desc': 'Messaging backend, fedmsg, rhmsg or fedora-messaging.'},

+             'desc': 'Messaging backend, rhmsg or fedora-messaging.'},

          'messaging_broker_urls': {

              'type': list,

              'default': [],

@@ -59,18 +59,6 @@ 

              producer.send(outgoing_msg)

  

  

- def _fedmsg_send_msg(msgs):

-     """Send message to fedmsg!  Yay!"""

- 

-     import fedmsg

- 

-     for msg in msgs:

-         # "event" is typically just "state-changed"

-         event = msg.get('event', 'event')

-         topic = "compose.%s" % event

-         fedmsg.publish(topic=topic, msg=msg)

- 

- 

  def _fedora_messaging_send_msg(msgs):

      """Send message to fedora-messaging."""

      from fedora_messaging import api, config
@@ -87,8 +75,6 @@ 

  def _get_messaging_backend():

      if conf.messaging_backend == 'rhmsg':

          return _umb_send_msg

-     elif conf.messaging_backend == 'fedmsg':

-         return _fedmsg_send_msg

      elif conf.messaging_backend == 'fedora-messaging':

          return _fedora_messaging_send_msg

      elif conf.messaging_backend:

@@ -40,11 +40,6 @@ 

      rhmsg = None

  

  try:

-     import fedmsg

- except ImportError:

-     fedmsg = None

- 

- try:

      import fedora_messaging

  except ImportError:

      fedora_messaging = None
@@ -107,58 +102,6 @@ 

          self.assert_messaging(compose)

  

  

- @unittest.skipUnless(fedmsg, 'fedmsg is required to run this test case.')

- class TestFedMsgSendMessageWhenComposeIsCreated(ModelsBaseTest):

-     """Test send message when compose is created"""

- 

-     disable_event_handlers = False

- 

-     def setUp(self):

-         super(TestFedMsgSendMessageWhenComposeIsCreated, self).setUp()

- 

-         # Real lock is not required for running tests

-         self.mock_lock = patch('threading.Lock')

-         self.mock_lock.start()

- 

-     def tearDown(self):

-         self.mock_lock.stop()

- 

-     def setup_composes(self):

-         self.compose = Compose.create(db.session,

-                                       "mine",

-                                       PungiSourceType.KOJI_TAG,

-                                       "f25",

-                                       COMPOSE_RESULTS["repository"],

-                                       3600)

-         db.session.commit()

- 

-     @patch.object(conf, 'messaging_backend', new='fedmsg')

-     @patch('fedmsg.publish')

-     def assert_messaging(self, compose, publish):

-         db.session.commit()

-         publish.assert_called_once_with(

-             topic='compose.state-changed',

-             msg={'event': 'state-changed', 'compose': compose.json()}

-         )

- 

-     def test_send_message(self):

-         compose = Compose.create(db.session,

-                                  "me",

-                                  PungiSourceType.MODULE,

-                                  "testmodule-master",

-                                  COMPOSE_RESULTS["repository"],

-                                  3600)

- 

-         self.assert_messaging(compose)

- 

-     def test_message_on_state_change(self):

-         compose = db.session.query(Compose).filter(

-             Compose.id == self.compose.id).all()[0]

-         compose.state = COMPOSE_STATES['generating']

- 

-         self.assert_messaging(compose)

- 

- 

  @unittest.skipUnless(fedora_messaging, 'fedora_messaging is required to run this test case.')

  class TestFedoraMessagingSendMessageWhenComposeIsCreated(ModelsBaseTest):

      """Test send message when compose is created"""