Exemplo n.º 1
0
        def __init__(self, imgroot, pubdir):
                self.__imgroot = imgroot
                self.__pubdir = pubdir
                self.__publishers = {}
                self.__publisher_search_order = []

                self.properties = dict((
                    (p, str(v))
                    for p, v in default_policies.iteritems()
                ))
                self.facets = facet.Facets()
                self.variants = variant.Variants()
                self.children = []
Exemplo n.º 2
0
    def test_get_directories(self):
        """Verifies that get_directories() works as expected."""

        v = variant.Variants({"variant.arch": "sparc"})
        vexcludes = [v.allow_action, lambda x, publisher: True]

        f = facet.Facets({"facet.test": False})
        fexcludes = [lambda x, publisher: True, f.allow_action]

        m1 = manifest.FactoredManifest("[email protected]",
                                       self.cache_dir,
                                       pathname=self.foo_content_p5m)

        all_expected = [
            "fdm", "fm", "vdo", "vo", "test", "opt/dir with spaces in value",
            "opt", "usr/bin", "opt/dir with whitespaces   in value", "usr"
        ]

        var_expected = [
            "fdm", "fm", "opt/dir with spaces in value", "opt", "test"
        ]

        facet_expected = [
            "fm", "vdo", "vo", "opt/dir with spaces in value", "opt",
            "usr/bin", "opt/dir with whitespaces   in value", "usr"
        ]

        def do_get_dirs():
            actual = m1.get_directories([])
            self.assertEqualDiff(sorted(all_expected), sorted(actual))

            actual = m1.get_directories(vexcludes)
            self.assertEqualDiff(sorted(var_expected), sorted(actual))

            actual = m1.get_directories(fexcludes)
            self.assertEqualDiff(sorted(facet_expected), sorted(actual))

        # Verify get_directories works for initial load.
        do_get_dirs()

        # Now repeat experiment using "cached" FactoredManifest.
        cfile_path = os.path.join(self.cache_dir, "manifest.dircache")
        self.assertTrue(os.path.isfile(cfile_path))
        m1 = manifest.FactoredManifest("[email protected]",
                                       self.cache_dir,
                                       pathname=self.foo_content_p5m)

        do_get_dirs()

        # Now rewrite the dircache so that it contains actions with
        # paths that are not properly quoted to simulate older, broken
        # behaviour and verify that the cache will be removed and that
        # get_directories() still works as expected.
        m1 = manifest.FactoredManifest("[email protected]",
                                       self.cache_dir,
                                       pathname=self.foo_content_p5m)

        with open(cfile_path, "w") as f:
            for a in m1.gen_actions_by_type("dir"):
                f.write("dir path={0} {1}\n".format(
                    a.attrs["path"], " ".join(
                        "{0}={1}".format(attr, a.attrs[attr])
                        for attr in itertools.chain(*a.get_varcet_keys()))))

        # Repeat tests again.
        do_get_dirs()

        # Verify cache file was removed (presumably because we
        # detected it was malformed).
        self.assertTrue(not os.path.exists(cfile_path))

        # Repeat tests again, verifying cache file is recreated.
        m1 = manifest.FactoredManifest("[email protected]",
                                       self.cache_dir,
                                       pathname=self.foo_content_p5m)
        do_get_dirs()
        self.assertTrue(os.path.isfile(cfile_path))
Exemplo n.º 3
0
    def test_reset(self):
        """ Send empty package [email protected], install and uninstall """

        self.pkgsend_bulk(self.rurl, self.foo10)
        api_obj = self.image_create(self.rurl, prefix="bobcat")

        facets = facet.Facets({"facet.devel": True})
        for pd in api_obj.gen_plan_change_varcets(facets=facets):
            continue
        self._api_finish(api_obj)

        for pd in api_obj.gen_plan_install(["foo"]):
            continue
        self.assertTrue(api_obj.describe() is not None)
        api_obj.reset()
        self.assertTrue(api_obj.describe() is None)
        for pd in api_obj.gen_plan_install(["foo"]):
            continue
        self.assertTrue(api_obj.describe() is not None)
        api_obj.prepare()
        api_obj.reset()
        self.assertTrue(api_obj.describe() is None)
        for pd in api_obj.gen_plan_install(["foo"]):
            continue
        self.assertTrue(api_obj.describe() is not None)
        api_obj.prepare()
        api_obj.execute_plan()
        api_obj.reset()
        self.assertTrue(api_obj.describe() is None)

        self.pkg("list")
        self.pkg("verify")

        self.pkgsend_bulk(self.rurl, self.foo12)
        api_obj.refresh(immediate=True)

        for pd in api_obj.gen_plan_update():
            continue
        self.assertTrue(api_obj.describe() is not None)
        api_obj.reset()
        self.assertTrue(api_obj.describe() is None)
        for pd in api_obj.gen_plan_update():
            continue
        self.assertTrue(api_obj.describe() is not None)
        api_obj.prepare()
        api_obj.reset()
        self.assertTrue(api_obj.describe() is None)
        for pd in api_obj.gen_plan_update():
            continue
        self.assertTrue(api_obj.describe() is not None)
        api_obj.prepare()
        api_obj.execute_plan()
        api_obj.reset()
        self.assertTrue(api_obj.describe() is None)

        self.pkg("list")
        self.pkg("verify")

        for pd in api_obj.gen_plan_uninstall(["foo"]):
            continue
        self.assertTrue(api_obj.describe() is not None)
        api_obj.reset()
        self.assertTrue(api_obj.describe() is None)
        for pd in api_obj.gen_plan_uninstall(["foo"]):
            continue
        self.assertTrue(api_obj.describe() is not None)
        api_obj.prepare()
        api_obj.reset()
        self.assertTrue(api_obj.describe() is None)
        for pd in api_obj.gen_plan_uninstall(["foo"]):
            continue
        self.assertTrue(api_obj.describe() is not None)
        api_obj.prepare()
        api_obj.execute_plan()
        api_obj.reset()
        self.assertTrue(api_obj.describe() is None)

        self.pkg("verify")