3eecde703e9ac3af788ac17357f378d6b6d7c658Serge Hallyn# CDDL HEADER START
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# The contents of this file are subject to the terms of the
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# Common Development and Distribution License (the "License").
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# You may not use this file except in compliance with the License.
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# See the License for the specific language governing permissions
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# and limitations under the License.
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# When distributing Covered Code, include this CDDL HEADER in each
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# If applicable, add the following below this CDDL HEADER, with the
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# fields enclosed by brackets "[]" replaced with your own identifying
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# information: Portions Copyright [yyyy] [name of copyright owner]
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# CDDL HEADER END
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
4759162d078d86628956cae4846c6efccf548e67Serge Hallynfrom six.moves.urllib.request import url2pathname
b08ee0ce9a17b575a35eb90778bcf166ecf3634aSerge Hallynclass TestUtilMerge(pkg5unittest.ManyDepotTestCase):
4759162d078d86628956cae4846c6efccf548e67Serge Hallyn # Cleanup after every test.
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn open pkg:/scheme@1.0,5.11-0
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn open tree@1.0,5.11-0
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn open amber@1.0,5.11-0
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add depend fmri=pkg:/tree@1.0 type=require
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn open amber@2.0,5.11-0
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add depend fmri=pkg:/tree@1.0 type=require
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn open bronze@1.0,5.11-0
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add dir mode=0755 owner=root group=bin path=/usr
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add dir mode=0755 owner=root group=bin path=/usr/bin
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add file tmp/sh mode=0555 owner=root group=bin path=/usr/bin/sh
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add link path=/usr/bin/jsh target=./sh
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add hardlink path=/lib/libc.bronze target=/lib/libc.so.1
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add file tmp/bronze1 mode=0444 owner=root group=bin path=/etc/bronze1
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add file tmp/bronze2 mode=0444 owner=root group=bin path=/etc/bronze2
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add file tmp/bronzeA1 mode=0444 owner=root group=bin path=/A/B/C/D/E/F/bronzeA1
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add depend fmri=pkg:/amber@1.0 type=require
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add license tmp/copyright2 license=copyright
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn open bronze@2.0,5.11-0
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add dir mode=0755 owner=root group=bin path=/etc
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add dir mode=0755 owner=root group=bin path=/lib
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add file tmp/sh mode=0555 owner=root group=bin path=/usr/bin/sh
80a881b232b8955b85b360d4def99e6e680ff61bSerge Hallyn add file tmp/libc.so.1 mode=0555 owner=root group=bin path=/lib/libc.bronze
80a881b232b8955b85b360d4def99e6e680ff61bSerge Hallyn add link path=/usr/bin/jsh target=./sh
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add hardlink path=/lib/libc.bronze2.0.hardlink target=/lib/libc.so.1
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn add file tmp/bronze1 mode=0444 owner=root group=bin path=/etc/bronze1
42ff5f0f8767114d060f5031055038a1a1c3759aSerge Hallyn add file tmp/bronze2 mode=0444 owner=root group=bin path=/etc/amber2
42ff5f0f8767114d060f5031055038a1a1c3759aSerge Hallyn add license tmp/copyright3 license=copyright
42ff5f0f8767114d060f5031055038a1a1c3759aSerge Hallyn add file tmp/bronzeA2 mode=0444 owner=root group=bin path=/A1/B2/C3/D4/E5/F6/bronzeA2
42ff5f0f8767114d060f5031055038a1a1c3759aSerge Hallyn add depend fmri=pkg:/amber@2.0 type=require
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn """ Start two depots.
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn depot 1 gets foo and moo, depot 2 gets foo and bar
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn depot1 is mapped to publisher test1 (preferred)
4759162d078d86628956cae4846c6efccf548e67Serge Hallyn depot2 is mapped to publisher test2 """
4759162d078d86628956cae4846c6efccf548e67Serge Hallyn # This test suite needs an actual depot.
4759162d078d86628956cae4846c6efccf548e67Serge Hallyn pkg5unittest.ManyDepotTestCase.setUp(self, ["os.org", "os.org"],
52c8f624b5f9ef665f33a7aa80e0aa18b91daa4aSerge Hallyn # Publish a set of packages to one repository.
4759162d078d86628956cae4846c6efccf548e67Serge Hallyn self.published = self.pkgsend_bulk(self.durl1, (self.amber10,
4759162d078d86628956cae4846c6efccf548e67Serge Hallyn self.amber20, self.bronze10, self.bronze20, self.tree10,
4759162d078d86628956cae4846c6efccf548e67Serge Hallyn # Ensure timestamps of all successive publications are greater.
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn # Publish the same set to another repository (minus the tree
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn # and scheme packages).
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn self.published += self.pkgsend_bulk(self.durl2, (self.amber10,
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn self.merge_dir = tempfile.mkdtemp(dir=self.test_root)
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn parts = urlparse(uri, "file", allow_fragments=0)
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn "repository's configuration data is not "
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn """Verify that merge functionality works as expected."""
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn # Only get the newest FMRIs for each package.
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn exp_lines = ["set name=pkg.fmri value={0}".format(f)]
4759162d078d86628956cae4846c6efccf548e67Serge Hallyn # Not in this repository, check next.
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn # These packages are only published for sparc.
3eecde703e9ac3af788ac17357f378d6b6d7c658Serge Hallyn exp_lines.append("set name=variant.arch value=sparc")
52c8f624b5f9ef665f33a7aa80e0aa18b91daa4aSerge Hallyn # Everything else is published for all variants.
52c8f624b5f9ef665f33a7aa80e0aa18b91daa4aSerge Hallyn exp_lines.append("set name=variant.arch value=sparc value=i386")
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn # Now load the manifest file for each package and verify that
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn # the merged manifest matches expectations.
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn mpath = os.path.join(self.merge_dir, "publisher",
d1458ac8d13880f83fa2d1e08623b97c50d311d7Serge Hallyn # Generate expected and verify.