#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
from . import testutils
if __name__ == "__main__":
import pkg5unittest
import hashlib
import os
import random
import unittest
foo10 = """
open foo@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/lib
close """
foo11 = """
open foo@1.1,5.11-0
add dir mode=0755 owner=root group=bin path=/lib
close """
bar10 = """
open bar@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/bin
close """
bar11 = """
open bar@1.1,5.11-0
add dir mode=0755 owner=root group=bin path=/bin
close """
baz10 = """
open baz@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/lib
close """
baz11 = """
open baz@1.1,5.11-0
add dir mode=0755 owner=root group=bin path=/lib
close """
qux10 = """
open qux@1.0,5.11-0
add depend type=require fmri=pkg:/quux@1.0
add dir mode=0755 owner=root group=bin path=/lib
close """
qux11 = """
open qux@1.1,5.11-0
add depend type=require fmri=pkg:/quux@1.1
add dir mode=0755 owner=root group=bin path=/lib
close """
quux10 = """
open quux@1.0,5.11-0
add depend type=require fmri=pkg:/corge@1.0
add dir mode=0755 owner=root group=bin path=/usr
close """
quux11 = """
open quux@1.1,5.11-0
add depend type=require fmri=pkg:/corge@1.1
add dir mode=0755 owner=root group=bin path=/usr
close """
corge10 = """
open corge@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/bin
close """
corge11 = """
open corge@1.1,5.11-0
add dir mode=0755 owner=root group=bin path=/bin
close """
incorp10 = """
open incorp@1.0,5.11-0
add depend type=incorporate fmri=foo@1.0
add depend type=incorporate fmri=bar@1.0
add set name=pkg.depend.install-hold value=test
close """
incorp11 = """
open incorp@1.1,5.11-0
add depend type=incorporate fmri=foo@1.1
add depend type=incorporate fmri=bar@1.1
add set name=pkg.depend.install-hold value=test
close """
elftest1 = """
open elftest@1.0
close """
elftest2 = """
open elftest@2.0
close """
# An example of dueling incorporations for an upgrade case.
dueling_inst = """
open entire@5.12-5.12.0.0.0.45.0
add set name=pkg.depend.install-hold value=core-os
add depend fmri=consolidation/java-7/java-7-incorporation type=require
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
add depend fmri=consolidation/java-7/java-7-incorporation@1.7.0 type=incorporate
add depend fmri=consolidation/osnet/osnet-incorporation type=require
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
add depend fmri=consolidation/osnet/osnet-incorporation@5.12-5.12.0 type=incorporate
close
open consolidation/java-7/java-7-incorporation@1.7.0.51.34-0
close
open consolidation/osnet/osnet-incorporation@5.12-5.12.0.0.0.45.25345
add set name=pkg.depend.install-hold value=core-os.osnet
add depend fmri=pkg:/system/resource-mgmt/dynamic-resource-pools@5.12,5.12-5.12.0.0.0.45.25345 type=incorporate
close
add depend fmri=consolidation/java-7/java-7-incorporation type=require
close
open system/resource-mgmt/dynamic-resource-pools@5.12-5.12.0.0.0.45.25345
add depend fmri=consolidation/osnet/osnet-incorporation type=require
close
"""
dueling_latest = """
open consolidation/osnet/osnet-incorporation@5.12-5.12.0.0.0.46.25205
add set name=pkg.depend.install-hold value=core-os.osnet
add depend fmri=pkg:/system/resource-mgmt/dynamic-resource-pools@5.12,5.12-5.12.0.0.0.46.25205 type=incorporate
close
add depend fmri=consolidation/java-7/java-7-incorporation type=require
close
open system/resource-mgmt/dynamic-resource-pools@5.12,5.12-5.12.0.0.0.46.25205
add depend fmri=consolidation/osnet/osnet-incorporation type=require
close
"""
# Two repositories are created for test2.
# Copy contents of repository 2 to repos 4 and 5.
for i in (4, 5):
"""Test update with bad options."""
"""Install packages from multiple publishers, then verify that
removal of the second publisher will not prevent an
update."""
# Install a package from the preferred publisher.
# Install a package from a second publisher.
# Remove the publisher of an installed package, then add the
# publisher back, but with an empty repository. An update
# should still be possible.
# Add two publishers with the same packages as a removed one;
# an update should be possible despite the conflict (as
# the newer versions will simply be ignored).
# Remove one of the conflicting publishers. An update
# should still be possible even though the conflicts no longer
# exist and the original publisher is unknown (see bug 6856).
# Remove the remaining test publisher.
"""Verify that updates work as expected when different
publishers offer the same package."""
# First, verify that the preferred status of a publisher will
# not affect which source is used for update when two
# publishers offer the same package and the package publisher
# was preferred at the time of install.
# Next, verify that the preferred status of a publisher will
# not cause an upgrade of a package if the newer version is
# offered by the preferred publisher and the package publisher
# was not preferred at the time of isntall and was not used
# to install the package.
# Finally, cleanup and verify no packages are installed.
"""Verify that update only updates specified packages."""
# Install a package from the preferred publisher.
# Install a package from a second publisher.
# Update just bar, and then verify foo wasn't updated.
# Now update bar back to 1.0 and then verify that update '*',
# update '*@*', or update without arguments will update all
# packages.
# Now rollback everything to 1.0, and then verify that
# '@latest' will take everything to the latest version.
"""Test that when a package specified on the command line can't
be upgraded because of a sticky publisher, the exception raised
is correct."""
"""Test that if we have multiple facets of equal length that
we don't accidently report that there are image updates when
there are not."""
facet_max = 1000
for i in range(15):
# skip dups
continue
"""Test that update shows correct behavior w/ and w/o
--ignore-missing."""
""" Test the content-update-policy property. When set to
'when-required' content should only be updated if the GELF content
hash has changed, if set to 'always' content should be updated
if there is any file change at all."""
""" Helper to get sha256 sum of installed test file."""
if fname is None:
return fsum
# Elftest1 and elftest2 have the same content and the same size,
# just different entries in the comment section. The content
# hash for both is the same, however the file hash is different.
"elftest.so.1"))
"elftest.so.2"))
# get the sha256 sums from the original files to distinguish
# what actually got installed
"elftest.so.1"))
"elftest.so.2"))
# prepare image, install elftest@1.0 and verify
# test default behavior (always update)
# reset and start over
# set policy to when-required, file shouldn't be updated
# reset and start over
# set policy to always, file should be updated now
# do tests again for downgrading, test file shouldn't change
# reset and start over
# set policy to always, file should be updated now
"""Verify that dueling incorporations don't result in a 'no
solution' error in a case sometimes found with 'nightly'
upgrades."""
"osnet-incorporation@5.12-5.12.0.0.0.45.25345 "
"system/resource-mgmt/dynamic-resource-pools@5.12-5.12.0.0.0.45.25345")
# Failure is expected for these cases because an installed
# incorporation prevents the upgrade of an installed dependency
# required by the new packages.
# Should fail and result in 'no solution' because user failed to
# specify any input.
# Should fail, but not result in 'no solution' because user
# specified a particular package.
# Should exit with 'nothing to do' since update to new version
# of osnet-incorporation is not possible.
# A pkg update (with no arguments) should not fail if we are a
# linked image child because we're likely constrained by our
# parent dependencies.
idr_comb = """
open pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1:20160225T115559Z
add set name=pkg.description value="test package"
close
open pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1.1697.1:20160225T115610Z
add set name=pkg.description value="test package"
add depend type=require fmri=idr1697@1
close
open pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1:20160225T115616Z
add set name=pkg.description value="test package"
close
open pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.3.2.906,5.11-0.1:20160225T115622Z
add set name=pkg.description value="test package"
close
open pkg://test/management/em-sysmgmt-ecpc/opscenter-ecpc-incorporation@12.2.2.1103,5.11-0.1:20141203T103418Z
add set name=pkg.description value="This incorporation constrains packages for the opscenter enterprise and proxy controller."
add depend fmri=management/em-sysmgmt-ecpc/em-oc-ec@12.2.2.1103-0.1 type=incorporate
add depend fmri=management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103-0.1 type=incorporate
add depend fmri=management/em-sysmgmt-ecpc/em-oc-pc@12.2.2.1103-0.1 type=incorporate
close
add set name=pkg.description value="idr package"
add depend type=incorporate fmri=management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103-0.1.1697.1
close"""
"""Verify branch versioning that might that might lead to odd
ordering of the possible FMRIs will not be erroneously trimmed
during installation or removal."""
# If branch versioning ordering is working correctly, the next
# two packages should be installable.
self.pkg("install pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1:20160225T115559Z")
self.pkg("install pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1:20160225T115616Z")
# If branch ordering is broken, only this package will be
# instalable.
# If branch ordering is broken, the upgrade will fail because
# em-oc-common won't be installable despite removal of the idr.
"pkg://test/management/em-sysmgmt-ecpc/em-oc-common@12.2.2.1103,5.11-0.1:20160225T115616Z")
a_1 = """
open a@1.0,5.11-0
close """
pub2_a_1 = """
open pkg://pub2/a@1.0,5.11-0
close """
a_11 = """
open a@1.1,5.11-0
close """
a_2 = """
open a@2.0,5.11-0
close """
pub2_a_2 = """
open pkg://pub2/a@2.0,5.11-0
close """
a_3 = """
open a@3.0,5.11-0
close """
aa_1 = """
open aa@1.0,5.11-0
close """
aa_2 = """
open aa@2.0,5.11-0
close """
afoo_1 = """
close """
bfoo_1 = """
close """
fooa_1 = """
open foo/a@1.0,5.11-0
close """
foob_1 = """
open foo/b@1.0,5.11-0
close """
# Test that naming a specific publisher and stem will override
# the general wildcard.
# Test that naming a specific publisher will correctly change
# the publisher of the installed package.
# Test that a specific publisher and stem will override an
# unspecified publisher with a specific stem.
# Test that a specific publisher with a wildcard will override a
# unspecified publisher with a wildcard.
# Test that a specific stem without a specific publisher
# overrides a specific publisher without a specific stem.
# Test that conflicting publishers results in an error.
if __name__ == "__main__":