Commit c96f735c authored by JINMEI Tatuya's avatar JINMEI Tatuya

[master] Merge branch trac1261 with fixing conflicts, etc.

- I need to add another mock method in xfrin/test to be compatible with the
  latest version of Diff class.
- I also replaced 'remove' with 'delete' more completely in the Diff class
  (and adjusted the caller side accordingly) for consistency.
parents 90ab0a15 95cbc4ef
......@@ -811,6 +811,7 @@ AC_CONFIG_FILES([Makefile
src/bin/sockcreator/tests/Makefile
src/bin/xfrin/Makefile
src/bin/xfrin/tests/Makefile
src/bin/xfrin/tests/testdata/Makefile
src/bin/xfrout/Makefile
src/bin/xfrout/tests/Makefile
src/bin/zonemgr/Makefile
......
SUBDIRS = testdata .
PYCOVERAGE_RUN=@PYCOVERAGE_RUN@
PYTESTS = xfrin_test.py
EXTRA_DIST = $(PYTESTS)
......@@ -20,5 +22,7 @@ endif
echo Running test: $$pytest ; \
$(LIBRARY_PATH_PLACEHOLDER) \
PYTHONPATH=$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/bin/xfrin:$(COMMON_PYTHON_PATH) \
TESTDATASRCDIR=$(abs_top_srcdir)/src/bin/xfrin/tests/testdata/ \
TESTDATAOBJDIR=$(abs_top_builddir)/src/bin/xfrin/tests/testdata/ \
$(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \
done
EXTRA_DIST = example.com # not necessarily needed, but for reference
EXTRA_DIST += example.com.sqlite3
;; This is a simplest form of zone file for 'example.com', which is the
;; source of the corresponding sqlite3 DB file. This file is provided
;; for reference purposes only; it's not actually used anywhere.
example.com. 3600 IN SOA master.example.com. admin.example.com. (
1230 ; serial
3600 ; refresh (1 hour)
1800 ; retry (30 minutes)
2419200 ; expire (4 weeks)
7200 ; minimum (2 hours)
)
3600 NS dns01.example.com.
3600 NS dns02.example.com.
3600 NS dns03.example.com.
dns01.example.com. 3600 IN A 192.0.2.1
dns02.example.com. 3600 IN A 192.0.2.2
dns03.example.com. 3600 IN A 192.0.2.3
This diff is collapsed.
This diff is collapsed.
......@@ -15,25 +15,26 @@
# No namespace declaration - these constants go in the global namespace
# of the xfrin messages python module.
% XFRIN_AXFR_INTERNAL_FAILURE AXFR transfer of zone %1 failed: %2
The AXFR transfer for the given zone has failed due to an internal
problem in the bind10 python wrapper library.
The error is shown in the log message.
% XFRIN_XFR_OTHER_FAILURE %1 transfer of zone %2 failed: %3
The XFR transfer for the given zone has failed due to a problem outside
of the xfrin module. Possible reasons are a broken DNS message or failure
in database connection. The error is shown in the log message.
% XFRIN_AXFR_DATABASE_FAILURE AXFR transfer of zone %1 failed: %2
The AXFR transfer for the given zone has failed due to a database problem.
The error is shown in the log message.
The error is shown in the log message. Note: due to the code structure
this can only happen for AXFR.
% XFRIN_AXFR_TRANSFER_FAILURE AXFR transfer of zone %1 failed: %2
The AXFR transfer for the given zone has failed due to a protocol error.
% XFRIN_XFR_TRANSFER_FAILURE %1 transfer of zone %2 failed: %3
The XFR transfer for the given zone has failed due to a protocol error.
The error is shown in the log message.
% XFRIN_AXFR_TRANSFER_STARTED AXFR transfer of zone %1 started
% XFRIN_XFR_TRANSFER_STARTED %1 transfer of zone %2 started
A connection to the master server has been made, the serial value in
the SOA record has been checked, and a zone transfer has been started.
% XFRIN_AXFR_TRANSFER_SUCCESS AXFR transfer of zone %1 succeeded
The AXFR transfer of the given zone was successfully completed.
% XFRIN_XFR_TRANSFER_SUCCESS %1 transfer of zone %2 succeeded
The XFR transfer of the given zone was successfully completed.
% XFRIN_BAD_MASTER_ADDR_FORMAT bad format for master address: %1
The given master address is not a valid IP address.
......@@ -89,3 +90,12 @@ daemon will now shut down.
% XFRIN_UNKNOWN_ERROR unknown error: %1
An uncaught exception was raised while running the xfrin daemon. The
exception message is printed in the log message.
% XFRIN_GOT_INCREMENTAL_RESP got incremental response for %1
In an attempt of IXFR processing, the begenning SOA of the first difference
(following the initial SOA that specified the final SOA for all the
differences) was found. This means a connection for xfrin tried IXFR
and really aot a response for incremental updates.
% XFRIN_GOT_NONINCREMENTAL_RESP got nonincremental response for %1
TBD
......@@ -641,8 +641,12 @@ doUpdate(SQLite3Parameters& dbparams, StatementID stmt_id,
const size_t column_count =
sizeof(update_params) / sizeof(update_params[0]);
for (int i = 0; i < column_count; ++i) {
if (sqlite3_bind_text(stmt, ++param_id, update_params[i].c_str(), -1,
SQLITE_TRANSIENT) != SQLITE_OK) {
// The old sqlite3 data source API assumes NULL for an empty column.
// We need to provide compatibility at least for now.
if (sqlite3_bind_text(stmt, ++param_id,
update_params[i].empty() ? NULL :
update_params[i].c_str(),
-1, SQLITE_TRANSIENT) != SQLITE_OK) {
isc_throw(DataSourceError, "failed to bind SQLite3 parameter: " <<
sqlite3_errmsg(dbparams.db_));
}
......
......@@ -93,7 +93,7 @@ class Diff:
"""
Schedules an operation with rr.
It does all the real work of add_data and remove_data, including
It does all the real work of add_data and delete_data, including
all checks.
"""
self.__check_commited()
......@@ -122,9 +122,9 @@ class Diff:
"""
self.__data_common(rr, 'add')
def remove_data(self, rr):
def delete_data(self, rr):
"""
Schedules removal of an RR from the zone in this diff.
Schedules deleting an RR from the zone in this diff.
The rr is of isc.dns.RRset type and it must contain only one RR.
If this is not the case or if the diff was already commited, this
......@@ -133,7 +133,7 @@ class Diff:
The rr class must match the one of the datasource client. If
it does not, ValueError is raised.
"""
self.__data_common(rr, 'remove')
self.__data_common(rr, 'delete')
def compact(self):
"""
......@@ -189,8 +189,8 @@ class Diff:
for (operation, rrset) in self.__buffer:
if operation == 'add':
self.__updater.add_rrset(rrset)
elif operation == 'remove':
self.__updater.remove_rrset(rrset)
elif operation == 'delete':
self.__updater.delete_rrset(rrset)
else:
raise ValueError('Unknown operation ' + operation)
# As everything is already in, drop the buffer
......@@ -219,15 +219,15 @@ class Diff:
# Remove the updater. That will free some resources for one, but
# mark this object as already commited, so we can check
# We remove it even in case the commit failed, as that makes us
# We delete it even in case the commit failed, as that makes us
# unusable.
self.__updater = None
def get_buffer(self):
"""
Returns the current buffer of changes not yet passed into the data
source. It is in a form like [('add', rrset), ('remove', rrset),
('remove', rrset), ...].
source. It is in a form like [('add', rrset), ('delete', rrset),
('delete', rrset), ...].
Probably useful only for testing and introspection purposes. Don't
modify the list.
......
......@@ -112,12 +112,12 @@ class DiffTest(unittest.TestCase):
"""
self.__data_operations.append(('add', rrset))
def remove_rrset(self, rrset):
def delete_rrset(self, rrset):
"""
This one is part of pretending to be a zone updater. It writes down
removal of an rrset was requested.
"""
self.__data_operations.append(('remove', rrset))
self.__data_operations.append(('delete', rrset))
def get_class(self):
"""
......@@ -162,7 +162,7 @@ class DiffTest(unittest.TestCase):
def __data_common(self, diff, method, operation):
"""
Common part of test for test_add and test_remove.
Common part of test for test_add and test_delte.
"""
# Try putting there the bad data first
self.assertRaises(ValueError, method, self.__rrset_empty)
......@@ -188,7 +188,7 @@ class DiffTest(unittest.TestCase):
diff = Diff(self, Name('example.org.'))
self.__data_common(diff, diff.add_data, 'add')
def test_remove(self):
def test_delete(self):
"""
Try scheduling removal of few items into the diff and see they are
stored in there.
......@@ -196,7 +196,7 @@ class DiffTest(unittest.TestCase):
Also try passing an rrset that has different amount of RRs than 1.
"""
diff = Diff(self, Name('example.org.'))
self.__data_common(diff, diff.remove_data, 'remove')
self.__data_common(diff, diff.delete_data, 'delete')
def test_apply(self):
"""
......@@ -206,8 +206,8 @@ class DiffTest(unittest.TestCase):
# Prepare the diff
diff = Diff(self, Name('example.org.'))
diff.add_data(self.__rrset1)
diff.remove_data(self.__rrset2)
dlist = [('add', self.__rrset1), ('remove', self.__rrset2)]
diff.delete_data(self.__rrset2)
dlist = [('add', self.__rrset1), ('delete', self.__rrset2)]
self.assertEqual(dlist, diff.get_buffer())
# Do the apply, hook the compact method
diff.compact = self.__mock_compact
......@@ -241,7 +241,7 @@ class DiffTest(unittest.TestCase):
# Now check all range of other methods raise ValueError
self.assertRaises(ValueError, diff.commit)
self.assertRaises(ValueError, diff.add_data, self.__rrset2)
self.assertRaises(ValueError, diff.remove_data, self.__rrset1)
self.assertRaises(ValueError, diff.delete_data, self.__rrset1)
diff.apply = orig_apply
self.assertRaises(ValueError, diff.apply)
# This one does not state it should raise, so check it doesn't
......@@ -278,14 +278,14 @@ class DiffTest(unittest.TestCase):
# Reset the buffer by calling the original apply.
orig_apply()
self.assertEqual([], diff.get_buffer())
# Similar with remove
# Similar with delete
self.__apply_called = False
for i in range(0, 99):
diff.remove_data(self.__rrset2)
expected = [('remove', self.__rrset2)] * 99
diff.delete_data(self.__rrset2)
expected = [('delete', self.__rrset2)] * 99
self.assertEqual(expected, diff.get_buffer())
self.assertFalse(self.__apply_called)
diff.remove_data(self.__rrset2)
diff.delete_data(self.__rrset2)
self.assertTrue(self.__apply_called)
def test_compact(self):
......@@ -310,9 +310,9 @@ class DiffTest(unittest.TestCase):
# Different type.
('add', 'a', 'AAAA', ['2001:db8::1', '2001:db8::2']),
# Different operation
('remove', 'a', 'AAAA', ['2001:db8::3']),
('delete', 'a', 'AAAA', ['2001:db8::3']),
# Different domain
('remove', 'b', 'AAAA', ['2001:db8::4']),
('delete', 'b', 'AAAA', ['2001:db8::4']),
# This does not get merged with the first, even if logically
# possible. We just don't do this.
('add', 'a', 'A', ['192.0.2.3'])
......@@ -327,7 +327,7 @@ class DiffTest(unittest.TestCase):
if op == 'add':
diff.add_data(rrset)
else:
diff.remove_data(rrset)
diff.delete_data(rrset)
# Compact it
diff.compact()
# Now check they got compacted. They should be in the same order as
......@@ -363,7 +363,7 @@ class DiffTest(unittest.TestCase):
self.__ttl)
rrset.add_rdata(Rdata(RRType.NS(), RRClass.CH(), 'ns.example.org.'))
self.assertRaises(ValueError, diff.add_data, rrset)
self.assertRaises(ValueError, diff.remove_data, rrset)
self.assertRaises(ValueError, diff.delete_data, rrset)
def __do_raise_test(self):
"""
......@@ -372,11 +372,11 @@ class DiffTest(unittest.TestCase):
"""
diff = Diff(self, Name('example.org.'))
diff.add_data(self.__rrset1)
diff.remove_data(self.__rrset2)
diff.delete_data(self.__rrset2)
self.assertRaises(TestError, diff.commit)
self.assertTrue(self.__broken_called)
self.assertRaises(ValueError, diff.add_data, self.__rrset1)
self.assertRaises(ValueError, diff.remove_data, self.__rrset2)
self.assertRaises(ValueError, diff.delete_data, self.__rrset2)
self.assertRaises(ValueError, diff.commit)
self.assertRaises(ValueError, diff.apply)
......@@ -388,12 +388,12 @@ class DiffTest(unittest.TestCase):
self.add_rrset = self.__broken_operation
self.__do_raise_test()
def test_raise_remove(self):
def test_raise_delete(self):
"""
Test the exception from remove_rrset is propagated and the diff can't be
Test the exception from delete_rrset is propagated and the diff can't be
used afterwards.
"""
self.remove_rrset = self.__broken_operation
self.delete_rrset = self.__broken_operation
self.__do_raise_test()
def test_raise_commit(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment