BIND 10 trac917, updated. 63f04832f2604868133a23d110ce6df5a9707993 [917] show the statistics data or the statistics spec with the module_name and the item_name even if module_name is specified or module_name and item_name are specified in arguments

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Nov 9 14:30:56 UTC 2011


The branch, trac917 has been updated
       via  63f04832f2604868133a23d110ce6df5a9707993 (commit)
       via  de07e6a0ab66de4d3c7720dc93bc7d9198c9d26b (commit)
       via  2139076757c1a14ecce96eafd1388f978732f8aa (commit)
       via  ab47b771999bd12171e65a8a3fb2ee512b709c4b (commit)
       via  ebe4e57805eda25ca347e0a9db8adad11fb3d4b5 (commit)
      from  50e96053742a30584f91a6bdb4b788977cd166bf (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 63f04832f2604868133a23d110ce6df5a9707993
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Wed Nov 9 14:29:27 2011 +0000

    [917] show the statistics data or the statistics spec with the module_name and the item_name
    even if module_name is specified or module_name and item_name are specified in arguments

commit de07e6a0ab66de4d3c7720dc93bc7d9198c9d26b
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Wed Nov 9 14:25:54 2011 +0000

    [917] remove plural "s" in the end of word in the table heading

commit 2139076757c1a14ecce96eafd1388f978732f8aa
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Wed Nov 9 08:07:48 2011 +0000

    [917] add TODOs for the temporary recursive functions

commit ab47b771999bd12171e65a8a3fb2ee512b709c4b
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Wed Nov 9 07:58:53 2011 +0000

    [917] add FIXMEs about handling non-ASCII characters

commit ebe4e57805eda25ca347e0a9db8adad11fb3d4b5
Author: Naoki Kambe <kambe at jprs.co.jp>
Date:   Wed Nov 9 07:53:31 2011 +0000

    [917] add a new logging id for the incorrect specified data, and print
    it when responding the 404 status code due to the data error

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

Summary of changes:
 src/bin/stats/stats.py.in                   |    8 ++--
 src/bin/stats/stats_httpd.py.in             |   33 ++++++++----
 src/bin/stats/stats_httpd_messages.mes      |    6 ++
 src/bin/stats/tests/b10-stats-httpd_test.py |   64 +++++++++++++---------
 src/bin/stats/tests/b10-stats_test.py       |   78 +++++++++++++-------------
 5 files changed, 111 insertions(+), 78 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/stats/stats.py.in b/src/bin/stats/stats.py.in
index 3a7f47a..51c4e09 100755
--- a/src/bin/stats/stats.py.in
+++ b/src/bin/stats/stats.py.in
@@ -246,12 +246,12 @@ class Stats:
         self.update_statistics_data()
         if owner and name:
             try:
-                return self.statistics_data[owner][name]
+                return {owner:{name:self.statistics_data[owner][name]}}
             except KeyError:
                 pass
         elif owner:
             try:
-                return self.statistics_data[owner]
+                return {owner: self.statistics_data[owner]}
             except KeyError:
                 pass
         elif name:
@@ -360,9 +360,9 @@ class Stats:
         if owner:
             try:
                 if name:
-                    return isc.config.create_answer(0, schema_byname[owner][name])
+                    return isc.config.create_answer(0, {owner:[schema_byname[owner][name]]})
                 else:
-                    return isc.config.create_answer(0, schema[owner])
+                    return isc.config.create_answer(0, {owner:schema[owner]})
             except KeyError:
                 pass
         else:
diff --git a/src/bin/stats/stats_httpd.py.in b/src/bin/stats/stats_httpd.py.in
index 0e4e91c..91901bb 100644
--- a/src/bin/stats/stats_httpd.py.in
+++ b/src/bin/stats/stats_httpd.py.in
@@ -129,7 +129,7 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
             # Couldn't find neither specified module name nor
             # specified item name
             self.send_error(404)
-            logger.error(STATHTTPD_SERVER_ERROR, err)
+            logger.error(STATHTTPD_SERVER_DATAERROR, err)
             return None
         except StatsHttpdError as err:
             self.send_error(500)
@@ -445,6 +445,9 @@ class StatsHttpd:
         owns. The second argument cannot be specified when the first
         argument is not specified."""
 
+        # TODO: Separate the following recursive function by type of
+        # the parameter. Because we should be sure what type there is
+        # when we call it recursively.
         def stats_data2xml(stats_spec, stats_data, xml_elem):
             """Internal use for xml_handler. Reads stats_data and
             stats_spec specified as first and second arguments, and
@@ -503,6 +506,8 @@ class StatsHttpd:
         # cases transparently, we first make sure tostring() returns
         # bytes by specifying utf-8 and then convert the result to a
         # plain string (code below assume it).
+        # FIXME: Non-ASCII characters might be lost here. Consider how
+        # the whole system should handle non-ASCII characters.
         xml_string = str(xml.etree.ElementTree.tostring(xml_elem, encoding='utf-8'),
                          encoding='us-ascii')
         self.xml_body = self.open_template(XML_TEMPLATE_LOCATION).substitute(
@@ -520,6 +525,9 @@ class StatsHttpd:
         which the the module owns. The second argument cannot be
         specified when the first argument is not specified."""
 
+        # TODO: Separate the following recursive function by type of
+        # the parameter. Because we should be sure what type there is
+        # when we call it recursively.
         def stats_spec2xsd(stats_spec, xsd_elem):
             """Internal use for xsd_handler. Reads stats_spec
             specified as first arguments, and modify the xml object
@@ -627,6 +635,8 @@ class StatsHttpd:
         # cases transparently, we first make sure tostring() returns
         # bytes by specifying utf-8 and then convert the result to a
         # plain string (code below assume it).
+        # FIXME: Non-ASCII characters might be lost here. Consider how
+        # the whole system should handle non-ASCII characters.
         xsd_string = str(xml.etree.ElementTree.tostring(xsd_root, encoding='utf-8'),
                          encoding='us-ascii')
         self.xsd_body = self.open_template(XSD_TEMPLATE_LOCATION).substitute(
@@ -643,6 +653,9 @@ class StatsHttpd:
         which the the module owns. The second argument cannot be
         specified when the first argument is not specified."""
 
+        # TODO: Separate the following recursive function by type of
+        # the parameter. Because we should be sure what type there is
+        # when we call it recursively.
         def stats_spec2xsl(stats_spec, xsl_elem, path=XML_URL_PATH):
             """Internal use for xsl_handler. Reads stats_spec
             specified as first arguments, and modify the xml object
@@ -657,10 +670,10 @@ class StatsHttpd:
                     table = xml.etree.ElementTree.Element("table")
                     tr = xml.etree.ElementTree.Element("tr")
                     th = xml.etree.ElementTree.Element("th")
-                    th.text = "Module Names"
+                    th.text = "Module Name"
                     tr.append(th)
                     th = xml.etree.ElementTree.Element("th")
-                    th.text = "Module Items"
+                    th.text = "Module Item"
                     tr.append(th)
                     table.append(tr)
                     for mod in stats_spec.keys():
@@ -686,10 +699,10 @@ class StatsHttpd:
                         table = xml.etree.ElementTree.Element("table")
                         tr = xml.etree.ElementTree.Element("tr")
                         th = xml.etree.ElementTree.Element("th")
-                        th.text = "Item Names"
+                        th.text = "Item Name"
                         tr.append(th)
                         th = xml.etree.ElementTree.Element("th")
-                        th.text = "Item Values"
+                        th.text = "Item Value"
                         tr.append(th)
                         table.append(tr)
                         foreach = xml.etree.ElementTree.Element(
@@ -724,10 +737,10 @@ class StatsHttpd:
                 table = xml.etree.ElementTree.Element("table")
                 tr = xml.etree.ElementTree.Element("tr")
                 th = xml.etree.ElementTree.Element("th")
-                th.text = "Item Names"
+                th.text = "Item Name"
                 tr.append(th)
                 th = xml.etree.ElementTree.Element("th")
-                th.text = "Item Values"
+                th.text = "Item Value"
                 tr.append(th)
                 table.append(tr)
                 for item_spec in stats_spec:
@@ -765,9 +778,7 @@ class StatsHttpd:
         xsd_root = xml.etree.ElementTree.Element( # started with xml:template tag
             "xsl:template",
             attrib={'match': "bind10:statistics"})
-        if module_name is not None and item_name is not None:
-            stats_spec2xsl([ stats_spec ], xsd_root, XML_URL_PATH + '/' + module_name)
-        elif module_name is not None:
+        if module_name is not None:
             stats_spec2xsl(stats_spec, xsd_root, XML_URL_PATH + '/' + module_name)
         else:
             stats_spec2xsl(stats_spec, xsd_root)
@@ -777,6 +788,8 @@ class StatsHttpd:
         # cases transparently, we first make sure tostring() returns
         # bytes by specifying utf-8 and then convert the result to a
         # plain string (code below assume it).
+        # FIXME: Non-ASCII characters might be lost here. Consider how
+        # the whole system should handle non-ASCII characters.
         xsl_string = str(xml.etree.ElementTree.tostring(xsd_root, encoding='utf-8'),
                          encoding='us-ascii')
         self.xsl_body = self.open_template(XSL_TEMPLATE_LOCATION).substitute(
diff --git a/src/bin/stats/stats_httpd_messages.mes b/src/bin/stats/stats_httpd_messages.mes
index 0e984dc..dbd0650 100644
--- a/src/bin/stats/stats_httpd_messages.mes
+++ b/src/bin/stats/stats_httpd_messages.mes
@@ -55,6 +55,12 @@ response will be sent back, and the specific error is printed. This
 is an error condition that likely points to a module that is not
 responding correctly to statistic requests.
 
+% STATHTTPD_SERVER_DATAERROR HTTP server data error: %1
+An internal error occurred while handling an HTTP request. An HTTP 404
+response will be sent back, and the specific error is printed. This
+is an error condition that likely points the specified data
+corresponding to the requested URI is incorrect.
+
 % STATHTTPD_SERVER_INIT_ERROR HTTP server initialization error: %1
 There was a problem initializing the HTTP server in the stats-httpd
 module upon receiving its configuration data. The most likely cause
diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py
index 2b2b1b4..7ded974 100644
--- a/src/bin/stats/tests/b10-stats-httpd_test.py
+++ b/src/bin/stats/tests/b10-stats-httpd_test.py
@@ -182,8 +182,9 @@ class TestHttpHandler(unittest.TestCase):
                                  + stats_httpd.XSL_URL_PATH + '/' + mod
                                  + '"?>'))
                 for k in DUMMY_DATA[mod].keys():
-                    self.assertIsNotNone(root.find(k))
-                    itm = root.find(k)
+                    self.assertIsNotNone(root.find(mod + '/' + k))
+                    itm = root.find(mod + '/' + k)
+                    self.assertIsNotNone(itm)
                     if type(DUMMY_DATA[mod][k]) is list:
                         for v in DUMMY_DATA[mod][k]:
                             for i in v:
@@ -198,7 +199,7 @@ class TestHttpHandler(unittest.TestCase):
                                  '<?xml-stylesheet type="text/xsl" href="'
                                  + stats_httpd.XSL_URL_PATH + '/' + mod + '/' + item
                                  + '"?>'))
-                self.assertIsNotNone(root.find(item))
+                self.assertIsNotNone(root.find(mod + '/' + item))
 
         # URL is '/bind10/statistics/xml'
         check_XML_URL_PATH(mod=None, item=None)
@@ -247,9 +248,12 @@ class TestHttpHandler(unittest.TestCase):
                                     self.assertTrue(
                                         k in [ elm.attrib['name'] for elm in itm_elm2['zones'].findall(xsdpath) ])
             elif item is None:
+                xsdpath = '/'.join([ url_xmlschema + t for t in [ 'element', 'complexType', 'all', 'element' ] ])
+                mod_elm = dict([ (elm.attrib['name'], elm) for elm in root.findall(xsdpath) ])
+                self.assertTrue(mod in mod_elm)
                 for (it, val) in DUMMY_DATA[mod].items():
-                    xsdpath = '/'.join([ url_xmlschema + t for t in [ 'element', 'complexType', 'all', 'element' ] ])
-                    itm_elm = dict([ (elm.attrib['name'], elm) for elm in root.findall(xsdpath) ])
+                    xsdpath = '/'.join([ url_xmlschema + t for t in [ 'complexType', 'all', 'element' ] ])
+                    itm_elm = dict([ (elm.attrib['name'], elm) for elm in mod_elm[mod].findall(xsdpath) ])
                     self.assertTrue(it in itm_elm)
                     if type(val) is list:
                         xsdpath = '/'.join([ url_xmlschema + t for t in [ 'complexType', 'sequence', 'element' ] ])
@@ -262,7 +266,10 @@ class TestHttpHandler(unittest.TestCase):
                                     k in [ elm.attrib['name'] for elm in itm_elm2['zones'].findall(xsdpath) ])
             else:
                 xsdpath = '/'.join([ url_xmlschema + t for t in [ 'element', 'complexType', 'all', 'element' ] ])
