BIND 10 master, updated. cd620bf3e4315d693582f25538b3bb71941a42e5 [master] merge trac588 into master
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Mar 15 04:07:14 UTC 2011
The branch, master has been updated
via cd620bf3e4315d693582f25538b3bb71941a42e5 (commit)
via 662e99ef050d98e86614c4443326568a0b5be437 (commit)
via 3b05e142949e5bee23b809625cb524e7e5ea66f8 (commit)
via 79e6083d6c946d9734337bd4ebb7f3a984fd6d05 (commit)
via a92158cc1d674e0dce9e75acbb40a1a9bd807f0e (commit)
via 3a4e135e22cb4e986ca4c1902d34172ccc9aeae1 (commit)
via 065327bbba5925b882af5230e5d312750e619a91 (commit)
via a72483929eb91cf20d41ca5c40bd6ba8b6f31e60 (commit)
via cf2b8ace9b9c295e46fdd5373bd70a13e7e3fbee (commit)
via cbc69359f3d9841a217ee55f0e30937a86cb0097 (commit)
via 45b76ba773367f8a490bbf19f0d74c02293c387b (commit)
via f009a637580c569a49a74b87a384a242c5a5f30a (commit)
from df2502bc7f9600f03dc410f01b1e6e060ea427ff (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 cd620bf3e4315d693582f25538b3bb71941a42e5
Author: chenzhengzhang <jerry.zzpku at gmail.com>
Date: Tue Mar 15 12:06:25 2011 +0800
[master] merge trac588 into master
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 4 ++
src/bin/bindctl/bindcmd.py | 18 +++++--
src/bin/bindctl/tests/bindctl_test.py | 88 +++++++++++++++++++++++++++++++--
3 files changed, 101 insertions(+), 9 deletions(-)
-----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index cc87bfa..09293ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+ 201. [bug] jerry
+ src/bin/bindctl: bindctl doesn't show traceback on shutdown.
+ (Trac #588, git 662e99ef050d98e86614c4443326568a0b5be437)
+
200. [bug] Jelte
Fixed a bug where incoming TCP connections were not closed.
(Trac #589, git 1d88daaa24e8b1ab27f28be876f40a144241e93b)
diff --git a/src/bin/bindctl/bindcmd.py b/src/bin/bindctl/bindcmd.py
index 83dab25..8973aa5 100644
--- a/src/bin/bindctl/bindcmd.py
+++ b/src/bin/bindctl/bindcmd.py
@@ -123,14 +123,19 @@ class BindCmdInterpreter(Cmd):
'''Parse commands from user and send them to cmdctl. '''
try:
if not self.login_to_cmdctl():
- return
+ return
self.cmdloop()
+ print('\nExit from bindctl')
except FailToLogin as err:
# error already printed when this was raised, ignoring
pass
except KeyboardInterrupt:
print('\nExit from bindctl')
+ except socket.error as err:
+ print('Failed to send request, the connection is closed')
+ except http.client.CannotSendRequest:
+ print('Can not send request, the connection is busy')
def _get_saved_user_info(self, dir, file_name):
''' Read all the available username and password pairs saved in
@@ -192,8 +197,10 @@ class BindCmdInterpreter(Cmd):
raise FailToLogin()
if response.status == http.client.OK:
- print(data + ' login as ' + row[0] )
- return True
+ # Is interactive?
+ if sys.stdin.isatty():
+ print(data + ' login as ' + row[0])
+ return True
count = 0
print("[TEMP MESSAGE]: username :root password :bind10")
@@ -273,8 +280,9 @@ class BindCmdInterpreter(Cmd):
self._update_commands()
def precmd(self, line):
- self._update_all_modules_info()
- return line
+ if line != 'EOF':
+ self._update_all_modules_info()
+ return line
def postcmd(self, stop, line):
'''Update the prompt after every command, but only if we
diff --git a/src/bin/bindctl/tests/bindctl_test.py b/src/bin/bindctl/tests/bindctl_test.py
index dd492c1..148bf3a 100644
--- a/src/bin/bindctl/tests/bindctl_test.py
+++ b/src/bin/bindctl/tests/bindctl_test.py
@@ -17,6 +17,10 @@
import unittest
import isc.cc.data
import os
+import io
+import sys
+import socket
+import http.client
import pwd
import getpass
from optparse import OptionParser
@@ -275,7 +279,33 @@ class FakeCCSession(MultiConfigData):
]
}
self.set_specification(ModuleSpec(spec))
-
+
+
+# fake socket
+class FakeSocket():
+ def __init__(self):
+ self.run = True
+
+ def connect(self, to):
+ if not self.run:
+ raise socket.error
+
+ def close(self):
+ self.run = False
+
+ def send(self, data):
+ if not self.run:
+ raise socket.error
+ return len(data)
+
+ def makefile(self, type):
+ return self
+
+ def sendall(self, data):
+ if not self.run:
+ raise socket.error
+ return len(data)
+
class TestConfigCommands(unittest.TestCase):
def setUp(self):
@@ -283,7 +313,47 @@ class TestConfigCommands(unittest.TestCase):
mod_info = ModuleInfo(name = "foo")
self.tool.add_module_info(mod_info)
self.tool.config_data = FakeCCSession()
-
+ self.stdout_backup = sys.stdout
+
+ def test_precmd(self):
+ def update_all_modules_info():
+ raise socket.error
+ def precmd(line):
+ self.tool.precmd(line)
+ self.tool._update_all_modules_info = update_all_modules_info
+ # If line is equals to 'EOF', _update_all_modules_info() shouldn't be called
+ precmd('EOF')
+ self.assertRaises(socket.error, precmd, 'continue')
+
+ def test_run(self):
+ def login_to_cmdctl():
+ return True
+ def cmd_loop():
+ self.tool._send_message("/module_spec", None)
+
+ self.tool.login_to_cmdctl = login_to_cmdctl
+ # rewrite cmdloop() to avoid interactive mode
+ self.tool.cmdloop = cmd_loop
+
+ self.tool.conn.sock = FakeSocket()
+ self.tool.conn.sock.close()
+
+ # validate log message for socket.err
+ socket_err_output = io.StringIO()
+ sys.stdout = socket_err_output
+ self.assertRaises(None, self.tool.run())
+ self.assertEqual("Failed to send request, the connection is closed\n",
+ socket_err_output.getvalue())
+ socket_err_output.close()
+
+ # validate log message for http.client.CannotSendRequest
+ cannot_send_output = io.StringIO()
+ sys.stdout = cannot_send_output
+ self.assertRaises(None, self.tool.run())
+ self.assertEqual("Can not send request, the connection is busy\n",
+ cannot_send_output.getvalue())
+ cannot_send_output.close()
+
def test_apply_cfg_command_int(self):
self.tool.location = '/'
@@ -332,10 +402,17 @@ class TestConfigCommands(unittest.TestCase):
# this should raise a TypeError
cmd = cmdparse.BindCmdParse("config set identifier=\"foo/a_list\" value=\"a\"")
self.assertRaises(isc.cc.data.DataTypeError, self.tool.apply_config_cmd, cmd)
-
+
cmd = cmdparse.BindCmdParse("config set identifier=\"foo/a_list\" value=[1]")
self.assertRaises(isc.cc.data.DataTypeError, self.tool.apply_config_cmd, cmd)
+ def tearDown(self):
+ sys.stdout = self.stdout_backup
+
+class FakeBindCmdInterpreter(bindcmd.BindCmdInterpreter):
+ def __init__(self):
+ pass
+
class TestBindCmdInterpreter(unittest.TestCase):
def _create_invalid_csv_file(self, csvfilename):
@@ -360,15 +437,18 @@ class TestBindCmdInterpreter(unittest.TestCase):
self.assertEqual(new_csv_dir, custom_cmd.csv_file_dir)
def test_get_saved_user_info(self):
+ old_stdout = sys.stdout
+ sys.stdout = open(os.devnull, 'w')
cmd = bindcmd.BindCmdInterpreter()
users = cmd._get_saved_user_info('/notexist', 'csv_file.csv')
self.assertEqual([], users)
-
+
csvfilename = 'csv_file.csv'
self._create_invalid_csv_file(csvfilename)
users = cmd._get_saved_user_info('./', csvfilename)
self.assertEqual([], users)
os.remove(csvfilename)
+ sys.stdout = old_stdout
class TestCommandLineOptions(unittest.TestCase):
More information about the bind10-changes
mailing list