BIND 10 trac931_2, updated. e3a81c18ff3f55727c1308bb894a8eb03e8f48b1 [trac931] Tweaks of addRemoteConfig

BIND 10 source code commits bind10-changes at lists.isc.org
Wed May 25 11:43:27 UTC 2011


The branch, trac931_2 has been updated
       via  e3a81c18ff3f55727c1308bb894a8eb03e8f48b1 (commit)
       via  d6b120403a24c9c233fa70ff8fca4a5da39f209e (commit)
      from  e156ec53472f22bbb890ebc76a1acdd9a9eda70c (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 e3a81c18ff3f55727c1308bb894a8eb03e8f48b1
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed May 25 13:43:05 2011 +0200

    [trac931] Tweaks of addRemoteConfig
    
    Small refactoring, one more test

commit d6b120403a24c9c233fa70ff8fca4a5da39f209e
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Wed May 25 13:35:24 2011 +0200

    [trac931] Remove stray experiment

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

Summary of changes:
 src/lib/cc/tests/session_unittests.cc       |    5 -----
 src/lib/config/ccsession.cc                 |   18 +++++++-----------
 src/lib/config/ccsession.h                  |    3 +--
 src/lib/config/tests/ccsession_unittests.cc |   12 ++++++++++++
 4 files changed, 20 insertions(+), 18 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/cc/tests/session_unittests.cc b/src/lib/cc/tests/session_unittests.cc
index e64925c..5f6e595 100644
--- a/src/lib/cc/tests/session_unittests.cc
+++ b/src/lib/cc/tests/session_unittests.cc
@@ -235,9 +235,4 @@ TEST_F(SessionTest, run_with_handler_timeout) {
     ASSERT_THROW(my_io_service.run(), SessionTimeout);
 }
 
-// Test it throws if we start it twice
-TEST_F(SessionTest, doubleStart) {
-    sess.start();
-}
-
 
diff --git a/src/lib/config/ccsession.cc b/src/lib/config/ccsession.cc
index 2dffbc5..e443c00 100644
--- a/src/lib/config/ccsession.cc
+++ b/src/lib/config/ccsession.cc
@@ -370,14 +370,11 @@ ModuleCCSession::checkCommand() {
     return (0);
 }
 
-std::string
-ModuleCCSession::fetchRemoteSpec(const std::string& module, bool is_filename,
-                                 ModuleSpec& spec)
-{
+ModuleSpec
+ModuleCCSession::fetchRemoteSpec(const std::string& module, bool is_filename) {
     if (is_filename) {
         // It is a filename, simply load it.
-        spec = readModuleSpecification(module);
-        return (spec.getModuleName());
+        return (readModuleSpecification(module));
     } else {
         // It's module name, request it from config manager
 
@@ -394,12 +391,12 @@ ModuleCCSession::fetchRemoteSpec(const std::string& module, bool is_filename,
         ConstElementPtr spec_data = parseAnswer(rcode, answer);
         if (rcode == 0 && spec_data) {
             // received OK, construct the spec out of it
-            spec = ModuleSpec(spec_data);
+            ModuleSpec spec = ModuleSpec(spec_data);
             if (module != spec.getModuleName()) {
                 // It's a different module!
                 isc_throw(CCSessionError, "Module name mismatch");
             }
-            return (module);
+            return (spec);
         } else {
             isc_throw(CCSessionError, "Error getting config for " +
                       module + ": " + answer->str());
@@ -414,9 +411,8 @@ ModuleCCSession::addRemoteConfig(const std::string& spec_name,
                                  bool spec_is_filename)
 {
     // First get the module name, specification and default config
-    ModuleSpec rmod_spec;
-    const std::string module_name(fetchRemoteSpec(spec_name, spec_is_filename,
-                                                  rmod_spec));
+    const ModuleSpec rmod_spec(fetchRemoteSpec(spec_name, spec_is_filename));
+    const std::string module_name(rmod_spec.getModuleName());
     ConfigData rmod_config(rmod_spec);
 
     // Get the current configuration values from config manager
diff --git a/src/lib/config/ccsession.h b/src/lib/config/ccsession.h
index 9274649..99e1b51 100644
--- a/src/lib/config/ccsession.h
+++ b/src/lib/config/ccsession.h
@@ -340,8 +340,7 @@ private:
     void updateRemoteConfig(const std::string& module_name,
                             isc::data::ConstElementPtr new_config);
 
-    std::string fetchRemoteSpec(const std::string& module, bool is_filename,
-                                ModuleSpec& spec);
+    ModuleSpec fetchRemoteSpec(const std::string& module, bool is_filename);
 };
 
 }
diff --git a/src/lib/config/tests/ccsession_unittests.cc b/src/lib/config/tests/ccsession_unittests.cc
index f143e36..104fa10 100644
--- a/src/lib/config/tests/ccsession_unittests.cc
+++ b/src/lib/config/tests/ccsession_unittests.cc
@@ -434,6 +434,18 @@ TEST_F(CCSessionTest, remoteConfig) {
     }
 
     {
+        SCOPED_TRACE("With bad module name");
+        // It is almost the same as above, but we supply wrong module name.
+        // It should fail.
+        // Try adding it with downloading the spec from config manager
+        ModuleSpec spec(moduleSpecFromFile(ccspecfile("spec2.spec")));
+        session.getMessages()->add(createAnswer(0, spec.getFullSpec()));
+
+        EXPECT_THROW(module_name = mccs.addRemoteConfig("Spec1", NULL, false),
+                     CCSessionError);
+    }
+
+    {
         // Try adding it with a handler.
         // Pass non-default value to see the handler is called after
         // downloading the configuration, not too soon.




More information about the bind10-changes mailing list