-                itm_elm = dict([ (elm.attrib['name'], elm) for elm in root.findall(xsdpath) ])
+                mod_elm = dict([ (elm.attrib['name'], elm) for elm in root.findall(xsdpath) ])
+                self.assertTrue(mod in mod_elm)
+                xsdpath = '/'.join([ url_xmlschema + t for t in [ 'complexType', 'all', 'element' ] ])
+                itm_elm = dict([ (elm.attrib['name'], elm) for elm in mod_elm[mod].findall(xsdpath) ])
                 self.assertTrue(item in itm_elm)
                 if type(DUMMY_DATA[mod][item]) is list:
                     xsdpath = '/'.join([ url_xmlschema + t for t in [ 'complexType', 'sequence', 'element' ] ])
@@ -328,11 +335,14 @@ class TestHttpHandler(unittest.TestCase):
                             itm_vo = [ x.attrib['select'] for x in mod_fe[mod].findall(xslpath) ]
                             self.assertTrue(k in itm_vo)
             elif item is None:
+                xslpath = url_trans + 'template/' + url_xhtml + 'table/' + url_trans + 'for-each'
+                mod_fe = dict([ (x.attrib['select'], x) for x in root.findall(xslpath) ])
+                self.assertTrue(mod in mod_fe)
                 for (k, v) in DUMMY_DATA[mod].items():
                     if type(v) is list:
