BIND 10 trac547, updated. 994ee58d6044415ed6e5e463ff601435e8127ccc [trac547] - add xml implementations (XML, XSD, XSL) - add constructing XML contents with HTTP response - add an individual exception - add implementation of reloading configure from CfgMgr without restarting process - refactor handling exceptions - add some minor changes
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Mar 1 13:28:22 UTC 2011
The branch, trac547 has been updated
via 994ee58d6044415ed6e5e463ff601435e8127ccc (commit)
via 43b2ee12c5de3e068175b0037b9f5f6d0e5e4c83 (commit)
via b440e3b14e7cd69b267c1e8f2893e10053bff4ac (commit)
via c26f3301c835e3c9a36540b410cd1aaa6eed8c64 (commit)
via d347d803776bfa808bebed78c566e8c405c698e7 (commit)
via fa79fdd0ef6c31a33b8544fb276205950dffaaf1 (commit)
via 6578275444403aac0939fd2643a7e6452bf769a6 (commit)
via c0569d7680907651494bf44f19b23ba9d748674a (commit)
via f414a80c2855613001cf2223e9874ebb2375d8fe (commit)
from e6fdd3e3e8b3d0a87987a2d7fbfa00ef4eeafbf3 (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 994ee58d6044415ed6e5e463ff601435e8127ccc
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 1 22:27:50 2011 +0900
[trac547]
- add xml implementations (XML, XSD, XSL)
- add constructing XML contents with HTTP response
- add an individual exception
- add implementation of reloading configure from CfgMgr without restarting process
- refactor handling exceptions
- add some minor changes
commit 43b2ee12c5de3e068175b0037b9f5f6d0e5e4c83
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 1 22:23:53 2011 +0900
[trac547] add new member variables (AF_INET, has_ipv6) and a new exception (gaierror) for testing
commit b440e3b14e7cd69b267c1e8f2893e10053bff4ac
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 1 22:22:44 2011 +0900
[trac547] add assertions
commit c26f3301c835e3c9a36540b410cd1aaa6eed8c64
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 1 22:22:22 2011 +0900
[trac547] add a new dummy function to clear queues for testing
commit d347d803776bfa808bebed78c566e8c405c698e7
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 1 22:21:33 2011 +0900
[trac547] add a new member variable as dummy
commit fa79fdd0ef6c31a33b8544fb276205950dffaaf1
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 1 22:21:02 2011 +0900
[trac547] add more tests and refactor
commit 6578275444403aac0939fd2643a7e6452bf769a6
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 1 22:20:08 2011 +0900
[trac547] fix typo
commit c0569d7680907651494bf44f19b23ba9d748674a
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Tue Mar 1 22:19:35 2011 +0900
[trac547] replace messages with variable in templates
commit f414a80c2855613001cf2223e9874ebb2375d8fe
Author: Naoki Kambe <kambe at jprs.co.jp>
Date: Sun Feb 27 00:42:01 2011 +0900
[trac547]
- move the xml files under build dir
- change suffixes of the xml files (do git-mv) and add their into configure.ac
- fix wrong paths: change relative to absolute
-----------------------------------------------------------------------
Summary of changes:
configure.ac | 3 +
src/bin/stats/Makefile.am | 20 +-
...ts-httpd-xml.tpl => stats-httpd-xml.tpl.pre.in} | 11 +-
src/bin/stats/stats-httpd-xsd.tpl | 116 -------
...ts-httpd-xml.tpl => stats-httpd-xsd.tpl.pre.in} | 37 ++-
src/bin/stats/stats-httpd-xsl.tpl | 114 -------
src/bin/stats/stats-httpd-xsl.tpl.pre.in | 53 +++
src/bin/stats/stats.py.in | 2 +-
src/bin/stats/stats.spec.pre.in | 2 +-
src/bin/stats/stats_httpd.py.in | 349 ++++++++++++++------
src/bin/stats/stats_httpd.spec.pre.in | 8 +-
src/bin/stats/tests/b10-stats-httpd_test.py | 64 ++--
src/bin/stats/tests/http/server.py | 1 +
src/bin/stats/tests/isc/cc/session.py | 5 +
src/bin/stats/tests/isc/config/ccsession.py | 2 +
src/bin/stats/tests/socket.py | 6 +
src/bin/stats/tests/testdata/Makefile.am | 23 +-
17 files changed, 411 insertions(+), 405 deletions(-)
copy src/bin/stats/{stats-httpd-xml.tpl => stats-httpd-xml.tpl.pre.in} (69%)
delete mode 100644 src/bin/stats/stats-httpd-xsd.tpl
rename src/bin/stats/{stats-httpd-xml.tpl => stats-httpd-xsd.tpl.pre.in} (50%)
delete mode 100644 src/bin/stats/stats-httpd-xsl.tpl
create mode 100644 src/bin/stats/stats-httpd-xsl.tpl.pre.in
-----------------------------------------------------------------------
diff --git a/configure.ac b/configure.ac
index a536155..2bb47c2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -740,6 +740,9 @@ AC_OUTPUT([doc/version.ent
src/bin/stats/stats_httpd.py
src/bin/stats/stats.spec.pre
src/bin/stats/stats_httpd.spec.pre
+ src/bin/stats/stats-httpd-xml.tpl.pre
+ src/bin/stats/stats-httpd-xsd.tpl.pre
+ src/bin/stats/stats-httpd-xsl.tpl.pre
src/bin/stats/run_b10-stats.sh
src/bin/stats/run_b10-stats-httpd.sh
src/bin/stats/tests/stats_test
diff --git a/src/bin/stats/Makefile.am b/src/bin/stats/Makefile.am
index d0451b2..8868b88 100644
--- a/src/bin/stats/Makefile.am
+++ b/src/bin/stats/Makefile.am
@@ -6,9 +6,11 @@ pkglibexec_SCRIPTS = b10-stats b10-stats-httpd
b10_statsdir = $(DESTDIR)$(pkgdatadir)
b10_stats_DATA = stats.spec stats_httpd.spec
+b10_stats_DATA += stats-httpd-xml.tpl stats-httpd-xsd.tpl stats-httpd-xsl.tpl
CLEANFILES = b10-stats stats.pyc stats.spec
CLEANFILES += b10-stats-httpd stats_httpd.pyc stats_httpd.spec
+CLEANFILES += stats-httpd-xml.tpl stats-httpd-xsd.tpl stats-httpd-xsl.tpl
man_MANS = b10-stats.8 b10-stats-httpd.8
EXTRA_DIST = $(man_MANS) b10-stats.xml b10-stats-httpd.xml
@@ -24,10 +26,24 @@ b10-stats-httpd.8: b10-stats-httpd.xml
endif
stats.spec: stats.spec.pre
- $(SED) -e "s|@@LOCALSTATEDIR@@|$(localstatedir)|" stats.spec.pre >$@
+ $(SED) -e "s|@@DATAROOTDIR@@|@datarootdir@|" \
+ -e "s|@@PACKAGEDIR@@|@PACKAGE@|" stats.spec.pre >$@
stats_httpd.spec: stats_httpd.spec.pre
- $(SED) -e "s|@@DATAROOTDIR@@|@datarootdir@|" stats_httpd.spec.pre >$@
+ $(SED) -e "s|@@DATAROOTDIR@@|@datarootdir@|" \
+ -e "s|@@PACKAGEDIR@@|@PACKAGE@|" stats_httpd.spec.pre >$@
+
+stats-httpd-xml.tpl: stats-httpd-xml.tpl.pre
+ $(SED) -e "s|@@DATAROOTDIR@@|@datarootdir@|" \
+ -e "s|@@PACKAGEDIR@@|@PACKAGE@|" stats-httpd-xml.tpl.pre >$@
+
+stats-httpd-xsd.tpl: stats-httpd-xsd.tpl.pre
+ $(SED) -e "s|@@DATAROOTDIR@@|@datarootdir@|" \
+ -e "s|@@PACKAGEDIR@@|@PACKAGE@|" stats-httpd-xsd.tpl.pre >$@
+
+stats-httpd-xsl.tpl: stats-httpd-xsl.tpl.pre
+ $(SED) -e "s|@@DATAROOTDIR@@|@datarootdir@|" \
+ -e "s|@@PACKAGEDIR@@|@PACKAGE@|" stats-httpd-xsl.tpl.pre >$@
# TODO: does this need $$(DESTDIR) also?
# this is done here since configure.ac AC_OUTPUT doesn't expand exec_prefix
diff --git a/src/bin/stats/stats-httpd-xml.tpl b/src/bin/stats/stats-httpd-xml.tpl
deleted file mode 100644
index 0826812..0000000
--- a/src/bin/stats/stats-httpd-xml.tpl
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet type="text/xsl" href="bind10-statistics.xsl"?>
-<!--
- - Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
- -
- - Permission to use, copy, modify, and/or distribute this software for any
- - purpose with or without fee is hereby granted, provided that the above
- - copyright notice and this permission notice appear in all copies.
- -
- - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- - PERFORMANCE OF THIS SOFTWARE.
--->
-
-<stats:stats_data version="1.0"
- xmlns:stats="http://bind10.isc.org/xsd/bind10-statistics"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://bind10.isc.org/xsd/bind10-statistics bind10-statistics.xsd">
- <report_time>2011-01-25T11:47:56Z</report_time>
- <bind10.boot_time>2011-01-25T11:47:45Z</bind10.boot_time>
- <stats.boot_time>2011-01-25T11:47:45Z</stats.boot_time>
- <stats.start_time>2011-01-25T11:47:47Z</stats.start_time>
- <stats.last_update_time>2011-01-25T11:47:56Z</stats.last_update_time>
- <stats.timestamp>1295956076.705266</stats.timestamp>
- <stats.lname>4d3eb863_d at covm</stats.lname>
- <auth.queries.tcp>123</auth.queries.tcp>
- <auth.queries.ucp>456</auth.queries.ucp>
-</stats:stats_data>
-$xml_contents
\ No newline at end of file
diff --git a/src/bin/stats/stats-httpd-xml.tpl.pre.in b/src/bin/stats/stats-httpd-xml.tpl.pre.in
new file mode 100644
index 0000000..7f2cb68
--- /dev/null
+++ b/src/bin/stats/stats-httpd-xml.tpl.pre.in
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?xml-stylesheet type="text/xsl" href="bind10-statistics.xsl"?>
+<!--
+ - Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
+ -
+ - Permission to use, copy, modify, and/or distribute this software for any
+ - purpose with or without fee is hereby granted, provided that the above
+ - copyright notice and this permission notice appear in all copies.
+ -
+ - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ - PERFORMANCE OF THIS SOFTWARE.
+-->
+
+<stats:stats_data version="1.0"
+ xmlns:stats="http://bind10.isc.org/xsd/bind10-statistics"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://bind10.isc.org/xsd/bind10-statistics bind10-statistics.xsd">
+ $xml_string
+</stats:stats_data>
diff --git a/src/bin/stats/stats-httpd-xsd.tpl b/src/bin/stats/stats-httpd-xsd.tpl
deleted file mode 100644
index baaaa5f..0000000
--- a/src/bin/stats/stats-httpd-xsd.tpl
+++ /dev/null
@@ -1,116 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- - Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
- -
- - Permission to use, copy, modify, and/or distribute this software for any
- - purpose with or without fee is hereby granted, provided that the above
- - copyright notice and this permission notice appear in all copies.
- -
- - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- - PERFORMANCE OF THIS SOFTWARE.
--->
-
-<schema targetNamespace="http://bind10.isc.org/xsd/bind10-statistics"
- xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:stats="http://bind10.isc.org/xsd/bind10-statistics">
- <annotation>
- <documentation xml:lang="en">XML schema of the statistics
- data in BIND 10</documentation>
- </annotation>
- <element name="stats_data">
- <annotation>
- <documentation>A set of statistics data</documentation>
- </annotation>
- <complexType>
- <all>
- <element name="report_time" type="dateTime" minOccurs="1"
- maxOccurs="1">
- <annotation>
- <appinfo>Report time</appinfo>
- <documentation>A date time when stats module reports
- </documentation>
- </annotation>
- </element>
- <element name="bind10.boot_time" type="dateTime"
- minOccurs="1" maxOccurs="1">
- <annotation>
- <appinfo>stats.BootTime</appinfo>
- <documentation>A date time when bind10 process starts
- initially</documentation>
- </annotation>
- </element>
- <element name="stats.boot_time" type="dateTime"
- minOccurs="1" maxOccurs="1">
- <annotation>
- <appinfo>stats.BootTime</appinfo>
- <documentation>A date time when the stats module starts
- initially or when the stats module restarts
- </documentation>
- </annotation>
- </element>
- <element name="stats.start_time" type="dateTime"
- minOccurs="1" maxOccurs="1">
- <annotation>
- <appinfo>stats.StartTime</appinfo>
- <documentation>A date time when the stats module starts
- collecting data or resetting values last time
- </documentation>
- </annotation>
- </element>
- <element name="stats.last_update_time" type="dateTime"
- minOccurs="1" maxOccurs="1">
- <annotation>
- <appinfo>stats.LastUpdateTime</appinfo>
- <documentation>The latest date time when the stats module
- receives from other modules like auth server or boss
- process and so on</documentation>
- </annotation>
- </element>
- <element name="stats.timestamp" type="float" minOccurs="1"
- maxOccurs="1">
- <annotation>
- <appinfo>stats.Timestamp</appinfo>
- <documentation>A current time stamp since epoch time
- (1970-01-01T00:00:00Z)</documentation>
- </annotation>
- </element>
- <element name="stats.lname" type="string" minOccurs="1" maxOccurs="1">
- <annotation>
- <appinfo>stats.LocalName</appinfo>
- <documentation>A localname of stats module given via CC
- protocol</documentation>
- </annotation>
- </element>
- <element name="auth.queries.tcp" type="integer"
- minOccurs="1" maxOccurs="1">
- <annotation>
- <appinfo>auth.queries.tcp</appinfo>
- <documentation>A number of total query counts which all auth
- servers receive over TCP since they started initially
- </documentation>
- </annotation>
- </element>
- <element name="auth.queries.ucp" type="integer"
- minOccurs="1" maxOccurs="1">
- <annotation>
- <appinfo>auth.queries.udp</appinfo>
- <documentation>A number of total query counts which all auth
- servers receive over UDP since they started initially
- </documentation>
- </annotation>
- </element>
- </all>
- <attribute name="version" type="token" use="optional" default="1.0">
- <annotation>
- <documentation>Version number of syntax</documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-</schema>
-$xsd_contents
\ No newline at end of file
diff --git a/src/bin/stats/stats-httpd-xsd.tpl.pre.in b/src/bin/stats/stats-httpd-xsd.tpl.pre.in
new file mode 100644
index 0000000..469140f
--- /dev/null
+++ b/src/bin/stats/stats-httpd-xsd.tpl.pre.in
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ - Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
+ -
+ - Permission to use, copy, modify, and/or distribute this software for any
+ - purpose with or without fee is hereby granted, provided that the above
+ - copyright notice and this permission notice appear in all copies.
+ -
+ - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ - PERFORMANCE OF THIS SOFTWARE.
+-->
+
+<schema targetNamespace="http://bind10.isc.org/xsd/bind10-statistics"
+ xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:stats="http://bind10.isc.org/xsd/bind10-statistics">
+ <annotation>
+ <documentation xml:lang="en">XML schema of the statistics
+ data in BIND 10</documentation>
+ </annotation>
+ <element name="stats_data">
+ <annotation>
+ <documentation>A set of statistics data</documentation>
+ </annotation>
+ <complexType>
+ $xsd_string
+ <attribute name="version" type="token" use="optional" default="1.0">
+ <annotation>
+ <documentation>Version number of syntax</documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+</schema>
diff --git a/src/bin/stats/stats-httpd-xsl.tpl b/src/bin/stats/stats-httpd-xsl.tpl
deleted file mode 100644
index 54e01ae..0000000
--- a/src/bin/stats/stats-httpd-xsl.tpl
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- - Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
- -
- - Permission to use, copy, modify, and/or distribute this software for any
- - purpose with or without fee is hereby granted, provided that the above
- - copyright notice and this permission notice appear in all copies.
- -
- - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
- - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
- - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- - PERFORMANCE OF THIS SOFTWARE.
--->
-
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"
- xmlns:stats="http://bind10.isc.org/xsd/bind10-statistics">
- <xsl:output method="html" encoding="UTF-8"
- doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
- doctype-system=" http://www.w3.org/TR/html4/loose.dtd " />
- <xsl:template match="/">
- <html lang="en">
- <head>
- <title>BIND 10 Statistics</title>
- <style type="text/css"><![CDATA[
-table {
- border: 1px #000000 solid;
- border-collapse: collapse;
-}
-td, th {
- padding: 3px 20px;
- border: 1px #000000 solid;
-}
-]]>
- </style>
- </head>
- <body>
- <h1>BIND 10 Statistics</h1>
- <table>
- <tr>
- <th>Title</th>
- <th>Value</th>
- </tr>
- <xsl:apply-templates />
- </table>
- </body>
- </html>
- </xsl:template>
- <xsl:template match="*">
- <tr>
- <td title="A date time when stats module reports">Report time</td>
- <td>
- <xsl:value-of select="report_time" />
- </td>
- </tr>
- <tr>
- <td title="A date time when bind10 process starts initially">stats.BootTime</td>
- <td>
- <xsl:value-of select="bind10.boot_time" />
- </td>
- </tr>
- <tr>
- <td
- title="A date time when the stats module starts initially or when the stats module restarts">stats.BootTime</td>
- <td>
- <xsl:value-of select="stats.boot_time" />
- </td>
- </tr>
- <tr>
- <td
- title="A date time when the stats module starts collecting data or resetting values last time">stats.StartTime</td>
- <td>
- <xsl:value-of select="stats.start_time" />
- </td>
- </tr>
- <tr>
- <td
- title="The latest date time when the stats module receives from other modules like auth server or boss process and so on">stats.LastUpdateTime</td>
- <td>
- <xsl:value-of select="stats.last_update_time" />
- </td>
- </tr>
- <tr>
- <td title="A current time stamp since epoch time (1970-01-01T00:00:00Z)">stats.Timestamp</td>
- <td>
- <xsl:value-of select="stats.timestamp" />
- </td>
- </tr>
- <tr>
- <td title="A localname of stats module given via CC protocol">stats.LocalName</td>
- <td>
- <xsl:value-of select="stats.lname" />
- </td>
- </tr>
- <tr>
- <td
- title="A number of total query counts which all auth servers receive over TCP since they started initially">auth.queries.tcp</td>
- <td>
- <xsl:value-of select="auth.queries.tcp" />
- </td>
- </tr>
- <tr>
- <td
- title="A number of total query counts which all auth servers receive over UDP since they started initially">auth.queries.udp</td>
- <td>
- <xsl:value-of select="auth.queries.ucp" />
- </td>
- </tr>
- </xsl:template>
-</xsl:stylesheet>
-$xsl_contents
\ No newline at end of file
diff --git a/src/bin/stats/stats-httpd-xsl.tpl.pre.in b/src/bin/stats/stats-httpd-xsl.tpl.pre.in
new file mode 100644
index 0000000..9354c78
--- /dev/null
+++ b/src/bin/stats/stats-httpd-xsl.tpl.pre.in
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ - Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
+ -
+ - Permission to use, copy, modify, and/or distribute this software for any
+ - purpose with or without fee is hereby granted, provided that the above
+ - copyright notice and this permission notice appear in all copies.
+ -
+ - THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ - AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ - PERFORMANCE OF THIS SOFTWARE.
+-->
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:stats="http://bind10.isc.org/xsd/bind10-statistics">
+ <xsl:output method="html" encoding="UTF-8"
+ doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
+ doctype-system=" http://www.w3.org/TR/html4/loose.dtd " />
+ <xsl:template match="/">
+ <html lang="en">
+ <head>
+ <title>BIND 10 Statistics</title>
+ <style type="text/css"><![CDATA[
+table {
+ border: 1px #000000 solid;
+ border-collapse: collapse;
+}
+td, th {
+ padding: 3px 20px;
+ border: 1px #000000 solid;
+}
+]]>
+ </style>
+ </head>
+ <body>
+ <h1>BIND 10 Statistics</h1>
+ <table>
+ <tr>
+ <th>Title</th>
+ <th>Value</th>
+ </tr>
+ <xsl:apply-templates />
+ </table>
+ </body>
+ </html>
+ </xsl:template>
+ $xsl_string
+</xsl:stylesheet>
diff --git a/src/bin/stats/stats.py.in b/src/bin/stats/stats.py.in
index 5362796..dbfde35 100755
--- a/src/bin/stats/stats.py.in
+++ b/src/bin/stats/stats.py.in
@@ -39,7 +39,7 @@ isc.util.process.rename()
# from a directory relative to that, otherwise we use the ones
# installed on the system
if "B10_FROM_BUILD" in os.environ:
- SPECFILE_LOCATION = os.environ["B10_FROM_BUILD"] + "/stats.spec"
+ SPECFILE_LOCATION = os.environ["B10_FROM_BUILD"] + os.sep + "stats.spec"
else:
PREFIX = "@prefix@"
DATAROOTDIR = "@datarootdir@"
diff --git a/src/bin/stats/stats.spec.pre.in b/src/bin/stats/stats.spec.pre.in
index 6970250..4d42ebf 100644
--- a/src/bin/stats/stats.spec.pre.in
+++ b/src/bin/stats/stats.spec.pre.in
@@ -17,7 +17,7 @@
"item_type": "string",
"item_optional": false,
"item_default": "1970-01-01T00:00:00Z",
- "item_title": "stats.BootTime",
+ "item_title": "bind10.BootTime",
"item_description": "A date time when bind10 process starts initially",
"item_format": "date-time"
},
diff --git a/src/bin/stats/stats_httpd.py.in b/src/bin/stats/stats_httpd.py.in
index 12ebfe4..d12c775 100644
--- a/src/bin/stats/stats_httpd.py.in
+++ b/src/bin/stats/stats_httpd.py.in
@@ -22,7 +22,9 @@ import errno
import select
from optparse import OptionParser, OptionValueError
import http.server
+import socket
import string
+import xml.etree.ElementTree
import isc.cc
import isc.config
@@ -32,7 +34,7 @@ import isc.util.process
# from a directory relative to that, otherwise we use the ones
# installed on the system
if "B10_FROM_BUILD" in os.environ:
- SPECFILE_LOCATION = os.environ["B10_FROM_BUILD"] + "/stats_httpd.spec"
+ SPECFILE_LOCATION = os.environ["B10_FROM_BUILD"] + os.sep + "stats_httpd.spec"
else:
PREFIX = "@prefix@"
DATAROOTDIR = "@datarootdir@"
@@ -48,42 +50,46 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
HTTP handler class
"""
def do_GET(self):
- self.wfile.write(self.send_head().encode())
+ body = self.send_head()
+ if type(body) is str:
+ self.wfile.write(body.encode())
def do_HEAD(self):
self.send_head()
def send_head(self):
contents = ''
- if self.path == '/':
- contents = self.server.stats_httpd.get_stats_xml()
- elif self.path == '/bind10-statistics.xsd':
- contents = self.server.stats_httpd.get_stats_xsd()
- elif self.path == '/bind10-statistics.xsl':
- contents = self.server.stats_httpd.get_stats_xsl()
+ try:
+ if self.path == '/':
+ contents = self.server.stats_httpd.get_stats_xml()
+ elif self.path == '/bind10-statistics.xsd':
+ contents = self.server.stats_httpd.get_stats_xsd()
+ elif self.path == '/bind10-statistics.xsl':
+ contents = self.server.stats_httpd.get_stats_xsl()
+ else:
+ self.send_error(404)
+ return None
+ except StatsHttpdError as err:
+ self.send_error(500)
+ raise StatsHttpdError(err)
else:
- contents = str(self.server.stats_httpd.get_stats_spec())
- contents = contents + str(self.server.stats_httpd.get_stats_data())
-
- if contents is None:
- self.send_error(500, 'Internal Server Error')
- return ""
-
- self.send_response(200)
- self.send_header("Content-type", "text/plain")
- self.send_header("Content-Length", len(contents))
- self.end_headers()
- return contents
+ self.send_response(200)
+ self.send_header("Content-type", "text/xml")
+ self.send_header("Content-Length", len(contents))
+ self.end_headers()
+ assert contents is not None and contents != ''
+ return contents
def log_message(self, format, *args):
"""
Change default log format
"""
if self.server.verbose:
- sys.stderr.write("[b10-stats-httpd] %s - - [%s] %s\n" %
- (self.address_string(),
- self.log_date_time_string(),
- format%args))
+ self.server.stats_httpd.write_log(
+ "[b10-stats-httpd] %s - - [%s] %s\n" %
+ (self.address_string(),
+ self.log_date_time_string(),
+ format%args))
class HttpServer(http.server.HTTPServer):
"""
@@ -97,69 +103,120 @@ class HttpServer(http.server.HTTPServer):
(self.stats_httpd.http_addr, self.stats_httpd.http_port),
handler)
+class StatsHttpdError(Exception):
+ pass
+
class StatsHttpd:
"""
"""
def __init__(self, verbose=False):
self.verbose = verbose
- self.running = False
- # create ccsession
- self.load_config()
- self.open_httpd()
+ self.running = True
+ self.exit_code = 0
self.poll_intval = 0.5
+ self.write_log = sys.stderr.write
+ self.ccs = None
+ try:
+ self.load_config()
+ self.open_httpd()
+ except StatsHttpdError as err:
+ self.write_log(
+ "[b10-stats-httpd] Unexpected error with initializing: %s" % err)
+ self.running = False
+ self.exit_code = 1
- def load_config(self):
- self.ccs = isc.config.ModuleCCSession(
- SPECFILE_LOCATION, self.config_handler, self.command_handler)
- self.ccs_fd = self.ccs.get_socket()
- self.cc_session = self.ccs._session
- self.http_addr = self.ccs.get_value('listen_on_address')[0]
- self.http_port = self.ccs.get_value('listen_on_port')[0]
- self.xml_template = self.read_template(self.ccs.get_value('xml_template')[0])
- self.xsd_template = self.read_template(self.ccs.get_value('xsd_template')[0])
- self.xsl_template = self.read_template(self.ccs.get_value('xsl_template')[0])
- self.stats_module_spec = isc.config.module_spec_from_file(
- self.ccs.get_value('stats_spec_file')[0])
+ def load_config(self, new_config=None):
+ # create ModuleCCSession
+ try:
+ if self.ccs is None:
+ # create ccsession
+ self.ccs = isc.config.ModuleCCSession(
+ SPECFILE_LOCATION, self.config_handler, self.command_handler)
+ self.ccs_fd = self.ccs.get_socket()
+ self.cc_session = self.ccs._session
+ except isc.config.ccsession.ModuleCCSessionError as err:
+ raise StatsHttpdError(err)
+ # load config
+ if new_config is not None:
+ assert type(new_config) is dict
+ assert self.config is not None
+ self.config.update(new_config)
+ else:
+ self.config={}
+ self.config.update(
+ dict([
+ (i['item_name'], self.ccs.get_value(i['item_name'])[0])
+ for i in self.ccs.get_module_spec().get_config_spec()
+ ]))
+ assert self.config is not None
+ assert len(self.config) > 0
+ assert type(self.config) is dict
+ self.stats_module_spec = isc.config.module_spec_from_file(self.config['stats_spec_file'])
self.stats_config_spec = self.stats_module_spec.get_config_spec()
self.stats_module_name = self.stats_module_spec.get_module_name()
+ self.http_addr = self.config['listen_on_address']
+ self.http_port = self.config['listen_on_port']
+ # load xml files
+ self.load_xml(self.config['xml_template'])
+ self.load_xsd(self.config['xsd_template'])
+ self.load_xsl(self.config['xsl_template'])
- def open_httpd(self):
- self.httpd = HttpServer(HttpHandler, self, self.verbose)
- self.http_fd = self.httpd.socket
+ def open_httpd(self, address_family=socket.AF_INET):
+ try:
+ # try IPv4 at first
+ HttpServer.address_family = address_family
+ self.httpd = HttpServer(HttpHandler, self, self.verbose)
+ except (socket.gaierror, socket.error) as err:
+ if type(err) is socket.gaierror and socket.has_ipv6 and HttpServer.address_family is socket.AF_INET:
+ # try IPv6 again
+ self.open_httpd(address_family=socket.AF_INET6)
+ else:
+ raise StatsHttpdError(
+ "Unexpected error: Invalid address %s: %s: %s\n" %
+ (self.http_addr, self.http_port, err))
+ else:
+ self.http_fd = self.httpd.socket
+ if self.verbose and self.running:
+ self.write_log(
+ "[b10-stats-httpd] Started on address %s, port %s\n" %
+ (self.http_addr, self.http_port))
def close_httpd(self):
- self.http_fd.close()
+ if self.http_fd is not None:
+ self.http_fd.close()
def start(self):
- if self.verbose:
- sys.stderr.write(
- "[b10-stats-httpd] Started on address "
- + str(self.http_addr)
- + ", port " + str(self.http_port) + "\n")
- self.running = True
- self.ccs.start()
- self.cc_session.group_subscribe(self.stats_module_name, "*")
- while self.running:
- try:
+ try:
+ self.ccs.start()
+ self.cc_session.group_subscribe(self.stats_module_name, "*")
+ while self.running:
(rfd, wfd, xfd) = select.select(
[self.ccs_fd, self.http_fd], [], [], self.poll_intval)
- except select.error as err:
- if err.args[0] == errno.EINTR:
- (rfd, wfd, xfd) = ([], [], [])
- else:
- sys.stderr.write(
- "[b10-stats-httpd] Unexpected error with select(); %s\n" % err)
- break
- for fd in rfd + xfd:
- if fd == self.ccs_fd:
- self.ccs.check_command(nonblock=False)
- elif fd == self.http_fd:
- self.httpd.handle_request()
- self.stop()
+ for fd in rfd + xfd:
+ if fd == self.ccs_fd:
+ self.ccs.check_command(nonblock=False)
+ elif fd == self.http_fd:
+ self.httpd.handle_request()
+ except (isc.cc.session.SessionError,
+ isc.config.ccsession.ModuleCCSessionError) as err:
+ self.write_log(
+ "[b10-stats-httpd] Unexpected error with CCSession; %s\n" % err)
+ self.running = False
+ self.exit_code = 1
+ except (select.error, StatsHttpdError) as err:
+ if type(err) is select.error and err.args[0] == errno.EINTR:
+ (rfd, wfd, xfd) = ([], [], [])
+ else:
+ self.write_log(
+ "[b10-stats-httpd] Unexpected error with selecting; %s\n" % err)
+ self.exit_code = 1
+ self.running = False
+ finally:
+ self.stop()
def stop(self):
if self.verbose:
- sys.stdout.write("[b10-stats-httpd] shutting down\n")
+ self.write_log("[b10-stats-httpd] Shutting down\n")
self.running = False
self.cc_session.group_unsubscribe(self.stats_module_name, "*")
self.close_httpd()
@@ -172,7 +229,21 @@ class StatsHttpd:
"""
config handler
"""
- return isc.config.ccsession.create_answer(0)
+ if self.verbose:
+ self.write_log("[b10-stats-httpd] Reloading new config : %s\n" % str(new_config))
+ self.close_httpd()
+ try:
+ self.load_config(new_config)
+ self.open_httpd()
+ except StatsHttpdError as err:
+ self.write_log(
+ "[b10-stats-httpd] Unexpected error with reloading config: %s" % err)
+ self.running = False
+ self.exit_code = 1
+ return isc.config.ccsession.create_answer(
+ 1, "Unexpected error with reading config: %s" % err )
+ else:
+ return isc.config.ccsession.create_answer(0)
def command_handler(self, command, args):
"""
@@ -180,34 +251,45 @@ class StatsHttpd:
"""
if command == "status":
if self.verbose:
- sys.stdout.write("[b10-stats-httpd] Received 'status' command\n")
+ self.write_log("[b10-stats-httpd] Received 'status' command\n")
return isc.config.ccsession.create_answer(
0, "Stats Httpd is up. (PID " + str(os.getpid()) + ")")
elif command == "shutdown":
if self.verbose:
- sys.stdout.write("[b10-stats-httpd] Received 'shutdown' command\n")
+ self.write_log("[b10-stats-httpd] Received 'shutdown' command\n")
self.running = False
return isc.config.ccsession.create_answer(0)
else:
if self.verbose:
- sys.stdout.write("[b10-stats-httpd] Received unknown command\n")
+ self.write_log("[b10-stats-httpd] Received unknown command\n")
return isc.config.ccsession.create_answer(
1, "Unknown command: " + str(command))
def get_stats_data(self):
- seq = self.cc_session.group_sendmsg(
- isc.config.ccsession.create_command('show'),
- self.stats_module_name)
try:
+ seq = self.cc_session.group_sendmsg(
+ isc.config.ccsession.create_command('show'),
+ self.stats_module_name)
answer, env = self.cc_session.group_recvmsg(False, seq)
- except isc.cc.SessionTimeout:
- sys.stderr.write("[b10-stats] Error Session timed out\n")
- return
- if answer:
- (rcode, value) = isc.config.ccsession.parse_answer(answer)
- self.cc_session.group_reply(
- env, isc.config.ccsession.create_answer(0))
- return (rcode, value)
+ if answer:
+ (rcode, value) = isc.config.ccsession.parse_answer(answer)
+ self.cc_session.group_reply(
+ env, isc.config.ccsession.create_answer(0))
+ except isc.cc.SessionTimeout as err:
+ raise StatsHttpdError(
+ "Unexpected error with stats: SessionTimeout: %s" % err)
+ except isc.cc.session.SessionError as err:
+ raise StatsHttpdError(
+ "Unexpected error with stats: SessionError: %s" % err)
+ except isc.config.ccsession.ModuleCCSessionError as err:
+ raise StatsHttpdError(
+ "Unexpected error with stats: ModuleCCSessionError: %s" % err)
+ else:
+ if rcode != 0:
+ raise StatsHttpdError("Unexpected error: can't get data from stats")
+ finally:
+ assert value is not None
+ return value
def get_stats_spec(self):
"""
@@ -215,36 +297,88 @@ class StatsHttpd:
"""
return self.stats_config_spec
+ def load_xml(self, template):
+ self.xml_template = self.read_template(template)
+ self.xml_content = "" # set empty string here
+
+ def load_xsd(self, template):
+ self.xsd_template = self.read_template(template)
+ root = xml.etree.ElementTree.Element("all") # started with "all" tag
+ for item in self.get_stats_spec():
+ element = xml.etree.ElementTree.Element(
+ "element",
+ dict( name=item["item_name"],
+ type=item["item_type"] if item["item_type"].lower() != 'real' else 'float',
+ minOccurs="1",
+ maxOccurs="1" ),
+ )
+ annotation = xml.etree.ElementTree.Element("annotation")
+ appinfo = xml.etree.ElementTree.Element("appinfo")
+ documentation = xml.etree.ElementTree.Element("documentation")
+ appinfo.text = item["item_title"]
+ documentation.text = item["item_description"]
+ annotation.append(appinfo)
+ annotation.append(documentation)
+ element.append(annotation)
+ root.append(element)
+ xsd_string = xml.etree.ElementTree.tostring(root)
+ assert self.xsd_template is not None
+ self.xsd_content = self.xsd_template.substitute(
+ xsd_string=xsd_string)
+
+ def load_xsl(self, template):
+ self.xsl_template = self.read_template(template)
+ root = xml.etree.ElementTree.Element(
+ "xsl:template",
+ dict(match="*")) # started with xml:template tag
+ for item in self.get_stats_spec():
+ tr = xml.etree.ElementTree.Element("tr")
+ td1 = xml.etree.ElementTree.Element(
+ "td", dict(title=item["item_description"]))
+ td1.text = item["item_title"]
+ td2 = xml.etree.ElementTree.Element("td")
+ xsl_valueof = xml.etree.ElementTree.Element(
+ "xsl:value-of",
+ dict(select=item["item_name"]))
+ td2.append(xsl_valueof)
+ tr.append(td1)
+ tr.append(td2)
+ root.append(tr)
+ xsl_string = xml.etree.ElementTree.tostring(root)
+ assert self.xsl_template is not None
+ self.xsl_content = self.xsl_template.substitute(
+ xsl_string=xsl_string)
+
def get_stats_xml(self):
- xml_contents = ''
- if self.xml_template is None:
- return None
- return self.xml_template.substitute(
- xml_contents=xml_contents)
+ xml_list=[]
+ for (k, v) in self.get_stats_data().items():
+ (k, v) = (str(k), str(v))
+ assert type(k) is str and type(v) is str
+ x = xml.etree.ElementTree.Element(k)
+ x.text = v
+ xml_list.append(
+ xml.etree.ElementTree.tostring(x))
+ assert len(xml_list) > 0
+ xml_string = "".join(xml_list)
+ assert self.xml_template is not None
+ self.xml_content = self.xml_template.substitute(
+ xml_string=xml_string)
+ return self.xml_content
def get_stats_xsd(self):
- xsd_contents = ''
- if self.xsd_template is None:
- return None
- return self.xsd_template.substitute(
- xsd_contents=xsd_contents)
+ return self.xsd_content
def get_stats_xsl(self):
- xsl_contents = ''
- if self.xsl_template is None:
- return None
- return self.xsl_template.substitute(
- xsl_contents=xsl_contents)
+ return self.xsl_content
def read_template(self, file_name):
try:
contents = "".join(
open(file_name, 'r').readlines(MAX_SIZE_OF_TEMPLATE))
except IOError as err:
- sys.stderr.write(
- "[b10-stats-httpd] Unexpected Error with opening file; %s\n" % err)
- return None
- return string.Template(contents)
+ raise StatsHttpdError("Unexpected error with opening file; %s" % err)
+ else:
+ return string.Template(contents)
if __name__ == "__main__":
try:
@@ -255,11 +389,12 @@ if __name__ == "__main__":
(options, args) = parser.parse_args()
stats_httpd = StatsHttpd(verbose=options.verbose)
stats_httpd.start()
- except KeyboardInterrupt as kie:
- sys.stderr.write("[b10-stats-httpd] Interrupted, exiting\n")
- stats_httpd.close()
+ except OptionValueError:
+ sys.stderr.write("[b10-stats-httpd] Error parsing options\n")
except isc.cc.session.SessionError as se:
sys.stderr.write("[b10-stats-httpd] Error creating module, "
+ "is the command channel daemon running?\n")
- except OptionValueError:
- sys.stderr.write("[b10-stats-httpd] Error parsing options\n")
+ except KeyboardInterrupt as kie:
+ sys.stderr.write("[b10-stats-httpd] Interrupted, exiting\n")
+ finally:
+ sys.exit(stats_httpd.exit_code)
diff --git a/src/bin/stats/stats_httpd.spec.pre.in b/src/bin/stats/stats_httpd.spec.pre.in
index 25eb7c1..956ea95 100644
--- a/src/bin/stats/stats_httpd.spec.pre.in
+++ b/src/bin/stats/stats_httpd.spec.pre.in
@@ -7,7 +7,7 @@
"item_name": "stats_spec_file",
"item_type": "string",
"item_optional": false,
- "item_default": "@@DATAROOTDIR@@/@PACKAGE@/stats.spec",
+ "item_default": "@@DATAROOTDIR@@/@@PACKAGEDIR@@/stats.spec",
"item_description": "the location of stats.spec",
"item_format": "filename"
},
@@ -15,7 +15,7 @@
"item_name": "xml_template",
"item_type": "string",
"item_optional": false,
- "item_default": "@@DATAROOTDIR@@/@PACKAGE@/stats-httpd-xml.tpl",
+ "item_default": "@@DATAROOTDIR@@/@@PACKAGEDIR@@/stats-httpd-xml.tpl",
"item_description": "the location of xml template",
"item_format": "filename"
},
@@ -23,7 +23,7 @@
"item_name": "xsd_template",
"item_type": "string",
"item_optional": false,
- "item_default": "@@DATAROOTDIR@@/@PACKAGE@/stats-httpd-xsd.tpl",
+ "item_default": "@@DATAROOTDIR@@/@@PACKAGEDIR@@/stats-httpd-xsd.tpl",
"item_description": "the location of xsd template",
"item_format": "filename"
},
@@ -31,7 +31,7 @@
"item_name": "xsl_template",
"item_type": "string",
"item_optional": false,
- "item_default": "@@DATAROOTDIR@@/@PACKAGE@/stats-httpd-xsl.tpl",
+ "item_default": "@@DATAROOTDIR@@/@@PACKAGEDIR@@/stats-httpd-xsl.tpl",
"item_description": "the location of xsl template",
"item_format": "filename"
},
diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py
index 357e416..0854306 100644
--- a/src/bin/stats/tests/b10-stats-httpd_test.py
+++ b/src/bin/stats/tests/b10-stats-httpd_test.py
@@ -19,6 +19,7 @@ import http.server
import string
import select
import imp
+import sys
import isc.cc
@@ -27,11 +28,21 @@ import stats_httpd
class TestStatsHttpd(unittest.TestCase):
def setUp(self):
+ self.sample_stats_data = {
+ "auth.queries.tcp": 0,
+ "auth.queries.udp": 0,
+ "bind10.boot_time": "1970-01-01T00:00:00Z",
+ "report_time": "2011-02-24T09:08:32Z",
+ "stats.boot_time": "2011-02-24T09:08:21Z",
+ "stats.last_update_time": "2011-02-24T09:08:21Z",
+ "stats.lname": "4d662005_a at fdvm",
+ "stats.start_time": "2011-02-24T09:08:21Z",
+ "stats.timestamp": 1298538512.87378 }
self.verbose = True
self.stats_httpd = stats_httpd.StatsHttpd(self.verbose)
self.http_server = self.stats_httpd.httpd
self.assertTrue(self.stats_httpd.verbose)
- self.assertFalse(self.stats_httpd.running)
+ self.assertTrue(self.stats_httpd.running)
self.assertEqual(self.stats_httpd.stats_module_name, "Stats")
self.assertEqual(type(self.stats_httpd.httpd), stats_httpd.HttpServer)
self.assertFalse(self.stats_httpd.ccs_fd._closed)
@@ -48,21 +59,28 @@ class TestStatsHttpd(unittest.TestCase):
self.assertTrue(self.stats_httpd.http_fd._closed)
def test_statshttpd_start(self):
- self.assertFalse(self.stats_httpd.running)
+ self.assertTrue(self.stats_httpd.running)
self.stats_httpd.start()
self.assertFalse(self.stats_httpd.running)
+ self.stats_httpd.running = True
+ self.stats_httpd.stop()
+ self.assertFalse(self.stats_httpd.running)
def test_statshttpd_read_template(self):
- self.assertIsNone(self.stats_httpd.read_template('/path/to/foo/bar'))
+ self.assertRaises(
+ stats_httpd.StatsHttpdError,
+ self.stats_httpd.read_template,
+ '/path/to/foo/bar')
def test_statshttpd_commands(self):
self.assertEqual(
self.stats_httpd.config_handler(None),
isc.config.ccsession.create_answer(0))
+ self.assertTrue(self.stats_httpd.running)
self.assertEqual(self.stats_httpd.command_handler("status", None),
isc.config.ccsession.create_answer(
0, "Stats Httpd is up. (PID " + str(os.getpid()) + ")"))
- self.assertFalse(self.stats_httpd.running)
+ self.assertTrue(self.stats_httpd.running)
self.stats_httpd.running = True
self.assertEqual(self.stats_httpd.command_handler("shutdown", None),
isc.config.ccsession.create_answer(0))
@@ -72,24 +90,21 @@ class TestStatsHttpd(unittest.TestCase):
isc.config.ccsession.create_answer(
1, "Unknown command: __UNKNOWN_COMMAND__"))
- def test_stats_spec(self):
+ def push_answer(self):
+ print(self.stats_httpd.cc_session._clear_ques())
self.stats_httpd.cc_session.group_sendmsg(
{ 'result':
- [ 0, { "auth.queries.tcp": 0,
- "auth.queries.udp": 0,
- "bind10.boot_time": "1970-01-01T00:00:00Z",
- "report_time": "2011-02-24T09:08:32Z",
- "stats.boot_time": "2011-02-24T09:08:21Z",
- "stats.last_update_time": "2011-02-24T09:08:21Z",
- "stats.lname": "4d662005_a at fdvm",
- "stats.start_time": "2011-02-24T09:08:21Z",
- "stats.timestamp": 1298538512.87378 }
- ]
- }, "Stats" )
- self.assertEqual(len(self.stats_httpd.get_stats_data()), 2)
+ [ 0, self.sample_stats_data ] }, "Stats")
+
+ def test_stats_spec(self):
+ self.push_answer()
+ self.assertEqual(
+ len(self.stats_httpd.get_stats_data()),
+ len(self.sample_stats_data))
self.assertEqual(type(self.stats_httpd.get_stats_spec()), list)
def test_stats_xml(self):
+ self.push_answer()
self.assertEqual(type(self.stats_httpd.get_stats_xml()), str)
self.assertEqual(type(self.stats_httpd.get_stats_xsd()), str)
self.assertEqual(type(self.stats_httpd.get_stats_xsl()), str)
@@ -97,25 +112,14 @@ class TestStatsHttpd(unittest.TestCase):
def test_http_handler(self):
self.assertTrue(self.stats_httpd.httpd.verbose)
self.stats_httpd.httpd.handler.path = '/'
+ self.push_answer()
self.stats_httpd.httpd.handler.do_GET()
+ self.push_answer()
self.stats_httpd.httpd.handler.do_HEAD()
self.stats_httpd.httpd.handler.path = '/bind10-statistics.xsd'
self.stats_httpd.httpd.handler.do_GET()
self.stats_httpd.httpd.handler.path = '/bind10-statistics.xsl'
self.stats_httpd.httpd.handler.do_GET()
- self.stats_httpd.cc_session.group_sendmsg(
- { 'result':
- [ 0, { "auth.queries.tcp": 0,
- "auth.queries.udp": 0,
- "bind10.boot_time": "1970-01-01T00:00:00Z",
- "report_time": "2011-02-24T09:08:32Z",
- "stats.boot_time": "2011-02-24T09:08:21Z",
- "stats.last_update_time": "2011-02-24T09:08:21Z",
- "stats.lname": "4d662005_a at fdvm",
- "stats.start_time": "2011-02-24T09:08:21Z",
- "stats.timestamp": 1298538512.87378 }
- ]
- }, "Stats" )
self.stats_httpd.httpd.handler.path = '/path/to'
self.stats_httpd.httpd.handler.do_GET()
self.stats_httpd.httpd.handler.log_message('%s', 'dummyrequest')
diff --git a/src/bin/stats/tests/http/server.py b/src/bin/stats/tests/http/server.py
index 98e8016..ab3341b 100644
--- a/src/bin/stats/tests/http/server.py
+++ b/src/bin/stats/tests/http/server.py
@@ -29,6 +29,7 @@ class HTTPServer:
"""
This module is a mock-up class of http.server.HTTPServer
"""
+ address_family = socket.AF_INET
def __init__(self, server_class, handler_class):
self.socket = socket.socket()
self.handler = handler_class(None, None, self)
diff --git a/src/bin/stats/tests/isc/cc/session.py b/src/bin/stats/tests/isc/cc/session.py
index 6ba44d9..65c2f03 100644
--- a/src/bin/stats/tests/isc/cc/session.py
+++ b/src/bin/stats/tests/isc/cc/session.py
@@ -47,6 +47,11 @@ class Session:
def close(self):
self._socket.close()
+ def _clear_ques(self):
+ while len(self.message_queue) > 0:
+ self.dequeue()
+ print("msgq: " + str(len(self.message_queue)))
+
def _next_sequence(self, que=None):
return len(self.message_queue)
diff --git a/src/bin/stats/tests/isc/config/ccsession.py b/src/bin/stats/tests/isc/config/ccsession.py
index 54c50fc..1b77952 100644
--- a/src/bin/stats/tests/isc/config/ccsession.py
+++ b/src/bin/stats/tests/isc/config/ccsession.py
@@ -22,6 +22,8 @@ from isc.cc.session import Session
COMMAND_CONFIG_UPDATE = "config_update"
def parse_answer(msg):
+ assert type(msg) is dict
+ assert 'result' in msg
try:
return msg['result'][0], msg['result'][1]
except IndexError:
diff --git a/src/bin/stats/tests/socket.py b/src/bin/stats/tests/socket.py
index 260098f..8c7bb11 100644
--- a/src/bin/stats/tests/socket.py
+++ b/src/bin/stats/tests/socket.py
@@ -13,6 +13,11 @@
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+AF_INET = -0xFFFF
+
+class gaierror(Exception):
+ pass
+
class socket:
"""
This module is a mock-up class of socket
@@ -20,6 +25,7 @@ class socket:
def __init__(self):
self._closed = False
self._called = 0
+ self.has_ipv6 = True
def close(self):
self._closed = True
diff --git a/src/bin/stats/tests/testdata/Makefile.am b/src/bin/stats/tests/testdata/Makefile.am
index a46e0bb..f92f18f 100644
--- a/src/bin/stats/tests/testdata/Makefile.am
+++ b/src/bin/stats/tests/testdata/Makefile.am
@@ -1,12 +1,27 @@
EXTRA_DIST = stats_test.spec
noinst_DATA = stats.spec stats_httpd.spec
+noinst_DATA += stats-httpd-xml.tpl stats-httpd-xsd.tpl stats-httpd-xsl.tpl
CLEANFILES = stats.spec stats_httpd.spec
+CLEANFILES += stats-httpd-xml.tpl stats-httpd-xsd.tpl stats-httpd-xsl.tpl
-stats.spec: ../../stats.spec.pre.in
- $(SED) -e "s|@@DATAROOTDIR@@/\@PACKAGE\@|$(abs_srcdir)/../..|" ../../stats.spec.pre.in >$@
+stats.spec: $(abs_builddir)/../../stats.spec.pre
+ $(SED) -e "s|@@DATAROOTDIR@@|@abs_builddir@|" \
+ -e "s|@@PACKAGEDIR@@|.|" $(abs_builddir)/../../stats.spec.pre >$@
-stats_httpd.spec: ../../stats_httpd.spec.pre.in
- $(SED) -e "s|@@DATAROOTDIR@@/\@PACKAGE\@|$(abs_srcdir)/../..|" ../../stats_httpd.spec.pre.in >$@
+stats_httpd.spec: $(abs_builddir)/../../stats_httpd.spec.pre
+ $(SED) -e "s|@@DATAROOTDIR@@|@abs_builddir@|" \
+ -e "s|@@PACKAGEDIR@@|.|" $(abs_builddir)/../../stats_httpd.spec.pre >$@
+stats-httpd-xml.tpl: $(abs_builddir)/../../stats-httpd-xml.tpl.pre
+ $(SED) -e "s|@@DATAROOTDIR@@|@abs_builddir@|" \
+ -e "s|@@PACKAGEDIR@@|.|" $(abs_builddir)/../../stats-httpd-xml.tpl.pre >$@
+
+stats-httpd-xsd.tpl: $(abs_builddir)/../../stats-httpd-xsd.tpl.pre
+ $(SED) -e "s|@@DATAROOTDIR@@|@abs_builddir@|" \
+ -e "s|@@PACKAGEDIR@@|.|" $(abs_builddir)/../../stats-httpd-xsd.tpl.pre >$@
+
+stats-httpd-xsl.tpl: $(abs_builddir)/../../stats-httpd-xsl.tpl.pre
+ $(SED) -e "s|@@DATAROOTDIR@@|@abs_builddir@|" \
+ -e "s|@@PACKAGEDIR@@|.|" $(abs_builddir)/../../stats-httpd-xsl.tpl.pre >$@
More information about the bind10-changes
mailing list