From 6a5f9082698f51e041c8932ddac10595d4301a1a Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Tue, 11 Feb 2014 21:17:19 +0100 Subject: [PATCH 1/5] yep, dryrun option has now a unittest, was hard to work out ... --- cdist/test/config/__init__.py | 17 +++++++++++++++++ .../config/fixtures/manifest/dryrun_manifest | 1 + .../config/fixtures/type/__dryrun_test/.keep | 0 .../fixtures/type/__dryrun_test/gencode-local | 3 +++ .../fixtures/type/__dryrun_test/gencode-remote | 3 +++ 5 files changed, 24 insertions(+) create mode 100644 cdist/test/config/fixtures/manifest/dryrun_manifest create mode 100644 cdist/test/config/fixtures/type/__dryrun_test/.keep create mode 100644 cdist/test/config/fixtures/type/__dryrun_test/gencode-local create mode 100644 cdist/test/config/fixtures/type/__dryrun_test/gencode-remote diff --git a/cdist/test/config/__init__.py b/cdist/test/config/__init__.py index 80a45d9b..70501c89 100644 --- a/cdist/test/config/__init__.py +++ b/cdist/test/config/__init__.py @@ -2,6 +2,7 @@ # # 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -137,6 +138,22 @@ class ConfigRunTestCase(test.CdistTestCase): with self.assertRaises(cdist.core.cdist_object.MissingObjectIdError): self.config.iterate_until_finished() + + def test_dryrun(self): + """Test if the dryrun option is working like expected""" + drylocal = cdist.exec.local.Local( + target_host=self.target_host, + base_path=self.local_dir, + #exec_path can not derivated from sys.argv in case of unittest ... + exec_path=os.path.abspath(os.path.join(my_dir,'../../../scripts/cdist')), + initial_manifest=os.path.join(fixtures, 'manifest/dryrun_manifest'), + add_conf_dirs=[ fixtures ] ) + + dryrun = cdist.config.Config(drylocal, self.remote, dry_run=True) + dryrun.run() + # if we are here, dryrun works like expected + + # Currently the resolving code will simply detect that this object does # not exist. It should probably check if the type is a singleton as well # - but maybe only in the emulator - to be discussed. diff --git a/cdist/test/config/fixtures/manifest/dryrun_manifest b/cdist/test/config/fixtures/manifest/dryrun_manifest new file mode 100644 index 00000000..53bb9aa5 --- /dev/null +++ b/cdist/test/config/fixtures/manifest/dryrun_manifest @@ -0,0 +1 @@ +__dryrun_test testit diff --git a/cdist/test/config/fixtures/type/__dryrun_test/.keep b/cdist/test/config/fixtures/type/__dryrun_test/.keep new file mode 100644 index 00000000..e69de29b diff --git a/cdist/test/config/fixtures/type/__dryrun_test/gencode-local b/cdist/test/config/fixtures/type/__dryrun_test/gencode-local new file mode 100644 index 00000000..ccd584bd --- /dev/null +++ b/cdist/test/config/fixtures/type/__dryrun_test/gencode-local @@ -0,0 +1,3 @@ +# this type is only for testing the dryrun feature, it does nothing usefull +echo 'echo "This gencode-local script should never be executed >&2"' +echo 'exit 1' diff --git a/cdist/test/config/fixtures/type/__dryrun_test/gencode-remote b/cdist/test/config/fixtures/type/__dryrun_test/gencode-remote new file mode 100644 index 00000000..e57e4e27 --- /dev/null +++ b/cdist/test/config/fixtures/type/__dryrun_test/gencode-remote @@ -0,0 +1,3 @@ +# this type is only for testing the dryrun feature, it does nothing usefull +echo 'echo "this gencode-remote script should never be executed >&2"' +echo 'exit 1' From 9ce3809eb37ec5c2d259f878aeb8ff2d0459e107 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 11 Feb 2014 22:31:30 +0100 Subject: [PATCH 2/5] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index 6aef1891..33b22f5b 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,8 @@ Changelog 3.0.8: * Core: Enhance object id verification (Daniel Heule) + * Core: Add unit tests for dependencies based on execution order (Daniel Heule) + * Core: Add unit tests for dry run (Daniel Heule) 3.0.7: 2014-02-08 * Core: Allow dependencies to be created based execution order (Daniel Heule) From e3464bef1b0499e19027772097a17b437aadcdb7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 11 Feb 2014 22:46:25 +0100 Subject: [PATCH 3/5] release 3.0.8 Signed-off-by: Nico Schottelius --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 33b22f5b..53df9fa7 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,7 +5,7 @@ Changelog * Exception: No braces means author == Nico Schottelius -3.0.8: +3.0.8: 2014-02-11 * Core: Enhance object id verification (Daniel Heule) * Core: Add unit tests for dependencies based on execution order (Daniel Heule) * Core: Add unit tests for dry run (Daniel Heule) From 23f85118f5bae462d0f1c1776dcc17650295b17c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 12 Feb 2014 16:42:02 +0100 Subject: [PATCH 4/5] add a hint about unsupported os Signed-off-by: Nico Schottelius --- cdist/conf/type/__locale/man.text | 4 ++-- cdist/conf/type/__locale/manifest | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__locale/man.text b/cdist/conf/type/__locale/man.text index f76c2059..5ccd3eab 100644 --- a/cdist/conf/type/__locale/man.text +++ b/cdist/conf/type/__locale/man.text @@ -16,7 +16,7 @@ This cdist type allows you to setup locales. OPTIONAL PARAMETERS ------------------- state:: - 'present' or 'absent' + 'present' or 'absent', defaults to present EXAMPLES @@ -43,5 +43,5 @@ SEE ALSO COPYING ------- -Copyright \(C) 2013 Nico Schottelius. Free use of this software is +Copyright \(C) 2013-2014 Nico Schottelius. Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__locale/manifest b/cdist/conf/type/__locale/manifest index 5dd5fd8f..f3d75d59 100644 --- a/cdist/conf/type/__locale/manifest +++ b/cdist/conf/type/__locale/manifest @@ -1,6 +1,6 @@ #!/bin/sh # -# 2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2013-2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -29,4 +29,9 @@ case "$os" in # Debian needs a seperate package __package locales --state present ;; + *) + echo "Sorry, do not know how to handle os: $os" >&2 + echo "Please edit the type ${__type##*/} to fix this." >&2 + exit 1 + ;; esac From c615a822129c992df3198682388f42742ef5e659 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 12 Feb 2014 16:42:39 +0100 Subject: [PATCH 5/5] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 53df9fa7..2ebd08e8 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,9 @@ Changelog * Exception: No braces means author == Nico Schottelius +3.0.9: + * Type __locale: Error out in case of unsupported OS + 3.0.8: 2014-02-11 * Core: Enhance object id verification (Daniel Heule) * Core: Add unit tests for dependencies based on execution order (Daniel Heule)