-                        xslpath = url_trans + 'template/' + url_xhtml + 'table/' \
-                            + url_trans + 'for-each'
-                        itm_fe = dict([ (x.attrib['select'], x) for x in root.findall(xslpath) ])
+                        xslpath = url_xhtml + 'tr/' + url_xhtml + 'td/' \
+                            + url_xhtml + 'table/' + url_trans + 'for-each'
+                        itm_fe = dict([ (x.attrib['select'], x) for x in mod_fe[mod].findall(xslpath) ])
                         self.assertTrue(k in itm_fe)
                         for itms in v:
                             xslpath = url_xhtml + 'tr/' + url_xhtml + 'td/' \
@@ -346,21 +356,24 @@ class TestHttpHandler(unittest.TestCase):
                                 itm_vo = [ x.attrib['select'] for x in itm_fe['zones'].findall(xslpath) ]
                                 self.assertTrue(k in itm_vo)
                     else:
-                        xslpath = url_trans + 'template/' + url_xhtml + 'table/' \
-                            + url_xhtml + 'tr/' + url_xhtml + 'td/' + url_trans + 'value-of'
-                        itm_vo = dict([ (x.attrib['select'], x) for x in root.findall(xslpath) ])
+                        xslpath = url_xhtml + 'tr/' + url_xhtml + 'td/' \
+                            + url_xhtml + 'table/' + url_xhtml + 'tr/' \
+                            + url_xhtml + 'td/' + url_trans + 'value-of'
+                        itm_vo = [ x.attrib['select'] for x in mod_fe[mod].findall(xslpath) ]
                         self.assertTrue(k in itm_vo)
             else:
