BIND 10 track1914, updated. b3c7d1eaf3835c8bc13a7cc136b85e79aaf16934 [1914] Update tests for the addMessage extension

BIND 10 source code commits bind10-changes at lists.isc.org
Thu May 17 19:20:53 UTC 2012


The branch, track1914 has been updated
       via  b3c7d1eaf3835c8bc13a7cc136b85e79aaf16934 (commit)
       via  51f3a86709293442f3bb04f775ae42d7d24b03dd (commit)
       via  12c0fa4fd0676ab17616d34a522d526f8139586a (commit)
      from  609581d6dd36f50ad9118b2869756c2f26c5afd4 (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 b3c7d1eaf3835c8bc13a7cc136b85e79aaf16934
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Thu May 17 21:20:12 2012 +0200

    [1914] Update tests for the addMessage extension
    
    As the internal data structure contains another element, we need to put
    it into each test that looks into the internal data structure.

commit 51f3a86709293442f3bb04f775ae42d7d24b03dd
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Thu May 17 20:51:00 2012 +0200

    [1914] Implemented the cancelAsyncRecv method
    
    Isn't it a little bit waste, to have 35 lines of tests for 1-line
    wrapper function? O:-)

commit 12c0fa4fd0676ab17616d34a522d526f8139586a
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Thu May 17 20:48:30 2012 +0200

    [1914] Tests for the cancelAsyncRecv call

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

Summary of changes:
 src/lib/config/ccsession.cc                        |    5 +++
 src/lib/config/tests/ccsession_unittests.cc        |   38 ++++++++++++++++++++
 .../server_common/tests/socket_requestor_test.cc   |    2 +
 3 files changed, 45 insertions(+), 0 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc
index cfb7e4b..d968e14 100644
--- a/src/lib/config/ccsession.cc
+++ b/src/lib/config/ccsession.cc
@@ -854,5 +854,10 @@ ModuleCCSession::requestMatch(const AsyncRecvRequest& request,
     return (false);
 }
 
+void
+ModuleCCSession::cancelAsyncRecv(const AsyncRecvRequestID& id) {
+    async_recv_requests_.erase(id);
+}
+
 }
 }
diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc
index ecf0d1b..b4bc0b0 100644
--- a/src/lib/config/tests/ccsession_unittests.cc
+++ b/src/lib/config/tests/ccsession_unittests.cc
@@ -948,6 +948,44 @@ TEST_F(AsyncReceiveCCSessionTest, outOfOrder) {
     nothingCalled();
 }
 
+// We first add, then remove the callback again and check that nothing is
+// matched.
+TEST_F(AsyncReceiveCCSessionTest, cancel) {
+    // Add the callback
+    ModuleCCSession::AsyncRecvRequestID request(registerReply(1));
+    // Add corresponding message
+    session.addMessage(msg_, "<ignored>", "<unused>", 1);
+    EXPECT_TRUE(mccs_.hasQueuedMsgs());
+    // And now, remove the callback again
+    mccs_.cancelAsyncRecv(request);
+    // And see that Nothing Happens(TM)
+    mccs_.checkCommand();
+    EXPECT_FALSE(mccs_.hasQueuedMsgs());
+    nothingCalled();
+}
+
+// We add multiple requests and cancel only one of them to see the rest
+// is unaffected.
+TEST_F(AsyncReceiveCCSessionTest, cancelSome) {
+    // Register few callbacks
+    registerReply(1);
+    ModuleCCSession::AsyncRecvRequestID request(registerCommand(""));
+    registerCommand("test group");
+    // Put some messages there
+    session.addMessage(msg_, "test group", "<unused>");
+    session.addMessage(msg_, "<ignored>", "<unused>", 1);
+    // Cancel the second callback. Therefore the first message will be matched
+    // by the third callback, not by the second.
+    mccs_.cancelAsyncRecv(request);
+    // Now, process the messages
+    mccs_.checkCommand();
+    mccs_.checkCommand();
+    // And see how they matched
+    called(2);
+    called(0);
+    nothingCalled();
+}
+
 void doRelatedLoggersTest(const char* input, const char* expected) {
     ConstElementPtr all_conf = isc::data::Element::fromJSON(input);
     ConstElementPtr expected_conf = isc::data::Element::fromJSON(expected);
diff --git a/src/lib/server_common/tests/socket_requestor_test.cc b/src/lib/server_common/tests/socket_requestor_test.cc
index 829b6d9..9adf84d 100644
--- a/src/lib/server_common/tests/socket_requestor_test.cc
+++ b/src/lib/server_common/tests/socket_requestor_test.cc
@@ -144,6 +144,7 @@ createExpectedRequest(const std::string& address,
     packet->add(Element::create("Boss"));
     packet->add(Element::create("*"));
     packet->add(createCommand("get_socket", command_args));
+    packet->add(Element::create(-1));
 
     return (packet);
 }
@@ -284,6 +285,7 @@ createExpectedRelease(const std::string& token) {
     packet->add(Element::create("Boss"));
     packet->add(Element::create("*"));
     packet->add(createCommand("drop_socket", command_args));
+    packet->add(Element::create(-1));
 
     return (packet);
 }



More information about the bind10-changes mailing list