[svn] commit: r2476 - in /branches/trac221b/src/bin/xfrin: tests/xfrin_test.py xfrin.py.in

BIND 10 source code commits bind10-changes at lists.isc.org
Sat Jul 10 07:29:20 UTC 2010


Author: jinmei
Date: Sat Jul 10 07:29:20 2010
New Revision: 2476

Log:
added test cases for notify, and fixed a bug identified by a test.

Modified:
    branches/trac221b/src/bin/xfrin/tests/xfrin_test.py
    branches/trac221b/src/bin/xfrin/xfrin.py.in

Modified: branches/trac221b/src/bin/xfrin/tests/xfrin_test.py
==============================================================================
--- branches/trac221b/src/bin/xfrin/tests/xfrin_test.py (original)
+++ branches/trac221b/src/bin/xfrin/tests/xfrin_test.py Sat Jul 10 07:29:20 2010
@@ -412,21 +412,26 @@
         return self.xfr._parse_cmd_params(self.args)
 
     def test_parse_cmd_params(self):
-        name, master_addrinfo, db_file = self._do_parse()
+        name, rrclass, master_addrinfo, db_file = self._do_parse()
         self.assertEqual(master_addrinfo[4][1], int(TEST_MASTER_PORT))
         self.assertEqual(name, TEST_ZONE_NAME)
+        self.assertEqual(rrclass, TEST_RRCLASS)
         self.assertEqual(master_addrinfo[4][0], TEST_MASTER_IPV4_ADDRESS)
         self.assertEqual(db_file, TEST_DB_FILE)
 
     def test_parse_cmd_params_default_port(self):
         del self.args['port']
-        master_addrinfo = self._do_parse()[1]
+        master_addrinfo = self._do_parse()[2]
         self.assertEqual(master_addrinfo[4][1], 53)
 
     def test_parse_cmd_params_ip6master(self):
         self.args['master'] = TEST_MASTER_IPV6_ADDRESS
-        master_addrinfo = self._do_parse()[1]
+        master_addrinfo = self._do_parse()[2]
         self.assertEqual(master_addrinfo[4][0], TEST_MASTER_IPV6_ADDRESS)
+
+    def test_parse_cmd_params_chclass(self):
+        self.args['rrclass'] = RRClass.CH()
+        self.assertEqual(self._do_parse()[1], RRClass.CH())
 
     def test_parse_cmd_params_nozone(self):
         # zone name is mandatory.
@@ -504,6 +509,12 @@
         self.assertEqual(self.xfr.command_handler("refresh",
                                                   self.args)['result'][0], 0)
 
+    def test_command_handler_notify(self):
+        # at this level, refresh is no different than retransfer.
+        self.args['master'] = TEST_MASTER_IPV6_ADDRESS
+        self.assertEqual(self.xfr.command_handler("notify",
+                                                  self.args)['result'][0], 0)
+
     def test_command_handler_unknown(self):
         self.assertEqual(self.xfr.command_handler("xxx", None)['result'][0], 1)
 

Modified: branches/trac221b/src/bin/xfrin/xfrin.py.in
==============================================================================
--- branches/trac221b/src/bin/xfrin/xfrin.py.in (original)
+++ branches/trac221b/src/bin/xfrin/xfrin.py.in Sat Jul 10 07:29:20 2010
@@ -404,22 +404,22 @@
             if command == 'shutdown':
                 self._shutdown_event.set()
             elif command == 'retransfer' or command == 'refresh':
-                # The default RR class is IN.  We should fix this so that
-                # the class is passed in the command arg (where we specify
-                # the default)
-                rrclass = RRClass.IN()
-                zone_name, master_addr, db_file = self._parse_cmd_params(args)
+                (zone_name, rrclass,
+                 master_addr, db_file) = self._parse_cmd_params(args)
                 ret = self.xfrin_start(zone_name, rrclass, db_file,
                                        master_addr,
                                    False if command == 'retransfer' else True)
                 answer = create_answer(ret[0], ret[1])
             elif command == 'notify':
-                # This is the temp implementation for notify
-                # actually the notfiy command should be sent to 
-                # Zone Manager module.
-                db_file = '@@LOCALSTATEDIR@@/@PACKAGE@/zone.sqlite3'
-                ret = self.xfrin_start(args['zone_name'], db_file,
-                                       args['master'], port=53)
+                # This is the temporary implementation for notify.
+                # actually the notfiy command should be sent to the
+                # Zone Manager module.  Being temporary, we separate this case
+                # from refresh/retransfer while we could (and should otherwise)
+                # share the code.
+                (zone_name, rrclass,
+                 master_addr, db_file) = self._parse_cmd_params(args)
+                ret = self.xfrin_start(zone_name, rrclass, db_file,
+                                       master_addr, True)
                 answer = create_answer(ret[0], ret[1])
             else:
                 answer = create_answer(1, 'unknown command: ' + command)
@@ -433,6 +433,13 @@
         zone_name = args.get('zone_name')
         if not zone_name:
             raise XfrinException('zone name should be provided')
+
+        rrclass = args.get('rrclass')
+        if not rrclass:
+            # The default RR class is IN.  We should fix this so that
+            # the class is passed in the command arg (where we specify
+            # the default)
+            rrclass = RRClass.IN()
 
         master = args.get('master')
         if not master:
@@ -459,7 +466,7 @@
                 db_file = os.environ["B10_FROM_BUILD"] + os.sep + "bind10_zones.sqlite3"
             self._cc.remove_remote_config(AUTH_SPECFILE_LOCATION)
 
-        return (zone_name, master_addrinfo, db_file)
+        return (zone_name, rrclass, master_addrinfo, db_file)
 
     def startup(self):
         while not self._shutdown_event.is_set():




More information about the bind10-changes mailing list