-                (k, v) = (item, DUMMY_DATA[mod][item])
-                if type(v) is list:
-                    xslpath = url_trans + 'template/' + url_xhtml + 'table/' \
-                        + url_trans + 'for-each'
-                    itm_fe = dict([ (x.attrib['select'], x) for x in root.findall(xslpath) ])
-                    self.assertTrue(k in itm_fe)
-                    for itms in v:
+                xslpath = url_trans + 'template/' + url_xhtml + 'table/' + url_trans + 'for-each'
+                mod_fe = dict([ (x.attrib['select'], x) for x in root.findall(xslpath) ])
+                self.assertTrue(mod in mod_fe)
+                if type(DUMMY_DATA[mod][item]) is list:
+                    xslpath = url_xhtml + 'tr/' + url_xhtml + 'td/' \
+                        + url_xhtml + 'table/' + url_trans + 'for-each'
+                    itm_fe = dict([ (x.attrib['select'], x) for x in mod_fe[mod].findall(xslpath) ])
+                    self.assertTrue(item in itm_fe)
+                    for itms in DUMMY_DATA[mod][item]:
                         xslpath = url_xhtml + 'tr/' + url_xhtml + 'td/' \
                             + url_xhtml + 'table/' + url_trans + 'for-each'
-                        itm_fe = dict([ (x.attrib['select'], x) for x in itm_fe[k].findall(xslpath) ])
+                        itm_fe = dict([ (x.attrib['select'], x) for x in itm_fe[item].findall(xslpath) ])
                         self.assertTrue('zones' in itm_fe)
                         for (k, v) in itms.items():
                             xslpath = url_xhtml + 'tr/' + url_xhtml + 'td/' \
