5a580c3a38ced62d4bcc95b8ac7c4f2935b5d294Timo Sirainen#!/usr/bin/python
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen#
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# CDDL HEADER START
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen#
ffd9a1898a18fadfc5dce399162c25d50548f905Timo Sirainen# The contents of this file are subject to the terms of the
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# Common Development and Distribution License (the "License").
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# You may not use this file except in compliance with the License.
a2f250a332dfc1e6cd4ffd196c621eb9dbf7b8a1Timo Sirainen#
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
5806683c1c3f5b1997e92a023c0fe39912d4df5dTimo Sirainen# or http://www.opensolaris.org/os/licensing.
5806683c1c3f5b1997e92a023c0fe39912d4df5dTimo Sirainen# See the License for the specific language governing permissions
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# and limitations under the License.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen#
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# When distributing Covered Code, include this CDDL HEADER in each
8e361d2906b0e44f7175a20981f8d2280645b58bTimo Sirainen# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# If applicable, add the following below this CDDL HEADER, with the
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# fields enclosed by brackets "[]" replaced with your own identifying
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# information: Portions Copyright [yyyy] [name of copyright owner]
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen#
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# CDDL HEADER END
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen#
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
221351ed85c839e0b03d82c47654c3d17202e3dbTimo Sirainenfrom . import testutils
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenif __name__ == "__main__":
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen testutils.setup_environment("../../../proto")
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenimport pkg5unittest
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenimport os
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenimport errno
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenimport shutil
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenimport unittest
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainenclass TestPkgChangeFacet(pkg5unittest.SingleDepotTestCase):
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # Only start/stop the depot once (instead of for every test)
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen persistent_setup = True
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen pkg_A = """
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen open pkg_A@1.0,5.11-0
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/facets_0 mode=0555 owner=root group=bin path=0
7ded22760598b78ee29f9418eacc0abe3fb51055Timo Sirainen add file tmp/facets_1 mode=0555 owner=root group=bin path=1 facet.locale.fr=True
7ded22760598b78ee29f9418eacc0abe3fb51055Timo Sirainen add file tmp/facets_2 mode=0555 owner=root group=bin path=2 facet.locale.fr_FR=True
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/facets_3 mode=0555 owner=root group=bin path=3 facet.locale.fr_CA=True
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen add file tmp/facets_4 mode=0555 owner=root group=bin path=4 facet.locale.fr_CA=True facet.locale.nl_ZA=True
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen add file tmp/facets_5 mode=0555 owner=root group=bin path=5 facet.locale.nl=True
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen add file tmp/facets_6 mode=0555 owner=root group=bin path=6 facet.locale.nl_NA=True
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen add file tmp/facets_7 mode=0555 owner=root group=bin path=7 facet.locale.nl_ZA=True
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen add file tmp/facets_8 mode=0555 owner=root group=bin path=8 facet.has/some/slashes=true
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen add file tmp/facets_9 mode=0555 owner=root group=bin path=debug facet.debug.foo=True
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen add link path=test target=1
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen close"""
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen
7ded22760598b78ee29f9418eacc0abe3fb51055Timo Sirainen pkg_B1 = """
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen open pkg_B@1.0,5.11-0
7ded22760598b78ee29f9418eacc0abe3fb51055Timo Sirainen close"""
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen pkg_B2 = """
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen open pkg_B@2.0,5.11-0
8ababf3e7b15f793370d1dedf85825d38b42633fTimo Sirainen close"""
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainen
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainen # All 'all's must be true AND any 'true's true.
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainen pkg_top_level = """
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainen open pkg_top_level@1.0,5.11-0
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainen add file tmp/facets_0 mode=0555 owner=root group=bin path=top0 facet.devel=all
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/facets_1 mode=0555 owner=root group=bin path=top1 facet.doc=all
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen add file tmp/facets_2 mode=0555 owner=root group=bin path=top2 facet.devel=all facet.doc=all
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen add file tmp/facets_3 mode=0555 owner=root group=bin path=top3 facet.doc=all facet.locale.fr_CA=true
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen add file tmp/facets_4 mode=0555 owner=root group=bin path=top4 facet.doc=all facet.locale.fr_CA=true facet.locale.nl_ZA=true
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/facets_5 mode=0555 owner=root group=bin path=top5 facet.devel=all facet.doc=all facet.locale.fr_CA=true facet.locale.nl_ZA=true
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/facets_6 mode=0555 owner=root group=bin path=top0.debug facet.devel=all facet.debug.top=all
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen add file tmp/facets_7 mode=0555 owner=root group=bin path=optional.doc facet.optional.doc=all facet.doc=true
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen add file tmp/facets_8 mode=0555 owner=root group=bin path=optional_fr.doc facet.optional.doc=all facet.doc=all facet.locale.fr_CA=true
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen close"""
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen misc_files = [
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen "tmp/facets_0", "tmp/facets_1", "tmp/facets_2", "tmp/facets_3",
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen "tmp/facets_4", "tmp/facets_5", "tmp/facets_6", "tmp/facets_7",
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen "tmp/facets_8", "tmp/facets_9"
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen ]
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen def setUp(self):
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen pkg5unittest.SingleDepotTestCase.setUp(self)
cfa9359fbd6a967ccdcd553c5e483a093885ab6fTimo Sirainen self.make_misc_files(self.misc_files)
8ababf3e7b15f793370d1dedf85825d38b42633fTimo Sirainen self.plist = self.pkgsend_bulk(self.rurl, (self.pkg_A,
8ababf3e7b15f793370d1dedf85825d38b42633fTimo Sirainen self.pkg_top_level))
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen self.plist_B = self.pkgsend_bulk(self.rurl,
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen [self.pkg_B1, self.pkg_B2])
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen def assert_files_exist(self, flist):
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen error = ""
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen for (path, exist) in flist:
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen file_path = os.path.join(self.get_img_path(), path)
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen try:
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen self.assert_file_is_there(file_path,
3675a7e9bd3775ba13fe8bc93915902513a0f1a4Timo Sirainen negate=not exist)
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen except AssertionError as e:
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen error += "\n{0}".format(e)
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen if error:
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen raise AssertionError(error)
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen def assert_file_is_there(self, path, negate=False):
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen """Verify that the specified path exists. If negate is true,
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen then make sure the path doesn't exist"""
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen file_path = os.path.join(self.get_img_path(), str(path))
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen try:
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen open(file_path).close()
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen except IOError as e:
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen if e.errno == errno.ENOENT and negate:
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen return
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assertTrue(False, "File {0} is missing".format(path))
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # file is there
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen if negate:
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assertTrue(False, "File {0} should not exist".format(path))
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen return
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen def test_01_facets(self):
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # create an image w/ locales set
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen ic_args = "";
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen ic_args += " --facet 'facet.locale*=False' "
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen ic_args += " --facet 'facet.locale.fr*=True' "
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen ic_args += " --facet 'facet.locale.fr_CA=False' "
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.pkg_image_create(self.rurl, additional_args=ic_args)
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.pkg("facet")
8ababf3e7b15f793370d1dedf85825d38b42633fTimo Sirainen self.pkg("facet -H -F tsv 'facet.locale*' | egrep False")
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # install a package and verify
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen alist = [self.plist[0]]
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.pkg("install --parsable=0 pkg_A")
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assertEqualParsable(self.output, add_packages=alist)
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.pkg("verify")
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.pkg("facet")
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # make sure it delivers its files as appropriate
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assert_file_is_there("0")
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assert_file_is_there("1")
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assert_file_is_there("2")
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assert_file_is_there("3", negate=True)
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assert_file_is_there("4", negate=True)
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assert_file_is_there("5", negate=True)
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assert_file_is_there("6", negate=True)
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assert_file_is_there("7", negate=True)
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assert_file_is_there("8")
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assert_file_is_there("debug", negate=True)
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # Verify that effective value is shown for facets that are
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # always implicity false such as debug / optional.
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.pkg("facet -H -F tsv debug.top optional.doc")
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assertEqual(
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen "facet.debug.top\tFalse\tsystem\n"
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen "facet.optional.doc\tFalse\tsystem\n",
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.output
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen )
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # notice that a file should not exist according to its facet
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen open(os.path.join(self.get_img_path(), "3"), "w").close()
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.pkg("verify", exit=1)
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen os.remove(os.path.join(self.get_img_path(), "3"))
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen # verify that a non-existent facet can be set when other facets
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen # are in effect
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen self.pkg("change-facet -n --parsable=0 wombat=false")
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen self.assertEqualParsable(self.output,
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen affect_packages=[],
a2aa37d224a70b2eccc00691d2893e09f107d7ccTimo Sirainen change_facets=[["facet.wombat", False, None, 'local',
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen False, False]])
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen # Again, but this time after removing the publisher cache data
4ad29660779873d7955151eb4568d132a32e9d9cTimo Sirainen # and as an unprivileged user to verify that cached manifest
4a01681e0ed9a7b3f7a105dd2fcd2511e7160e99Timo Sirainen # data doesn't affect operation.
4a01681e0ed9a7b3f7a105dd2fcd2511e7160e99Timo Sirainen cache_dir = os.path.join(self.get_img_api_obj().img.imgdir,
4a01681e0ed9a7b3f7a105dd2fcd2511e7160e99Timo Sirainen "cache", "publisher")
4a01681e0ed9a7b3f7a105dd2fcd2511e7160e99Timo Sirainen shutil.rmtree(cache_dir)
4a01681e0ed9a7b3f7a105dd2fcd2511e7160e99Timo Sirainen self.pkg("change-facet --no-refresh -n --parsable=0 "
4a01681e0ed9a7b3f7a105dd2fcd2511e7160e99Timo Sirainen "wombat=false", su_wrap=True)
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assertEqualParsable(self.output,
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen affect_packages=[],
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen change_facets=[["facet.wombat", False, None, 'local',
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen False, False]])
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # Again, but this time after removing the cache directory
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen # entirely.
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen cache_dir = os.path.join(self.get_img_api_obj().img.imgdir,
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen "cache")
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen shutil.rmtree(cache_dir)
9573f4283f9118315b0865998d43223fedee0246Timo Sirainen self.pkg("change-facet --no-refresh -n --parsable=0 "
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen "wombat=false", su_wrap=True)
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen self.assertEqualParsable(self.output,
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen affect_packages=[],
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen change_facets=[["facet.wombat", False, None, 'local',
6c9699d37fbe4d8af3682ee7f341ede8d54faa87Timo Sirainen False, False]])
6c9699d37fbe4d8af3682ee7f341ede8d54faa87Timo Sirainen
6c9699d37fbe4d8af3682ee7f341ede8d54faa87Timo Sirainen # change to pick up another file w/ two tags and test the
6c9699d37fbe4d8af3682ee7f341ede8d54faa87Timo Sirainen # parsable output
6c9699d37fbe4d8af3682ee7f341ede8d54faa87Timo Sirainen self.pkg("change-facet --parsable=0 facet.locale.nl_ZA=True")
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assertEqualParsable(self.output,
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen affect_packages=alist,
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen change_facets=[["facet.locale.nl_ZA", True, None, 'local',
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen False, False]])
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.pkg("verify")
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.pkg("facet")
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assert_file_is_there("0")
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assert_file_is_there("1")
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assert_file_is_there("2")
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assert_file_is_there("3", negate=True)
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assert_file_is_there("4")
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assert_file_is_there("5", negate=True)
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assert_file_is_there("6", negate=True)
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assert_file_is_there("7")
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.assert_file_is_there("8")
4a01681e0ed9a7b3f7a105dd2fcd2511e7160e99Timo Sirainen self.assert_file_is_there("debug", negate=True)
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen # remove all the facets
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen self.pkg("change-facet --parsable=0 facet.locale*=None "
eb958701f57066bce9cc8bbf9df73616bd322d09Timo Sirainen "'facet.locale.fr*'=None facet.locale.fr_CA=None")
ed50658501d9ae8c85f6264831056b1debed11c3Timo Sirainen self.assertEqualParsable(self.output,
ed50658501d9ae8c85f6264831056b1debed11c3Timo Sirainen affect_packages=alist,
ed50658501d9ae8c85f6264831056b1debed11c3Timo Sirainen change_facets=[
ed50658501d9ae8c85f6264831056b1debed11c3Timo Sirainen ["facet.locale*", None, False, 'local', False, False],
ed50658501d9ae8c85f6264831056b1debed11c3Timo Sirainen ["facet.locale.fr*", None, True, 'local', False,
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen False],
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen ["facet.locale.fr_CA", None, False, 'local', False,
746d35bf3dba3ae5ddbcecb9732f60d5e9de77efTimo Sirainen False]
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen ])
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("verify")
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen for i in range(8):
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.assert_file_is_there("{0:d}".format(i))
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # zap all the locales
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("change-facet -v facet.locale*=False facet.locale.nl_ZA=None")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("verify")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("facet")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen for i in range(8):
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.assert_file_is_there("{0:d}".format(i), negate=(i != 0))
c59ce1887df061441a31f8243c730d4ec6a62a07Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # Verify that effective value is shown for facets that are
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # implicity false due to wildcards whether they're known to the
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # system through packages or not.
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("facet -H -F tsv facet.locale.fr facet.locale.nl_ZA")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.assertEqual(
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen "facet.locale.fr\tFalse\tlocal\n"
1d3f7c1278168d5b1cbfa9a2cc9929a0909056b4Timo Sirainen "facet.locale.nl_ZA\tFalse\tlocal\n",
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.output
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen )
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # Verify that an action with multiple facets will be installed
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # if at least one is implicitly true even when the first facet
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # evaluated matches an explicit wildcard facet set to false.
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # This test relies on Python iterating over the action
b0be0bead3d6963149f7f2a9504b8ab5aced9af5Timo Sirainen # attributes dictionary such that facet.locale.nl_ZA is
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # evaluated first. (There's no way to influence that and the
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # order seems 100% consistent for now.)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("change-facet --parsable=0 'facet.locale*=None' "
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen "'facet.locale.*=false' facet.locale.fr_CA=true");
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.assertEqualParsable(self.output,
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen affect_packages=alist,
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen change_facets=[
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen ["facet.locale*", None, False, 'local', False, False],
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen ["facet.locale.*", False, None, 'local', False, False],
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen ["facet.locale.fr_CA", True, None, 'local', False,
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen False]
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen ])
0f66f12eb4cdbf47670975044c88d8f388bf92dfTimo Sirainen self.assert_file_is_there("4")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen # This test is merely here so that if the evaluation order is
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen # reversed for some reason that expected results are still seen.
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("change-facet --parsable=0 'facet.locale.*=None' "
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen "facet.locale.fr_*=false facet.locale.fr_CA=None");
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assertEqualParsable(self.output,
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen affect_packages=alist,
a2f250a332dfc1e6cd4ffd196c621eb9dbf7b8a1Timo Sirainen change_facets=[
7de1c472fd23ddac6b4dc5cbeee6fa6a8418b071Timo Sirainen ["facet.locale.*", None, False, 'local', False, False],
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen ["facet.locale.fr_*", False, None, 'local', False,
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen False],
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen ["facet.locale.fr_CA", None, True, 'local', False,
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen False]
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen ])
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assert_file_is_there("4")
8ae72ad7d0c69e972cfa65d1e2ce4e3e9a8b765cTimo Sirainen
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen def test_02_removing_facets(self):
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen self.image_create(self.rurl)
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen # Test that setting an unset, non-existent facet to None works.
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen self.pkg("change-facet foo=None", exit=4)
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen # Test that setting a non-existent facet to True then removing
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen # it works.
8ae72ad7d0c69e972cfa65d1e2ce4e3e9a8b765cTimo Sirainen self.pkg("change-facet -v foo=True")
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen self.pkg("facet -H -F tsv")
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen self.assertEqual("facet.foo\tTrue\tlocal\n", self.output)
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen self.pkg("change-facet --parsable=0 foo=None")
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen self.assertEqualParsable(self.output, change_facets=[
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen ["facet.foo", None, True, 'local', False, False]])
7bd72e4deca3cbf757dd1ea298486d9f3bc24226Timo Sirainen self.pkg("facet -H")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assertEqual("", self.output)
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen
b0be0bead3d6963149f7f2a9504b8ab5aced9af5Timo Sirainen self.pkg("change-facet -v foo=None", exit=4)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # Test that setting a facet at the same time as removing a facet
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # sees both as changing.
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # First, install faceted package.
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("install pkg_A")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen for i in range(9):
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.assert_file_is_there(i)
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen
14c474d9f4591c397ed0b5206af6537c7b52c924Timo Sirainen # Next, set general locale.*=False, but locale.fr=True.
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("change-facet 'locale.*=False' 'locale.fr=True'")
648d24583c1574441c4fa0331a90bd4d6e7996c5Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # General 0 file, locale.fr file, and has slashes file should be
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # there.
0f66f12eb4cdbf47670975044c88d8f388bf92dfTimo Sirainen for i in (0, 1, 8):
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.assert_file_is_there(i)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # No other locale files should be present.
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen for i in (2, 3, 4, 5, 6, 7):
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assert_file_is_there(i, negate=True)
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # Now set wombat=False and unset locale.fr.
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("change-facet -vv locale.fr=None wombat=False")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.assert_file_is_there(0) # general 0 file exists
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assert_file_is_there(1, negate=True) # locale.fr file gone
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen def test_03_slashed_facets(self):
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg_image_create(self.rurl)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("install pkg_A")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("verify")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
d7c8280f58292cc292eba9209dcc9024fe96cf06Timo Sirainen self.assert_file_is_there("8")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("change-facet -v facet.has/some/slashes=False")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assert_file_is_there("8", negate=True)
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("verify")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("change-facet -v facet.has/some/slashes=True")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assert_file_is_there("8")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("verify")
19779377be72c9fe8365bb9ba7a2e0d06dc99c3bTimo Sirainen
a85d0d2b75e5effadf4d3c2167af0ff9ae95904aTimo Sirainen def test_04_no_accidental_changes(self):
a85d0d2b75e5effadf4d3c2167af0ff9ae95904aTimo Sirainen """Verify that non-facet related packaging operation don't
5787e39e2be32f657b8c98fee8bac794aa852cf8Timo Sirainen accidentally change facets."""
5787e39e2be32f657b8c98fee8bac794aa852cf8Timo Sirainen
5787e39e2be32f657b8c98fee8bac794aa852cf8Timo Sirainen rurl = self.dc.get_repo_url()
5787e39e2be32f657b8c98fee8bac794aa852cf8Timo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # create an image w/ two facets set.
5787e39e2be32f657b8c98fee8bac794aa852cf8Timo Sirainen ic_args = ""
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen ic_args += " --facet 'locale.fr=False' "
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen ic_args += " --facet 'locale.fr_FR=False' "
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg_image_create(rurl, additional_args=ic_args)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("install pkg_A")
19779377be72c9fe8365bb9ba7a2e0d06dc99c3bTimo Sirainen
19779377be72c9fe8365bb9ba7a2e0d06dc99c3bTimo Sirainen # install a random package and make sure we don't accidentally
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen # change facets.
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen self.pkg("install pkg_B@1.0")
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen self.pkg("facet -H -F tsv")
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen expected = (
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen "facet.locale.fr\tFalse\tlocal\n"
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen "facet.locale.fr_FR\tFalse\tlocal\n")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.assertEqualDiff(expected, self.output)
5787e39e2be32f657b8c98fee8bac794aa852cf8Timo Sirainen for i in [ 0, 3, 4, 5, 6, 7 ]:
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.assert_file_is_there(str(i))
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen for i in [ 1, 2 ]:
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assert_file_is_there(str(i), negate=True)
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("verify")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen # update an image and make sure we don't accidentally change
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen # facets.
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("update")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("facet -H -F tsv")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen expected = (
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen "facet.locale.fr\tFalse\tlocal\n"
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen "facet.locale.fr_FR\tFalse\tlocal\n")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assertEqualDiff(expected, self.output)
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen for i in [ 0, 3, 4, 5, 6, 7 ]:
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.assert_file_is_there(str(i))
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen for i in [ 1, 2 ]:
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen self.assert_file_is_there(str(i), negate=True)
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen self.pkg("verify")
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen def test_05_reset_facet(self):
b0be0bead3d6963149f7f2a9504b8ab5aced9af5Timo Sirainen """Verify that resetting a Facet explicitly set to false
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen restores/removes delivered content."""
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen # create an image with pkg_A and no facets
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen self.pkg_image_create(self.rurl)
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen self.pkg("install pkg_A")
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen self.pkg("facet -H")
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen self.assertEqualDiff("", self.output)
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen for i in range(8):
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen self.assert_file_is_there(str(i))
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.assert_file_is_there("debug", negate=True)
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("verify")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen
d7c8280f58292cc292eba9209dcc9024fe96cf06Timo Sirainen # set a facet on an image with no facets
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.pkg("change-facet -v locale.fr=False")
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.pkg("facet -H -F tsv")
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen output = self.reduceSpaces(self.output)
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen expected = (
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen "facet.locale.fr\tFalse\tlocal\n")
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.assertEqualDiff(expected, output)
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen for i in [ 0, 2, 3, 4, 5, 6, 7 ]:
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.assert_file_is_there(str(i))
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen for i in [ 1 ]:
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.assert_file_is_there(str(i), negate=True)
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen self.pkg("verify")
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen # set a facet on an image with existing facets
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen self.pkg("change-facet -v locale.fr_FR=False")
e20e638805c4bd54e039891a3e92760b1dfa189aTimo Sirainen self.pkg("facet -H -F tsv")
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen expected = (
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen "facet.locale.fr\tFalse\tlocal\n"
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen "facet.locale.fr_FR\tFalse\tlocal\n")
d051664df497582e1eb75a9f238d04b65e858db8Timo Sirainen self.assertEqualDiff(expected, self.output)
d051664df497582e1eb75a9f238d04b65e858db8Timo Sirainen for i in [ 0, 3, 4, 5, 6, 7 ]:
d051664df497582e1eb75a9f238d04b65e858db8Timo Sirainen self.assert_file_is_there(str(i))
d051664df497582e1eb75a9f238d04b65e858db8Timo Sirainen for i in [ 1, 2 ]:
d051664df497582e1eb75a9f238d04b65e858db8Timo Sirainen self.assert_file_is_there(str(i), negate=True)
d051664df497582e1eb75a9f238d04b65e858db8Timo Sirainen self.pkg("verify")
d051664df497582e1eb75a9f238d04b65e858db8Timo Sirainen
d051664df497582e1eb75a9f238d04b65e858db8Timo Sirainen # clear a facet while setting a facet on an image with other
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # facets that aren't being changed
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.pkg("change-facet -v locale.fr=None locale.nl=False")
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.pkg("facet -H -F tsv")
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen output = self.reduceSpaces(self.output)
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen expected = (
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen "facet.locale.fr_FR\tFalse\tlocal\n"
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen "facet.locale.nl\tFalse\tlocal\n")
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.assertEqualDiff(expected, output)
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen for i in [ 0, 1, 3, 4, 6, 7 ]:
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.assert_file_is_there(str(i))
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen for i in [ 2, 5 ]:
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.assert_file_is_there(str(i), negate=True)
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.pkg("verify")
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen
90a989e4f8bcb4fb86af32cbae577402e3f92b1aTimo Sirainen # clear a facet on an image with other facets that aren't
90a989e4f8bcb4fb86af32cbae577402e3f92b1aTimo Sirainen # being changed
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.pkg("change-facet -v locale.nl=None")
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.pkg("facet -H -F tsv")
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen output = self.reduceSpaces(self.output)
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen expected = (
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen "facet.locale.fr_FR\tFalse\tlocal\n")
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.assertEqualDiff(expected, output)
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen for i in [ 0, 1, 3, 4, 5, 6, 7 ]:
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.assert_file_is_there(str(i))
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen for i in [ 2 ]:
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.assert_file_is_there(str(i), negate=True)
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.pkg("verify")
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen # clear the only facet on an image
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.pkg("change-facet -v locale.fr_FR=None")
d0ab5936be1cd971007fc2241e0be120c442cb84Timo Sirainen self.pkg("facet -H -F tsv")
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen self.assertEqualDiff("", self.output)
a28a6267f48971117dec958b160deefd14ebb7a6Timo Sirainen for i in range(8):
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.assert_file_is_there(str(i))
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("verify")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen # verify debug content removed when debug facet reset
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("change-facet -v debug.foo=True")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen self.pkg("facet -H -F tsv")
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen output = self.reduceSpaces(self.output)
7de1c472fd23ddac6b4dc5cbeee6fa6a8418b071Timo Sirainen expected = (
7de1c472fd23ddac6b4dc5cbeee6fa6a8418b071Timo Sirainen "facet.debug.foo\tTrue\tlocal\n")
7de1c472fd23ddac6b4dc5cbeee6fa6a8418b071Timo Sirainen self.assertEqualDiff(expected, output)
7de1c472fd23ddac6b4dc5cbeee6fa6a8418b071Timo Sirainen self.assert_file_is_there("debug")
7de1c472fd23ddac6b4dc5cbeee6fa6a8418b071Timo Sirainen
7de1c472fd23ddac6b4dc5cbeee6fa6a8418b071Timo Sirainen self.pkg("change-facet -v debug.foo=None")
7de1c472fd23ddac6b4dc5cbeee6fa6a8418b071Timo Sirainen self.pkg("facet -H -F tsv")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen output = self.reduceSpaces(self.output)
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assertEqualDiff("", self.output)
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assert_file_is_there("debug", negate=True)
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen def test_06_facet_all(self):
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen """Verify that the 'all' value for facets is handled as
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen expected."""
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen
88187ee880b4829443e0d55ea7d145d9d5880217Timo Sirainen self.pkg_image_create(self.rurl)
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen # All faceted files except debug/optional should be installed.
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.pkg("install pkg_top_level")
3697080532ccd9f51fac108be6079b616c7a2ddfTimo Sirainen self.assert_files_exist((
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen ("top0", True),
2a6af811ea3de3cf9e2f15e446674dd21b0705f3Timo Sirainen ("top0.debug", False),
12053b7b4b57dbd2790057426d1633988eedad56Timo Sirainen ("top1", True),
12053b7b4b57dbd2790057426d1633988eedad56Timo Sirainen ("top2", True),
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen ("top3", True),
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen ("top4", True),
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen ("top5", True),
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen ("optional.doc", False),
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen ("optional_fr.doc", False),
12053b7b4b57dbd2790057426d1633988eedad56Timo Sirainen ))
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen # All faceted files should be installed.
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.pkg("change-facet -v debug.top=true optional.doc=true")
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen self.assert_files_exist((
2a34e2be33f8a17d21384a5527ed9f75f4d270e0Timo Sirainen ("top0", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0.debug", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top1", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top2", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top3", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top4", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top5", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional.doc", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional_fr.doc", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ))
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen # Only top0[.debug] should be installed.
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.pkg('change-facet -v doc=false')
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.assert_files_exist((
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0.debug", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top1", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top2", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top3", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top4", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top5", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional.doc", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional_fr.doc", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ))
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen # No faceted files should be installed.
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.pkg('change-facet -v devel=false optional.doc=false')
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.assert_files_exist((
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0.debug", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top1", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top2", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top3", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top4", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top5", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional.doc", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional_fr.doc", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ))
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen # Only top1, top3, top4, optional.doc, and optional_fr.doc
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen # should be installed.
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.pkg('change-facet -v doc=true optional.doc=true')
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.assert_files_exist((
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0.debug", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top1", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top2", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top3", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top4", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top5", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional.doc", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional_fr.doc", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ))
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen # All faceted files should be installed.
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.pkg("change-facet -v devel=true optional.doc=true")
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.assert_files_exist((
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0.debug", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top1", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top2", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top3", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top4", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top5", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional.doc", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional_fr.doc", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ))
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen # Only top0[.debug], top1, top2, top4, top5, and optional.doc
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen # should be installed.
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.pkg("change-facet -v locale.fr_CA=false")
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.assert_files_exist((
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top0.debug", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top1", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top2", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top3", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top4", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("top5", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional.doc", True),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ("optional_fr.doc", False),
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen ))
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen # Only top0[.debug], top1, top2, and optional.doc should be
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen # installed.
c24c0f0a208e5ffc35dc8be19a9b504a5326467aTimo Sirainen self.pkg("change-facet -v locale.nl_ZA=false")
self.assert_files_exist((
("top0", True),
("top0.debug", True),
("top1", True),
("top2", True),
("top3", False),
("top4", False),
("top5", False),
("optional.doc", True),
("optional_fr.doc", False),
))
# Reset all facets and verify all files except optional/debug
# are installed.
self.pkg("change-facet -vvv devel=None doc=None locale.fr_CA=None "
"locale.nl_ZA=None optional.doc=None debug.top=None")
self.assert_files_exist((
("top0", True),
("top0.debug", False),
("top1", True),
("top2", True),
("top3", True),
("top4", True),
("top5", True),
("optional.doc", False),
("optional_fr.doc", False),
))
# Set a false wildcard for the 'devel' and 'doc' facets. No
# files should be installed.
self.pkg("change-facet -v 'facet.d*=False' optional.*=true "
"debug.*=true")
self.assert_files_exist((
("top0", False),
("top0.debug", False),
("top1", False),
("top2", False),
("top3", False),
("top4", False),
("top5", False),
("optional.doc", False),
("optional_fr.doc", False),
))
# Set the devel facet True and the debug.top facet true and
# verify that explicit sets trump wildcard matching. Only
# top0[.debug] should be installed.
self.pkg("change-facet -v devel=True debug.top=True")
self.assert_files_exist((
("top0", True),
("top0.debug", True),
("top1", False),
("top2", False),
("top3", False),
("top4", False),
("top5", False),
("optional.doc", False),
("optional_fr.doc", False),
))
def test_07_invalid_facet_name(self):
"""Test that invalid facet names are handled appropriately"""
self.image_create(self.rurl)
self.pkg("change-facet --no-refresh "
"facet.foo\ bar=false", exit=1)
self.assertTrue("facet.foo bar" in self.errout)
if __name__ == "__main__":
unittest.main()