1516N/A#!/usr/bin/python
581N/A#
581N/A# CDDL HEADER START
581N/A#
581N/A# The contents of this file are subject to the terms of the
581N/A# Common Development and Distribution License (the "License").
581N/A# You may not use this file except in compliance with the License.
581N/A#
581N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
581N/A# or http://www.opensolaris.org/os/licensing.
581N/A# See the License for the specific language governing permissions
581N/A# and limitations under the License.
581N/A#
581N/A# When distributing Covered Code, include this CDDL HEADER in each
581N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
581N/A# If applicable, add the following below this CDDL HEADER, with the
581N/A# fields enclosed by brackets "[]" replaced with your own identifying
581N/A# information: Portions Copyright [yyyy] [name of copyright owner]
581N/A#
581N/A# CDDL HEADER END
581N/A#
581N/A
3311N/A# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
581N/A
3339N/Afrom . import testutils
581N/Aif __name__ == "__main__":
581N/A testutils.setup_environment("../../../proto")
1715N/Aimport pkg5unittest
581N/A
2931N/Afrom pkg.client.pkgdefs import *
2931N/A
3054N/Aimport hashlib
2931N/Aimport os
2931N/Aimport random
581N/Aimport unittest
581N/A
3054N/Aimport pkg.misc as misc
1895N/A
3317N/Aclass NoTestImageUpdate(pkg5unittest.ManyDepotTestCase):
581N/A # Only start/stop the depot once (instead of for every test)
1715N/A persistent_setup = True
3054N/A need_ro_data = True
581N/A
988N/A foo10 = """
988N/A open foo@1.0,5.11-0
988N/A add dir mode=0755 owner=root group=bin path=/lib
988N/A close """
988N/A
988N/A foo11 = """
988N/A open foo@1.1,5.11-0
988N/A add dir mode=0755 owner=root group=bin path=/lib
988N/A close """
988N/A
988N/A bar10 = """
988N/A open bar@1.0,5.11-0
988N/A add dir mode=0755 owner=root group=bin path=/bin
988N/A close """
988N/A
988N/A bar11 = """
988N/A open bar@1.1,5.11-0
988N/A add dir mode=0755 owner=root group=bin path=/bin
988N/A close """
988N/A
1158N/A baz10 = """
1158N/A open baz@1.0,5.11-0
1158N/A add dir mode=0755 owner=root group=bin path=/lib
1158N/A close """
1158N/A
1158N/A baz11 = """
1158N/A open baz@1.1,5.11-0
1158N/A add dir mode=0755 owner=root group=bin path=/lib
1158N/A close """
1158N/A
1158N/A qux10 = """
1158N/A open qux@1.0,5.11-0
1158N/A add depend type=require fmri=pkg:/quux@1.0
1158N/A add dir mode=0755 owner=root group=bin path=/lib
1158N/A close """
1158N/A
1158N/A qux11 = """
1158N/A open qux@1.1,5.11-0
1158N/A add depend type=require fmri=pkg:/quux@1.1
1158N/A add dir mode=0755 owner=root group=bin path=/lib
1158N/A close """
1158N/A
1158N/A quux10 = """
1158N/A open quux@1.0,5.11-0
1158N/A add depend type=require fmri=pkg:/corge@1.0
1158N/A add dir mode=0755 owner=root group=bin path=/usr
1158N/A close """
1158N/A
1158N/A quux11 = """
1158N/A open quux@1.1,5.11-0
1158N/A add depend type=require fmri=pkg:/corge@1.1
1158N/A add dir mode=0755 owner=root group=bin path=/usr
1158N/A close """
1158N/A
1158N/A corge10 = """
1158N/A open corge@1.0,5.11-0
1158N/A add dir mode=0755 owner=root group=bin path=/bin
1158N/A close """
1158N/A
1158N/A corge11 = """
1158N/A open corge@1.1,5.11-0
1158N/A add dir mode=0755 owner=root group=bin path=/bin
1158N/A close """
1158N/A
2089N/A incorp10 = """
2089N/A open incorp@1.0,5.11-0
2089N/A add depend type=incorporate fmri=foo@1.0
2089N/A add depend type=incorporate fmri=bar@1.0
2089N/A add set name=pkg.depend.install-hold value=test
2089N/A close """
2089N/A
2089N/A incorp11 = """
2089N/A open incorp@1.1,5.11-0
2089N/A add depend type=incorporate fmri=foo@1.1
2089N/A add depend type=incorporate fmri=bar@1.1
2089N/A add set name=pkg.depend.install-hold value=test
2089N/A close """
2089N/A
3054N/A elftest1 = """
3054N/A open elftest@1.0
3158N/A add file {0} mode=0755 owner=root group=bin path=/bin/true
3054N/A close """
3054N/A
3054N/A elftest2 = """
3054N/A open elftest@2.0
3158N/A add file {0} mode=0755 owner=root group=bin path=/bin/true
3054N/A close """
3054N/A
3094N/A # An example of dueling incorporations for an upgrade case.
3094N/A dueling_inst = """
3094N/A open entire@5.12-5.12.0.0.0.45.0
3094N/A add set name=pkg.depend.install-hold value=core-os
3094N/A add depend fmri=consolidation/java-7/java-7-incorporation type=require
3094N/A add depend facet.version-lock.consolidation/java-7/java-7-incorporation=true fmri=consolidation/java-7/java-7-incorporation@1.7.0.51.34-0 type=incorporate
3094N/A add depend fmri=consolidation/java-7/java-7-incorporation@1.7.0 type=incorporate
3094N/A add depend fmri=consolidation/osnet/osnet-incorporation type=require
3094N/A add depend facet.version-lock.consolidation/osnet/osnet-incorporation=true fmri=consolidation/osnet/osnet-incorporation@5.12-5.12.0.0.0.45.2 type=incorporate
3094N/A add depend fmri=consolidation/osnet/osnet-incorporation@5.12-5.12.0 type=incorporate
3094N/A close
3094N/A open consolidation/java-7/java-7-incorporation@1.7.0.51.34-0
3094N/A add depend fmri=runtime/java/jre-7@1.7.0.51.34,5.11 type=incorporate
3094N/A close
3094N/A open consolidation/osnet/osnet-incorporation@5.12-5.12.0.0.0.45.25345
3094N/A add set name=pkg.depend.install-hold value=core-os.osnet
3094N/A add depend fmri=pkg:/system/resource-mgmt/dynamic-resource-pools@5.12,5.12-5.12.0.0.0.45.25345 type=incorporate
3094N/A close
3094N/A open runtime/java/jre-7@1.7.0.51.34
3094N/A add depend fmri=consolidation/java-7/java-7-incorporation type=require
3094N/A close
3094N/A open system/resource-mgmt/dynamic-resource-pools@5.12-5.12.0.0.0.45.25345
3094N/A add depend fmri=consolidation/osnet/osnet-incorporation type=require
3094N/A add depend fmri=pkg:/runtime/java/jre-7@1.7.0.51.34 type=require
3094N/A close
3094N/A """
3094N/A
3094N/A dueling_latest = """
3094N/A open consolidation/osnet/osnet-incorporation@5.12-5.12.0.0.0.46.25205
3094N/A add set name=pkg.depend.install-hold value=core-os.osnet
3094N/A add depend fmri=pkg:/system/resource-mgmt/dynamic-resource-pools@5.12,5.12-5.12.0.0.0.46.25205 type=incorporate
3094N/A close
3094N/A open runtime/java/jre-7@1.7.0.55.13
3094N/A add depend fmri=consolidation/java-7/java-7-incorporation type=require
3094N/A close
3094N/A open system/resource-mgmt/dynamic-resource-pools@5.12,5.12-5.12.0.0.0.46.25205
3094N/A add depend fmri=consolidation/osnet/osnet-incorporation type=require
3094N/A add depend fmri=pkg:/runtime/java/jre-7@1.7.0.55.13 type=require
3094N/A close
3094N/A """
3094N/A
988N/A def setUp(self):
1736N/A # Two repositories are created for test2.
1715N/A pkg5unittest.ManyDepotTestCase.setUp(self, ["test1", "test2",
3277N/A "test2", "test4", "test5", "nightly"], image_count=2)
1895N/A self.rurl1 = self.dcs[1].get_repo_url()
1895N/A self.rurl2 = self.dcs[2].get_repo_url()
1895N/A self.rurl3 = self.dcs[3].get_repo_url()
1895N/A self.rurl4 = self.dcs[4].get_repo_url()
1895N/A self.rurl5 = self.dcs[5].get_repo_url()
3094N/A self.rurl6 = self.dcs[6].get_repo_url()
1895N/A self.pkgsend_bulk(self.rurl1, (self.foo10, self.foo11,
1895N/A self.baz11, self.qux10, self.qux11, self.quux10,
2089N/A self.quux11, self.corge11, self.incorp10, self.incorp11))
1736N/A
1895N/A self.pkgsend_bulk(self.rurl2, (self.foo10, self.bar10,
1895N/A self.bar11, self.baz10, self.qux10, self.qux11,
1895N/A self.quux10, self.quux11, self.corge10))
1736N/A
1736N/A # Copy contents of repository 2 to repos 4 and 5.
1736N/A for i in (4, 5):
2028N/A self.copy_repository(self.dcs[2].get_repodir(),
2028N/A self.dcs[i].get_repodir(),
3158N/A { "test1": "test{0:d}".format(i) })
1895N/A self.dcs[i].get_repo(auto_create=True).rebuild()
988N/A
3094N/A self.pkgsend_bulk(self.rurl6, (self.dueling_inst,
3094N/A self.dueling_latest))
3094N/A
581N/A def test_image_update_bad_opts(self):
2089N/A """Test update with bad options."""
581N/A
1895N/A self.image_create(self.rurl1, prefix="test1")
2089N/A self.pkg("update -@", exit=2)
2089N/A self.pkg("update -vq", exit=2)
581N/A
1158N/A def test_01_after_pub_removal(self):
988N/A """Install packages from multiple publishers, then verify that
988N/A removal of the second publisher will not prevent an
2089N/A update."""
988N/A
1895N/A self.image_create(self.rurl1, prefix="test1")
988N/A
988N/A # Install a package from the preferred publisher.
988N/A self.pkg("install foo@1.0")
988N/A
988N/A # Install a package from a second publisher.
3158N/A self.pkg("set-publisher -O {0} test2".format(self.rurl2))
988N/A self.pkg("install bar@1.0")
988N/A
988N/A # Remove the publisher of an installed package, then add the
2089N/A # publisher back, but with an empty repository. An update
988N/A # should still be possible.
988N/A self.pkg("unset-publisher test2")
3158N/A self.pkg("set-publisher -O {0} test2".format(self.rurl3))
2089N/A self.pkg("update -nv")
988N/A
1431N/A # Add two publishers with the same packages as a removed one;
2089N/A # an update should be possible despite the conflict (as
1158N/A # the newer versions will simply be ignored).
1431N/A self.pkg("unset-publisher test2")
3158N/A self.pkg("set-publisher -O {0} test4".format(self.rurl4))
3158N/A self.pkg("set-publisher -O {0} test5".format(self.rurl5))
2089N/A self.pkg("update -nv")
988N/A
2089N/A # Remove one of the conflicting publishers. An update
1431N/A # should still be possible even though the conflicts no longer
1431N/A # exist and the original publisher is unknown (see bug 6856).
1431N/A self.pkg("unset-publisher test4")
2089N/A self.pkg("update -nv")
988N/A
1431N/A # Remove the remaining test publisher.
1431N/A self.pkg("unset-publisher test5")
1431N/A
1158N/A def test_02_update_multi_publisher(self):
2089N/A """Verify that updates work as expected when different
1158N/A publishers offer the same package."""
1158N/A
1895N/A self.image_create(self.rurl1, prefix="test1")
1158N/A
1158N/A # First, verify that the preferred status of a publisher will
2089N/A # not affect which source is used for update when two
1158N/A # publishers offer the same package and the package publisher
1158N/A # was preferred at the time of install.
3158N/A self.pkg("set-publisher -P -O {0} test2".format(self.rurl2))
1158N/A self.pkg("install foo@1.0")
1158N/A self.pkg("info foo@1.0 | grep test2")
1158N/A self.pkg("set-publisher -P test1")
2089N/A self.pkg("update -v", exit=4)
1505N/A self.pkg("info foo@1.1 | grep test1", exit=1)
1158N/A self.pkg("uninstall foo")
1158N/A
1158N/A # Next, verify that the preferred status of a publisher will
1158N/A # not cause an upgrade of a package if the newer version is
1158N/A # offered by the preferred publisher and the package publisher
1158N/A # was not preferred at the time of isntall and was not used
1158N/A # to install the package.
1158N/A self.pkg("install baz@1.0")
1158N/A self.pkg("info baz@1.0 | grep test2")
1158N/A
1158N/A # Finally, cleanup and verify no packages are installed.
1505N/A self.pkg("uninstall '*'")
1158N/A self.pkg("list", exit=1)
1158N/A
2089N/A def test_03_update_specific_packages(self):
2089N/A """Verify that update only updates specified packages."""
2089N/A
2089N/A self.image_create(self.rurl1, prefix="test1")
2089N/A
2089N/A # Install a package from the preferred publisher.
2089N/A self.pkg("install foo@1.0")
2089N/A
2089N/A # Install a package from a second publisher.
3158N/A self.pkg("set-publisher -O {0} test2".format(self.rurl2))
2089N/A self.pkg("install bar@1.0")
2089N/A
2089N/A # Update just bar, and then verify foo wasn't updated.
2089N/A self.pkg("update bar")
2089N/A self.pkg("info bar@1.1 foo@1.0")
2089N/A
2089N/A # Now update bar back to 1.0 and then verify that update '*',
2089N/A # update '*@*', or update without arguments will update all
2089N/A # packages.
2089N/A self.pkg("update bar@1.0")
2089N/A self.pkg("install incorp@1.0")
2089N/A
2089N/A self.pkg("update")
2089N/A self.pkg("info bar@1.1 foo@1.1 incorp@1.1")
2089N/A
2089N/A self.pkg("update *@1.0")
2089N/A self.pkg("info bar@1.0 foo@1.0 incorp@1.0")
2089N/A
2089N/A self.pkg("update '*'")
2089N/A self.pkg("info bar@1.1 foo@1.1 incorp@1.1")
2089N/A
2089N/A self.pkg("update bar@1.0 foo@1.0 incorp@1.0")
2089N/A self.pkg("info bar@1.0 foo@1.0 incorp@1.0")
2089N/A
2089N/A self.pkg("update '*@*'")
2089N/A self.pkg("info bar@1.1 foo@1.1 incorp@1.1")
2089N/A
2224N/A # Now rollback everything to 1.0, and then verify that
2224N/A # '@latest' will take everything to the latest version.
2224N/A self.pkg("update '*@1.0'")
2224N/A self.pkg("info bar@1.0 foo@1.0 incorp@1.0")
2224N/A
2224N/A self.pkg("update '*@latest'")
2224N/A self.pkg("info bar@1.1 foo@1.1 incorp@1.1")
2224N/A
3094N/A def test_upgrade_sticky(self):
2420N/A """Test that when a package specified on the command line can't
2420N/A be upgraded because of a sticky publisher, the exception raised
2420N/A is correct."""
2420N/A
2420N/A self.image_create(self.rurl2)
2420N/A self.pkg("install foo")
3158N/A self.pkg("set-publisher -p {0}".format(self.rurl1))
2420N/A self.pkg("update foo@1.1", exit=1)
3339N/A self.assertTrue("test1" in self.errout)
2420N/A
2931N/A def test_nothingtodo(self):
2931N/A """Test that if we have multiple facets of equal length that
2931N/A we don't accidently report that there are image updates when
2931N/A there are not."""
2931N/A
2931N/A facet_max = 1000
3158N/A facet_fmt = "{{0:{0:d}d}}".format(len("{0:d}".format(facet_max)))
2931N/A
2931N/A facet_set = set()
2931N/A random.seed()
2931N/A self.image_create()
2931N/A for i in range(15):
3158N/A facet = facet_fmt.format(random.randint(0, facet_max))
2931N/A if facet in facet_set:
2931N/A # skip dups
2931N/A continue
2931N/A facet_set.add(facet)
3158N/A self.pkg("change-facet {0}=False".format(facet))
2931N/A self.pkg("update -nv", exit=EXIT_NOP)
2931N/A
3025N/A def test_ignore_missing(self):
3025N/A """Test that update shows correct behavior w/ and w/o
3025N/A --ignore-missing."""
3025N/A self.image_create(self.rurl1)
3025N/A self.pkg("update missing", exit=1)
3025N/A self.pkg("update --ignore-missing missing", exit=4)
3025N/A
3054N/A def test_content_policy(self):
3054N/A """ Test the content-update-policy property. When set to
3445N/A 'when-required' content should only be updated if the GELF content
3054N/A hash has changed, if set to 'always' content should be updated
3054N/A if there is any file change at all."""
3054N/A
3054N/A def get_test_sum(fname=None):
3054N/A """ Helper to get sha256 sum of installed test file."""
3054N/A if fname is None:
3054N/A fname = os.path.join(self.get_img_path(),
3054N/A "bin/true")
3054N/A fsum , data = misc.get_data_digest(fname,
3054N/A hash_func=hashlib.sha256)
3054N/A return fsum
3054N/A
3054N/A # Elftest1 and elftest2 have the same content and the same size,
3054N/A # just different entries in the comment section. The content
3054N/A # hash for both is the same, however the file hash is different.
3158N/A elftest1 = self.elftest1.format(os.path.join("ro_data",
3158N/A "elftest.so.1"))
3158N/A elftest2 = self.elftest2.format(os.path.join("ro_data",
3158N/A "elftest.so.2"))
3054N/A
3054N/A # get the sha256 sums from the original files to distinguish
3054N/A # what actually got installed
3054N/A elf1sum = get_test_sum(fname=os.path.join(self.ro_data_root,
3054N/A "elftest.so.1"))
3054N/A elf2sum = get_test_sum(fname=os.path.join(self.ro_data_root,
3054N/A "elftest.so.2"))
3054N/A
3054N/A elf1, elf2 = self.pkgsend_bulk(self.rurl1, (elftest1, elftest2))
3054N/A
3054N/A # prepare image, install elftest@1.0 and verify
3054N/A self.image_create(self.rurl1)
3158N/A self.pkg("install -v {0}".format(elf1))
3158N/A self.pkg("contents -m {0}".format(elf1))
3054N/A self.assertEqual(elf1sum, get_test_sum())
3054N/A
3054N/A # test default behavior (always update)
3054N/A self.pkg("update -v elftest")
3158N/A self.pkg("contents -m {0}".format(elf2))
3054N/A self.assertEqual(elf2sum, get_test_sum())
3054N/A # reset and start over
3054N/A self.pkg("uninstall elftest")
3158N/A self.pkg("install -v {0}".format(elf1))
3054N/A
3054N/A # set policy to when-required, file shouldn't be updated
3054N/A self.pkg("set-property content-update-policy when-required")
3054N/A self.pkg("update -v elftest")
3158N/A self.pkg("list {0}".format(elf2))
3054N/A self.assertEqual(elf1sum, get_test_sum())
3054N/A # reset and start over
3054N/A self.pkg("uninstall elftest")
3158N/A self.pkg("install -v {0}".format(elf1))
3054N/A
3054N/A # set policy to always, file should be updated now
3054N/A self.pkg("set-property content-update-policy always")
3054N/A self.pkg("update -v elftest")
3158N/A self.pkg("list {0}".format(elf2))
3054N/A self.assertEqual(elf2sum, get_test_sum())
3054N/A
3054N/A # do tests again for downgrading, test file shouldn't change
3054N/A self.pkg("set-property content-update-policy when-required")
3158N/A self.pkg("update -v {0}".format(elf1))
3158N/A self.pkg("list {0}".format(elf1))
3054N/A self.assertEqual(elf2sum, get_test_sum())
3054N/A # reset and start over
3054N/A self.pkg("uninstall elftest")
3158N/A self.pkg("install -v {0}".format(elf2))
3054N/A
3054N/A # set policy to always, file should be updated now
3054N/A self.pkg("set-property content-update-policy always")
3158N/A self.pkg("update -v {0}".format(elf1))
3158N/A self.pkg("list {0}".format(elf1))
3054N/A self.assertEqual(elf1sum, get_test_sum())
3054N/A
3094N/A def test_dueling_incs(self):
3094N/A """Verify that dueling incorporations don't result in a 'no
3094N/A solution' error in a case sometimes found with 'nightly'
3094N/A upgrades."""
3094N/A
3094N/A self.image_create(self.rurl6)
3277N/A self.image_clone(1)
3094N/A self.pkg("change-facet "
3094N/A "version-lock.consolidation/osnet/osnet-incorporation=false")
3094N/A self.pkg("install entire@5.12-5.12.0.0.0.45.0 "
3094N/A "osnet-incorporation@5.12-5.12.0.0.0.45.25345 "
3094N/A "system/resource-mgmt/dynamic-resource-pools@5.12-5.12.0.0.0.45.25345")
3094N/A
3094N/A # Failure is expected for these cases because an installed
3094N/A # incorporation prevents the upgrade of an installed dependency
3094N/A # required by the new packages.
3094N/A
3094N/A # Should fail and result in 'no solution' because user failed to
3094N/A # specify any input.
3094N/A self.pkg("update -nv", exit=1, assert_solution=False)
3339N/A self.assertTrue("No solution" in self.errout)
3094N/A
3094N/A # Should fail, but not result in 'no solution' because user
3094N/A # specified a particular package.
3094N/A self.pkg("update -nv osnet-incorporation@latest", exit=1)
3339N/A self.assertTrue("No matching version" in self.errout)
3094N/A
3094N/A # Should exit with 'nothing to do' since update to new version
3094N/A # of osnet-incorporation is not possible.
3094N/A self.pkg("update -nv osnet-incorporation", exit=4)
3094N/A
3277N/A # A pkg update (with no arguments) should not fail if we are a
3277N/A # linked image child because we're likely constrained by our
3277N/A # parent dependencies.
3277N/A self.pkg("attach-linked --linked-md-only -p system:foo "
3277N/A "{0}".format(self.img_path(1)))
3277N/A self.pkg("update -nv", exit=4)
3277N/A
581N/A
3317N/Aclass TestIDROps(pkg5unittest.SingleDepotTestCase):
3317N/A
3317N/A need_ro_data = True
3317N/A
3317N/A idr_comb = """
3317N/A open pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1:20160225T115559Z
3317N/A add set name=pkg.description value="test package"
3458N/A add dir path=foo/hello owner=root group=sys mode=555
3317N/A close
3317N/A open pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1.1697.1:20160225T115610Z
3317N/A add set name=pkg.description value="test package"
3458N/A add dir path=foo/hello owner=root group=sys mode=555
3317N/A add depend type=require fmri=idr1697@1
3317N/A close
3317N/A open pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1:20160225T115616Z
3317N/A add set name=pkg.description value="test package"
3458N/A add dir path=foo/hello owner=root group=sys mode=555
3317N/A close
3317N/A open pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.3.2.906,5.11-0.1:20160225T115622Z
3317N/A add set name=pkg.description value="test package"
3458N/A add dir path=foo/hello owner=root group=sys mode=555
3317N/A close
3317N/A open pkg://test/management/em-sysmgmt-ecpc/opscenter-ecpc-incorporation@12.2.2.1103,5.11-0.1:20141203T103418Z
3317N/A add set name=pkg.description value="This incorporation constrains packages for the opscenter enterprise and proxy controller."
3317N/A add depend fmri=management/em-sysmgmt-ecpc/em-oc-ec@12.2.2.1103-0.1 type=incorporate
3317N/A add depend fmri=management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103-0.1 type=incorporate
3317N/A add depend fmri=management/em-sysmgmt-ecpc/em-oc-pc@12.2.2.1103-0.1 type=incorporate
3317N/A close
3317N/A open pkg://test/idr1697@1
3317N/A add set name=pkg.description value="idr package"
3458N/A add dir path=foo/hello owner=root group=sys mode=555
3317N/A add depend type=incorporate fmri=management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103-0.1.1697.1
3317N/A close"""
3317N/A
3317N/A
3317N/A def setUp(self):
3317N/A pkg5unittest.SingleDepotTestCase.setUp(self)
3317N/A self.pkgsend_bulk(self.rurl, self.idr_comb)
3317N/A
3317N/A def test_idr_application(self):
3317N/A """Verify branch versioning that might that might lead to odd
3317N/A ordering of the possible FMRIs will not be erroneously trimmed
3317N/A during installation or removal."""
3317N/A
3317N/A self.image_create(self.rurl)
3317N/A self.pkg("install opscenter-ecpc-incorporation")
3317N/A self.pkg("list -afv em-oc-common")
3317N/A # If branch versioning ordering is working correctly, the next
3317N/A # two packages should be installable.
3317N/A self.pkg("install pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1:20160225T115559Z")
3317N/A self.pkg("install pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1:20160225T115616Z")
3317N/A # If branch ordering is broken, only this package will be
3317N/A # instalable.
3317N/A self.pkg("install pkg://test/management/em-sysmgmt-ecpc/em-oc-common")
3317N/A self.pkg("list -afv em-oc-common")
3317N/A # If branch ordering is broken, the upgrade will fail because
3317N/A # em-oc-common won't be installable despite removal of the idr.
3317N/A self.pkg("update --reject pkg://test/idr1697@1 "
3317N/A "pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1:20160225T115616Z")
3317N/A
3317N/A
3317N/Aclass NoTestPkgUpdateOverlappingPatterns(pkg5unittest.SingleDepotTestCase):
2681N/A
2681N/A a_1 = """
2681N/A open a@1.0,5.11-0
2681N/A close """
2681N/A
2681N/A pub2_a_1 = """
2681N/A open pkg://pub2/a@1.0,5.11-0
2681N/A close """
2681N/A
2681N/A a_11 = """
2681N/A open a@1.1,5.11-0
2681N/A close """
2681N/A
2681N/A a_2 = """
2681N/A open a@2.0,5.11-0
2681N/A close """
2681N/A
2681N/A pub2_a_2 = """
2681N/A open pkg://pub2/a@2.0,5.11-0
2681N/A close """
2681N/A
2681N/A a_3 = """
2681N/A open a@3.0,5.11-0
2681N/A close """
2681N/A
2681N/A aa_1 = """
2681N/A open aa@1.0,5.11-0
2681N/A close """
2681N/A
2681N/A aa_2 = """
2681N/A open aa@2.0,5.11-0
2681N/A close """
2681N/A
2681N/A afoo_1 = """
2681N/A open a/foo@1.0,5.11-0
2681N/A close """
2681N/A
2681N/A bfoo_1 = """
2681N/A open b/foo@1.0,5.11-0
2681N/A close """
2681N/A
2681N/A fooa_1 = """
2681N/A open foo/a@1.0,5.11-0
2681N/A close """
2681N/A
2681N/A foob_1 = """
2681N/A open foo/b@1.0,5.11-0
2681N/A close """
2681N/A
2681N/A def test_overlapping_patterns_one_stem_update(self):
2681N/A self.pkgsend_bulk(self.rurl, self.a_1 + self.a_2 + self.a_11)
2681N/A api_inst = self.image_create(self.rurl)
2681N/A
2681N/A self._api_install(api_inst, ["a@1.0"])
2681N/A self._api_update(api_inst, pkgs_update=["a@latest", "a@2"],
2681N/A noexecute=True)
2681N/A self.pkg("update a@1.1 a@2", exit=1)
2681N/A
2681N/A def test_overlapping_patterns_multi_stems_update(self):
2681N/A self.pkgsend_bulk(self.rurl, self.a_1 + self.a_11 + self.a_2 +
2681N/A self.aa_1 + self.aa_2)
2681N/A api_inst = self.image_create(self.rurl)
2681N/A
2681N/A self._api_install(api_inst, ["a@1.0", "aa@1.0"])
2681N/A self._api_update(api_inst, pkgs_update=["*", "a@1.1"])
2681N/A self.pkg("list aa@2.0 a@1.1")
2681N/A self._api_uninstall(api_inst, ["*"])
2681N/A
2681N/A self._api_install(api_inst, ["a@1.0", "aa@1.0"])
2681N/A self._api_update(api_inst, pkgs_update=["*", "a@1.1", "a*@2"])
2681N/A self.pkg("list aa@2.0 a@1.1")
2681N/A self._api_uninstall(api_inst, ["*"])
2681N/A
2681N/A def test_overlapping_patterns_multi_publisher_update(self):
2681N/A self.pkgsend_bulk(self.rurl, self.a_1 + self.a_2 +
2681N/A self.aa_1 + self.aa_2 + self.pub2_a_1 + self.pub2_a_2)
2681N/A api_inst = self.image_create(self.rurl)
2681N/A self.pkg("set-publisher -P test")
2681N/A
2681N/A # Test that naming a specific publisher and stem will override
2681N/A # the general wildcard.
2681N/A self._api_install(api_inst, ["a@1", "aa@1"])
2681N/A self.pkg("update '*' 'pkg://pub2/a@1'")
2681N/A self.pkg("list -Hv pkg://pub2/a@1 pkg://test/aa@2")
2681N/A self._api_uninstall(api_inst, ["*"])
2681N/A
2681N/A # Test that naming a specific publisher will correctly change
2681N/A # the publisher of the installed package.
2681N/A self._api_install(api_inst, ["a@1", "aa@1"])
2681N/A self.pkg("update 'pkg://pub2/*@1'")
2681N/A self.pkg("list -Hv pkg://pub2/a@1 pkg://test/aa@1")
2681N/A self._api_uninstall(api_inst, ["*"])
2681N/A
2681N/A # Test that a specific publisher and stem will override an
2681N/A # unspecified publisher with a specific stem.
2681N/A self._api_install(api_inst, ["a@1"])
2681N/A self.pkg("update 'a@1' 'pkg://pub2/a@1'")
2681N/A self.pkg("list -Hv pkg://pub2/a@1")
2681N/A self.pkg("update 'a@2' '//test/a@2'")
2681N/A self.pkg("list -Hv pkg://test/a@2")
2681N/A self._api_uninstall(api_inst, ["*"])
2681N/A
2681N/A self._api_install(api_inst, ["a@1"])
2681N/A self.pkg("update 'a@1' 'pkg://pub2/a@2'", exit=1)
2681N/A self._api_uninstall(api_inst, ["*"])
2681N/A
2681N/A # Test that a specific publisher with a wildcard will override a
2681N/A # unspecified publisher with a wildcard.
2681N/A self._api_install(api_inst, ["a@1", "aa@1"])
2681N/A self.pkg("update '*' 'pkg://pub2/*@1'")
2681N/A self.pkg("list -Hv pkg://pub2/a@1 pkg://test/aa@2")
2681N/A self._api_uninstall(api_inst, ["*"])
2681N/A
2681N/A # Test that a specific stem without a specific publisher
2681N/A # overrides a specific publisher without a specific stem.
2681N/A self._api_install(api_inst, ["a@1", "aa@1"])
2681N/A self.pkg("update '*' 'pkg://pub2/*@1' 'a@2'")
2681N/A self.pkg("list -Hv pkg://test/a@2 pkg://test/aa@2")
2681N/A self._api_uninstall(api_inst, ["*"])
2681N/A
2681N/A # Test that conflicting publishers results in an error.
2681N/A self._api_install(api_inst, ["a@1", "aa@1"])
2681N/A self.pkg("update '*' 'pkg://pub2/a@1' 'pkg://test/a@2'", exit=1)
2681N/A self.pkg("update '*' 'pkg://pub2/*@1' 'pkg://test/*@2'", exit=1)
2681N/A self._api_uninstall(api_inst, ["*"])
2681N/A
3094N/A
581N/Aif __name__ == "__main__":
581N/A unittest.main()