@@ -369,10 +382,11 @@ class TestHttpHandler(unittest.TestCase):
                             itm_vo = [ x.attrib['select'] for x in itm_fe['zones'].findall(xslpath) ]
                             self.assertTrue(k in itm_vo)
                 else:
-                    xslpath = url_trans + 'template/' + url_xhtml + 'table/' \
-                        + url_xhtml + 'tr/' + url_xhtml + 'td/' + url_trans + 'value-of'
-                    itm_vo = dict([ (x.attrib['select'], x) for x in root.findall(xslpath) ])
-                    self.assertTrue(k in itm_vo)
+                    xslpath = url_xhtml + 'tr/' + url_xhtml + 'td/' \
+                        + url_xhtml + 'table/' + url_xhtml + 'tr/' \
+                        + url_xhtml + 'td/' + url_trans + 'value-of'
+                    itm_vo = [ x.attrib['select'] for x in mod_fe[mod].findall(xslpath) ]
+                    self.assertTrue(item in itm_vo)
 
         # URL is '/bind10/statistics/xsl'
         check_XSL_URL_PATH(mod=None, item=None)
@@ -1205,7 +1219,7 @@ class TestStatsHttpd(unittest.TestCase):
               }
         xsl_body1 = self.stats_httpd.open_template(
             stats_httpd.XSL_TEMPLATE_LOCATION).substitute(
-            xsl_string='<xsl:template match="bind10:statistics"><table><tr><th>Module Names</th><th>Module Items</th></tr><xsl:for-each select="Dummy"><tr><td><a href="' + stats_httpd.XML_URL_PATH + '/Dummy">Dummy</a></td><td><table><tr><th>Item Names</th><th>Item Values</th></tr><tr><td class="title" title="foo bar"><a href="' + stats_httpd.XML_URL_PATH + '/Dummy/foo">Foo</a></td><td><xsl:value-of select="foo" /></td></tr><xsl:for-each select="foo2"><tr><td class="title" title="Foo bar"><a href="' + stats_httpd.XML_URL_PATH + '/Dummy/foo2">Foo bar</a></td><td><table><tr><th>Item Names</th><th>Item Values</th></tr><xsl:for-each select="foo2-1"><tr><td class="title" title="">foo2-1</td><td><table><tr><th>Item Names</th><th>Item Values</th></tr><tr><td class="title" title="Foo bar">Foo2 1 1</td><td><xsl:value-of select="foo2-1-1" /></td></tr><tr><td class="title" title="Foo bar">Foo2 1 2</td><td><xsl:value-of select="foo2-1-2" /></td></tr><tr><td class="title" title="Foo bar">
 Foo2 1 3</td><td><xsl:value-of select="foo2-1-3" /></td></tr></table></td></tr></xsl:for-each></table></td></tr></xsl:for-each></table></td></tr></xsl:for-each></table></xsl:template>',
+            xsl_string='<xsl:template match="bind10:statistics"><table><tr><th>Module Name</th><th>Module Item</th></tr><xsl:for-each select="Dummy"><tr><td><a href="' + stats_httpd.XML_URL_PATH + '/Dummy">Dummy</a></td><td><table><tr><th>Item Name</th><th>Item Value</th></tr><tr><td class="title" title="foo bar"><a href="' + stats_httpd.XML_URL_PATH + '/Dummy/foo">Foo</a></td><td><xsl:value-of select="foo" /></td></tr><xsl:for-each select="foo2"><tr><td class="title" title="Foo bar"><a href="' + stats_httpd.XML_URL_PATH + '/Dummy/foo2">Foo bar</a></td><td><table><tr><th>Item Name</th><th>Item Value</th></tr><xsl:for-each select="foo2-1"><tr><td class="title" title="">foo2-1</td><td><table><tr><th>Item Name</th><th>Item Value</th></tr><tr><td class="title" title="Foo bar">Foo2 1 1</td><td><xsl:value-of select="foo2-1-1" /></td></tr><tr><td class="title" title="Foo bar">Foo2 1 2</td><td><xsl:value-of select="foo2-1-2" /></td></tr><tr><td class="title" title="Foo bar">Foo2 1 3
 </td><td><xsl:value-of select="foo2-1-3" /></td></tr></table></td></tr></xsl:for-each></table></td></tr></xsl:for-each></table></td></tr></xsl:for-each></table></xsl:template>',
             xsd_namespace=stats_httpd.XSD_NAMESPACE)
         xsl_body2 = self.stats_httpd.xsl_handler()
         self.assertEqual(type(xsl_body1), str)
