BIND 10 master, updated. 4c4e2711beeb2eed8104055cf66dd4e8151c4fd1 [master] Update changelog for merge of #1897
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jan 28 14:29:27 UTC 2013
The branch, master has been updated
via 4c4e2711beeb2eed8104055cf66dd4e8151c4fd1 (commit)
via 93716b025a4755a8a2cbf250a9e4187741dbc9bb (commit)
via cd2c2c8ec6cf8a335897176339c8150228be4a36 (commit)
via 779d9312bf84dcf7ce26bd1b1d6276179e026ad2 (commit)
via 09c24690d48f8b8b7239668216b8fed9bac179e0 (commit)
via 4d6c30931eee834bb63b11fabec9d84390a9f6b7 (commit)
via eb1b9e524157d9c378ba0350fe3217d56dbc0665 (commit)
via 769bbb5edb0fe537e497ebe1a9fc3dfc130a5866 (commit)
from d94641e52198629abdd3ffe82751b0b6ce11ff28 (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 4c4e2711beeb2eed8104055cf66dd4e8151c4fd1
Author: Jelte Jansen <jelte at isc.org>
Date: Mon Jan 28 15:06:36 2013 +0100
[master] Update changelog for merge of #1897
commit 93716b025a4755a8a2cbf250a9e4187741dbc9bb
Merge: d94641e cd2c2c8
Author: Jelte Jansen <jelte at isc.org>
Date: Mon Jan 28 15:05:20 2013 +0100
[master] Merge branch 'trac1897'
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 6 +++
src/bin/stats/stats_httpd.py.in | 50 +++++++++++++----------
src/bin/stats/stats_httpd_messages.mes | 40 ++++++++++--------
tests/lettuce/features/bindctl_commands.feature | 2 +-
tests/lettuce/features/stats_httpd.feature | 16 ++++++++
tests/lettuce/features/terrain/http.py | 41 +++++++++++++++++++
tests/lettuce/features/terrain/steps.py | 2 +-
tests/lettuce/features/terrain/terrain.py | 4 ++
8 files changed, 121 insertions(+), 40 deletions(-)
create mode 100644 tests/lettuce/features/stats_httpd.feature
create mode 100644 tests/lettuce/features/terrain/http.py
-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 7f8cbde..73c08df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+561. [bug] kambe, jelte
+ b10-stats-httpd no longer dumps request information to the console,
+ but uses the bind10 logging system. Additionally, the logging
+ identifiers have been changed from STATHTTPD_* to STATSHTTPD_*
+ (Trac #1897, git 93716b025a4755a8a2cbf250a9e4187741dbc9bb)
+
560. [bug] jinmei
b10-auth now sets the TTL of SOA RR for negative responses to
the minimum of the RR TTL and the minimum TTL of the SOA RDATA
diff --git a/src/bin/stats/stats_httpd.py.in b/src/bin/stats/stats_httpd.py.in
index 057b8ca..736029b 100644
--- a/src/bin/stats/stats_httpd.py.in
+++ b/src/bin/stats/stats_httpd.py.in
@@ -43,8 +43,8 @@ isc.log.init("b10-stats-httpd", buffer=True)
logger = isc.log.Logger("stats-httpd")
# Some constants for debug levels.
-DBG_STATHTTPD_INIT = logger.DBGLVL_START_SHUT
-DBG_STATHTTPD_MESSAGING = logger.DBGLVL_COMMAND
+DBG_STATSHTTPD_INIT = logger.DBGLVL_START_SHUT
+DBG_STATSHTTPD_MESSAGING = logger.DBGLVL_COMMAND
# If B10_FROM_SOURCE is set in the environment, we use data files
# from a directory relative to that, otherwise we use the ones
@@ -187,11 +187,11 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
# Couldn't find neither specified module name nor
# specified item name
self.send_error(404)
- logger.error(STATHTTPD_SERVER_DATAERROR, err)
+ logger.error(STATSHTTPD_SERVER_DATAERROR, err)
return None
except Exception as err:
self.send_error(500)
- logger.error(STATHTTPD_SERVER_ERROR, err)
+ logger.error(STATSHTTPD_SERVER_ERROR, err)
return None
else:
self.send_response(200)
@@ -201,6 +201,14 @@ class HttpHandler(http.server.BaseHTTPRequestHandler):
self.end_headers()
return body
+ def log_message(self, format, *args):
+ """overrides the parent method log_message()
+ to use the bind10 logging framework.
+ """
+ logger.debug(DBG_STATSHTTPD_MESSAGING, STATSHTTPD_HTTPLOG,
+ self.address_string(),
+ format%args)
+
class HttpServerError(Exception):
"""Exception class for HttpServer class. It is intended to be
passed from the HttpServer object to the StatsHttpd object."""
@@ -263,7 +271,7 @@ class StatsHttpd:
def open_mccs(self):
"""Opens a ModuleCCSession object"""
# create ModuleCCSession
- logger.debug(DBG_STATHTTPD_INIT, STATHTTPD_STARTING_CC_SESSION)
+ logger.debug(DBG_STATSHTTPD_INIT, STATSHTTPD_STARTING_CC_SESSION)
self.mccs = isc.config.ModuleCCSession(
SPECFILE_LOCATION, self.config_handler, self.command_handler)
self.cc_session = self.mccs._session
@@ -274,7 +282,7 @@ class StatsHttpd:
return
self.mccs.send_stopping()
- logger.debug(DBG_STATHTTPD_INIT, STATHTTPD_CLOSING_CC_SESSION)
+ logger.debug(DBG_STATSHTTPD_INIT, STATSHTTPD_CLOSING_CC_SESSION)
self.mccs.close()
self.mccs = None
@@ -317,7 +325,7 @@ class StatsHttpd:
server_address, HttpHandler,
self.xml_handler, self.xsd_handler, self.xsl_handler,
self.write_log)
- logger.info(STATHTTPD_STARTED, server_address[0],
+ logger.info(STATSHTTPD_STARTED, server_address[0],
server_address[1])
return httpd
except (socket.gaierror, socket.error,
@@ -333,7 +341,7 @@ class StatsHttpd:
"""Closes sockets for HTTP"""
while len(self.httpd)>0:
ht = self.httpd.pop()
- logger.info(STATHTTPD_CLOSING, ht.server_address[0],
+ logger.info(STATSHTTPD_CLOSING, ht.server_address[0],
ht.server_address[1])
ht.server_close()
@@ -369,7 +377,7 @@ class StatsHttpd:
def stop(self):
"""Stops the running StatsHttpd objects. Closes CC session and
HTTP handling sockets"""
- logger.info(STATHTTPD_SHUTDOWN)
+ logger.info(STATSHTTPD_SHUTDOWN)
self.close_httpd()
self.close_mccs()
self.running = False
@@ -387,7 +395,7 @@ class StatsHttpd:
def config_handler(self, new_config):
"""Config handler for the ModuleCCSession object. It resets
addresses and ports to listen HTTP requests on."""
- logger.debug(DBG_STATHTTPD_MESSAGING, STATHTTPD_HANDLE_CONFIG,
+ logger.debug(DBG_STATSHTTPD_MESSAGING, STATSHTTPD_HANDLE_CONFIG,
new_config)
errors = []
if not self.mccs.get_module_spec().\
@@ -405,7 +413,7 @@ class StatsHttpd:
try:
self.open_httpd()
except HttpServerError as err:
- logger.error(STATHTTPD_SERVER_ERROR, err)
+ logger.error(STATSHTTPD_SERVER_ERROR, err)
# restore old config
self.load_config(old_config)
self.open_httpd()
@@ -417,18 +425,18 @@ class StatsHttpd:
"""Command handler for the ModuleCCSesson object. It handles
"status" and "shutdown" commands."""
if command == "status":
- logger.debug(DBG_STATHTTPD_MESSAGING,
- STATHTTPD_RECEIVED_STATUS_COMMAND)
+ logger.debug(DBG_STATSHTTPD_MESSAGING,
+ STATSHTTPD_RECEIVED_STATUS_COMMAND)
return isc.config.ccsession.create_answer(
0, "Stats Httpd is up. (PID " + str(os.getpid()) + ")")
elif command == "shutdown":
- logger.debug(DBG_STATHTTPD_MESSAGING,
- STATHTTPD_RECEIVED_SHUTDOWN_COMMAND)
+ logger.debug(DBG_STATSHTTPD_MESSAGING,
+ STATSHTTPD_RECEIVED_SHUTDOWN_COMMAND)
self.running = False
return isc.config.ccsession.create_answer(0)
else:
- logger.debug(DBG_STATHTTPD_MESSAGING,
- STATHTTPD_RECEIVED_UNKNOWN_COMMAND, command)
+ logger.debug(DBG_STATSHTTPD_MESSAGING,
+ STATSHTTPD_RECEIVED_UNKNOWN_COMMAND, command)
return isc.config.ccsession.create_answer(
1, "Unknown command: " + str(command))
@@ -613,13 +621,13 @@ if __name__ == "__main__":
stats_httpd = StatsHttpd()
stats_httpd.start()
except OptionValueError as ove:
- logger.fatal(STATHTTPD_BAD_OPTION_VALUE, ove)
+ logger.fatal(STATSHTTPD_BAD_OPTION_VALUE, ove)
sys.exit(1)
except isc.cc.session.SessionError as se:
- logger.fatal(STATHTTPD_CC_SESSION_ERROR, se)
+ logger.fatal(STATSHTTPD_CC_SESSION_ERROR, se)
sys.exit(1)
except HttpServerError as hse:
- logger.fatal(STATHTTPD_START_SERVER_INIT_ERROR, hse)
+ logger.fatal(STATSHTTPD_START_SERVER_INIT_ERROR, hse)
sys.exit(1)
except KeyboardInterrupt as kie:
- logger.info(STATHTTPD_STOPPED_BY_KEYBOARD)
+ logger.info(STATSHTTPD_STOPPED_BY_KEYBOARD)
diff --git a/src/bin/stats/stats_httpd_messages.mes b/src/bin/stats/stats_httpd_messages.mes
index ad2e97f..62fbd45 100644
--- a/src/bin/stats/stats_httpd_messages.mes
+++ b/src/bin/stats/stats_httpd_messages.mes
@@ -15,84 +15,90 @@
# No namespace declaration - these constants go in the global namespace
# of the stats_httpd_messages python module.
-% STATHTTPD_BAD_OPTION_VALUE bad command line argument: %1
+% STATSHTTPD_BAD_OPTION_VALUE bad command line argument: %1
The stats-httpd module was called with a bad command-line argument
and will not start.
-% STATHTTPD_CC_SESSION_ERROR error connecting to message bus: %1
+% STATSHTTPD_CC_SESSION_ERROR error connecting to message bus: %1
The stats-httpd module was unable to connect to the BIND 10 command
and control bus. A likely problem is that the message bus daemon
(b10-msgq) is not running. The stats-httpd module will now shut down.
-% STATHTTPD_CLOSING closing %1#%2
+% STATSHTTPD_CLOSING closing %1#%2
The stats-httpd daemon will stop listening for requests on the given
address and port number.
-% STATHTTPD_CLOSING_CC_SESSION stopping cc session
+% STATSHTTPD_CLOSING_CC_SESSION stopping cc session
Debug message indicating that the stats-httpd module is disconnecting
from the command and control bus.
-% STATHTTPD_HANDLE_CONFIG reading configuration: %1
+% STATSHTTPD_HANDLE_CONFIG reading configuration: %1
The stats-httpd daemon has received new configuration data and will now
process it. The (changed) data is printed.
-% STATHTTPD_RECEIVED_SHUTDOWN_COMMAND shutdown command received
+% STATSHTTPD_RECEIVED_SHUTDOWN_COMMAND shutdown command received
A shutdown command was sent to the stats-httpd module, and it will
now shut down.
-% STATHTTPD_RECEIVED_STATUS_COMMAND received command to return status
+% STATSHTTPD_RECEIVED_STATUS_COMMAND received command to return status
A status command was sent to the stats-httpd module, and it will
respond with 'Stats Httpd is up.' and its PID.
-% STATHTTPD_RECEIVED_UNKNOWN_COMMAND received unknown command: %1
+% STATSHTTPD_RECEIVED_UNKNOWN_COMMAND received unknown command: %1
An unknown command has been sent to the stats-httpd module. The
stats-httpd module will respond with an error, and the command will
be ignored.
-% STATHTTPD_SERVER_DATAERROR HTTP server data error: %1
+% STATSHTTPD_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_ERROR HTTP server error: %1
+% STATSHTTPD_SERVER_ERROR HTTP server error: %1
An internal error occurred while handling an HTTP request. An HTTP 500
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_INIT_ERROR HTTP server initialization error: %1
+% STATSHTTPD_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
is a port binding problem or a bad configuration value. The specific
error is printed in the message. The new configuration is ignored,
and an error is sent back.
-% STATHTTPD_SHUTDOWN shutting down
+% STATSHTTPD_SHUTDOWN shutting down
The stats-httpd daemon is shutting down.
-% STATHTTPD_STARTED listening on %1#%2
+% STATSHTTPD_STARTED listening on %1#%2
The stats-httpd daemon will now start listening for requests on the
given address and port number.
-% STATHTTPD_STARTING_CC_SESSION starting cc session
+% STATSHTTPD_STARTING_CC_SESSION starting cc session
Debug message indicating that the stats-httpd module is connecting to
the command and control bus.
-% STATHTTPD_START_SERVER_INIT_ERROR HTTP server initialization error: %1
+% STATSHTTPD_START_SERVER_INIT_ERROR HTTP server initialization error: %1
There was a problem initializing the HTTP server in the stats-httpd
module upon startup. The most likely cause is that it was not able
to bind to the listening port. The specific error is printed, and the
module will shut down.
-% STATHTTPD_STOPPED_BY_KEYBOARD keyboard interrupt, shutting down
+% STATSHTTPD_STOPPED_BY_KEYBOARD keyboard interrupt, shutting down
There was a keyboard interrupt signal to stop the stats-httpd
daemon. The daemon will now shut down.
-% STATHTTPD_UNKNOWN_CONFIG_ITEM unknown configuration item: %1
+% STATSHTTPD_UNKNOWN_CONFIG_ITEM unknown configuration item: %1
The stats-httpd daemon received a configuration update from the
configuration manager. However, one of the items in the
configuration is unknown. The new configuration is ignored, and an
error is sent back. As possible cause is that there was an upgrade
problem, and the stats-httpd version is out of sync with the rest of
the system.
+
+% STATSHTTPD_HTTPLOG %1 %2
+Debug HTTP log message. These are the messages logged by the http server
+instance. For most logs, the message shows HTTP client and query
+information like HTTP method, URI, and status code, but the http server
+can also log other information, such as extended status reports.
diff --git a/tests/lettuce/features/bindctl_commands.feature b/tests/lettuce/features/bindctl_commands.feature
index 20a28fc..57406c3 100644
--- a/tests/lettuce/features/bindctl_commands.feature
+++ b/tests/lettuce/features/bindctl_commands.feature
@@ -17,7 +17,7 @@ Feature: control with bindctl
And wait for bind10 stderr message XFRIN_STARTED
And wait for bind10 stderr message XFROUT_STARTED
And wait for bind10 stderr message STATS_STARTING
- And wait for bind10 stderr message STATHTTPD_STARTED
+ And wait for bind10 stderr message STATSHTTPD_STARTED
Then remove bind10 configuration Boss/components/NOSUCHMODULE
last bindctl output should contain Error
diff --git a/tests/lettuce/features/stats_httpd.feature b/tests/lettuce/features/stats_httpd.feature
new file mode 100644
index 0000000..50d5efa
--- /dev/null
+++ b/tests/lettuce/features/stats_httpd.feature
@@ -0,0 +1,16 @@
+Feature: b10-stats-httpd module
+ Tests the stats httpd module
+
+ Scenario: Check that the module logs and responds to requests
+ Given I have bind10 running with configuration bindctl_commands.config
+ And wait for bind10 stderr message STATSHTTPD_STARTED
+
+ When I request the URL http://127.0.0.1:47811/
+ # Should result in redirect, so two query logs
+ And wait for new bind10 stderr message "GET / HTTP/1.0" 302 -
+ And wait for new bind10 stderr message "GET /bind10/statistics/xml/ HTTP/1.0" 200 -
+ The last http response status code should be 200
+
+ When I request the URL http://127.0.0.1:47811/no_such_url
+ And wait for new bind10 stderr message "GET /no_such_url HTTP/1.0" 404 -
+ The last http response status code should be 404
diff --git a/tests/lettuce/features/terrain/http.py b/tests/lettuce/features/terrain/http.py
new file mode 100644
index 0000000..f1f72f5
--- /dev/null
+++ b/tests/lettuce/features/terrain/http.py
@@ -0,0 +1,41 @@
+# Copyright (C) 2013 Internet Systems Consortium.
+#
+# Permission to use, copy, modify, and 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 INTERNET SYSTEMS CONSORTIUM
+# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+# INTERNET SYSTEMS CONSORTIUM 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.
+
+from lettuce import *
+import urllib
+
+# Basic request
+ at step('request the URL (.*)')
+def request_url(step, url):
+ """
+ Performs one basic HTTP GET request. The resulting HTTPResponse object
+ will we placed in world.last_http_response
+ Parameters:
+ url: the full URL to query
+ """
+ world.last_http_response = urllib.urlopen(url)
+
+ at step('last http response status code should be ([0-9]+)')
+def check_last_response_code(step, code):
+ """
+ Checks whether the last call to request_url resulted in a response
+ with the given (numeric) status code
+ Fails if it does not, or if there never was a complete request_url
+ operation
+ """
+ assert world.last_http_response != None, "No HTTP request made yet"
+ assert int(code) == world.last_http_response.getcode(),\
+ code + " != " +\
+ str(world.last_http_response.getcode())
diff --git a/tests/lettuce/features/terrain/steps.py b/tests/lettuce/features/terrain/steps.py
index 8df0bae..f0fad4d 100644
--- a/tests/lettuce/features/terrain/steps.py
+++ b/tests/lettuce/features/terrain/steps.py
@@ -30,7 +30,7 @@ def stop_a_named_process(step, process_name):
"""
world.processes.stop_process(process_name)
- at step('wait (?:(\d+) times )?for (new )?(\w+) stderr message (\w+)(?: not (\w+))?')
+ at step('wait (?:(\d+) times )?for (new )?(\w+) stderr message (.+)(?: not (.+))?')
def wait_for_stderr_message(step, times, new, process_name, message, not_message):
"""
Block until the given message is printed to the given process's stderr
diff --git a/tests/lettuce/features/terrain/terrain.py b/tests/lettuce/features/terrain/terrain.py
index bc05341..6af5c16 100644
--- a/tests/lettuce/features/terrain/terrain.py
+++ b/tests/lettuce/features/terrain/terrain.py
@@ -1,3 +1,4 @@
+
# Copyright (C) 2011 Internet Systems Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
@@ -380,6 +381,9 @@ def initialize(scenario):
# Convenience variable to access the last query result from querying.py
world.last_query_result = None
+ # Convenience variable to access the last HTTP response from http.py
+ world.last_http_response = None
+
# For slightly better errors, initialize a process_pids for the relevant
# steps
world.process_pids = None
More information about the bind10-changes
mailing list