Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for an origin dependency #456

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions src/tests/api/t_pkg_api_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,29 @@ class TestPkgApiInstall(pkg5unittest.SingleDepotTestCase):
add file tmp/motd mode=0644 owner=root group=bin path=etc/motd
close"""

barge10 = """
open [email protected],5.11-0
add file tmp/cat mode=0555 owner=root group=bin path=/bin/cat
add file tmp/motd mode=0444 owner=root group=bin path=etc/motd
close """

derelict = """
open [email protected],5.11-0
add file tmp/motd mode=0444 owner=root group=bin path=etc/motd
close """

barge11 = """
open [email protected],5.11-0
add file tmp/cat mode=0555 owner=root group=bin path=/bin/cat
add depend type=require fmri=pkg:/derelict
close """

barge12 = """
open [email protected],5.11-0
add file tmp/cat mode=0555 owner=root group=bin path=/bin/cat
add depend type=origin fmri=pkg:/[email protected]
close """

misc_files = ["tmp/libc.so.1", "tmp/cat", "tmp/baz", "tmp/motd"]

def setUp(self):
Expand Down Expand Up @@ -492,6 +515,66 @@ def test_update_backwards(self):
self.__do_update(api_obj, ["carriage", "horse@1"])
self.pkg("list carriage@3 horse@1")

def test_origin_depend(self):
"""Confirm that an origin dependency causes the proper sequence of
upgrades to occur."""

self.pkgsend_bulk(self.rurl, self.barge10)
api_obj = self.image_create(self.rurl)

self.__do_install(api_obj, ["barge"])

self.pkg("list barge derelict", exit=3)

# Attempting to update barge should result in nothing to do.
api_obj.reset()
for pd in api_obj.gen_plan_update(["barge"]):
continue
self.assertTrue(api_obj.planned_nothingtodo())

# Publish derelict and barge versions 1.1 and 1.2
self.pkgsend_bulk(
self.rurl, (self.barge11, self.barge12, self.derelict)
)

# It should not be possible to update directly to [email protected] due to
# its origin dependency.
api_obj.reset()
self.assertRaises(
api_errors.PlanCreationException,
lambda *args, **kwargs: list(
api_obj.gen_plan_update(*args, **kwargs)
),
["[email protected]"],
)

# Upgrading barge should result in derelict being installed, and barge
# only going to version 1.1
api_obj.reset()
self.__do_update(api_obj, ["barge"])
self.pkg("list [email protected] derelict")

# It should not be possible to uninstall derelict at this point as it
# is required by [email protected]
api_obj.reset()
self.assertRaises(
api_errors.NonLeafPackageException,
lambda *args, **kwargs: list(
api_obj.gen_plan_uninstall(*args, **kwargs)
),
["derelict"],
)

# A subsequent update of barge should move it to 1.2
api_obj.reset()
self.__do_update(api_obj, ["barge"])
self.pkg("list [email protected] derelict")

# And now derelict should be uninstallable
api_obj.reset()
self.__do_uninstall(api_obj, ["derelict"])
self.pkg("list derelict", exit=1)

def test_multi_publisher(self):
"""Verify that package install works as expected when multiple
publishers share the same repository."""
Expand Down