diff --git a/src/bin/stats/tests/b10-stats_test.py b/src/bin/stats/tests/b10-stats_test.py
index b9b491d..3c8599a 100644
--- a/src/bin/stats/tests/b10-stats_test.py
+++ b/src/bin/stats/tests/b10-stats_test.py
@@ -226,7 +226,7 @@ class TestStats(unittest.TestCase):
                 'show', 'Stats',
                 params={ 'owner' : 'Boss',
                   'name'  : 'boot_time' }),
-            (0, self.const_datetime))
+            (0, {'Boss': {'boot_time': self.const_datetime}}))
         self.assertEqual(
             send_command(
                 'set', 'Stats',
@@ -238,7 +238,7 @@ class TestStats(unittest.TestCase):
                 'show', 'Stats',
                 params={ 'owner' : 'Boss',
                   'name'  : 'boot_time' }),
-            (0, self.const_datetime))
+            (0, {'Boss': {'boot_time': self.const_datetime}}))
         self.assertEqual(
             send_command('status', 'Stats'),
             (0, "Stats is up. (PID " + str(os.getpid()) + ")"))
@@ -321,25 +321,25 @@ class TestStats(unittest.TestCase):
         my_statistics_data = self.stats.get_statistics_data()
         self.assertTrue('Stats' in my_statistics_data)
         self.assertTrue('Boss' in my_statistics_data)
+        self.assertTrue('boot_time' in my_statistics_data['Boss'])
         my_statistics_data = self.stats.get_statistics_data(owner='Stats')
-        self.assertTrue('report_time' in my_statistics_data)
-        self.assertTrue('boot_time' in my_statistics_data)
-        self.assertTrue('last_update_time' in my_statistics_data)
-        self.assertTrue('timestamp' in my_statistics_data)
-        self.assertTrue('lname' in my_statistics_data)
+        self.assertTrue('Stats' in my_statistics_data)
+        self.assertTrue('report_time' in my_statistics_data['Stats'])
+        self.assertTrue('boot_time' in my_statistics_data['Stats'])
+        self.assertTrue('last_update_time' in my_statistics_data['Stats'])
+        self.assertTrue('timestamp' in my_statistics_data['Stats'])
+        self.assertTrue('lname' in my_statistics_data['Stats'])
         self.assertRaises(stats.StatsError, self.stats.get_statistics_data, owner='Foo')
