BIND 10 trac2930, updated. fafa0dd4a0c97aeef84b7c95ed624c3873ca4cb4 [2930] Test empty params in python

BIND 10 source code commits bind10-changes at lists.isc.org
Wed May 22 10:33:38 UTC 2013


The branch, trac2930 has been updated
       via  fafa0dd4a0c97aeef84b7c95ed624c3873ca4cb4 (commit)
       via  85dff79c7ec72f5079dea7646baa557de2e98c5b (commit)
       via  2ae9ac7bb5a19741eb21b0ccec951588c5672d1d (commit)
       via  e7591db5df9c7694e1e0e3f7dd3e2d77753999c1 (commit)
       via  453f362d6c7bba06582e713b9fa243fa0b8ef5b7 (commit)
      from  c738282e2dabd4004dd451edc1d5dd36b4e59df7 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit fafa0dd4a0c97aeef84b7c95ed624c3873ca4cb4
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Wed May 22 12:33:21 2013 +0200

    [2930] Test empty params in python

commit 85dff79c7ec72f5079dea7646baa557de2e98c5b
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Wed May 22 11:37:33 2013 +0200

    [2930] Update python docs to match the C++ ones

commit 2ae9ac7bb5a19741eb21b0ccec951588c5672d1d
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Wed May 22 11:22:07 2013 +0200

    [2930] Add test for missing parameters

commit e7591db5df9c7694e1e0e3f7dd3e2d77753999c1
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Wed May 22 11:17:48 2013 +0200

    [2930] Doxygen update
    
    Clarify few points in the method's doxygen comment.

commit 453f362d6c7bba06582e713b9fa243fa0b8ef5b7
Author: Michal 'vorner' Vaner <vorner at vorner.cz>
Date:   Wed May 22 11:14:09 2013 +0200

    [2930] Update docs for notifications
    
    The group prefix is now lower-case.

-----------------------------------------------------------------------

Summary of changes:
 doc/design/ipc-high.txt                           |    4 ++--
 src/lib/config/ccsession.h                        |    9 +++++++-
 src/lib/config/tests/ccsession_unittests.cc       |   18 +++++++++++++++
 src/lib/python/isc/config/ccsession.py            |   25 +++++++++++++++------
 src/lib/python/isc/config/tests/ccsession_test.py |   14 ++++++++++++
 5 files changed, 60 insertions(+), 10 deletions(-)

-----------------------------------------------------------------------
diff --git a/doc/design/ipc-high.txt b/doc/design/ipc-high.txt
index 3f46b5c..5addb88 100644
--- a/doc/design/ipc-high.txt
+++ b/doc/design/ipc-high.txt
@@ -210,7 +210,7 @@ about changes to zone data, they'd subscribe to the
 `Notifications/ZoneUpdates` group. Then, other client (let's say
 `XfrIn`, with session ID `s12345`) would send something like:
 
