diff --git a/configure.ac b/configure.ac index 3f7a269b19..614cde6c79 100644 --- a/configure.ac +++ b/configure.ac @@ -1176,6 +1176,7 @@ AC_CONFIG_FILES([Makefile src/bin/dbutil/tests/Makefile src/bin/dbutil/tests/testdata/Makefile src/bin/loadzone/Makefile + src/bin/loadzone/tests/Makefile src/bin/loadzone/tests/correct/Makefile src/bin/loadzone/tests/error/Makefile src/bin/msgq/Makefile @@ -1352,6 +1353,7 @@ AC_OUTPUT([doc/version.ent src/bin/loadzone/tests/correct/correct_test.sh src/bin/loadzone/tests/error/error_test.sh src/bin/loadzone/b10-loadzone.py + src/bin/loadzone/loadzone.py src/bin/usermgr/run_b10-cmdctl-usermgr.sh src/bin/usermgr/b10-cmdctl-usermgr.py src/bin/msgq/msgq.py diff --git a/src/bin/loadzone/Makefile.am b/src/bin/loadzone/Makefile.am index 790f75722f..65d2008ab3 100644 --- a/src/bin/loadzone/Makefile.am +++ b/src/bin/loadzone/Makefile.am @@ -1,8 +1,13 @@ -SUBDIRS = . tests/correct tests/error +#SUBDIRS = . tests/correct tests/error <= TBD: clean this up later +SUBDIRS = . tests bin_SCRIPTS = b10-loadzone +# tentative setup: clean this up: +bin_SCRIPTS += b10-loadzone-ng noinst_SCRIPTS = run_loadzone.sh CLEANFILES = b10-loadzone +# tentative setup: clean this up: +CLEANFILES += b10-loadzone-ng man_MANS = b10-loadzone.8 DISTCLEANFILES = $(man_MANS) @@ -27,6 +32,11 @@ b10-loadzone: b10-loadzone.py -e "s|@@LIBEXECDIR@@|$(pkglibexecdir)|" b10-loadzone.py >$@ chmod a+x $@ +# tentatively named "-ng". +b10-loadzone-ng: loadzone.py + $(SED) -e "s|@@PYTHONPATH@@|@pyexecdir@|" loadzone.py >$@ + chmod a+x $@ + EXTRA_DIST += tests/normal/README EXTRA_DIST += tests/normal/dsset-subzone.example.com EXTRA_DIST += tests/normal/example.com diff --git a/src/bin/loadzone/loadzone.py.in b/src/bin/loadzone/loadzone.py.in new file mode 100755 index 0000000000..8376acd8d9 --- /dev/null +++ b/src/bin/loadzone/loadzone.py.in @@ -0,0 +1,52 @@ +#!@PYTHON@ + +# Copyright (C) 2012 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. + +import sys +sys.path.append('@@PYTHONPATH@@') +from optparse import OptionParser +import isc.log + +isc.log.init("b10-loadzone", buffer=True) +logger = isc.log.Logger("loadzone") + +def set_cmd_options(parser): + '''Helper function to set command-line options. + + ''' + parser.add_option("-v", "--verbose", dest="verbose", action="store_true", + help="display more about what is going on") + +class LoadZoneRunner: + '''TBD + + ''' + def __init__(self, command_args): + usage_txt = 'usage: %prog [options] zonename zonefile' + parser = OptionParser(usage=usage_txt) + set_cmd_options(parser) + (options, args) = parser.parse_args(args=command_args) + + def run(self): + pass + +if '__main__' == __name__: + runner = LoadZoneRunner(sys.argv[1:]) + runner.run() + +## Local Variables: +## mode: python +## End: diff --git a/src/bin/loadzone/tests/Makefile.am b/src/bin/loadzone/tests/Makefile.am new file mode 100644 index 0000000000..419704f950 --- /dev/null +++ b/src/bin/loadzone/tests/Makefile.am @@ -0,0 +1,25 @@ +PYCOVERAGE_RUN=@PYCOVERAGE_RUN@ +PYTESTS = loadzone_test.py +EXTRA_DIST = $(PYTESTS) + +# If necessary (rare cases), explicitly specify paths to dynamic libraries +# required by loadable python modules. +LIBRARY_PATH_PLACEHOLDER = +if SET_ENV_LIBRARY_PATH +LIBRARY_PATH_PLACEHOLDER += $(ENV_LIBRARY_PATH)=$(abs_top_builddir)/src/lib/cryptolink/.libs:$(abs_top_builddir)/src/lib/dns/.libs:$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/lib/cc/.libs:$(abs_top_builddir)/src/lib/config/.libs:$(abs_top_builddir)/src/lib/log/.libs:$(abs_top_builddir)/src/lib/util/.libs:$(abs_top_builddir)/src/lib/exceptions/.libs:$(abs_top_builddir)/src/lib/util/io/.libs:$(abs_top_builddir)/src/lib/datasrc/.libs:$(abs_top_builddir)/src/lib/acl/.libs:$$$(ENV_LIBRARY_PATH) +endif + +# test using command-line arguments, so use check-local target instead of TESTS +check-local: +if ENABLE_PYTHON_COVERAGE + touch $(abs_top_srcdir)/.coverage + rm -f .coverage + ${LN_S} $(abs_top_srcdir)/.coverage .coverage +endif + for pytest in $(PYTESTS) ; do \ + echo Running test: $$pytest ; \ + B10_FROM_SOURCE=$(abs_top_srcdir) \ + $(LIBRARY_PATH_PLACEHOLDER) \ + PYTHONPATH=$(COMMON_PYTHON_PATH):$(abs_top_builddir)/src/bin/loadzone:$(abs_top_builddir)/src/lib/dns/python/.libs:$(abs_top_builddir)/src/lib/util/io/.libs \ + $(PYCOVERAGE_RUN) $(abs_srcdir)/$$pytest || exit ; \ + done diff --git a/src/bin/loadzone/tests/loadzone_test.py b/src/bin/loadzone/tests/loadzone_test.py new file mode 100755 index 0000000000..c6f81815a9 --- /dev/null +++ b/src/bin/loadzone/tests/loadzone_test.py @@ -0,0 +1,38 @@ +# Copyright (C) 2012 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. + +'''Tests for the loadzone module''' + +import unittest +from loadzone import * +import isc.log + +class TestLoadZoneRunner(unittest.TestCase): + def setUp(self): + pass + + def tearDown(self): + pass + + def test_dummy(self): + ''' + Test the old socket file is removed (if any) and a new socket + is created when the ddns server is created. + ''' + runner = LoadZoneRunner(['-h', 'example.org', 'example.zone']) + +if __name__== "__main__": + isc.log.resetUnitTestRootLogger() + unittest.main()