← Back to team overview

cloud-init-dev team mailing list archive

Re: [Merge] ~chad.smith/cloud-init:config-modules-allow-distros-all into cloud-init:master

 


Diff comments:

> diff --git a/tests/unittests/test_runs/test_simple_run.py b/tests/unittests/test_runs/test_simple_run.py
> index 5cf666f..a8a2032 100644
> --- a/tests/unittests/test_runs/test_simple_run.py
> +++ b/tests/unittests/test_runs/test_simple_run.py
> @@ -63,5 +75,86 @@ class TestSimpleRun(helpers.FilesystemMockingTestCase):
>          self.assertIn('write-files', which_ran)
>          contents = util.load_file('/etc/blah.ini')
>          self.assertEqual(contents, 'blah')
> +        self.assertNotIn(
> +            "Skipping modules ['write-files'] because they are not verified on"
> +            " distro 'ubuntu'",
> +            self.logs.getvalue())
> +
> +    def test_none_ds_skips_modules_which_define_unmatched_distros(self):
> +        """Skip modules which define distros which don't match the current."""
> +        initer = stages.Init()
> +        initer.read_cfg()
> +        initer.initialize()
> +        initer.fetch()
> +        initer.instancify()
> +        initer.update()
> +        initer.cloudify().run('consume_data',
> +                              initer.consume_data,
> +                              args=[PER_INSTANCE],
> +                              freq=PER_INSTANCE)
> +
> +        mods = stages.Modules(initer)
> +        (which_ran, failures) = mods.run_section('cloud_init_modules')
> +        self.assertTrue(len(failures) == 0)
> +        self.assertIn(
> +            "Skipping modules 'spacewalk' because they are not verified on"
> +            " distro 'ubuntu'",
> +            self.logs.getvalue())
> +        self.assertNotIn('spacewalk', which_ran)
> +
> +    def test_none_ds_runs_modules_which_distros_all(self):
> +        """Skip modules which define distros attribute as supporting 'all'.
> +
> +        This is done in the module with the declaration:
> +        distros = [CONFIG_MODULE_SUPPORT_ALL_DISTROS]. runcmd is an example.
> +        """
> +        initer = stages.Init()
> +        initer.read_cfg()
> +        initer.initialize()
> +        initer.fetch()
> +        initer.instancify()
> +        initer.update()
> +        initer.cloudify().run('consume_data',
> +                              initer.consume_data,
> +                              args=[PER_INSTANCE],
> +                              freq=PER_INSTANCE)
> +
> +        mods = stages.Modules(initer)
> +        (which_ran, failures) = mods.run_section('cloud_init_modules')
> +        self.assertTrue(len(failures) == 0)
> +        self.assertIn('runcmd', which_ran)
> +        self.assertNotIn(
> +            "Skipping modules 'runcmd' because they are not verified on"
> +            " distro 'ubuntu'",
> +            self.logs.getvalue())
> +
> +    def test_none_ds_forces_run_via_unverified_modules(self):
> +        """run_section forced skipped modules by using unverified_modules."""
> +
> +        # re-write cloud.cfg with unverified_modules override
> +        self.cfg['unverified_modules'] = ['spacewalk']  # Would have skipped
> +        cloud_cfg = util.yaml_dumps(self.cfg)
> +        util.ensure_dir(os.path.join(self.new_root, 'etc', 'cloud'))
> +        util.write_file(os.path.join(self.new_root, 'etc',
> +                                     'cloud', 'cloud.cfg'), cloud_cfg)
> +
> +        initer = stages.Init()
> +        initer.read_cfg()
> +        initer.initialize()
> +        initer.fetch()
> +        initer.instancify()
> +        initer.update()
> +        initer.cloudify().run('consume_data',

fixed.

> +                              initer.consume_data,
> +                              args=[PER_INSTANCE],
> +                              freq=PER_INSTANCE)
> +
> +        mods = stages.Modules(initer)
> +        (which_ran, failures) = mods.run_section('cloud_init_modules')
> +        self.assertTrue(len(failures) == 0)
> +        self.assertIn('spacewalk', which_ran)
> +        self.assertIn(
> +            "running unverified_modules: 'spacewalk'",
> +            self.logs.getvalue())
>  
>  # vi: ts=4 expandtab


-- 
https://code.launchpad.net/~chad.smith/cloud-init/+git/cloud-init/+merge/330384
Your team cloud-init commiters is requested to review the proposed merge of ~chad.smith/cloud-init:config-modules-allow-distros-all into cloud-init:master.