-  s12345 -> Notifications/ZoneUpdates
+  s12345 -> notifications/ZoneUpdates
   {"notification": ["zone-update", {
       "class": "IN",
       "origin": "example.org.",
@@ -221,7 +221,7 @@ Both receivers would receive the message and know that the
 `example.org` zone is now at version 123456. Note that multiple users
 may produce the same kind of notification. Also, single group may be
 used to send multiple notification names (but they should be related;
-in our example, the `Notifications/ZoneUpdates` could be used for
+in our example, the `notifications/ZoneUpdates` could be used for
 `zone-update`, `zone-available` and `zone-unavailable` notifications
 for change in zone data, configuration of new zone in the system and
 removal of a zone from configuration).
diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h
index aee6518..fd93545 100644
--- a/src/lib/config/ccsession.h
+++ b/src/lib/config/ccsession.h
@@ -430,13 +430,20 @@ public:
     /// Send a notification message to all clients subscribed to the given
     /// notification group.
     ///
+    /// This method does not not block.
+    ///
+    /// See docs/design/ipc-high.txt for details about notifications and
+    /// the format of messages sent.
+    ///
+    /// \throw CCSessionError for low-level communication errors.
     /// \param notification_group This parameter (indirectly) signifies what
     ///     clients should receive the notification. Only the clients that
     ///     subscribed to notifications on the same group receive it.
     /// \param name The name of the event to notify about (for example
     ///     `config_changed`).
     /// \param params Other parameters that describe the event. This might
-    ///     be, for example, the new configuration value.
+    ///     be, for example, the new configuration value. This can be any
+    ///     data element, but it is common for it to be map.
     void notify(const std::string& notification_group,
                 const std::string& name,
                 const isc::data::ConstElementPtr& params =
diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc
index ffc5434..700ffe4 100644
--- a/src/lib/config/tests/ccsession_unittests.cc
+++ b/src/lib/config/tests/ccsession_unittests.cc
@@ -139,6 +139,24 @@ TEST_F(CCSessionTest, notify) {
             session.getMsgQueue()->get(1)->toWire();
 }
 
+// Test sending a notification
+TEST_F(CCSessionTest, notifyNoParams) {
+    ModuleCCSession mccs(ccspecfile("spec1.spec"), session, NULL, NULL, false,
+                         false);
+    mccs.notify("group", "event");
+    const ConstElementPtr notification(el(
+        "["
+        "   \"notifications/group\","
+        "   \"*\","
+        "   {"
+        "       \"notification\": [\"event\"]"
+        "   },"
+        "   -1"
+        "]"));
+    EXPECT_TRUE(notification->equals(*session.getMsgQueue()->get(1))) <<
+            session.getMsgQueue()->get(1)->toWire();
+}
+
 TEST_F(CCSessionTest, createAnswer) {
     ConstElementPtr answer;
     answer = createAnswer();
diff --git a/src/lib/python/isc/config/ccsession.py b/src/lib/python/isc/config/ccsession.py
index f0e852a..5261cea 100644
--- a/src/lib/python/isc/config/ccsession.py
+++ b/src/lib/python/isc/config/ccsession.py
@@ -541,15 +541,26 @@ class ModuleCCSession(ConfigData):
 
     def notify(self, notification_group, event_name, params=None):
         """
-        Send a notification about an event to a group of recipients.
+        Send a notification to subscribed clients.
 
+        Send a notification message to all clients subscribed to the given
+        notification group.
+
+        See docs/design/ipc-high.txt for details about notifications
+        and the format of messages sent.
+
+        Throws:
+        - CCSessionError: for low-level communication errors.
         Params:
-        - notification_group: This indirectly specifies which recipients get
-          the notification. Only the ones that register callback for the same
-          gorup get it.
-        - event_name: The name of the notification.
-        - params: Additional description of the event.
-        Return: Nothing
+        - notification_group (string): This parameter (indirectly) signifies what
+          clients should receive the notification. Only clients that subscribed
+          to notifications on the same group receive it.
+        - event_name (string): The name of the event to notify about (for example
+          `config_changed`).
+        - params: Other parameters that describe the event. This might be, for
+          example, the new configuration value. This can be any data that can be
+          sent over the isc.cc.Session, but it is common for it to be dict.
+        Returns: Nothing
         """
         notification = [event_name]
         if params is not None:
diff --git a/src/lib/python/isc/config/tests/ccsession_test.py b/src/lib/python/isc/config/tests/ccsession_test.py
index f7d014d..3585337 100644
--- a/src/lib/python/isc/config/tests/ccsession_test.py
+++ b/src/lib/python/isc/config/tests/ccsession_test.py
@@ -362,6 +362,20 @@ class TestModuleCCSession(unittest.TestCase):
                 "param": True
             }]}, False]], fake_session.message_queue)
 
+    def test_notify_no_params(self):
+        """
+        Test the sent notification has the right format, this time
+        without passing parameters.
+        """
+        fake_session = FakeModuleCCSession()
+        mccs = self.create_session("spec1.spec", None, None, fake_session)
+        mccs.notify("group", "event")
+        self.assertEqual([
+                ["notifications/group", "*", {"notification": ["event"]},
+                 False]
+            ],
+            fake_session.message_queue)
+
     def my_config_handler_ok(self, new_config):
         return isc.config.ccsession.create_answer(0)
 



More information about the bind10-changes mailing list