Browse Source

[2252] treat an xfr request as success with an XfrinZoneUptodate raised

Naoki Kambe 12 years ago
parent
commit
8544c8e88d
2 changed files with 38 additions and 0 deletions
  1. 28 0
      src/bin/xfrin/tests/xfrin_test.py
  2. 10 0
      src/bin/xfrin/xfrin.py.in

+ 28 - 0
src/bin/xfrin/tests/xfrin_test.py

@@ -2206,6 +2206,20 @@ class TestStatisticsXfrinAXFRv4(TestStatisticsXfrinConn):
                                         'xfrsuccess': 1,
                                         'last_axfr_duration': self._const_sec})
 
+    def test_axfrreq_xfrsuccess_last_axfr_duration2(self):
+        '''tests that axfrreqv4 or axfrreqv6 and xfrsuccess counters
+        and last_axfr_duration timer are incremented even if a successful
+        XfrinZoneUptodate is raised while handling an xfr response'''
+        def exception_raiser():
+            raise XfrinZoneUptodate()
+        self.conn._handle_xfrin_responses = exception_raiser
+        self._check_init_statistics()
+        self.assertEqual(self.conn.do_xfrin(False), XFRIN_OK)
+        self._check_updated_statistics({'axfrreq' + self._ipver: 1,
+                                        'xfrsuccess': 1,
+                                        'last_axfr_duration':
+                                            self._const_sec})
+
     def test_axfrreq_xfrfail(self):
         '''tests that axfrreqv4 or axfrreqv6 and xfrfail counters are
         incremented even if some failure exceptions are expected to be
@@ -2241,6 +2255,20 @@ class TestStatisticsXfrinIXFRv4(TestStatisticsXfrinConn):
                                         'last_ixfr_duration':
                                             self._const_sec})
 
+    def test_ixfrreq_xfrsuccess_last_ixfr_duration2(self):
+        '''tests that ixfrreqv4 or ixfrreqv6 and xfrsuccess counters
+        and last_ixfr_duration timer are incremented even if a successful
+        XfrinZoneUptodate is raised while handling an xfr response'''
+        def exception_raiser():
+            raise XfrinZoneUptodate()
+        self.conn._handle_xfrin_responses = exception_raiser
+        self._check_init_statistics()
+        self.assertEqual(self.conn.do_xfrin(False, RRType.IXFR), XFRIN_OK)
+        self._check_updated_statistics({'ixfrreq' + self._ipver: 1,
+                                        'xfrsuccess': 1,
+                                        'last_ixfr_duration':
+                                            self._const_sec})
+
     def test_ixfrreq_xfrfail(self):
         '''tests that ixfrreqv4 or ixfrreqv6 and xfrfail counters are
         incremented even if some failure exceptions are expected to be

+ 10 - 0
src/bin/xfrin/xfrin.py.in

@@ -972,6 +972,16 @@ class XfrinConnection(asyncore.dispatcher):
                 self._send_query(self._request_type)
                 self.__state = XfrinInitialSOA()
                 self._handle_xfrin_responses()
+            except XfrinZoneUptodate:
+                # Note: Catching an exception XfrinZoneUptodate
+                # defines that IXFR succeeded.  xfrsuccess is
+                # incremented and the timer is stopped here.
+                self._counters.inc('zones', self._zone_name.to_text(),
+                                   'xfrsuccess')
+                self._counters.stop_timer('zones', self._zone_name.to_text(),
+                                          'last_' + req_str.lower() +
+                                          '_duration')
+                raise
             except:
                 # The AXFR or IXFR request failed.
                 self._counters.inc('zones', self._zone_name.to_text(),