-        my_statistics_data = self.stats.get_statistics_data(owner='Stats')
-        self.assertTrue('boot_time' in my_statistics_data)
         my_statistics_data = self.stats.get_statistics_data(owner='Stats', name='report_time')
-        self.assertEqual(my_statistics_data, self.const_default_datetime)
+        self.assertEqual(my_statistics_data['Stats']['report_time'], self.const_default_datetime)
         my_statistics_data = self.stats.get_statistics_data(owner='Stats', name='boot_time')
-        self.assertEqual(my_statistics_data, self.const_default_datetime)
+        self.assertEqual(my_statistics_data['Stats']['boot_time'], self.const_default_datetime)
         my_statistics_data = self.stats.get_statistics_data(owner='Stats', name='last_update_time')
-        self.assertEqual(my_statistics_data, self.const_default_datetime)
+        self.assertEqual(my_statistics_data['Stats']['last_update_time'], self.const_default_datetime)
         my_statistics_data = self.stats.get_statistics_data(owner='Stats', name='timestamp')
-        self.assertEqual(my_statistics_data, 0.0)
+        self.assertEqual(my_statistics_data['Stats']['timestamp'], 0.0)
         my_statistics_data = self.stats.get_statistics_data(owner='Stats', name='lname')
-        self.assertEqual(my_statistics_data, '')
+        self.assertEqual(my_statistics_data, {'Stats': {'lname':''}})
         self.assertRaises(stats.StatsError, self.stats.get_statistics_data,
                           owner='Stats', name='Bar')
         self.assertRaises(stats.StatsError, self.stats.get_statistics_data,
@@ -385,25 +385,25 @@ class TestStats(unittest.TestCase):
                 1, "specified arguments are incorrect: owner: Foo, name: bar"))
         self.assertEqual(self.stats.command_show(owner='Auth'),
                          isc.config.create_answer(
-                0, { 'queries.udp': 0,
+                0, {'Auth':{ 'queries.udp': 0,
                      'queries.tcp': 0,
                      'queries.perzone': [{ 'zonename': 'test1.example',
                                            'queries.udp': 1,
                                            'queries.tcp': 2 },
                                          { 'zonename': 'test2.example',
                                            'queries.udp': 3,
-                                           'queries.tcp': 4 }] }))
+                                           'queries.tcp': 4 }] }}))
         self.assertEqual(self.stats.command_show(owner='Auth', name='queries.udp'),
                          isc.config.create_answer(
-                0, 0))
+                0, {'Auth': {'queries.udp':0}}))
         self.assertEqual(self.stats.command_show(owner='Auth', name='queries.perzone'),
                          isc.config.create_answer(
-                0, [{ 'zonename': 'test1.example',
+                0, {'Auth': {'queries.perzone': [{ 'zonename': 'test1.example',
                       'queries.udp': 1,
                       'queries.tcp': 2 },
                     { 'zonename': 'test2.example',
                       'queries.udp': 3,
-                      'queries.tcp': 4 }]))
+                      'queries.tcp': 4 }]}}))
         orig_get_timestamp = stats.get_timestamp
         orig_get_datetime = stats.get_datetime
         stats.get_timestamp = lambda : self.const_timestamp
@@ -411,7 +411,7 @@ class TestStats(unittest.TestCase):
         self.assertEqual(stats.get_timestamp(), self.const_timestamp)
         self.assertEqual(stats.get_datetime(), self.const_datetime)
         self.assertEqual(self.stats.command_show(owner='Stats', name='report_time'), \
-                             isc.config.create_answer(0, self.const_datetime))
+                             isc.config.create_answer(0, {'Stats': {'report_time':self.const_datetime}}))
         self.assertEqual(self.stats.statistics_data['Stats']['timestamp'], self.const_timestamp)
         self.assertEqual(self.stats.statistics_data['Stats']['boot_time'], self.const_default_datetime)
         stats.get_timestamp = orig_get_timestamp
