BIND 10 trac2947, updated. 4012aad8a19815d80d0e50e701f578667e28dc6b [2947] Add testcase to check that library errors don't cause rest of data sources to be skipped

BIND 10 source code commits bind10-changes at lists.isc.org
Tue Jun 18 10:53:26 UTC 2013


The branch, trac2947 has been updated
       via  4012aad8a19815d80d0e50e701f578667e28dc6b (commit)
       via  9957604343d1ae607b253fd348e7c8ad20617bc8 (commit)
      from  69b623493bfc426fc0ae2d605ad834a925d58384 (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 4012aad8a19815d80d0e50e701f578667e28dc6b
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Jun 18 16:22:04 2013 +0530

    [2947] Add testcase to check that library errors don't cause rest of data sources to be skipped

commit 9957604343d1ae607b253fd348e7c8ad20617bc8
Author: Mukund Sivaraman <muks at isc.org>
Date:   Tue Jun 18 16:12:41 2013 +0530

    [2947] Update exception hierarchy
    
    Put all the library exceptions under DataSourceLibraryError.

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

Summary of changes:
 src/lib/datasrc/factory.cc                    |    4 +--
 src/lib/datasrc/factory.h                     |   15 ++++++++---
 src/lib/datasrc/tests/client_list_unittest.cc |   34 +++++++++++++++++++++++++
 3 files changed, 48 insertions(+), 5 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/factory.cc b/src/lib/datasrc/factory.cc
index 34ab6d8..26b31dd 100644
--- a/src/lib/datasrc/factory.cc
+++ b/src/lib/datasrc/factory.cc
@@ -83,8 +83,8 @@ LibraryContainer::LibraryContainer(const std::string& name) {
     if (ds_lib_ == NULL) {
         // This may cause the filename to appear twice in the actual
         // error, but the output of dlerror is implementation-dependent
-        isc_throw(DataSourceLibraryError, "dlopen failed for " << name <<
-                                          ": " << dlerror());
+        isc_throw(DataSourceLibraryOpenError,
+                  "dlopen failed for " << name << ": " << dlerror());
     }
 }
 
diff --git a/src/lib/datasrc/factory.h b/src/lib/datasrc/factory.h
index 4e669ec..b9b6578 100644
--- a/src/lib/datasrc/factory.h
+++ b/src/lib/datasrc/factory.h
@@ -27,7 +27,7 @@ namespace isc {
 namespace datasrc {
 
 
-/// \brief Raised if there is an error loading the datasource implementation
+/// \brief Raised if there is an error in the datasource implementation
 ///        library
 class DataSourceLibraryError : public DataSourceError {
 public:
@@ -35,13 +35,22 @@ public:
         DataSourceError(file, line, what) {}
 };
 
+/// \brief Raised if there is an error opening the the datasource
+///        implementation library
+class DataSourceLibraryOpenError : public DataSourceLibraryError {
+public:
+    DataSourceLibraryOpenError(const char* file, size_t line,
+                               const char* what) :
+        DataSourceLibraryError(file, line, what) {}
+};
+
 /// \brief Raised if there is an error reading a symbol from the datasource
 ///        implementation library
-class DataSourceLibrarySymbolError : public DataSourceError {
+class DataSourceLibrarySymbolError : public DataSourceLibraryError {
 public:
     DataSourceLibrarySymbolError(const char* file, size_t line,
                                  const char* what) :
-        DataSourceError(file, line, what) {}
+        DataSourceLibraryError(file, line, what) {}
 };
 
 typedef DataSourceClient* ds_creator(isc::data::ConstElementPtr config,
diff --git a/src/lib/datasrc/tests/client_list_unittest.cc b/src/lib/datasrc/tests/client_list_unittest.cc
index 5b173a9..36c5005 100644
--- a/src/lib/datasrc/tests/client_list_unittest.cc
+++ b/src/lib/datasrc/tests/client_list_unittest.cc
@@ -16,6 +16,7 @@
 
 #include <datasrc/client_list.h>
 #include <datasrc/client.h>
+#include <datasrc/factory.h>
 #include <datasrc/cache_config.h>
 #include <datasrc/zone_iterator.h>
 #include <datasrc/exceptions.h>
@@ -71,6 +72,10 @@ public:
         if (type == "error") {
             isc_throw(DataSourceError, "The error data source type");
         }
+        if (type == "library_error") {
+            isc_throw(DataSourceLibraryError,
+                      "The library error data source type");
+        }
         if (type == "MasterFiles") {
             return (DataSourcePair(0, DataSourceClientContainerPtr()));
         }
@@ -705,6 +710,35 @@ TEST_P(ListTest, dataSrcError) {
     checkDS(0, "test_type", "{}", false);
 }
 
+// In case of library errors, the rest of the data sources should be
+// unaffected.
+TEST_P(ListTest, dataSrcLibraryError) {
+    EXPECT_EQ(0, list_->getDataSources().size());
+    const ConstElementPtr elem(Element::fromJSON("["
+        "{"
+        "   \"type\": \"type1\","
+        "   \"cache-enable\": false,"
+        "   \"params\": {}"
+        "},"
+        "{"
+        "   \"type\": \"library_error\","
+        "   \"cache-enable\": false,"
+        "   \"params\": {}"
+        "},"
+        "{"
+        "   \"type\": \"type2\","
+        "   \"cache-enable\": false,"
+        "   \"params\": {}"
+        "}]"
+    ));
+    list_->configure(elem, true);
+    EXPECT_EQ(2, list_->getDataSources().size());
+    checkDS(0, "type1", "{}", false);
+    checkDS(1, "type2", "{}", false);
+    // Check the exact configuration is preserved
+    EXPECT_EQ(elem, list_->getConfiguration());
+}
+
 // Check we can get the cache
 TEST_P(ListTest, configureCacheEmpty) {
     const ConstElementPtr elem(Element::fromJSON("["



More information about the bind10-changes mailing list