@@ -473,10 +473,10 @@ class TestStats(unittest.TestCase):
         (rcode, value) = isc.config.ccsession.parse_answer(
             self.stats.command_showschema(owner='Stats'))
         self.assertEqual(rcode, 0)
-        self.assertFalse('Stats' in value)
+        self.assertTrue('Stats' in value)
         self.assertFalse('Boss' in value)
         self.assertFalse('Auth' in value)
-        for item in value:
+        for item in value['Stats']:
             self.assertTrue(len(item) == 6 or len(item) == 7)
             self.assertTrue('item_name' in item)
             self.assertTrue('item_type' in item)
@@ -490,19 +490,19 @@ class TestStats(unittest.TestCase):
         (rcode, value) = isc.config.ccsession.parse_answer(
             self.stats.command_showschema(owner='Stats', name='report_time'))
         self.assertEqual(rcode, 0)
-        self.assertFalse('Stats' in value)
+        self.assertTrue('Stats' in value)
         self.assertFalse('Boss' in value)
         self.assertFalse('Auth' in value)
-        self.assertTrue(len(value) == 7)
-        self.assertTrue('item_name' in value)
-        self.assertTrue('item_type' in value)
-        self.assertTrue('item_optional' in value)
-        self.assertTrue('item_default' in value)
-        self.assertTrue('item_title' in value)
-        self.assertTrue('item_description' in value)
-        self.assertTrue('item_format' in value)
-        self.assertEqual(value['item_name'], 'report_time')
-        self.assertEqual(value['item_format'], 'date-time')
+        self.assertEqual(len(value['Stats'][0]), 7)
+        self.assertTrue('item_name' in value['Stats'][0])
+        self.assertTrue('item_type' in value['Stats'][0])
+        self.assertTrue('item_optional' in value['Stats'][0])
+        self.assertTrue('item_default' in value['Stats'][0])
+        self.assertTrue('item_title' in value['Stats'][0])
+        self.assertTrue('item_description' in value['Stats'][0])
+        self.assertTrue('item_format' in value['Stats'][0])
+        self.assertEqual(value['Stats'][0]['item_name'], 'report_time')
+        self.assertEqual(value['Stats'][0]['item_format'], 'date-time')
 
         self.assertEqual(self.stats.command_showschema(owner='Foo'),
                          isc.config.create_answer(
@@ -512,7 +512,7 @@ class TestStats(unittest.TestCase):
                 1, "specified arguments are incorrect: owner: Foo, name: bar"))
         self.assertEqual(self.stats.command_showschema(owner='Auth'),
                          isc.config.create_answer(
-                0, [{
+                0, {'Auth': [{
                         "item_default": 0,
                         "item_description": "A number of total query counts which all auth servers receive over TCP since they started initially",
                         "item_name": "queries.tcp",
@@ -578,20 +578,20 @@ class TestStats(unittest.TestCase):
                                     }
                                 ]
                             }
-                        }]))
+                        }]}))
         self.assertEqual(self.stats.command_showschema(owner='Auth', name='queries.tcp'),
                          isc.config.create_answer(
-                0, {
+                0, {'Auth': [{
                     "item_default": 0,
                     "item_description": "A number of total query counts which all auth servers receive over TCP since they started initially",
                     "item_name": "queries.tcp",
                     "item_optional": False,
                     "item_title": "Queries TCP",
                     "item_type": "integer"
-                    }))
+                    }]}))
         self.assertEqual(self.stats.command_showschema(owner='Auth', name='queries.perzone'),
                          isc.config.create_answer(
-                0, {
+                0, {'Auth':[{
                     "item_name": "queries.perzone",
                     "item_type": "list",
                     "item_optional": False,
@@ -641,7 +641,7 @@ class TestStats(unittest.TestCase):
                                 }
                             ]
                         }
-                    }))
+                    }]}))
 
         self.assertEqual(self.stats.command_showschema(owner='Stats', name='bar'),
                          isc.config.create_answer(




More information about the bind10-changes mailing list