1516N/A#!/usr/bin/python
941N/A#
941N/A# CDDL HEADER START
941N/A#
941N/A# The contents of this file are subject to the terms of the
941N/A# Common Development and Distribution License (the "License").
941N/A# You may not use this file except in compliance with the License.
941N/A#
941N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
941N/A# or http://www.opensolaris.org/os/licensing.
941N/A# See the License for the specific language governing permissions
941N/A# and limitations under the License.
941N/A#
941N/A# When distributing Covered Code, include this CDDL HEADER in each
941N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
941N/A# If applicable, add the following below this CDDL HEADER, with the
941N/A# fields enclosed by brackets "[]" replaced with your own identifying
941N/A# information: Portions Copyright [yyyy] [name of copyright owner]
941N/A#
941N/A# CDDL HEADER END
941N/A#
941N/A
3315N/A# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
941N/A
3339N/Afrom . import testutils
941N/Aif __name__ == "__main__":
941N/A testutils.setup_environment("../../../proto")
1715N/Aimport pkg5unittest
941N/A
1230N/Aimport copy
941N/Aimport os
941N/Aimport shutil
1230N/Aimport tempfile
941N/Aimport time
1230N/Aimport unittest
3234N/Afrom six.moves.urllib.error import HTTPError
3234N/Afrom six.moves.urllib.request import urlopen
941N/A
941N/Aimport pkg.client.api as api
941N/Aimport pkg.client.api_errors as api_errors
941N/Aimport pkg.client.query_parser as query_parser
941N/Aimport pkg.fmri as fmri
1286N/Aimport pkg.indexer as indexer
941N/Aimport pkg.portable as portable
941N/Aimport pkg.search_storage as ss
3339N/Afrom pkg.misc import force_str
941N/A
941N/A
1715N/Aclass TestApiSearchBasics(pkg5unittest.SingleDepotTestCase):
3315N/A # Tests in this suite use the read only data directory.
3315N/A need_ro_data = True
941N/A
941N/A example_pkg10 = """
941N/A open example_pkg@1.0,5.11-0
941N/A add dir mode=0755 owner=root group=bin path=/bin
941N/A add dir mode=0755 owner=root group=bin path=/bin/example_dir
3177N/A add dir mode=0755 owner=root group=bin path=/usr/lib/python2.7/vendor-packages/OpenSSL
1715N/A add file tmp/example_file mode=0555 owner=root group=bin path=/bin/example_path
2453N/A add link path=/bin/exlink target=/bin/example_path mediator=example mediator-version=7.0 mediator-implementation=unladen-swallow
941N/A add set name=com.sun.service.incorporated_changes value="6556919 6627937"
941N/A add set name=com.sun.service.random_test value=42 value=79
1682N/A add set name=com.sun.service.bug_ids value=4641790 value=4725245 value=4817791 value=4851433 value=4897491 value=4913776 value=6178339 value=6556919 value=6627937
941N/A add set name=com.sun.service.keywords value="sort null -n -m -t sort 0x86 separator"
941N/A add set name=com.sun.service.info_url value=http://service.opensolaris.com/xml/pkg/SUNWcsu@0.5.11,5.11-1:20080514I120000Z
1682N/A add set name=description value='FOOO bAr O OO OOO' value="whee fun"
941N/A add set name='weirdness' value='] [ * ?'
2291N/A add set name=org.opensolaris.smf.fmri value=svc:/milestone/multi-user-server:default
941N/A close """
941N/A
941N/A example_pkg11 = """
941N/A open example_pkg@1.1,5.11-0
941N/A add dir mode=0755 owner=root group=bin path=/bin
1715N/A add file tmp/example_file mode=0555 owner=root group=bin path=/bin/example_path11
941N/A close """
941N/A
1843N/A incorp_pkg10 = """
1843N/A open incorp_pkg@1.0,5.11-0
1843N/A add depend fmri=example_pkg@1.0,5.11-0 type=incorporate
1843N/A close """
1843N/A
1843N/A incorp_pkg11 = """
1843N/A open incorp_pkg@1.1,5.11-0
1843N/A add depend fmri=example_pkg@1.1,5.11-0 type=incorporate
1843N/A close """
1843N/A
941N/A another_pkg10 = """
941N/A open another_pkg@1.0,5.11-0
1715N/A add dir mode=0755 owner=root group=bin path=/bazbin
941N/A close """
941N/A
941N/A bad_pkg10 = """
941N/A open bad_pkg@1.0,5.11-0
1127N/A add dir path=badfoo/ mode=0755 owner=root group=bin
941N/A close """
941N/A
941N/A space_pkg10 = """
941N/A open space_pkg@1.0,5.11-0
1715N/A add file tmp/example_file mode=0444 owner=nobody group=sys path='unique/with a space'
941N/A add dir mode=0755 owner=root group=bin path=unique_dir
941N/A close """
941N/A
941N/A cat_pkg10 = """
941N/A open cat@1.0,5.11-0
1115N/A add set name=info.classification value=org.opensolaris.category.2008:System/Security value=org.random:Other/Category
941N/A close """
941N/A
941N/A cat2_pkg10 = """
941N/A open cat2@1.0,5.11-0
1115N/A add set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video" value=Developer/C
941N/A close """
941N/A
941N/A cat3_pkg10 = """
941N/A open cat3@1.0,5.11-0
941N/A add set name=info.classification value="org.opensolaris.category.2008:foo/bar/baz/bill/beam/asda"
941N/A close """
941N/A
941N/A bad_cat_pkg10 = """
941N/A open badcat@1.0,5.11-0
941N/A add set name=info.classification value="TestBad1/TestBad2"
941N/A close """
941N/A
941N/A bad_cat2_pkg10 = """
941N/A open badcat2@1.0,5.11-0
941N/A add set name=info.classification value="org.opensolaris.category.2008:TestBad1:TestBad2"
941N/A close """
941N/A
1127N/A fat_pkg10 = """
1127N/Aopen fat@1.0,5.11-0
1127N/Aadd set name=variant.arch value=sparc value=i386
1127N/Aadd set name=description value="i386 variant" variant.arch=i386
1127N/Aadd set name=description value="sparc variant" variant.arch=sparc
1127N/Aclose """
1127N/A
1127N/A bogus_pkg10 = """
1431N/Aset name=pkg.fmri value=pkg:/bogus_pkg@1.0,5.11-0:20090326T233451Z
1127N/Aset name=description value=""validation with simple chains of constraints ""
1127N/Aset name=pkg.description value="pseudo-hashes as arrays tied to a "type" (list of fields)"
1127N/Adepend fmri=XML-Atom-Entry
1127N/Aset name=com.sun.service.incorporated_changes value="6556919 6627937"
1127N/A"""
1127N/A bogus_fmri = fmri.PkgFmri("bogus_pkg@1.0,5.11-0:20090326T233451Z")
1127N/A
1728N/A hierarchical_named_pkg = """
1728N/Aopen pa/pb/pc/pfoo@1.0,5.11-0
1728N/Aclose """
1728N/A
1661N/A bug_8492_manf_1 = """
1661N/Aopen b1@1.0,5.11-0
1661N/Aadd set description="Image Packaging System"
1661N/Aclose """
1661N/A
1661N/A bug_8492_manf_2 = """
1661N/Aopen b2@1.0,5.11-0
1661N/Aadd set description="Image Packaging System"
1661N/Aclose """
1661N/A
2185N/A require_any_manf = """
2185N/Aopen ra@1.0,5.11-0
2185N/Aadd depend type=require-any fmri=another_pkg@1.0,5.11-0 fmri=pkg:/space_pkg@1.0,5.11-0
2185N/Aclose
2185N/A"""
2185N/A
1682N/A res_8492_1 = set([('pkg:/b1@1.0-0', 'Image Packaging System', 'set name=description value="Image Packaging System"')])
1682N/A res_8492_2 = set([('pkg:/b2@1.0-0', 'Image Packaging System', 'set name=description value="Image Packaging System"')])
2453N/A
1431N/A remote_fmri_string = ('pkg:/example_pkg@1.0-0', 'test/example_pkg',
1431N/A 'set name=pkg.fmri value=pkg://test/example_pkg@1.0,5.11-0:')
1431N/A
1431N/A res_remote_pkg = set([
1431N/A remote_fmri_string
1431N/A ])
1431N/A
941N/A res_remote_path = set([
3460N/A ("pkg:/example_pkg@1.0-0", "basename","file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin mode=0555 owner=root path=bin/example_path pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 pkg.csize=30 pkg.size=12"),
941N/A ])
941N/A
1360N/A res_remote_path_of_example_path = set([
3460N/A ("pkg:/example_pkg@1.0-0", "path","file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin mode=0555 owner=root path=bin/example_path pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 pkg.csize=30 pkg.size=12")
1360N/A ])
1360N/A
941N/A res_remote_bin = set([
941N/A ("pkg:/example_pkg@1.0-0", "path", "dir group=bin mode=0755 owner=root path=bin")
941N/A ])
941N/A
941N/A res_remote_openssl = set([
3177N/A ("pkg:/example_pkg@1.0-0", "basename", "dir group=bin mode=0755 owner=root path=usr/lib/python2.7/vendor-packages/OpenSSL")
941N/A ])
941N/A
941N/A res_remote_bug_id = set([
1682N/A ("pkg:/example_pkg@1.0-0", "4851433", 'set name=com.sun.service.bug_ids value=4641790 value=4725245 value=4817791 value=4851433 value=4897491 value=4913776 value=6178339 value=6556919 value=6627937')
941N/A ])
941N/A
1127N/A res_remote_bug_id_4725245 = set([
1682N/A ("pkg:/example_pkg@1.0-0", "4725245", 'set name=com.sun.service.bug_ids value=4641790 value=4725245 value=4817791 value=4851433 value=4897491 value=4913776 value=6178339 value=6556919 value=6627937')
1127N/A ])
1127N/A
1127N/A
941N/A res_remote_inc_changes = set([
1682N/A ("pkg:/example_pkg@1.0-0", "6556919 6627937", 'set name=com.sun.service.incorporated_changes value="6556919 6627937"'),
1682N/A ("pkg:/example_pkg@1.0-0", "6556919", 'set name=com.sun.service.bug_ids value=4641790 value=4725245 value=4817791 value=4851433 value=4897491 value=4913776 value=6178339 value=6556919 value=6627937')
941N/A ])
941N/A
2453N/A res_remote_mediator = set([
2453N/A ("pkg:/example_pkg@1.0-0", "mediator", "link mediator=example mediator-implementation=unladen-swallow mediator-version=7.0 path=bin/exlink target=/bin/example_path")
2453N/A ])
2453N/A
2453N/A res_remote_mediator_version = set([
2453N/A ("pkg:/example_pkg@1.0-0", "mediator-version", "link mediator=example mediator-implementation=unladen-swallow mediator-version=7.0 path=bin/exlink target=/bin/example_path")
2453N/A ])
2453N/A
2453N/A res_remote_mediator_impl = set([
2453N/A ("pkg:/example_pkg@1.0-0", "mediator-implementation", "link mediator=example mediator-implementation=unladen-swallow mediator-version=7.0 path=bin/exlink target=/bin/example_path")
2453N/A ])
2453N/A
2453N/A res_remote_mediator_and_ver = res_remote_mediator.union(
2453N/A res_remote_mediator_version)
2453N/A
2453N/A res_remote_mediator_and_ver_impl = res_remote_mediator.union(
2453N/A res_remote_mediator_version).union(res_remote_mediator_impl)
2453N/A
941N/A res_remote_random_test = set([
941N/A ("pkg:/example_pkg@1.0-0", "42", "set name=com.sun.service.random_test value=42 value=79")
941N/A ])
941N/A
1127N/A res_remote_random_test_79 = set([
1127N/A ("pkg:/example_pkg@1.0-0", "79", "set name=com.sun.service.random_test value=42 value=79")
1127N/A ])
1127N/A
941N/A res_remote_keywords = set([
1682N/A ("pkg:/example_pkg@1.0-0", "sort null -n -m -t sort 0x86 separator", 'set name=com.sun.service.keywords value="sort null -n -m -t sort 0x86 separator"')
1127N/A ])
1127N/A
941N/A res_remote_wildcard = res_remote_path.union(set([
1431N/A remote_fmri_string,
2453N/A ('pkg:/example_pkg@1.0-0', 'basename', 'dir group=bin mode=0755 owner=root path=bin/example_dir'),
2453N/A ("pkg:/example_pkg@1.0-0", "mediator", "link mediator=example mediator-implementation=unladen-swallow mediator-version=7.0 path=bin/exlink target=/bin/example_path")
941N/A ]))
941N/A
941N/A res_remote_glob = set([
1431N/A remote_fmri_string,
941N/A ('pkg:/example_pkg@1.0-0', 'path', 'dir group=bin mode=0755 owner=root path=bin/example_dir'),
941N/A ('pkg:/example_pkg@1.0-0', 'basename', 'dir group=bin mode=0755 owner=root path=bin/example_dir'),
3460N/A ('pkg:/example_pkg@1.0-0', 'path', 'file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin mode=0555 owner=root path=bin/example_path pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 pkg.csize=30 pkg.size=12'),
2453N/A ("pkg:/example_pkg@1.0-0", "mediator", "link mediator=example mediator-implementation=unladen-swallow mediator-version=7.0 path=bin/exlink target=/bin/example_path")
941N/A ]) | res_remote_path
941N/A
941N/A res_remote_foo = set([
1682N/A ('pkg:/example_pkg@1.0-0', 'FOOO bAr O OO OOO', 'set name=description value="FOOO bAr O OO OOO" value="whee fun"')
941N/A ])
941N/A
1682N/A res_remote_weird = set([
1682N/A ('pkg:/example_pkg@1.0-0', '] [ * ?', 'set name=weirdness value="] [ * ?"')
941N/A ])
1431N/A
1352N/A local_fmri_string = ('pkg:/example_pkg@1.0-0', 'test/example_pkg',
1431N/A 'set name=pkg.fmri value=pkg://test/example_pkg@1.0,5.11-0:')
941N/A
941N/A res_local_pkg = set([
941N/A local_fmri_string
941N/A ])
941N/A
941N/A res_local_path = copy.copy(res_remote_path)
941N/A
941N/A res_local_bin = copy.copy(res_remote_bin)
941N/A
941N/A res_local_bug_id = copy.copy(res_remote_bug_id)
941N/A
941N/A res_local_inc_changes = copy.copy(res_remote_inc_changes)
941N/A
941N/A res_local_random_test = copy.copy(res_remote_random_test)
941N/A
941N/A res_local_keywords = copy.copy(res_remote_keywords)
941N/A
2453N/A res_local_mediator = copy.copy(res_remote_mediator)
2453N/A res_local_mediator_version = copy.copy(res_remote_mediator_version)
2453N/A res_local_mediator_impl = copy.copy(res_remote_mediator_impl)
2453N/A res_local_mediator_and_ver = copy.copy(res_remote_mediator_and_ver)
2453N/A res_local_mediator_and_ver_impl = copy.copy(
2453N/A res_remote_mediator_and_ver_impl)
2453N/A
941N/A res_local_wildcard = copy.copy(res_remote_wildcard)
941N/A res_local_wildcard.add(local_fmri_string)
941N/A
941N/A res_local_glob = copy.copy(res_remote_glob)
941N/A res_local_glob.add(local_fmri_string)
941N/A
941N/A res_local_foo = copy.copy(res_remote_foo)
941N/A
941N/A res_local_openssl = copy.copy(res_remote_openssl)
1431N/A
941N/A res_local_path_example11 = set([
3460N/A ("pkg:/example_pkg@1.1-0", "basename", "file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin mode=0555 owner=root path=bin/example_path11 pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 pkg.csize=30 pkg.size=12")
941N/A ])
941N/A
941N/A res_local_bin_example11 = set([
941N/A ("pkg:/example_pkg@1.1-0", "path", "dir group=bin mode=0755 owner=root path=bin")
941N/A ])
941N/A
1325N/A res_local_pkg_example11 = set([
1431N/A ("pkg:/example_pkg@1.1-0", "test/example_pkg", "set name=pkg.fmri value=pkg://test/example_pkg@1.1,5.11-0:")
1325N/A ])
1325N/A
941N/A res_local_wildcard_example11 = set([
3460N/A ("pkg:/example_pkg@1.1-0", "basename", "file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin mode=0555 owner=root path=bin/example_path11 pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 pkg.csize=30 pkg.size=12"),
1325N/A ]).union(res_local_pkg_example11)
941N/A
941N/A res_cat_pkg10 = set([
1115N/A ('pkg:/cat@1.0-0', 'System/Security', 'set name=info.classification value=org.opensolaris.category.2008:System/Security value=org.random:Other/Category')
1115N/A ])
1115N/A
1115N/A res_cat_pkg10_2 = set([
1115N/A ('pkg:/cat@1.0-0', 'Other/Category', 'set name=info.classification value=org.opensolaris.category.2008:System/Security value=org.random:Other/Category')
941N/A ])
941N/A
941N/A res_cat2_pkg10 = set([
1115N/A ('pkg:/cat2@1.0-0', 'Applications/Sound and Video', 'set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video" value=Developer/C')
1115N/A ])
1115N/A
1115N/A res_cat2_pkg10_2 = set([
1115N/A ('pkg:/cat2@1.0-0', 'Developer/C', 'set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video" value=Developer/C')
941N/A ])
941N/A
941N/A res_cat3_pkg10 = set([
941N/A ('pkg:/cat3@1.0-0', 'foo/bar/baz/bill/beam/asda', 'set name=info.classification value=org.opensolaris.category.2008:foo/bar/baz/bill/beam/asda')
941N/A ])
941N/A
1127N/A res_fat10_i386 = set([
1682N/A ('pkg:/fat@1.0-0', 'i386 variant', 'set name=description value="i386 variant" variant.arch=i386'),
1682N/A ('pkg:/fat@1.0-0', 'i386 variant', 'set name=description value="i386 variant" variant.arch=i386'),
1127N/A ('pkg:/fat@1.0-0', 'i386', 'set name=variant.arch value=sparc value=i386'),
1127N/A ])
1127N/A
1127N/A res_fat10_sparc = set([
1682N/A ('pkg:/fat@1.0-0', 'sparc variant', 'set name=description value="sparc variant" variant.arch=sparc'),
1682N/A ('pkg:/fat@1.0-0', 'sparc', 'set name=variant.arch value=sparc value=i386')
1127N/A ])
1127N/A
1431N/A fat_10_fmri_string = set([('pkg:/fat@1.0-0', 'test/fat', 'set name=pkg.fmri value=pkg://test/fat@1.0,5.11-0:')])
1431N/A
1431N/A res_remote_fat10_star = fat_10_fmri_string | res_fat10_sparc | res_fat10_i386
1127N/A
1127N/A res_local_fat10_i386_star = res_fat10_i386.union(set([
1127N/A ('pkg:/fat@1.0-0', 'sparc', 'set name=variant.arch value=sparc value=i386')
1431N/A ])).union(fat_10_fmri_string)
1127N/A
1127N/A res_local_fat10_sparc_star = res_fat10_sparc.union(set([
1127N/A ('pkg:/fat@1.0-0', 'i386', 'set name=variant.arch value=sparc value=i386')
1431N/A ])).union(fat_10_fmri_string)
1431N/A
941N/A res_space_with_star = set([
3460N/A ('pkg:/space_pkg@1.0-0', 'basename', 'file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=sys mode=0444 owner=nobody path="unique/with a space" pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 pkg.csize=30 pkg.size=12')
941N/A ])
941N/A
941N/A res_space_space_star = set([
3460N/A ('pkg:/space_pkg@1.0-0', 'basename', 'file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=sys mode=0444 owner=nobody path="unique/with a space" pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 pkg.csize=30 pkg.size=12'), ('pkg:/space_pkg@1.0-0', 'path', 'file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=sys mode=0444 owner=nobody path="unique/with a space" pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 pkg.csize=30 pkg.size=12')
941N/A ])
941N/A
941N/A res_space_unique = set([
941N/A ('pkg:/space_pkg@1.0-0', 'basename', 'dir group=bin mode=0755 owner=root path=unique_dir')
941N/A ])
941N/A
941N/A # This is a copy of the 3.81%2C5.11-0.89%3A20080527T163123Z version of
941N/A # SUNWgmake from ipkg with the file and liscense actions changed so
941N/A # that they all take /tmp/example file when sending.
941N/A bug_983_manifest = """
941N/Aopen SUNWgmake@3.81,5.11-0.89
941N/Aadd dir group=sys mode=0755 owner=root path=usr
941N/Aadd dir group=bin mode=0755 owner=root path=usr/bin
941N/Aadd dir group=bin mode=0755 owner=root path=usr/gnu
941N/Aadd dir group=bin mode=0755 owner=root path=usr/gnu/bin
941N/Aadd link path=usr/gnu/bin/make target=../../bin/gmake
941N/Aadd dir group=sys mode=0755 owner=root path=usr/gnu/share
941N/Aadd dir group=bin mode=0755 owner=root path=usr/gnu/share/man
941N/Aadd dir group=bin mode=0755 owner=root path=usr/gnu/share/man/man1
941N/Aadd link path=usr/gnu/share/man/man1/make.1 target=../../../../share/man/man1/gmake.1
941N/Aadd dir group=bin mode=0755 owner=root path=usr/sfw
941N/Aadd dir group=bin mode=0755 owner=root path=usr/sfw/bin
941N/Aadd link path=usr/sfw/bin/gmake target=../../bin/gmake
941N/Aadd dir group=bin mode=0755 owner=root path=usr/sfw/share
941N/Aadd dir group=bin mode=0755 owner=root path=usr/sfw/share/man
941N/Aadd dir group=bin mode=0755 owner=root path=usr/sfw/share/man/man1
941N/Aadd link path=usr/sfw/share/man/man1/gmake.1 target=../../../../share/man/man1/gmake.1
941N/Aadd dir group=sys mode=0755 owner=root path=usr/share
941N/Aadd dir group=bin mode=0755 owner=root path=usr/share/info
941N/Aadd dir group=bin mode=0755 owner=root path=usr/share/man
941N/Aadd dir group=bin mode=0755 owner=root path=usr/share/man/man1
3402N/Aadd file ro_data/elftest.so.1 elfarch=i386 elfbits=32 elfhash=083308992c921537fd757548964f89452234dd11 group=bin mode=0555 owner=root path=usr/bin/gmake pkg.content-hash=bad_data pkg.size=12
1715N/Aadd file tmp/example_file group=bin mode=0444 owner=root path=usr/share/info/make.info pkg.size=12
1715N/Aadd file tmp/example_file group=bin mode=0444 owner=root path=usr/share/info/make.info-1 pkg.size=12
1715N/Aadd file tmp/example_file group=bin mode=0444 owner=root path=usr/share/info/make.info-2 pkg.size=12
1715N/Aadd file tmp/example_file group=bin mode=0444 owner=root path=usr/share/man/man1/gmake.1 pkg.size=12
1715N/Aadd license tmp/example_file license=SUNWgmake.copyright pkg.size=12 transaction_id=1211931083_pkg%3A%2FSUNWgmake%403.81%2C5.11-0.89%3A20080527T163123Z
941N/Aadd depend fmri=pkg:/SUNWcsl@0.5.11-0.89 type=require
1146N/Aadd depend fmri=SUNWtestbar@0.5.11-0.111 type=require
1146N/Aadd depend fmri=SUNWtestfoo@0.5.11-0.111 type=incorporate
941N/Aadd set name=description value="gmake - GNU make"
941N/Aadd legacy arch=i386 category=system desc="GNU make - A utility used to build software (gmake) 3.81" hotline="Please contact your local service provider" name="gmake - GNU make" pkg=SUNWgmake vendor="Sun Microsystems, Inc." version=11.11.0,REV=2008.04.29.02.08
941N/Aclose
941N/A"""
941N/A
941N/A res_bug_983 = set([
941N/A ("pkg:/SUNWgmake@3.81-0.89", "basename", "link path=usr/sfw/bin/gmake target=../../bin/gmake"),
3460N/A ('pkg:/SUNWgmake@3.81-0.89', 'basename', 'file 038cc7a09940928aeac6966331a2f18bc40e7792 chash=a3e76bd1b97b715cddc93b2ad6502b41efa4d833 elfarch=i386 elfbits=32 elfhash=083308992c921537fd757548964f89452234dd11 group=bin mode=0555 owner=root path=usr/bin/gmake pkg.content-hash=gelf:sha512t_256:d83d7d72909d64b455da54095f65b6f36917c53be456d61740dd83d98f0c6c4e pkg.content-hash=gelf.unsigned:sha512t_256:d83d7d72909d64b455da54095f65b6f36917c53be456d61740dd83d98f0c6c4e pkg.content-hash=file:sha512t_256:2374db2dfb4968baad246ab37afc560cc9d278b6104a889a2727d9bcf6a20b17 pkg.content-hash=gzip:sha512t_256:17e38c279aad2c4877618246cb60cb4c795f6754880649c56d847e653fadd71c pkg.csize=1358 pkg.size=3948'),
1682N/A ('pkg:/SUNWgmake@3.81-0.89', 'gmake - GNU make', 'set name=description value="gmake - GNU make"')
941N/A ])
941N/A
1146N/A res_983_csl_dependency = set([
1146N/A ('pkg:/SUNWgmake@3.81-0.89', 'require', 'depend fmri=pkg:/SUNWcsl@0.5.11-0.89 type=require')
1146N/A ])
1146N/A
1146N/A res_983_bar_dependency = set([
1146N/A ('pkg:/SUNWgmake@3.81-0.89', 'require', 'depend fmri=SUNWtestbar@0.5.11-0.111 type=require')
1146N/A ])
1146N/A
1146N/A res_983_foo_dependency = set([
1146N/A ('pkg:/SUNWgmake@3.81-0.89', 'incorporate', 'depend fmri=SUNWtestfoo@0.5.11-0.111 type=incorporate')
1146N/A ])
1146N/A
1127N/A res_local_pkg_ret_pkg = set([
1127N/A "pkg:/example_pkg@1.0-0"
1127N/A ])
1127N/A
1127N/A res_remote_pkg_ret_pkg = set([
1127N/A "pkg:/example_pkg@1.0-0"
1127N/A ])
1127N/A
1127N/A res_remote_file = set([
2962N/A ("pkg:/example_pkg@1.0-0",
2962N/A "path",
2962N/A "file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
2962N/A "chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
3445N/A "mode=0555 owner=root path=bin/example_path "
3445N/A "pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 "
3460N/A "pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 "
3445N/A "pkg.csize=30 "
2962N/A "pkg.size=12"),
2962N/A ("pkg:/example_pkg@1.0-0",
2962N/A "a686473102ba73bd7920fc0ab1d97e00a24ed704",
2962N/A "file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
2962N/A "chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
3445N/A "mode=0555 owner=root path=bin/example_path "
3445N/A "pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 "
3460N/A "pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 "
3445N/A "pkg.csize=30 "
2962N/A "pkg.size=12"),
2962N/A ("pkg:/example_pkg@1.0-0",
2962N/A "hash",
2962N/A "file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
2962N/A "chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
3445N/A "mode=0555 owner=root path=bin/example_path "
3445N/A "pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 "
3460N/A "pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 "
3445N/A "pkg.csize=30 "
3445N/A "pkg.size=12"),
3445N/A ("pkg:/example_pkg@1.0-0",
3445N/A "pkg.content-hash",
3445N/A "file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
3445N/A "chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
3445N/A "mode=0555 owner=root path=bin/example_path "
3445N/A "pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 "
3460N/A "pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 "
3445N/A "pkg.csize=30 "
2962N/A "pkg.size=12")
1127N/A ]) | res_remote_path
1431N/A
1127N/A res_remote_url = set([
1127N/A ('pkg:/example_pkg@1.0-0',
1127N/A 'http://service.opensolaris.com/xml/pkg/SUNWcsu@0.5.11,5.11-1:20080514I120000Z',
1715N/A 'set name=com.sun.service.info_url value=http://service.opensolaris.com/xml/pkg/SUNWcsu@0.5.11,5.11-1:20080514I120000Z'),
1127N/A ])
1127N/A
1127N/A res_remote_path_extra = set([
2962N/A ("pkg:/example_pkg@1.0-0",
2962N/A "basename",
2962N/A "file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
2962N/A "chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
3445N/A "mode=0555 owner=root path=bin/example_path "
3445N/A "pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 "
3460N/A "pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 "
3445N/A "pkg.csize=30 "
2962N/A "pkg.size=12"),
2962N/A ("pkg:/example_pkg@1.0-0",
2962N/A "path",
2962N/A "file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
2962N/A "chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
3445N/A "mode=0555 owner=root path=bin/example_path "
3445N/A "pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 "
3460N/A "pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 "
3445N/A "pkg.csize=30 "
2962N/A "pkg.size=12"),
2962N/A ("pkg:/example_pkg@1.0-0",
2962N/A "a686473102ba73bd7920fc0ab1d97e00a24ed704",
2962N/A "file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
2962N/A "chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
3445N/A "mode=0555 owner=root path=bin/example_path "
3445N/A "pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 "
3460N/A "pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 "
3445N/A "pkg.csize=30 "
2962N/A "pkg.size=12"),
2962N/A ("pkg:/example_pkg@1.0-0",
2962N/A "hash",
2962N/A "file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
2962N/A "chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
3445N/A "mode=0555 owner=root path=bin/example_path "
3445N/A "pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 "
3460N/A "pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 "
3445N/A "pkg.csize=30 "
3445N/A "pkg.size=12"),
3445N/A ("pkg:/example_pkg@1.0-0",
3445N/A "pkg.content-hash",
3445N/A "file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
3445N/A "chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
3445N/A "mode=0555 owner=root path=bin/example_path "
3445N/A "pkg.content-hash=file:sha512t_256:e4e6f08153d331ec9d342f9f52c512fcbb2c4b46d4b5e8de5640ae5fbe022011 "
3460N/A "pkg.content-hash=gzip:sha512t_256:98026acb06f550ed66c22b4314c3ca48a92fce49735aa4c61c5cb4330bb83b81 "
3445N/A "pkg.csize=30 "
3445N/A "pkg.size=12")
1127N/A ])
1127N/A
1127N/A res_bad_pkg = set([
1127N/A ('pkg:/bad_pkg@1.0-0', 'basename',
1127N/A 'dir group=bin mode=0755 owner=root path=badfoo/')
1127N/A ])
1354N/A
1728N/A hierarchical_named_pkg_res = set([
1728N/A ("pkg:/pa/pb/pc/pfoo@1.0-0", "test/pa/pb/pc/pfoo", "set name=pkg.fmri value=pkg://test/pa/pb/pc/pfoo@1.0,5.11-0:")
1728N/A ])
1728N/A
1354N/A fast_add_after_install = set([
1354N/A "VERSION: 2\n",
1354N/A "pkg22@1.0,5.11",
1354N/A "pkg21@1.0,5.11"
1354N/A ])
1354N/A
1354N/A fast_remove_after_install = set([
1354N/A "VERSION: 2\n",
1354N/A ])
1354N/A
1354N/A fast_add_after_first_update = set([
1354N/A "VERSION: 2\n",
1354N/A "pkg0@2.0,5.11",
1354N/A "pkg22@1.0,5.11",
1354N/A "pkg21@1.0,5.11",
1354N/A "pkg1@2.0,5.11"
1354N/A ])
1354N/A
1354N/A fast_remove_after_first_update = set([
1354N/A "VERSION: 2\n",
1354N/A "pkg0@1.0,5.11",
1354N/A "pkg1@1.0,5.11"
1354N/A ])
1354N/A
1844N/A res_smf_svc = set([
1844N/A ('pkg:/example_pkg@1.0-0',
1844N/A 'svc:/milestone/multi-user-server:default',
2291N/A 'set name=org.opensolaris.smf.fmri value=svc:/milestone/multi-user-server:default')
1844N/A ])
1844N/A
2204N/A res_dir = set([
2204N/A ('pkg:/example_pkg@1.0-0', 'path',
2204N/A 'dir group=bin mode=0755 owner=root path=bin/example_dir')])
2204N/A
1354N/A fast_add_after_second_update = set(["VERSION: 2\n"])
1354N/A
1354N/A fast_remove_after_second_update = set(["VERSION: 2\n"])
1431N/A
1431N/A debug_features = []
941N/A
1715N/A # We wire the contents of the example file to a well known string
1715N/A # so that the hash is also well known.
1715N/A misc_files = { "tmp/example_file" : "magic banana" }
1715N/A
941N/A def setUp(self):
1715N/A pkg5unittest.SingleDepotTestCase.setUp(self,
1895N/A debug_features=self.debug_features, start_depot=True)
1715N/A self.testdata_dir = os.path.join(self.test_root,
1715N/A "search_results")
941N/A os.mkdir(self.testdata_dir)
941N/A self._dir_restore_functions = [self._restore_dir,
941N/A self._restore_dir_preserve_hash]
1715N/A self.make_misc_files(self.misc_files)
941N/A
941N/A def _check(self, proposed_answer, correct_answer):
941N/A if correct_answer == proposed_answer:
941N/A return True
941N/A else:
1352N/A self.debug("Proposed Answer: " + str(proposed_answer))
1352N/A self.debug("Correct Answer : " + str(correct_answer))
941N/A if isinstance(correct_answer, set) and \
941N/A isinstance(proposed_answer, set):
1728N/A self.debug("Missing: " +
1728N/A str(correct_answer - proposed_answer))
1728N/A self.debug("Extra : " +
1728N/A str(proposed_answer - correct_answer))
2453N/A self.assertEqualDiff(correct_answer, proposed_answer)
941N/A
2028N/A def _get_repo_index_dir(self):
2028N/A depotpath = self.dc.get_repodir()
2028N/A repo = self.dc.get_repo()
2028N/A rstore = repo.get_pub_rstore("test")
2028N/A return rstore.index_root
2028N/A
2028N/A def _get_repo_writ_dir(self):
2028N/A depotpath = self.dc.get_repodir()
2028N/A repo = self.dc.get_repo()
2028N/A rstore = repo.get_pub_rstore("test")
2028N/A return rstore.writable_root
2028N/A
2028N/A def _get_repo_catalog(self):
2028N/A repo = self.dc.get_repo()
2028N/A rstore = repo.get_pub_rstore("test")
2028N/A return rstore.catalog
2028N/A
941N/A @staticmethod
941N/A def _replace_act(act):
1431N/A if act.startswith('set name=pkg.fmri'):
1325N/A return act.strip().rsplit(":", 1)[0] + ":"
941N/A else:
941N/A return act.strip()
1431N/A
941N/A @staticmethod
941N/A def _extract_action_from_res(it):
941N/A return (
941N/A (fmri.PkgFmri(str(pkg_name)).get_short_fmri(), piece,
941N/A TestApiSearchBasics._replace_act(act))
941N/A for query_num, auth, (version, return_type,
941N/A (pkg_name, piece, act))
941N/A in it
941N/A )
1127N/A
1127N/A @staticmethod
1127N/A def _extract_package_from_res(it):
1127N/A return (
1127N/A (fmri.PkgFmri(str(pkg_name)).get_short_fmri())
1127N/A for query_num, auth, (version, return_type, pkg_name)
1127N/A in it
1127N/A )
1127N/A
1354N/A @staticmethod
1354N/A def _get_lines(fp):
3339N/A with open(fp, "r") as fh:
3339N/A lines = fh.readlines()
1354N/A return lines
1354N/A
941N/A def _search_op(self, api_obj, remote, token, test_value,
941N/A case_sensitive=False, return_actions=True, num_to_return=None,
1843N/A start_point=None, servers=None, prune_versions=True):
1360N/A query = [api.Query(token, case_sensitive, return_actions,
1360N/A num_to_return, start_point)]
1360N/A self._search_op_common(api_obj, remote, query, test_value,
1843N/A return_actions, servers, prune_versions)
1360N/A
1360N/A def _search_op_multi(self, api_obj, remote, tokens, test_value,
1360N/A case_sensitive=False, return_actions=True, num_to_return=None,
1843N/A start_point=None, servers=None, prune_versions=True):
1360N/A query = [api.Query(token, case_sensitive, return_actions,
1360N/A num_to_return, start_point) for token in tokens]
1360N/A self._search_op_common(api_obj, remote, query, test_value,
1843N/A return_actions, servers, prune_versions)
1360N/A
1360N/A def _search_op_common(self, api_obj, remote, query, test_value,
1843N/A return_actions, servers, prune_versions):
3158N/A self.debug("Search for: {0}".format(" ".join([str(q) for q in query])))
941N/A search_func = api_obj.local_search
941N/A if remote:
1081N/A search_func = lambda x: api_obj.remote_search(x,
1843N/A servers=servers, prune_versions=prune_versions)
1505N/A init_time = time.time()
1505N/A
1505N/A # servers may not be ready immediately - retry search
1505N/A # operation for 5 seconds
1505N/A
1505N/A while (time.time() - init_time) < 5:
1505N/A try:
1505N/A res = search_func(query)
1505N/A if return_actions:
1505N/A res = self._extract_action_from_res(res)
1505N/A else:
1505N/A res = self._extract_package_from_res(res)
1505N/A res = set(res)
1505N/A break
3171N/A except api_errors.ProblematicSearchServers as e:
1505N/A pass
1505N/A
941N/A self._check(set(res), test_value)
941N/A
941N/A def _search_op_slow(self, api_obj, remote, token, test_value,
941N/A case_sensitive=False, return_actions=True, num_to_return=None,
941N/A start_point=None):
1360N/A query = [api.Query(token, case_sensitive, return_actions,
1360N/A num_to_return, start_point)]
1360N/A self._search_op_slow_common(api_obj, query, test_value,
1360N/A return_actions)
1360N/A
1360N/A def _search_op_slow_multi(self, api_obj, remote, tokens, test_value,
1360N/A case_sensitive=False, return_actions=True, num_to_return=None,
1360N/A start_point=None):
1360N/A query = [api.Query(token, case_sensitive, return_actions,
1360N/A num_to_return, start_point) for token in tokens]
1360N/A self._search_op_slow_common(api_obj, query, test_value,
1360N/A return_actions)
1360N/A
1360N/A def _search_op_slow_common(self, api_obj, query, test_value,
1360N/A return_actions):
941N/A search_func = api_obj.local_search
1360N/A tmp = search_func(query)
941N/A res = []
1127N/A ssu = False
941N/A try:
941N/A for i in tmp:
941N/A res.append(i)
941N/A except api_errors.SlowSearchUsed:
1127N/A ssu = True
3339N/A self.assertTrue(ssu)
1127N/A if return_actions:
1127N/A res = self._extract_action_from_res(res)
1127N/A else:
1127N/A res = self._extract_package_from_res(res)
1127N/A res = set(res)
941N/A self._check(set(res), test_value)
941N/A
1127N/A def _run_full_remote_tests(self, api_obj):
1431N/A self._search_op(api_obj, True, "example_pkg",
1431N/A self.res_remote_pkg)
941N/A self._search_op(api_obj, True, "example_path",
941N/A self.res_remote_path)
1127N/A self._search_op(api_obj, True, "(example_path)",
1127N/A self.res_remote_path)
1127N/A self._search_op(api_obj, True, "<exam*:::>",
1127N/A self.res_remote_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, True, "::com.sun.service.info_url:",
1127N/A self.res_remote_url)
1127N/A self._search_op(api_obj, True, ":::e* AND *path",
1127N/A self.res_remote_path)
1127N/A self._search_op(api_obj, True, "e* AND *path",
1127N/A self.res_remote_path)
1127N/A self._search_op(api_obj, True, "<e*>",
1127N/A self.res_remote_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, True, "<e*> AND <e*>",
1127N/A self.res_remote_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, True, "<e*> OR <e*>",
1127N/A self.res_remote_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, True, "<exam:::>",
1127N/A self.res_remote_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, True, "exam:::e*path",
1127N/A self.res_remote_path)
1127N/A self._search_op(api_obj, True, "exam:::e*path AND e*:::",
1127N/A self.res_remote_path)
1127N/A self._search_op(api_obj, True, "e*::: AND exam:::*path",
1127N/A self.res_remote_path_extra)
941N/A self._search_op(api_obj, True, "example*",
941N/A self.res_remote_wildcard)
2453N/A self._search_op(api_obj, True, "example",
2453N/A self.res_remote_mediator)
2453N/A self._search_op(api_obj, True, "7.0",
2453N/A self.res_remote_mediator_version)
2453N/A self._search_op(api_obj, True, "unladen-swallow",
2453N/A self.res_remote_mediator_impl)
2453N/A self._search_op(api_obj, True, "::mediator-implementation:unladen*",
2453N/A self.res_remote_mediator_impl)
2453N/A self._search_op(api_obj, True, ":link:mediator:example",
2453N/A self.res_remote_mediator)
2453N/A self._search_op(api_obj, True, ":link:mediator:example OR :link:mediator-version:7.0",
2453N/A self.res_remote_mediator_and_ver)
2453N/A self._search_op(api_obj, True, ":link:mediator:example OR :link:mediator-version:7.0 OR :link:mediator-implementation:unladen-swallow",
2453N/A self.res_remote_mediator_and_ver_impl)
941N/A self._search_op(api_obj, True, "/bin", self.res_remote_bin)
941N/A self._search_op(api_obj, True, "4851433",
941N/A self.res_remote_bug_id)
1127N/A self._search_op(api_obj, True, "<4851433> AND <4725245>",
1127N/A self.res_remote_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, True, "4851433 AND 4725245",
1127N/A self.res_remote_bug_id)
1127N/A self._search_op(api_obj, True,
1127N/A "4851433 AND 4725245 OR example_path",
1127N/A self.res_remote_bug_id)
1127N/A self._search_op(api_obj, True,
1127N/A "4851433 AND (4725245 OR example_path)",
1127N/A self.res_remote_bug_id)
1127N/A self._search_op(api_obj, True,
1127N/A "(4851433 AND 4725245) OR example_path",
1127N/A self.res_remote_bug_id | self.res_remote_path)
1127N/A self._search_op(api_obj, True, "4851433 OR 4725245",
1127N/A self.res_remote_bug_id | self.res_remote_bug_id_4725245)
941N/A self._search_op(api_obj, True, "6556919",
941N/A self.res_remote_inc_changes)
941N/A self._search_op(api_obj, True, "6556?19",
941N/A self.res_remote_inc_changes)
941N/A self._search_op(api_obj, True, "42",
1127N/A self.res_remote_random_test)
1127N/A self._search_op(api_obj, True, "79",
1127N/A self.res_remote_random_test_79)
941N/A self._search_op(api_obj, True, "separator",
941N/A self.res_remote_keywords)
1127N/A self._search_op(api_obj, True, "\"sort 0x86\"",
1682N/A self.res_remote_keywords)
941N/A self._search_op(api_obj, True, "*example*",
941N/A self.res_remote_glob)
941N/A self._search_op(api_obj, True, "fooo", self.res_remote_foo)
941N/A self._search_op(api_obj, True, "fo*", self.res_remote_foo)
1682N/A self._search_op(api_obj, True, "bar", self.res_remote_foo)
941N/A self._search_op(api_obj, True, "openssl",
941N/A self.res_remote_openssl)
941N/A self._search_op(api_obj, True, "OPENSSL",
941N/A self.res_remote_openssl)
941N/A self._search_op(api_obj, True, "OpEnSsL",
941N/A self.res_remote_openssl)
1364N/A # Test for bug 11235, case insensitive phrase search, and bug
1364N/A # 11354, mangled fields during phrase search.
1364N/A self._search_op(api_obj, True, "'OpEnSsL'",
1364N/A self.res_remote_openssl)
941N/A self._search_op(api_obj, True, "OpEnS*",
941N/A self.res_remote_openssl)
941N/A
941N/A # These tests are included because a specific bug
941N/A # was found during development. This prevents regression back
941N/A # to that bug. Exit status of 1 is expected because the
941N/A # token isn't in the packages.
941N/A self._search_op(api_obj, True, "a_non_existent_token", set())
1127N/A
1127N/A self._search_op(api_obj, True, "42 AND 4641790", set())
1127N/A self.assertRaises(api_errors.BooleanQueryException,
1127N/A self._search_op, api_obj, True, "<e*> AND e*", set())
1127N/A self.assertRaises(api_errors.BooleanQueryException,
1127N/A self._search_op, api_obj, True, "e* AND <e*>", set())
1127N/A self.assertRaises(api_errors.BooleanQueryException,
1127N/A self._search_op, api_obj, True, "<e*> OR e*", set())
1127N/A self.assertRaises(api_errors.BooleanQueryException,
1127N/A self._search_op, api_obj, True, "e* OR <e*>", set())
1844N/A # Test for bug 15284, \ not being treated as an escape character
1844N/A # for : as well as testing that \: when used with field queries
1844N/A # works as expected.
1844N/A svc_name = "svc\:/milestone/multi-user-server\:default"
1844N/A self._search_op(api_obj, True,
1844N/A svc_name,
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, True,
3158N/A "example_pkg:set:org.opensolaris.smf.fmri:{0}".format(svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, True,
3158N/A "set:org.opensolaris.smf.fmri:{0}".format(svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, True,
3158N/A "org.opensolaris.smf.fmri:{0}".format(svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, True,
3158N/A ":set:org.opensolaris.smf.fmri:{0}".format(svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, True,
3158N/A "{0} *milestone*".format(svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, True,
3158N/A "example_pkg:set:org.opensolaris.smf.fmri:{0} {1}".format(svc_name, svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, True,
3158N/A "example_pkg:set:org.opensolaris.smf.fmri:{0} example_pkg:set:org.opensolaris.smf.fmri:{1}".format(
3158N/A svc_name, svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, True,
3158N/A "{0} example_pkg:set:org.opensolaris.smf.fmri:{1}".format(
3158N/A svc_name, svc_name),
1844N/A self.res_smf_svc)
1844N/A # Test that a single escaped colon doesn't cause a traceback.
1844N/A self._search_op(api_obj, True, "\:", set())
2204N/A
2204N/A # Test that doing a search restricted to dir actions works
2204N/A # correctly. This is a test for bug 17645.
2204N/A self._search_op(api_obj, True, "dir::/bin/example_dir",
2204N/A self.res_dir)
2453N/A
1127N/A def _run_remote_tests(self, api_obj):
1431N/A self._search_op(api_obj, True, "example_pkg",
1431N/A self.res_remote_pkg)
1127N/A self._search_op(api_obj, True, "example_path",
1127N/A self.res_remote_path)
1127N/A self._search_op(api_obj, True, "::com.sun.service.info_url:",
1127N/A self.res_remote_url)
1127N/A self._search_op(api_obj, True, "<e*>",
1127N/A self.res_remote_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, True, "<exam:::>",
1127N/A self.res_remote_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, True, "exam:::e*path",
1127N/A self.res_remote_path)
1127N/A self._search_op(api_obj, True, "example*",
1127N/A self.res_remote_wildcard)
1127N/A self._search_op(api_obj, True, "/bin", self.res_remote_bin)
1127N/A self._search_op(api_obj, True, "4851433",
1127N/A self.res_remote_bug_id)
1127N/A self._search_op(api_obj, True, "4725245",
1127N/A self.res_remote_bug_id_4725245)
1127N/A self._search_op(api_obj, True, "6556919",
1127N/A self.res_remote_inc_changes)
1127N/A self._search_op(api_obj, True, "42",
1127N/A self.res_remote_random_test)
1127N/A self._search_op(api_obj, True, "79",
1127N/A self.res_remote_random_test_79)
1127N/A self._search_op(api_obj, True, "separator",
1127N/A self.res_remote_keywords)
1127N/A self._search_op(api_obj, True, "\"sort 0x86\"",
1682N/A self.res_remote_keywords)
1127N/A self._search_op(api_obj, True, "*example*",
1127N/A self.res_remote_glob)
1127N/A self._search_op(api_obj, True, "fooo", self.res_remote_foo)
1682N/A self._search_op(api_obj, True, "bar", self.res_remote_foo)
1127N/A self._search_op(api_obj, True, "OpEnSsL",
1127N/A self.res_remote_openssl)
1127N/A
1127N/A # These tests are included because a specific bug
1127N/A # was found during development. This prevents regression back
1127N/A # to that bug.
1127N/A self._search_op(api_obj, True, "a_non_existent_token", set())
1127N/A
1127N/A def _run_full_local_tests(self, api_obj):
941N/A outfile = os.path.join(self.testdata_dir, "res")
941N/A
941N/A # This finds something because the client side
941N/A # manifest has had the name of the package inserted
941N/A # into it.
941N/A
941N/A self._search_op(api_obj, False, "example_pkg",
941N/A self.res_local_pkg)
941N/A self._search_op(api_obj, False, "example_path",
941N/A self.res_local_path)
1127N/A self._search_op(api_obj, False, "(example_path)",
1127N/A self.res_local_path)
1127N/A self._search_op(api_obj, False, "<exam*:::>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, False, "::com.sun.service.info_url:",
1127N/A self.res_remote_url)
1127N/A self._search_op(api_obj, False, ":::e* AND *path",
1127N/A self.res_local_path)
1127N/A self._search_op(api_obj, False, "e* AND *path",
1127N/A self.res_local_path)
1127N/A self._search_op(api_obj, False, "<e*>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, False, "<e*> AND <e*>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, False, "<e*> OR <e*>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, False, "<exam:::>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, False, "exam:::e*path",
1127N/A self.res_local_path)
1127N/A self._search_op(api_obj, False, "exam:::e*path AND e*:::",
1127N/A self.res_local_path)
1127N/A self._search_op(api_obj, False, "e*::: AND exam:::*path",
1127N/A self.res_remote_path_extra)
941N/A self._search_op(api_obj, False, "example*",
941N/A self.res_local_wildcard)
2453N/A self._search_op(api_obj, True, "example",
2453N/A self.res_local_mediator)
2453N/A self._search_op(api_obj, True, "7.0",
2453N/A self.res_local_mediator_version)
2453N/A self._search_op(api_obj, True, "unladen-swallow",
2453N/A self.res_local_mediator_impl)
2453N/A self._search_op(api_obj, True, "::mediator-implementation:unladen*",
2453N/A self.res_local_mediator_impl)
2453N/A self._search_op(api_obj, True, ":link:mediator:example",
2453N/A self.res_local_mediator)
2453N/A self._search_op(api_obj, True, ":link:mediator:example OR :link:mediator-version:7.0",
2453N/A self.res_local_mediator_and_ver)
2453N/A self._search_op(api_obj, True, ":link:mediator:example OR :link:mediator-version:7.0 OR :link:mediator-implementation:unladen-swallow",
2453N/A self.res_local_mediator_and_ver_impl)
941N/A self._search_op(api_obj, False, "/bin", self.res_local_bin)
941N/A self._search_op(api_obj, False, "4851433",
941N/A self.res_local_bug_id)
1127N/A self._search_op(api_obj, False, "<4851433> AND <4725245>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, False, "4851433 AND 4725245",
1127N/A self.res_local_bug_id)
1127N/A self._search_op(api_obj, False,
1127N/A "4851433 AND 4725245 OR example_path",
1127N/A self.res_local_bug_id)
1127N/A self._search_op(api_obj, False,
1127N/A "4851433 AND (4725245 OR example_path)",
1127N/A self.res_local_bug_id)
1127N/A self._search_op(api_obj, False,
1127N/A "(4851433 AND 4725245) OR example_path",
1127N/A self.res_local_bug_id | self.res_local_path)
1127N/A self._search_op(api_obj, False, "4851433 OR 4725245",
1127N/A self.res_local_bug_id | self.res_remote_bug_id_4725245)
941N/A self._search_op(api_obj, False, "6556919",
941N/A self.res_local_inc_changes)
941N/A self._search_op(api_obj, False, "65569??",
941N/A self.res_local_inc_changes)
941N/A self._search_op(api_obj, False, "42",
941N/A self.res_local_random_test)
1127N/A self._search_op(api_obj, False, "79",
1127N/A self.res_remote_random_test_79)
941N/A self._search_op(api_obj, False, "separator",
941N/A self.res_local_keywords)
1127N/A self._search_op(api_obj, False, "\"sort 0x86\"",
1682N/A self.res_remote_keywords)
941N/A self._search_op(api_obj, False, "*example*",
941N/A self.res_local_glob)
941N/A self._search_op(api_obj, False, "fooo", self.res_local_foo)
941N/A self._search_op(api_obj, False, "fo*", self.res_local_foo)
1682N/A self._search_op(api_obj, False, "bar", self.res_local_foo)
941N/A self._search_op(api_obj, False, "openssl",
941N/A self.res_local_openssl)
941N/A self._search_op(api_obj, False, "OPENSSL",
941N/A self.res_local_openssl)
941N/A self._search_op(api_obj, False, "OpEnSsL",
941N/A self.res_local_openssl)
1364N/A # Test for bug 11235, case insensitive phrase search, and bug
1364N/A # 11354, mangled fields during phrase search.
1364N/A self._search_op(api_obj, False, "'OpEnSsL'",
1364N/A self.res_remote_openssl)
941N/A self._search_op(api_obj, False, "OpEnS*",
941N/A self.res_local_openssl)
941N/A # These tests are included because a specific bug
941N/A # was found during development. These tests prevent regression
941N/A # back to that bug. Exit status of 1 is expected because the
941N/A # token isn't in the packages.
941N/A self._search_op(api_obj, False, "a_non_existent_token", set())
1127N/A self._search_op(api_obj, False, "42 AND 4641790", set())
1127N/A self.assertRaises(api_errors.BooleanQueryException,
1127N/A self._search_op, api_obj, False, "<e*> AND e*", set())
1127N/A self.assertRaises(api_errors.BooleanQueryException,
1127N/A self._search_op, api_obj, False, "e* AND <e*>", set())
1127N/A self.assertRaises(api_errors.BooleanQueryException,
1127N/A self._search_op, api_obj, False, "<e*> OR e*", set())
1127N/A self.assertRaises(api_errors.BooleanQueryException,
1127N/A self._search_op, api_obj, False, "e* OR <e*>", set())
1844N/A # Test for bug 15284, \ not being treated as an escape character
1844N/A # for : as well as testing that \: when used with field queries
1844N/A # works as expected.
1844N/A svc_name = "svc\:/milestone/multi-user-server\:default"
1844N/A self._search_op(api_obj, False,
1844N/A svc_name,
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, False,
3158N/A "example_pkg:set:org.opensolaris.smf.fmri:{0}".format(svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, False,
3158N/A "set:org.opensolaris.smf.fmri:{0}".format(svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, False,
3158N/A "org.opensolaris.smf.fmri:{0}".format(svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, False,
3158N/A ":set:org.opensolaris.smf.fmri:{0}".format(svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, False,
3158N/A "{0} *milestone*".format(svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, False,
3158N/A "example_pkg:set:org.opensolaris.smf.fmri:{0} {1}".format(svc_name, svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, False,
3158N/A "example_pkg:set:org.opensolaris.smf.fmri:{0} example_pkg:set:org.opensolaris.smf.fmri:{1}".format(
3158N/A svc_name, svc_name),
1844N/A self.res_smf_svc)
1844N/A self._search_op(api_obj, False,
3158N/A "{0} example_pkg:set:org.opensolaris.smf.fmri:{1}".format(
3158N/A svc_name, svc_name),
1844N/A self.res_smf_svc)
1844N/A # Test that a single escaped colon doesn't cause a traceback.
1844N/A self._search_op(api_obj, True, "\:", set())
1127N/A
1127N/A def _run_local_tests(self, api_obj):
1127N/A outfile = os.path.join(self.testdata_dir, "res")
1127N/A
1127N/A # This finds something because the client side
1127N/A # manifest has had the name of the package inserted
1127N/A # into it.
1127N/A
1127N/A self._search_op(api_obj, False, "example_pkg",
1127N/A self.res_local_pkg)
1127N/A self._search_op(api_obj, False, "example_path",
1127N/A self.res_local_path)
1127N/A self._search_op(api_obj, False, "::com.sun.service.info_url:",
1127N/A self.res_remote_url)
1127N/A self._search_op(api_obj, False, "<e*>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, False, "<exam:::>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op(api_obj, False, "exam:::e*path",
1127N/A self.res_local_path)
1127N/A self._search_op(api_obj, False, "example*",
1127N/A self.res_local_wildcard)
1127N/A self._search_op(api_obj, False, "/bin", self.res_local_bin)
1127N/A self._search_op(api_obj, False, "4851433",
1127N/A self.res_local_bug_id)
1127N/A self._search_op(api_obj, False, "4725245",
1127N/A self.res_remote_bug_id_4725245)
1127N/A self._search_op(api_obj, False, "6556919",
1127N/A self.res_local_inc_changes)
1127N/A self._search_op(api_obj, False, "42",
1127N/A self.res_local_random_test)
1127N/A self._search_op(api_obj, False, "79",
1127N/A self.res_remote_random_test_79)
1127N/A self._search_op(api_obj, False, "separator",
1127N/A self.res_local_keywords)
1127N/A self._search_op(api_obj, False, "\"sort 0x86\"",
1682N/A self.res_remote_keywords)
1127N/A self._search_op(api_obj, False, "*example*",
1127N/A self.res_local_glob)
1127N/A self._search_op(api_obj, False, "fooo", self.res_local_foo)
1682N/A self._search_op(api_obj, False, "bar", self.res_local_foo)
1127N/A self._search_op(api_obj, False, "OpEnSsL",
1127N/A self.res_local_openssl)
1127N/A # These tests are included because a specific bug
1127N/A # was found during development. These tests prevent regression
1127N/A # back to that bug.
1127N/A self._search_op(api_obj, False, "a_non_existent_token", set())
941N/A
2204N/A # Test that doing a search restricted to dir actions works
2204N/A # correctly. This is a test for bug 17645.
2204N/A self._search_op(api_obj, False, "dir::/bin/example_dir",
2204N/A self.res_dir)
2204N/A
941N/A def _run_degraded_local_tests(self, api_obj):
941N/A outfile = os.path.join(self.testdata_dir, "res")
941N/A
941N/A # This finds something because the client side
941N/A # manifest has had the name of the package inserted
941N/A # into it.
941N/A
941N/A self._search_op_slow(api_obj, False, "example_pkg",
941N/A self.res_local_pkg)
941N/A self._search_op_slow(api_obj, False, "example_path",
941N/A self.res_local_path)
1127N/A self._search_op_slow(api_obj, False, "(example_path)",
1127N/A self.res_local_path)
1127N/A self._search_op_slow(api_obj, False, "<exam*:::>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op_slow(api_obj, False,
1127N/A "::com.sun.service.info_url:",
1127N/A self.res_remote_url)
1127N/A self._search_op_slow(api_obj, False, ":::e* AND *path",
1127N/A self.res_local_path)
1127N/A self._search_op_slow(api_obj, False, "e* AND *path",
1127N/A self.res_local_path)
1127N/A self._search_op_slow(api_obj, False, "<e*>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op_slow(api_obj, False, "<e*> AND <e*>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op_slow(api_obj, False, "<e*> OR <e*>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op_slow(api_obj, False, "<exam:::>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op_slow(api_obj, False, "exam:::e*path",
1127N/A self.res_local_path)
1127N/A self._search_op_slow(api_obj, False, "exam:::e*path AND e*:::",
1127N/A self.res_local_path)
1127N/A self._search_op_slow(api_obj, False, "e*::: AND exam:::*path",
1127N/A self.res_remote_path_extra)
941N/A self._search_op_slow(api_obj, False, "example*",
941N/A self.res_local_wildcard)
2453N/A self._search_op_slow(api_obj, True, "example",
2453N/A self.res_local_mediator)
2453N/A self._search_op_slow(api_obj, True, "7.0",
2453N/A self.res_local_mediator_version)
2453N/A self._search_op_slow(api_obj, True, "unladen-swallow",
2453N/A self.res_local_mediator_impl)
2453N/A self._search_op_slow(api_obj, True,
2453N/A "::mediator-implementation:unladen*",
2453N/A self.res_local_mediator_impl)
2453N/A self._search_op_slow(api_obj, True, ":link:mediator:example",
2453N/A self.res_local_mediator)
2453N/A self._search_op_slow(api_obj, True,
2453N/A ":link:mediator:example OR :link:mediator-version:7.0",
2453N/A self.res_local_mediator_and_ver)
2453N/A self._search_op_slow(api_obj, True,
2453N/A ":link:mediator:example OR :link:mediator-version:7.0 OR :link:mediator-implementation:unladen-swallow",
2453N/A self.res_local_mediator_and_ver_impl)
941N/A self._search_op_slow(api_obj, False, "/bin", self.res_local_bin)
941N/A self._search_op_slow(api_obj, False, "4851433",
941N/A self.res_local_bug_id)
1127N/A self._search_op_slow(api_obj, False, "<4851433> AND <4725245>",
1127N/A self.res_local_pkg_ret_pkg, return_actions=False)
1127N/A self._search_op_slow(api_obj, False, "4851433 AND 4725245",
1127N/A self.res_local_bug_id)
1127N/A self._search_op_slow(api_obj, False,
1127N/A "4851433 AND 4725245 OR example_path",
1127N/A self.res_local_bug_id)
1127N/A self._search_op_slow(api_obj, False,
1127N/A "4851433 AND (4725245 OR example_path)",
1127N/A self.res_local_bug_id)
1127N/A self._search_op_slow(api_obj, False,
1127N/A "(4851433 AND 4725245) OR example_path",
1127N/A self.res_local_bug_id | self.res_local_path)
1127N/A self._search_op_slow(api_obj, False, "4851433 OR 4725245",
1127N/A self.res_local_bug_id | self.res_remote_bug_id_4725245)
941N/A self._search_op_slow(api_obj, False, "6556919",
941N/A self.res_local_inc_changes)
941N/A self._search_op_slow(api_obj, False, "65569??",
941N/A self.res_local_inc_changes)
941N/A self._search_op_slow(api_obj, False, "42",
941N/A self.res_local_random_test)
1127N/A self._search_op_slow(api_obj, False, "79",
1127N/A self.res_remote_random_test_79)
941N/A self._search_op_slow(api_obj, False, "separator",
941N/A self.res_local_keywords)
1127N/A self._search_op_slow(api_obj, False, "\"sort 0x86\"",
1682N/A self.res_remote_keywords)
941N/A self._search_op_slow(api_obj, False, "*example*",
941N/A self.res_local_glob)
941N/A self._search_op_slow(api_obj, False, "fooo", self.res_local_foo)
941N/A self._search_op_slow(api_obj, False, "fo*", self.res_local_foo)
1682N/A self._search_op_slow(api_obj, False, "bar", self.res_local_foo)
941N/A self._search_op_slow(api_obj, False, "openssl",
941N/A self.res_local_openssl)
941N/A self._search_op_slow(api_obj, False, "OPENSSL",
941N/A self.res_local_openssl)
941N/A self._search_op_slow(api_obj, False, "OpEnSsL",
941N/A self.res_local_openssl)
941N/A self._search_op_slow(api_obj, False, "OpEnS*",
941N/A self.res_local_openssl)
941N/A # These tests are included because a specific bug
941N/A # was found during development. These tests prevent regression
941N/A # back to that bug. Exit status of 1 is expected because the
941N/A # token isn't in the packages.
941N/A self._search_op_slow(api_obj, False, "a_non_existent_token",
941N/A set())
941N/A
1360N/A def _run_remove_root_search(self, search_func, remote, api_obj, ip):
1360N/A search_func(api_obj, remote, [ip + "example_pkg"], set())
1360N/A search_func(api_obj, remote, [ip + "bin/example_path"],
1360N/A self.res_remote_path_of_example_path)
3158N/A search_func(api_obj, remote, ["({0}bin/example_path)".format(ip)],
1360N/A self.res_remote_path_of_example_path)
3158N/A search_func(api_obj, remote, ["<{0}exam*:::>".format(ip)],
1360N/A set(), return_actions=False)
1360N/A search_func(api_obj, remote,
3158N/A ["::{0}com.sun.service.info_url:".format(ip)], set())
1360N/A search_func(api_obj, remote,
3158N/A ["{0}bin/e* AND {1}*path".format(ip, ip)],
1360N/A self.res_remote_path_of_example_path)
1360N/A search_func(api_obj, remote,
3158N/A ["(4851433 AND 4725245) OR :file::{0}bin/example_path".format(ip)],
1360N/A self.res_remote_bug_id |
1360N/A self.res_remote_path_of_example_path)
1360N/A search_func(api_obj, remote,
3158N/A [":::{0}bin/example_path OR (4851433 AND 4725245)".format(ip)],
1360N/A self.res_remote_bug_id |
1360N/A self.res_remote_path_of_example_path)
1360N/A search_func(api_obj, remote,
3158N/A ["{0}bin/example_path OR {1}bin/example_path".format(ip, ip)],
1360N/A self.res_remote_path_of_example_path)
1360N/A search_func(api_obj, remote,
3158N/A ["<::path:{0}bin/example_path> OR <(a AND b)>".format(ip)],
1360N/A self.res_remote_pkg_ret_pkg, return_actions=False)
1360N/A search_func(api_obj, remote,
3158N/A ["<(a AND b)> OR <{0}bin/example_path>".format(ip)],
1360N/A self.res_remote_pkg_ret_pkg, return_actions=False)
1360N/A # The tests below here are for testing that multiple queries
1360N/A # to search return the results from both queries (bug 10365)
1360N/A search_func(api_obj, remote,
1360N/A ["<(a AND b)>", "example_path"],
1360N/A self.res_remote_path)
1360N/A search_func(api_obj, remote,
1360N/A ["example_path", "<(a AND b)>"],
1360N/A self.res_remote_path)
1360N/A search_func(api_obj, remote,
3158N/A [":::{0}bin/example_path".format(ip), "(4851433 AND 4725245)"],
1360N/A self.res_remote_bug_id |
1360N/A self.res_remote_path_of_example_path)
1360N/A search_func(api_obj, remote,
3158N/A ["(4851433 AND 4725245)", ":::{0}bin/example_path".format(ip)],
1360N/A self.res_remote_bug_id |
1360N/A self.res_remote_path_of_example_path)
1360N/A
941N/A def _run_local_tests_example11_installed(self, api_obj):
941N/A outfile = os.path.join(self.testdata_dir, "res")
941N/A
941N/A # This finds something because the client side
941N/A # manifest has had the name of the package inserted
941N/A # into it.
941N/A
941N/A self._search_op(api_obj, False, "example_pkg",
941N/A self.res_local_pkg_example11)
941N/A self._search_op(api_obj, False, "example_path", set())
941N/A self._search_op(api_obj, False, "example_path11",
941N/A self.res_local_path_example11)
941N/A self._search_op(api_obj, False, "example*",
941N/A self.res_local_wildcard_example11)
941N/A self._search_op(api_obj, False, "/bin",
941N/A self.res_local_bin_example11)
941N/A
941N/A def _run_local_empty_tests(self, api_obj):
941N/A self._search_op(api_obj, False, "example_pkg", set())
941N/A self._search_op(api_obj, False, "example_path", set())
941N/A self._search_op(api_obj, False, "example*", set())
941N/A self._search_op(api_obj, False, "/bin", set())
941N/A
941N/A def _run_remote_empty_tests(self, api_obj):
941N/A self._search_op(api_obj, True, "example_pkg", set())
941N/A self._search_op(api_obj, True, "example_path", set())
941N/A self._search_op(api_obj, True, "example*", set())
941N/A self._search_op(api_obj, True, "/bin", set())
941N/A self._search_op(api_obj, True, "*unique*", set())
941N/A
941N/A @staticmethod
941N/A def _restore_dir(index_dir, index_dir_tmp):
941N/A shutil.rmtree(index_dir)
941N/A shutil.move(index_dir_tmp, index_dir)
941N/A
941N/A @staticmethod
941N/A def _restore_dir_preserve_hash(index_dir, index_dir_tmp):
941N/A tmp_file = "full_fmri_list.hash"
941N/A portable.remove(os.path.join(index_dir_tmp, tmp_file))
941N/A shutil.move(os.path.join(index_dir, tmp_file),
941N/A index_dir_tmp)
941N/A fh = open(os.path.join(index_dir_tmp, ss.MAIN_FILE), "r")
941N/A fh.seek(0)
941N/A fh.seek(9)
941N/A ver = fh.read(1)
941N/A fh.close()
941N/A fh = open(os.path.join(index_dir_tmp, tmp_file), "r+")
941N/A fh.seek(0)
941N/A fh.seek(9)
941N/A # Overwrite the existing version number.
941N/A # By definition, the version 0 is never used.
3158N/A fh.write("{0}".format(ver))
3339N/A fh.close()
941N/A shutil.rmtree(index_dir)
941N/A shutil.move(index_dir_tmp, index_dir)
941N/A
941N/A def _get_index_dirs(self):
2339N/A index_dir = os.path.join(self.img_path(), "var", "pkg",
2144N/A "cache", "index")
941N/A index_dir_tmp = index_dir + "TMP"
941N/A return index_dir, index_dir_tmp
941N/A
941N/A @staticmethod
941N/A def _overwrite_version_number(file_path):
941N/A fh = open(file_path, "r+")
941N/A fh.seek(0)
941N/A fh.seek(9)
941N/A # Overwrite the existing version number.
941N/A # By definition, the version 0 is never used.
941N/A fh.write("0")
941N/A fh.close()
941N/A
941N/A @staticmethod
941N/A def _overwrite_on_disk_format_version_number(file_path):
941N/A fh = open(file_path, "r+")
941N/A fh.seek(0)
941N/A fh.seek(16)
941N/A # Overwrite the existing version number.
941N/A # By definition, the version 0 is never used.
941N/A fh.write("9")
941N/A fh.close()
941N/A
941N/A @staticmethod
941N/A def _overwrite_on_disk_format_version_number_with_letter(file_path):
941N/A fh = open(file_path, "r+")
941N/A fh.seek(0)
941N/A fh.seek(16)
941N/A # Overwrite the existing version number.
941N/A # By definition, the version 0 is never used.
941N/A fh.write("a")
941N/A fh.close()
941N/A
941N/A @staticmethod
941N/A def _replace_on_disk_format_version(dir):
941N/A file_path = os.path.join(dir, ss.BYTE_OFFSET_FILE)
941N/A fh = open(file_path, "r")
941N/A lst = fh.readlines()
941N/A fh.close()
941N/A fh = open(file_path, "w")
941N/A fh.write(lst[0])
941N/A for l in lst[2:]:
941N/A fh.write(l)
941N/A fh.close()
941N/A
941N/A @staticmethod
941N/A def _overwrite_hash(ffh_path):
1230N/A fd, tmp = tempfile.mkstemp()
1230N/A portable.copyfile(ffh_path, tmp)
1230N/A fh = open(tmp, "r+")
941N/A fh.seek(0)
941N/A fh.seek(20)
941N/A fh.write("*")
941N/A fh.close()
1230N/A portable.rename(tmp, ffh_path)
941N/A
941N/A def _check_no_index(self):
941N/A ind_dir, ind_dir_tmp = self._get_index_dirs()
941N/A if os.listdir(ind_dir):
3339N/A self.assertTrue(0)
941N/A if os.path.exists(ind_dir_tmp):
3339N/A self.assertTrue(0)
941N/A
1291N/A @staticmethod
1291N/A def validateAssertRaises(ex_type, validate_func, func, *args, **kwargs):
1291N/A try:
1291N/A func(*args, **kwargs)
3171N/A except ex_type as e:
1291N/A validate_func(e)
1291N/A else:
1291N/A raise RuntimeError("Didn't raise expected exception.")
1291N/A
1291N/A @staticmethod
1291N/A def _check_err(e, expected_str, expected_code):
3339N/A err = force_str(e.read())
1291N/A if expected_code != e.code:
3158N/A raise RuntimeError("Got wrong code, expected {0} got "
3158N/A "{1}".format(expected_code, e.code))
1291N/A if expected_str not in err:
1291N/A raise RuntimeError("Got unexpected error message of:\n"
3158N/A "{0}".format(err))
1291N/A
1127N/A
1715N/Aclass TestApiSearchBasicsP(TestApiSearchBasics):
1127N/A # Only start/stop the depot once (instead of for every test)
1715N/A persistent_setup = True
1127N/A
1127N/A def __init__(self, *args, **kwargs):
1127N/A TestApiSearchBasics.__init__(self, *args, **kwargs)
1127N/A self.sent_pkgs = set()
1431N/A
1127N/A def pkgsend_bulk(self, durl, pkg, optional=True):
1127N/A if pkg not in self.sent_pkgs or optional == False:
1127N/A self.sent_pkgs.add(pkg)
2028N/A # Ensures indexing is done for every pkgsend.
2028N/A TestApiSearchBasics.pkgsend_bulk(self, durl, pkg,
2028N/A refresh_index=True)
2028N/A self.wait_repo(self.dc.get_repodir())
1431N/A
1715N/A def setUp(self):
1715N/A TestApiSearchBasics.setUp(self)
1715N/A durl = self.dc.get_depot_url()
2028N/A self.pkgsend_bulk(durl, (self.example_pkg10, self.fat_pkg10,
2028N/A self.another_pkg10))
1715N/A
1127N/A def test_010_remote(self):
941N/A """Test remote search."""
941N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
1127N/A # This should be a full test to test all functionality.
1127N/A self._run_full_remote_tests(api_obj)
1127N/A self._search_op(api_obj, True, ":file::", self.res_remote_file)
1127N/A
1127N/A def test_020_local_0(self):
941N/A """Install one package, and run the search suite."""
941N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
941N/A
1886N/A self._api_install(api_obj, ["example_pkg"])
941N/A
1127N/A self._run_full_local_tests(api_obj)
941N/A
1127N/A def test_030_degraded_local(self):
941N/A """Install one package, and run the search suite."""
941N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
941N/A
1886N/A self._api_install(api_obj, ["example_pkg@1.0"])
941N/A
2339N/A index_dir = os.path.join(self.img_path(), "var", "pkg",
2144N/A "cache", "index")
941N/A shutil.rmtree(index_dir)
941N/A
941N/A self._run_degraded_local_tests(api_obj)
941N/A
1127N/A def test_040_repeated_install_uninstall(self):
941N/A """Install and uninstall a package. Checking search both
941N/A after each change to the image."""
941N/A # During development, the index could become corrupted by
941N/A # repeated installing and uninstalling a package. This
941N/A # tests if that has been fixed.
941N/A repeat = 3
941N/A
941N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
941N/A
1886N/A self._api_install(api_obj, ["example_pkg@1.0"])
1886N/A self._api_uninstall(api_obj, ["example_pkg"])
941N/A
941N/A for i in range(1, repeat):
1886N/A self._api_install(api_obj, ["example_pkg"])
941N/A self._run_local_tests(api_obj)
1886N/A self._api_uninstall(api_obj, ["example_pkg"])
941N/A api_obj.reset()
941N/A self._run_local_empty_tests(api_obj)
941N/A
1127N/A def test_050_local_case_sensitive(self):
1127N/A """Test local case sensitive search"""
941N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
941N/A
1886N/A self._api_install(api_obj, ["example_pkg@1.0"])
1127N/A self._search_op(api_obj, False, "fooo", set(), True)
1127N/A self._search_op(api_obj, False, "fo*", set(), True)
1127N/A self._search_op(api_obj, False, "bar", set(), True)
1127N/A self._search_op(api_obj, False, "FOOO", self.res_local_foo,
1127N/A True)
1682N/A self._search_op(api_obj, False, "bAr", self.res_local_foo, True)
941N/A
1127N/A def test_060_missing_files(self):
941N/A """Test to check for stack trace when files missing.
941N/A Bug 2753"""
941N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
941N/A
1886N/A self._api_install(api_obj, ["example_pkg@1.0"])
1431N/A
2339N/A index_dir = os.path.join(self.img_path(), "var", "pkg",
2144N/A "cache", "index")
3072N/A self._search_op(api_obj, False, "fooo", set(), True)
941N/A
1127N/A first = True
1431N/A
1895N/A for d in query_parser.TermQuery._get_gdd(index_dir).values():
941N/A orig_fn = d.get_file_name()
941N/A orig_path = os.path.join(index_dir, orig_fn)
941N/A dest_fn = orig_fn + "TMP"
941N/A dest_path = os.path.join(index_dir, dest_fn)
941N/A portable.rename(orig_path, dest_path)
941N/A self.assertRaises(api_errors.InconsistentIndexException,
1054N/A self._search_op, api_obj, False,
1054N/A "exam:::example_pkg", [])
1127N/A if first:
1127N/A # Run the shell version once to check that no
1127N/A # stack trace happens.
1127N/A self.pkg("search -l 'exam:::example_pkg'",
1127N/A exit=1)
1127N/A first = False
941N/A portable.rename(dest_path, orig_path)
1127N/A self._search_op(api_obj, False, "exam:::example_pkg",
941N/A self.res_local_pkg)
1127N/A
1127N/A def test_070_mismatched_versions(self):
941N/A """Test to check for stack trace when files missing.
941N/A Bug 2753"""
941N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
1886N/A self._api_install(api_obj, ["example_pkg@1.0"])
1431N/A
2339N/A index_dir = os.path.join(self.img_path(), "var", "pkg",
2144N/A "cache", "index")
3072N/A self._search_op(api_obj, False, "fooo", set(), True)
941N/A
1127N/A first = True
1127N/A
1895N/A for d in query_parser.TermQuery._get_gdd(index_dir).values():
941N/A orig_fn = d.get_file_name()
941N/A orig_path = os.path.join(index_dir, orig_fn)
941N/A dest_fn = orig_fn + "TMP"
941N/A dest_path = os.path.join(index_dir, dest_fn)
941N/A shutil.copy(orig_path, dest_path)
941N/A self._overwrite_version_number(orig_path)
941N/A api_obj.reset()
941N/A self.assertRaises(api_errors.InconsistentIndexException,
1054N/A self._search_op, api_obj, False,
1054N/A "exam:::example_pkg", [])
1127N/A if first:
1127N/A # Run the shell version once to check that no
1127N/A # stack trace happens.
1127N/A self.pkg("search -l 'exam:::example_pkg'",
1127N/A exit=1)
1127N/A first = False
941N/A portable.rename(dest_path, orig_path)
941N/A self._search_op(api_obj, False, "example_pkg",
941N/A self.res_local_pkg)
941N/A self._overwrite_version_number(orig_path)
1286N/A self.assertRaises(
1286N/A api_errors.WrapSuccessfulIndexingException,
2339N/A self._api_uninstall, api_obj, ["example_pkg"],
2339N/A catch_wsie=False)
1286N/A api_obj.reset()
941N/A self._search_op(api_obj, False, "example_pkg", set())
941N/A self._overwrite_version_number(orig_path)
1286N/A self.assertRaises(
1286N/A api_errors.WrapSuccessfulIndexingException,
2339N/A self._api_install, api_obj, ["example_pkg"],
2339N/A catch_wsie=False)
941N/A api_obj.reset()
941N/A self._search_op(api_obj, False, "example_pkg",
941N/A self.res_local_pkg)
1230N/A
941N/A ffh = ss.IndexStoreSetHash(ss.FULL_FMRI_HASH_FILE)
941N/A ffh_path = os.path.join(index_dir, ffh.get_file_name())
1230N/A dest_fh, dest_path = tempfile.mkstemp()
941N/A shutil.copy(ffh_path, dest_path)
941N/A self._overwrite_hash(ffh_path)
941N/A self.assertRaises(api_errors.IncorrectIndexFileHash,
941N/A self._search_op, api_obj, False, "example_pkg", set())
1127N/A # Run the shell version of the test to check for a stack trace.
1127N/A self.pkg("search -l 'exam:::example_pkg'", exit=1)
941N/A portable.rename(dest_path, ffh_path)
941N/A self._search_op(api_obj, False, "example_pkg",
941N/A self.res_local_pkg)
941N/A self._overwrite_hash(ffh_path)
1286N/A self.assertRaises(api_errors.WrapSuccessfulIndexingException,
2339N/A self._api_uninstall, api_obj, ["example_pkg"],
2339N/A catch_wsie=False)
941N/A self._search_op(api_obj, False, "example_pkg", set())
1127N/A
1127N/A def test_080_weird_patterns(self):
1127N/A """Test strange patterns to ensure they're handled correctly"""
1127N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
1127N/A
1682N/A self._search_op(api_obj, True, "[*]", self.res_remote_weird)
1682N/A self._search_op(api_obj, True, "[?]", self.res_remote_weird)
1682N/A self._search_op(api_obj, True, "[[]", self.res_remote_weird)
1682N/A self._search_op(api_obj, True, "[]]", self.res_remote_weird)
1127N/A self._search_op(api_obj, True, "FO[O]O", self.res_remote_foo)
1127N/A self._search_op(api_obj, True, "FO[?O]O", self.res_remote_foo)
1127N/A self._search_op(api_obj, True, "FO[*O]O", self.res_remote_foo)
1127N/A self._search_op(api_obj, True, "FO[]O]O", self.res_remote_foo)
1127N/A
1127N/A def test_090_bug_7660(self):
1127N/A """Test that installing a package doesn't prevent searching on
1127N/A package names from working on previously installed packages."""
1127N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
1127N/A
2339N/A tmp_dir = os.path.join(self.img_path(), "var", "pkg",
2144N/A "cache", "index", "TMP")
1886N/A self._api_install(api_obj, ["example_pkg"])
1127N/A api_obj.rebuild_search_index()
1886N/A self._api_install(api_obj, ["fat"])
3339N/A self.assertTrue(not os.path.exists(tmp_dir))
1127N/A self._run_local_tests(api_obj)
1127N/A
1127N/A def test_100_bug_6712_i386(self):
1127N/A """Install one package, and run the search suite."""
1127N/A durl = self.dc.get_depot_url()
1127N/A
1895N/A variants = { "variant.arch": "i386" }
1895N/A api_obj = self.image_create(durl, variants=variants)
1127N/A remote = True
1127N/A
1127N/A self._search_op(api_obj, remote, "fat:::*",
1127N/A self.res_remote_fat10_star)
1886N/A self._api_install(api_obj, ["fat"])
1127N/A remote = False
1127N/A self._search_op(api_obj, remote, "fat:::*",
1127N/A self.res_local_fat10_i386_star)
1127N/A
1127N/A def test_110_bug_6712_sparc(self):
1127N/A """Install one package, and run the search suite."""
1127N/A durl = self.dc.get_depot_url()
1431N/A
1895N/A variants = { "variant.arch": "sparc" }
1895N/A api_obj = self.image_create(durl, variants=variants)
1127N/A remote = True
1127N/A
1127N/A self._search_op(api_obj, remote, "fat:::*",
1127N/A self.res_remote_fat10_star)
1886N/A self._api_install(api_obj, ["fat"])
1127N/A remote = False
1127N/A self._search_op(api_obj, remote, "fat:::*",
1127N/A self.res_local_fat10_sparc_star)
1127N/A
1127N/A def test_120_bug_3046(self):
1127N/A """Checks if directories ending in / break the indexer."""
1127N/A durl = self.dc.get_depot_url()
1127N/A self.pkgsend_bulk(durl, self.bad_pkg10)
1859N/A api_obj = self.image_create(durl)
1127N/A
1127N/A self._search_op(api_obj, True, "foo", set())
1127N/A self._search_op(api_obj, True, "/", set())
1127N/A
1360N/A def test_130_bug_1059(self):
1360N/A """Checks whether the fallback of removing the image root works.
1360N/A Also tests whether multiple queries submitted via the api work.
1360N/A """
1360N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
1360N/A
1360N/A ip = self.get_img_path()
1360N/A if not ip.endswith("/"):
1360N/A ip += "/"
1360N/A
1360N/A # Do remote searches
1360N/A self._run_remove_root_search(self._search_op_multi, True,
1360N/A api_obj, ip)
1360N/A
1886N/A self._api_install(api_obj, ["example_pkg"])
1360N/A # Do local searches
1360N/A self._run_remove_root_search(self._search_op_multi, False,
1360N/A api_obj, ip)
1360N/A
2339N/A index_dir = os.path.join(self.img_path(), "var", "pkg",
2144N/A "cache", "index")
1360N/A shutil.rmtree(index_dir)
1360N/A # Do slow local searches
1360N/A self._run_remove_root_search(self._search_op_slow_multi, False,
1360N/A api_obj, ip)
1360N/A
1127N/A def test_bug_2849(self):
1127N/A """Checks if things with spaces break the indexer."""
1127N/A durl = self.dc.get_depot_url()
1127N/A self.pkgsend_bulk(durl, self.space_pkg10)
1859N/A api_obj = self.image_create(durl)
1127N/A
1886N/A self._api_install(api_obj, ["space_pkg"])
1127N/A
1127N/A self.pkgsend_bulk(durl, self.space_pkg10, optional=False)
1127N/A api_obj.refresh(immediate=True)
1127N/A
1886N/A self._api_install(api_obj, ["space_pkg"])
1127N/A
1127N/A remote = False
1127N/A self._search_op(api_obj, remote, 'with', set())
1127N/A self._search_op(api_obj, remote, 'with*',
1127N/A self.res_space_with_star)
1127N/A self._search_op(api_obj, remote, '*space',
1127N/A self.res_space_space_star)
1127N/A self._search_op(api_obj, remote, 'space', set())
1127N/A self._search_op(api_obj, remote, 'unique_dir',
1127N/A self.res_space_unique)
1127N/A remote = True
1127N/A self._search_op(api_obj, remote, 'with', set())
1127N/A self._search_op(api_obj, remote, 'with*',
1127N/A self.res_space_with_star)
1127N/A self._search_op(api_obj, remote, '*space',
1127N/A self.res_space_space_star)
1127N/A self._search_op(api_obj, remote, 'space', set())
1127N/A self.pkgsend_bulk(durl, self.space_pkg10, optional=False)
1127N/A # Need to add install of subsequent package and
1127N/A # local side search as well as remote
1127N/A self._search_op(api_obj, remote, 'with', set())
1127N/A self._search_op(api_obj, remote, 'with*',
1127N/A self.res_space_with_star)
1127N/A self._search_op(api_obj, remote, '*space',
1127N/A self.res_space_space_star)
1127N/A self._search_op(api_obj, remote, 'space', set())
1127N/A self._search_op(api_obj, remote, 'unique_dir',
1127N/A self.res_space_unique)
1127N/A
1127N/A def test_bug_2863(self):
1127N/A """Check that disabling indexing works as expected"""
1127N/A durl = self.dc.get_depot_url()
1859N/A api_obj = self.image_create(durl)
1127N/A
1127N/A self._check_no_index()
1886N/A self._api_install(api_obj, ["example_pkg"], update_index=False)
1127N/A self._check_no_index()
1127N/A api_obj.rebuild_search_index()
1127N/A self._run_local_tests(api_obj)
1886N/A self._api_uninstall(api_obj, ["example_pkg"], update_index=False)
1127N/A # Running empty test because search will notice the index
1127N/A # does not match the installed packages and complain.
1127N/A self.assertRaises(api_errors.IncorrectIndexFileHash,
1127N/A self._search_op, api_obj, False, "example_pkg", set())
1127N/A api_obj.rebuild_search_index()
1127N/A self._run_local_empty_tests(api_obj)
1886N/A self._api_install(api_obj, ["example_pkg"])
1127N/A self._run_local_tests(api_obj)
1127N/A self.pkgsend_bulk(durl, self.example_pkg11)
1127N/A api_obj.refresh(immediate=True)
2401N/A self._api_update(api_obj, update_index=False)
1127N/A # Running empty test because search will notice the index
1127N/A # does not match the installed packages and complain.
1127N/A self.assertRaises(api_errors.IncorrectIndexFileHash,
1127N/A self._search_op, api_obj, False, "example_pkg", set())
1127N/A api_obj.rebuild_search_index()
1127N/A self._run_local_tests_example11_installed(api_obj)
1886N/A self._api_uninstall(api_obj, ["example_pkg"],
1886N/A update_index=False)
1127N/A # Running empty test because search will notice the index
1127N/A # does not match the installed packages and complain.
1127N/A self.assertRaises(api_errors.IncorrectIndexFileHash,
1127N/A self._search_op, api_obj, False, "example_pkg", set())
1127N/A api_obj.rebuild_search_index()
1127N/A self._run_local_empty_tests(api_obj)
1127N/A
941N/A def test_bug_2989_1(self):
941N/A durl = self.dc.get_depot_url()
941N/A
941N/A for f in self._dir_restore_functions:
1859N/A api_obj = self.image_create(durl)
1859N/A
941N/A api_obj.rebuild_search_index()
941N/A
941N/A index_dir, index_dir_tmp = self._get_index_dirs()
941N/A
941N/A shutil.copytree(index_dir, index_dir_tmp)
1431N/A
1886N/A self._api_install(api_obj, ["example_pkg"])
941N/A
941N/A f(index_dir, index_dir_tmp)
941N/A
1286N/A self.assertRaises(
1286N/A api_errors.WrapSuccessfulIndexingException,
2339N/A self._api_uninstall, api_obj, ["example_pkg"],
2339N/A catch_wsie=False)
941N/A
941N/A self.image_destroy()
941N/A
941N/A def test_bug_2989_2(self):
941N/A durl = self.dc.get_depot_url()
941N/A
941N/A for f in self._dir_restore_functions:
1859N/A api_obj = self.image_create(durl)
941N/A
1886N/A self._api_install(api_obj, ["example_pkg"])
941N/A
941N/A index_dir, index_dir_tmp = self._get_index_dirs()
1431N/A
941N/A shutil.copytree(index_dir, index_dir_tmp)
941N/A
1886N/A self._api_install(api_obj, ["another_pkg"])
941N/A
941N/A f(index_dir, index_dir_tmp)
941N/A
1286N/A self.assertRaises(
1286N/A api_errors.WrapSuccessfulIndexingException,
2339N/A self._api_uninstall, api_obj, ["another_pkg"],
2339N/A catch_wsie=False)
941N/A
941N/A self.image_destroy()
1431N/A
941N/A def test_bug_2989_3(self):
941N/A durl = self.dc.get_depot_url()
941N/A self.pkgsend_bulk(durl, self.example_pkg11)
941N/A
941N/A for f in self._dir_restore_functions:
1859N/A api_obj = self.image_create(durl)
1431N/A
1886N/A self._api_install(api_obj, ["example_pkg@1.0,5.11-0"])
941N/A
941N/A index_dir, index_dir_tmp = self._get_index_dirs()
941N/A
941N/A shutil.copytree(index_dir, index_dir_tmp)
941N/A
1886N/A self._api_install(api_obj, ["example_pkg"])
941N/A
941N/A f(index_dir, index_dir_tmp)
1127N/A
1286N/A self.assertRaises(
1286N/A api_errors.WrapSuccessfulIndexingException,
2339N/A self._api_uninstall, api_obj, ["example_pkg"],
2339N/A catch_wsie=False)
941N/A
941N/A self.image_destroy()
941N/A
941N/A def test_bug_2989_4(self):
941N/A durl = self.dc.get_depot_url()
941N/A self.pkgsend_bulk(durl, self.example_pkg11)
941N/A
941N/A for f in self._dir_restore_functions:
1859N/A api_obj = self.image_create(durl)
1431N/A
1886N/A self._api_install(api_obj, ["another_pkg"])
1431N/A
941N/A index_dir, index_dir_tmp = self._get_index_dirs()
1431N/A
941N/A shutil.copytree(index_dir, index_dir_tmp)
941N/A
1886N/A self._api_install(api_obj, ["example_pkg@1.0,5.11-0"])
941N/A
941N/A f(index_dir, index_dir_tmp)
941N/A
1286N/A self.assertRaises(
1286N/A api_errors.WrapSuccessfulIndexingException,
2401N/A self._api_update, api_obj, catch_wsie=False)
941N/A
941N/A self.image_destroy()
941N/A
941N/A def test_bug_4239(self):
941N/A """Tests whether categories are indexed and searched for
941N/A correctly."""
941N/A
941N/A def _run_cat_tests(self, remote):
941N/A self._search_op(api_obj, remote, "System",
941N/A self.res_cat_pkg10, case_sensitive=False)
941N/A self._search_op(api_obj, remote, "Security",
941N/A self.res_cat_pkg10, case_sensitive=False)
941N/A self._search_op(api_obj, remote, "System/Security",
941N/A self.res_cat_pkg10, case_sensitive=False)
1115N/A self._search_op(api_obj, remote, "Other/Category",
1115N/A self.res_cat_pkg10_2, case_sensitive=False)
1115N/A self._search_op(api_obj, remote, "Other",
1115N/A self.res_cat_pkg10_2, case_sensitive=False)
1115N/A self._search_op(api_obj, remote, "Category",
1115N/A self.res_cat_pkg10_2, case_sensitive=False)
941N/A
941N/A def _run_cat2_tests(self, remote):
941N/A self._search_op(api_obj, remote, "Applications",
941N/A self.res_cat2_pkg10, case_sensitive=False)
941N/A self._search_op(api_obj, True, "Sound",
941N/A self.res_cat2_pkg10, case_sensitive=False)
1127N/A self._search_op(api_obj, remote, "Sound and Video",
941N/A self.res_cat2_pkg10, case_sensitive=False)
941N/A self._search_op(api_obj, remote, "Sound*",
941N/A self.res_cat2_pkg10, case_sensitive=False)
941N/A self._search_op(api_obj, remote, "*Video",
941N/A self.res_cat2_pkg10, case_sensitive=False)
941N/A self._search_op(api_obj, remote,
941N/A "'Applications/Sound and Video'",
941N/A self.res_cat2_pkg10, case_sensitive=False)
1653N/A # This is a test for bug 11002 which ensures that the
1653N/A # unquoting is being performed correctly.
1653N/A self._search_op(api_obj, remote,
1653N/A "'Applications/Sound%20and%20Video'",
1653N/A set(), case_sensitive=False)
1115N/A self._search_op(api_obj, remote, "Developer/C",
1115N/A self.res_cat2_pkg10_2, case_sensitive=False)
1115N/A self._search_op(api_obj, remote, "Developer",
1115N/A self.res_cat2_pkg10_2, case_sensitive=False)
1115N/A self._search_op(api_obj, remote, "C",
1115N/A self.res_cat2_pkg10_2, case_sensitive=False)
1115N/A
941N/A def _run_cat3_tests(self, remote):
941N/A self._search_op(api_obj, remote, "foo",
941N/A self.res_cat3_pkg10,case_sensitive=False)
941N/A self._search_op(api_obj, remote, "baz",
941N/A self.res_cat3_pkg10, case_sensitive=False)
941N/A self._search_op(api_obj, remote, "asda",
941N/A self.res_cat3_pkg10, case_sensitive=False)
941N/A self._search_op(api_obj, remote,
941N/A "foo/bar/baz/bill/beam/asda", self.res_cat3_pkg10,
941N/A case_sensitive=False)
941N/A
1127N/A durl = self.dc.get_depot_url()
2028N/A self.pkgsend_bulk(durl, (self.cat_pkg10, self.cat2_pkg10,
2028N/A self.cat3_pkg10, self.bad_cat_pkg10, self.bad_cat2_pkg10))
1859N/A api_obj = self.image_create(durl)
1127N/A
941N/A remote = True
941N/A _run_cat_tests(self, remote)
941N/A _run_cat2_tests(self, remote)
941N/A _run_cat3_tests(self, remote)
941N/A
941N/A remote = False
1886N/A self._api_install(api_obj, ["cat"])
941N/A _run_cat_tests(self, remote)
941N/A
1886N/A self._api_install(api_obj, ["cat2"])
941N/A _run_cat2_tests(self, remote)
1127N/A
1886N/A self._api_install(api_obj, ["cat3"])
941N/A _run_cat3_tests(self, remote)
1127N/A
1886N/A self._api_install(api_obj, ["badcat"])
1886N/A self._api_install(api_obj, ["badcat2"])
941N/A _run_cat_tests(self, remote)
941N/A _run_cat2_tests(self, remote)
941N/A _run_cat3_tests(self, remote)
941N/A
1127N/A def test_bug_7628(self):
1127N/A """Checks whether incremental update generates wrong
1127N/A additional lines."""
1127N/A durl = self.dc.get_depot_url()
2028N/A ind_dir = self._get_repo_index_dir()
1127N/A tok_file = os.path.join(ind_dir, ss.BYTE_OFFSET_FILE)
1127N/A main_file = os.path.join(ind_dir, ss.MAIN_FILE)
2028N/A
1127N/A self.pkgsend_bulk(durl, self.example_pkg10)
1127N/A fh = open(tok_file)
1127N/A tok_1 = fh.readlines()
1127N/A tok_len = len(tok_1)
1127N/A fh.close()
2028N/A
1127N/A fh = open(main_file)
1127N/A main_1 = fh.readlines()
1127N/A main_len = len(main_1)
3339N/A fh.close()
2028N/A
1127N/A self.pkgsend_bulk(durl, self.example_pkg10, optional=False)
1127N/A fh = open(tok_file)
1127N/A tok_2 = fh.readlines()
1127N/A new_tok_len = len(tok_2)
1127N/A fh.close()
2028N/A
1127N/A fh = open(main_file)
1127N/A main_2 = fh.readlines()
1127N/A new_main_len = len(main_2)
1127N/A fh.close()
2028N/A
1431N/A # Since the server now adds a set action for the FMRI to
1431N/A # manifests during publication, there should be one
1431N/A # additional line for the token file.
1431N/A self.assertEqual(new_tok_len, tok_len + 1)
1431N/A self.assertEqual(new_main_len, main_len + 1)
1127N/A
1127N/A def test_bug_983(self):
1127N/A """Test for known bug 983."""
1127N/A durl = self.dc.get_depot_url()
1127N/A self.pkgsend_bulk(durl, self.bug_983_manifest)
1859N/A api_obj = self.image_create(durl)
1127N/A
1127N/A self._search_op(api_obj, True, "gmake", self.res_bug_983)
1146N/A self._search_op(api_obj, True, "SUNWcsl@0.5.11-0.89",
1146N/A self.res_983_csl_dependency)
1146N/A self._search_op(api_obj, True, "SUNWcsl",
1146N/A self.res_983_csl_dependency)
1146N/A self._search_op(api_obj, True, "SUNWtestbar@0.5.11-0.111",
1146N/A self.res_983_bar_dependency)
1146N/A self._search_op(api_obj, True, "SUNWtestbar",
1146N/A self.res_983_bar_dependency)
1146N/A self._search_op(api_obj, True, "SUNWtestfoo@0.5.11-0.111",
1146N/A self.res_983_foo_dependency)
1146N/A self._search_op(api_obj, True, "SUNWtestfoo",
1146N/A self.res_983_foo_dependency)
1146N/A self._search_op(api_obj, True, "depend:require:",
1146N/A self.res_983_csl_dependency | self.res_983_bar_dependency)
1146N/A self._search_op(api_obj, True, "depend:incorporate:",
1146N/A self.res_983_foo_dependency)
1146N/A self._search_op(api_obj, True, "depend::",
1146N/A self.res_983_csl_dependency | self.res_983_bar_dependency |
1146N/A self.res_983_foo_dependency)
1146N/A
1286N/A def test_bug_7534(self):
1286N/A """Tests that an automatic reindexing is detected by the test
1286N/A suite."""
1286N/A durl = self.dc.get_depot_url()
1286N/A self.pkgsend_bulk(durl, self.example_pkg10)
1859N/A api_obj = self.image_create(durl)
1286N/A
2339N/A index_dir = os.path.join(self.img_path(), "var", "pkg",
2144N/A "cache", "index")
3072N/A api_obj.rebuild_search_index()
3072N/A self._search_op(api_obj, False, 'example', set())
1286N/A
1286N/A orig_fn = os.path.join(index_dir,
3234N/A list(query_parser.TermQuery._get_gdd(index_dir).values())[0].\
1286N/A get_file_name())
1286N/A dest_fn = orig_fn + "TMP"
1431N/A
1886N/A self._api_install(api_obj, ["example_pkg"])
1286N/A api_obj.rebuild_search_index()
1286N/A
1286N/A portable.rename(orig_fn, dest_fn)
1286N/A self.assertRaises(api_errors.WrapSuccessfulIndexingException,
2339N/A self._api_uninstall, api_obj, ["example_pkg"],
2339N/A catch_wsie=False)
1286N/A
1661N/A def test_bug_8492(self):
1661N/A """Tests that field queries and phrase queries work together.
1661N/A """
1661N/A durl = self.dc.get_depot_url()
2028N/A self.pkgsend_bulk(durl, (self.bug_8492_manf_1,
2028N/A self.bug_8492_manf_2))
1859N/A api_obj = self.image_create(durl)
1661N/A
1661N/A self._search_op(api_obj, True, "set::'image packaging'",
1661N/A self.res_8492_1 | self.res_8492_2)
1661N/A self._search_op(api_obj, True, "b1:set::'image packaging'",
1661N/A self.res_8492_1)
1661N/A
1886N/A self._api_install(api_obj, ["b1", "b2"])
1661N/A
1661N/A self._search_op(api_obj, False, "set::'image packaging'",
1661N/A self.res_8492_1 | self.res_8492_2)
1661N/A self._search_op(api_obj, False, "b2:set::'image packaging'",
1661N/A self.res_8492_2)
1661N/A
1661N/A api_obj.rebuild_search_index()
1661N/A
1661N/A self._search_op(api_obj, True, "set::'image packaging'",
1661N/A self.res_8492_1 | self.res_8492_2)
1661N/A self._search_op(api_obj, True, "b1:set::'image packaging'",
1661N/A self.res_8492_1)
1661N/A
1291N/A def test_bug_9845_01(self):
1291N/A """Test that a corrupt query doesn't break the server."""
1291N/A durl = self.dc.get_depot_url()
1291N/A expected_string = _("A query is expected to have five fields: "
1291N/A "case sensitivity, return type, number of results to "
1291N/A "return, the number at which to start returning results, "
1291N/A "and the text of the query. The query provided lacked at "
1291N/A "least one of those fields:")
1291N/A expected_code = 404
1291N/A q_str = "foo"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1291N/A def test_bug_9845_02(self):
1291N/A """Test that a corrupt case_sensitive value doesn't break the "
1291N/A server."""
1291N/A durl = self.dc.get_depot_url()
3158N/A expected_string = _("{name} had a bad value of '{bv}'").format(
3158N/A name="case_sensitive",
3158N/A bv="FAlse"
3158N/A )
1291N/A expected_code = 404
1291N/A q_str = "FAlse_2_None_None_foo"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1431N/A def test_bug_9845_03(self):
1291N/A """Test that a corrupt return_type value doesn't break the "
1291N/A server."""
1291N/A durl = self.dc.get_depot_url()
3158N/A expected_string = _("{name} had a bad value of '{bv}'").format(
3158N/A name="return_type",
3158N/A bv="3"
3158N/A )
1291N/A expected_code = 404
1291N/A q_str = "False_3_None_None_foo"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1291N/A def test_bug_9845_04(self):
1291N/A """Test that a corrupt return_type value doesn't break the "
1291N/A server."""
1291N/A durl = self.dc.get_depot_url()
3158N/A expected_string = _("{name} had a bad value of '{bv}'").format(
3158N/A name="return_type",
3158N/A bv="A"
3158N/A )
1291N/A expected_code = 404
1291N/A q_str = "False_A_None_None_foo"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1291N/A def test_bug_9845_05(self):
1291N/A """Test that a corrupt num_to_return value doesn't break the "
1291N/A server."""
1291N/A durl = self.dc.get_depot_url()
3158N/A expected_string = _("{name} had a bad value of '{bv}'").format(
3158N/A name="num_to_return",
3158N/A bv="NOne"
3158N/A )
1291N/A expected_code = 404
1291N/A q_str = "False_2_NOne_None_foo"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1291N/A def test_bug_9845_06(self):
1291N/A """Test that a corrupt start_point value doesn't break the "
1291N/A server."""
1291N/A durl = self.dc.get_depot_url()
3158N/A expected_string = _("{name} had a bad value of '{bv}'").format(
3158N/A name="start_point",
3158N/A bv="NOne"
3158N/A )
1291N/A expected_code = 404
1291N/A q_str = "False_2_None_NOne_foo"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1291N/A def test_bug_9845_07(self):
1291N/A """Test that a corrupt case_sensitive value doesn't break the "
1291N/A server."""
1291N/A durl = self.dc.get_depot_url()
3158N/A expected_string = _("{name} had a bad value of '{bv}'").format(
3158N/A name="case_sensitive",
3158N/A bv=""
3158N/A )
1291N/A expected_code = 404
1291N/A q_str = "_2_None_None_foo"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1291N/A def test_bug_9845_08(self):
1291N/A """Test that a missing return_type value doesn't break the "
1291N/A server."""
1291N/A durl = self.dc.get_depot_url()
3158N/A expected_string = _("{name} had a bad value of '{bv}'").format(
3158N/A name="return_type",
3158N/A bv=""
3158N/A )
1291N/A expected_code = 404
1291N/A q_str = "False__None_None_foo"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1291N/A def test_bug_9845_09(self):
1291N/A """Test that a missing num_to_return value doesn't break the "
1291N/A server."""
1291N/A durl = self.dc.get_depot_url()
3158N/A expected_string = _("{name} had a bad value of '{bv}'").format(
3158N/A name="num_to_return",
3158N/A bv=""
3158N/A )
1291N/A expected_code = 404
1291N/A q_str = "False_2__None_foo"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1291N/A def test_bug_9845_10(self):
1291N/A """Test that a missing start_point value doesn't break the "
1291N/A server."""
1291N/A durl = self.dc.get_depot_url()
3158N/A expected_string = _("{name} had a bad value of '{bv}'").format(
3158N/A name="start_point",
3158N/A bv=""
3158N/A )
1291N/A expected_code = 404
1291N/A q_str = "False_2_None__foo"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1291N/A def test_bug_9845_11(self):
1291N/A """Test that missing query text doesn't break the server."""
1291N/A durl = self.dc.get_depot_url()
1291N/A expected_string = _("Could not parse query.")
1291N/A expected_code = 400
1291N/A q_str = "False_2_None_None_"
3234N/A self.validateAssertRaises(HTTPError,
1291N/A lambda x: self._check_err(x, expected_string,
1291N/A expected_code),
3234N/A urlopen, durl + "/search/1/" + q_str)
1291N/A
1728N/A def test_bug_14177(self):
1728N/A def run_tests(api_obj, remote):
1728N/A self._search_op(api_obj, remote, "pfoo",
1728N/A self.hierarchical_named_pkg_res,
1728N/A case_sensitive=False)
1728N/A self._search_op(api_obj, remote, "pc/pfoo",
1728N/A self.hierarchical_named_pkg_res,
1728N/A case_sensitive=False)
1728N/A self._search_op(api_obj, remote, "pb/pc/pfoo",
1728N/A self.hierarchical_named_pkg_res,
1728N/A case_sensitive=False)
1728N/A self._search_op(api_obj, remote, "pa/pb/pc/pfoo",
1728N/A self.hierarchical_named_pkg_res,
1728N/A case_sensitive=False)
1728N/A self._search_op(api_obj, remote, "test/pa/pb/pc/pfoo",
1728N/A self.hierarchical_named_pkg_res,
1728N/A case_sensitive=False)
1728N/A
1728N/A durl = self.dc.get_depot_url()
1728N/A self.pkgsend_bulk(durl, self.hierarchical_named_pkg)
1859N/A api_obj = self.image_create(durl)
1859N/A
1728N/A remote = True
1728N/A run_tests(api_obj, remote)
1886N/A self._api_install(api_obj, ["pfoo"])
1728N/A remote = False
1728N/A run_tests(api_obj, remote)
1728N/A api_obj.rebuild_search_index()
1728N/A api_obj.reset()
1728N/A run_tests(api_obj, remote)
1728N/A
1291N/A
1715N/Aclass TestApiSearchBasics_nonP(TestApiSearchBasics):
1127N/A def setUp(self):
1127N/A self.debug_features = ["headers"]
1127N/A TestApiSearchBasics.setUp(self)
1127N/A
2028N/A def pkgsend_bulk(self, durl, pkg):
2028N/A # Ensures indexing is done for every pkgsend.
2028N/A TestApiSearchBasics.pkgsend_bulk(self, durl, pkg,
2028N/A refresh_index=True)
2028N/A self.wait_repo(self.dc.get_repodir())
2028N/A
1127N/A def test_local_image_update(self):
2089N/A """Test that the index gets updated by update and
1127N/A that rebuilding the index works after updating the
1127N/A image. Specifically, this tests that rebuilding indexes with
1127N/A gaps in them works correctly."""
1127N/A durl = self.dc.get_depot_url()
1127N/A self.pkgsend_bulk(durl, self.example_pkg10)
1859N/A api_obj = self.image_create(durl)
1127N/A
1886N/A self._api_install(api_obj, ["example_pkg"])
1127N/A
1127N/A self.pkgsend_bulk(durl, self.example_pkg11)
1127N/A api_obj.refresh(immediate=True)
1127N/A
2401N/A self._api_update(api_obj)
1127N/A
1127N/A self._run_local_tests_example11_installed(api_obj)
1127N/A
1127N/A api_obj.rebuild_search_index()
1127N/A
1127N/A self._run_local_tests_example11_installed(api_obj)
1127N/A
1843N/A def test_bug_6177(self):
1843N/A durl = self.dc.get_depot_url()
2028N/A self.pkgsend_bulk(durl, (self.example_pkg10, self.example_pkg11,
2028N/A self.incorp_pkg10, self.incorp_pkg11))
1895N/A api_obj = self.image_create(durl)
1843N/A
1843N/A res_both_actions = set([
1843N/A ('pkg:/example_pkg@1.1-0', 'path',
1843N/A 'dir group=bin mode=0755 owner=root path=bin'),
1843N/A ('pkg:/example_pkg@1.0-0', 'path',
1843N/A 'dir group=bin mode=0755 owner=root path=bin')
1843N/A ])
1843N/A
1843N/A res_10_action = set([
1843N/A ('pkg:/example_pkg@1.0-0', 'path',
1843N/A 'dir group=bin mode=0755 owner=root path=bin')
1843N/A ])
1843N/A
1843N/A res_11_action = set([
1843N/A ('pkg:/example_pkg@1.1-0', 'path',
1843N/A 'dir group=bin mode=0755 owner=root path=bin')
1843N/A ])
1843N/A
1843N/A res_both_packages = set([
1843N/A "pkg:/example_pkg@1.1-0",
1843N/A "pkg:/example_pkg@1.0-0"
1843N/A ])
1843N/A
1843N/A res_10_package = set([
1843N/A "pkg:/example_pkg@1.0-0"
1843N/A ])
1843N/A
1843N/A res_11_package = set([
1843N/A "pkg:/example_pkg@1.1-0"
1843N/A ])
1843N/A
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions)
1843N/A
1843N/A # Test that if a package is installed, its version and newer
1843N/A # versions are shown.
1886N/A self._api_install(api_obj, ["example_pkg@1.0"])
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions)
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions,
1843N/A prune_versions=False)
1843N/A
1843N/A # Check that after uninstall, back to returning all versions.
1886N/A self._api_uninstall(api_obj, ["example_pkg"])
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions)
1843N/A self._search_op(api_obj, True, "/bin", res_both_packages,
1843N/A return_actions=False)
1843N/A
1843N/A # Test that if a package is installed, its version and newer
1843N/A # versions are shown. Older versions should not be shown.
1886N/A self._api_install(api_obj, ["example_pkg@1.1"])
1843N/A self._search_op(api_obj, True, "/bin", res_11_action)
1843N/A self._search_op(api_obj, True, "</bin>", res_11_package,
1843N/A return_actions=False)
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions,
1843N/A prune_versions=False)
1843N/A self._search_op(api_obj, True, "</bin>", res_both_packages,
1843N/A return_actions=False, prune_versions=False)
3234N/A
1843N/A # Check that after uninstall, back to returning all versions.
1886N/A self._api_uninstall(api_obj, ["example_pkg"])
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions)
1843N/A
1843N/A # Check that only the incorporated package is returned.
1886N/A self._api_install(api_obj, ["incorp_pkg@1.0"])
1843N/A self._search_op(api_obj, True, "/bin", res_10_action)
1843N/A self._search_op(api_obj, True, "/bin", res_10_package,
1843N/A return_actions=False)
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions,
1843N/A prune_versions=False)
1843N/A self._search_op(api_obj, True, "/bin", res_both_packages,
1843N/A return_actions=False, prune_versions=False)
1843N/A
1843N/A # Should now show the 1.1 version of example_pkg since the
1843N/A # version has been upgraded.
1886N/A self._api_install(api_obj, ["incorp_pkg"])
1843N/A self._search_op(api_obj, True, "/bin", res_11_action)
1843N/A self._search_op(api_obj, True, "</bin>", res_11_package,
1843N/A return_actions=False)
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions,
1843N/A prune_versions=False)
1843N/A self._search_op(api_obj, True, "</bin>", res_both_packages,
1843N/A return_actions=False, prune_versions=False)
1843N/A
1843N/A # Should now show both again since the incorporation has been
1843N/A # removed.
1886N/A self._api_uninstall(api_obj, ["incorp_pkg"])
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions)
1843N/A
1843N/A # Check that installed and incorporated work correctly together.
1886N/A self._api_install(api_obj,
1886N/A ["incorp_pkg@1.0", "example_pkg@1.0"])
1843N/A self._search_op(api_obj, True, "/bin", res_10_action)
1843N/A self._search_op(api_obj, True, "</bin>", res_10_package,
1843N/A return_actions=False)
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions,
1843N/A prune_versions=False)
1843N/A self._search_op(api_obj, True, "</bin>", res_both_packages,
1843N/A return_actions=False, prune_versions=False)
1843N/A
1843N/A # And that it works after the incorporation has been changed.
1886N/A self._api_install(api_obj, ["incorp_pkg"])
1843N/A self._search_op(api_obj, True, "/bin", res_11_action)
1843N/A self._search_op(api_obj, True, "</bin>", res_11_package,
1843N/A return_actions=False)
1843N/A self._search_op(api_obj, True, "/bin", res_both_actions,
1843N/A prune_versions=False)
1843N/A self._search_op(api_obj, True, "</bin>", res_both_packages,
1843N/A return_actions=False, prune_versions=False)
1843N/A
2028N/A def __corrupt_depot(self, root):
1009N/A self.dc.stop()
2028N/A for entry in os.walk(root):
2028N/A dirpath, dirnames, fnames = entry
2028N/A if ss.MAIN_FILE in fnames:
2028N/A src = os.path.join(dirpath, ss.MAIN_FILE)
2028N/A dest = os.path.join(dirpath,
2028N/A "main_dict.ascii.v1")
3158N/A self.debug("moving {0} to {1}".format(src, dest))
2028N/A shutil.move(src, dest)
1009N/A self.dc.start()
1009N/A
1009N/A def test_bug_7358_1(self):
1009N/A """Move files so that an inconsistent index is created and
1009N/A check that the server rebuilds the index when possible, and
1009N/A doesn't stack trace when it can't write to the directory."""
1009N/A
1009N/A durl = self.dc.get_depot_url()
2028N/A repo_path = self.dc.get_repodir()
2028N/A
1859N/A api_obj = self.image_create(durl)
1009N/A # Check when depot is empty.
2028N/A self.__corrupt_depot(repo_path)
2028N/A repo = self.dc.get_repo() # Every time to ensure current state.
2028N/A repo.refresh_index()
1009N/A # Since the depot is empty, should return no results but
1009N/A # not error.
1009N/A self._search_op(api_obj, True, 'e*', set())
1009N/A
1009N/A self.pkgsend_bulk(durl, self.example_pkg10)
2028N/A repo = self.dc.get_repo() # Every time to ensure current state.
2028N/A repo.refresh_index()
2028N/A self.dc.refresh()
1009N/A
1009N/A # Check when depot contains a package.
2028N/A self.__corrupt_depot(repo_path)
2028N/A repo = self.dc.get_repo() # Every time to ensure current state.
2028N/A repo.refresh_index()
1009N/A self._run_remote_tests(api_obj)
1009N/A
1009N/A def test_bug_7358_2(self):
1009N/A """Does same check as 7358_1 except it checks for interactions
1009N/A with writable root."""
1009N/A
1009N/A durl = self.dc.get_depot_url()
2028N/A repo_path = self.dc.get_repodir()
2028N/A ind_dir = self._get_repo_index_dir()
2028N/A if os.path.exists(ind_dir):
2028N/A shutil.rmtree(ind_dir)
1715N/A writable_root = os.path.join(self.test_root,
1009N/A "writ_root")
1009N/A self.dc.set_writable_root(writable_root)
1431N/A
1859N/A api_obj = self.image_create(durl)
1009N/A
1009N/A # Check when depot is empty.
2028N/A writ_dir = self._get_repo_writ_dir()
1009N/A self.__corrupt_depot(writ_dir)
1009N/A # Since the depot is empty, should return no results but
1009N/A # not error.
3339N/A self.assertTrue(not os.path.isdir(ind_dir))
1009N/A self._search_op(api_obj, True, 'e*', set())
1009N/A
1009N/A self.pkgsend_bulk(durl, self.example_pkg10)
1431N/A
1009N/A # Check when depot contains a package.
1009N/A self.__corrupt_depot(writ_dir)
3339N/A self.assertTrue(not os.path.isdir(ind_dir))
1009N/A self._run_remote_tests(api_obj)
1431N/A
1081N/A def test_bug_8318(self):
1081N/A durl = self.dc.get_depot_url()
1081N/A self.pkgsend_bulk(durl, self.example_pkg10)
1859N/A api_obj = self.image_create(durl)
1081N/A uuids = []
1081N/A for p in api_obj.img.gen_publishers():
1081N/A uuids.append(p.client_uuid)
1431N/A
1081N/A self._search_op(api_obj, True, "example_path",
1081N/A self.res_remote_path)
1081N/A self._search_op(api_obj, True, "example_path",
1081N/A self.res_remote_path, servers=[{"origin": durl}])
3339N/A lfh = open(self.dc.get_logpath(), "r")
1081N/A found = 0
2330N/A num_expected = 7
1081N/A for line in lfh:
1081N/A if "X-IPKG-UUID:" in line:
1081N/A tmp = line.split()
1081N/A s_uuid = tmp[1]
1081N/A if s_uuid not in uuids:
3158N/A raise RuntimeError("Uuid found:{0} not "
1081N/A "found in list of possible "
3158N/A "uuids:{1}".format(s_uuid, uuids))
1081N/A found += 1
3339N/A lfh.close()
1081N/A if found != num_expected:
3158N/A raise RuntimeError(("Found {0} instances of a "
3158N/A "client uuid, expected to find {1}.").format(
3158N/A found, num_expected))
1127N/A
1715N/A def test_bug_9729_1(self):
1715N/A """Test that installing more than
2693N/A indexer.MAX_FAST_INDEXED_PKGS packages at a time doesn't
1715N/A cause any type of indexing error."""
1715N/A durl = self.dc.get_depot_url()
1715N/A pkg_list = []
2693N/A for i in range(0, indexer.MAX_FAST_INDEXED_PKGS + 1):
1715N/A self.pkgsend_bulk(durl,
3158N/A "open pkg{0}@1.0,5.11-0\nclose\n".format(i))
3158N/A pkg_list.append("pkg{0}".format(i))
1859N/A api_obj = self.image_create(durl)
1886N/A self._api_install(api_obj, pkg_list)
1715N/A
1715N/A def test_bug_9729_2(self):
1715N/A """Test that installing more than
2693N/A indexer.MAX_FAST_INDEXED_PKGS packages one after another
1715N/A doesn't cause any type of indexing error."""
1715N/A def _remove_extra_info(v):
1715N/A return v.split("-")[0]
1715N/A durl = self.dc.get_depot_url()
1715N/A pkg_list = []
2693N/A for i in range(0, indexer.MAX_FAST_INDEXED_PKGS + 3):
1715N/A self.pkgsend_bulk(durl,
3158N/A "open pkg{0}@1.0,5.11-0\nclose\n".format(i))
3158N/A pkg_list.append("pkg{0}".format(i))
1859N/A api_obj = self.image_create(durl)
1715N/A fast_add_loc = os.path.join(self._get_index_dirs()[0],
1715N/A "fast_add.v1")
1715N/A fast_remove_loc = os.path.join(self._get_index_dirs()[0],
1715N/A "fast_remove.v1")
1715N/A api_obj.rebuild_search_index()
1715N/A for p in pkg_list:
1886N/A self._api_install(api_obj, [p])
1715N/A # Test for bug 11104. The fast_add.v1 file was not being updated
1715N/A # correctly by install or image update, it was growing with
1715N/A # each modification.
1715N/A self._check(set((
1715N/A _remove_extra_info(v)
1715N/A for v in self._get_lines(fast_add_loc)
1715N/A )), self.fast_add_after_install)
1715N/A self._check(set((
1715N/A _remove_extra_info(v)
1715N/A for v in self._get_lines(fast_remove_loc)
1715N/A )), self.fast_remove_after_install)
1715N/A # Now check that image update also handles fast_add
1715N/A # appropriately when a small number of packages have changed.
1715N/A for i in range(0, 2):
1715N/A self.pkgsend_bulk(durl,
3158N/A "open pkg{0}@2.0,5.11-0\nclose\n".format(i))
3158N/A pkg_list.append("pkg{0}".format(i))
1715N/A api_obj.refresh(immediate=True)
2401N/A self._api_update(api_obj)
1715N/A self._check(set((
1715N/A _remove_extra_info(v)
1715N/A for v in self._get_lines(fast_add_loc)
1715N/A )), self.fast_add_after_first_update)
1715N/A
1715N/A self._check(set((
1715N/A _remove_extra_info(v)
1715N/A for v in self._get_lines(fast_remove_loc)
1715N/A )), self.fast_remove_after_first_update)
2754N/A # Check that a local search actually works.
3158N/A test_value = 'pkg:/pkg{0}@2.0-0', 'test/pkg{0}', \
3158N/A 'set name=pkg.fmri value=pkg://test/pkg{0}@2.0,5.11-0:'
2754N/A for n in range(0, 2):
3158N/A tv = set([tuple(v.format(n) for v in test_value)])
2754N/A self._search_op(api_obj, remote=False,
3158N/A token="pkg{0}".format(n), test_value=tv)
2754N/A
1715N/A # Now check that image update also handles fast_add
1715N/A # appropriately when a large number of packages have changed.
2693N/A for i in range(3, indexer.MAX_FAST_INDEXED_PKGS + 3):
1715N/A self.pkgsend_bulk(durl,
3158N/A "open pkg{0}@2.0,5.11-0\nclose\n".format(i))
3158N/A pkg_list.append("pkg{0}".format(i))
1715N/A api_obj.refresh(immediate=True)
2401N/A self._api_update(api_obj)
1715N/A self._check(set((
1715N/A _remove_extra_info(v)
1715N/A for v in self._get_lines(fast_add_loc)
1715N/A )), self.fast_add_after_second_update)
1715N/A self._check(set((
1715N/A _remove_extra_info(v)
1715N/A for v in self._get_lines(fast_remove_loc)
1715N/A )), self.fast_remove_after_second_update)
2754N/A # Check that a local search actually works.
2754N/A for n in range(3, indexer.MAX_FAST_INDEXED_PKGS + 3):
3158N/A tv = set([tuple(v.format(n) for v in test_value)])
2754N/A self._search_op(api_obj, remote=False,
3158N/A token="pkg{0}".format(n), test_value=tv)
1715N/A
1635N/A def test_bug_13485(self):
1635N/A """Test that indexer.Indexer's check_for_updates function works
1635N/A as excepted. This needs to be a separate test because other
1635N/A tests are likely to conintue working while reindexing more
1635N/A frequently than they should."""
1635N/A
1635N/A durl = self.dc.get_depot_url()
2028N/A ind_dir = self._get_repo_index_dir()
1635N/A
1635N/A # Check that an empty index works correctly.
2028N/A fmris = indexer.Indexer.check_for_updates(ind_dir,
2028N/A self._get_repo_catalog())
1635N/A self.assertEqual(set(), fmris)
1635N/A
1635N/A self.pkgsend_bulk(durl, self.example_pkg10)
2028N/A cat = self._get_repo_catalog()
2028N/A self.assertEqual(len(set(cat.fmris())), 1)
1635N/A # Check that after publishing one package, no packages need
1635N/A # indexing.
2028N/A fmris = indexer.Indexer.check_for_updates(ind_dir,
2028N/A self._get_repo_catalog())
1635N/A self.assertEqual(set(), fmris)
3234N/A
1635N/A back_dir = ind_dir + ".BACKUP"
1635N/A shutil.copytree(ind_dir, back_dir)
1635N/A self.pkgsend_bulk(durl, self.example_pkg10)
2028N/A cat = self._get_repo_catalog()
2028N/A self.assertEqual(len(set(cat.fmris())), 2)
1635N/A # Check that publishing a second package also works.
2028N/A fmris = indexer.Indexer.check_for_updates(ind_dir,
2028N/A self._get_repo_catalog())
1635N/A self.assertEqual(set(), fmris)
1635N/A
1635N/A # Check that a package that was publisher but not index is
1635N/A # reported.
1635N/A fmris = indexer.Indexer.check_for_updates(back_dir,
2028N/A self._get_repo_catalog())
1635N/A self.assertEqual(len(fmris), 1)
941N/A
2185N/A def test_bug_17672(self):
2185N/A durl = self.dc.get_depot_url()
2185N/A self.pkgsend_bulk(durl, (self.another_pkg10, self.space_pkg10,
2185N/A self.require_any_manf))
2185N/A repo = self.dc.get_repo()
2185N/A repo.rebuild(build_catalog=False, build_index=True)
2185N/A api_obj = self.image_create(durl)
2185N/A expected_result = set([
2185N/A ('pkg:/ra@1.0-0', 'require-any',
2185N/A 'depend fmri=another_pkg@1.0,5.11-0 ' +
2185N/A 'fmri=pkg:/space_pkg@1.0,5.11-0 type=require-any')
2185N/A ])
2185N/A self._search_op(api_obj, True, "depend::", expected_result)
2185N/A self._api_install(api_obj, ["ra"])
2185N/A self._search_op(api_obj, False, "depend::", expected_result)
2185N/A api_obj.rebuild_search_index()
2185N/A self._search_op(api_obj, False, "depend::", expected_result)
2185N/A self._search_op(api_obj, False, "depend::another_pkg",
2185N/A expected_result)
2185N/A self._search_op(api_obj, False, "depend::space_pkg",
2185N/A expected_result)
2185N/A
1715N/A
1715N/Aclass TestApiSearchMulti(pkg5unittest.ManyDepotTestCase):
941N/A
941N/A example_pkg10 = """
941N/A open example_pkg@1.0,5.11-0
1628N/A add dir mode=0755 owner=root group=bin path=/bin/example_dir
941N/A close """
941N/A
1325N/A res_alternate_server_local = set([
1431N/A ('pkg:/example_pkg@1.0-0', 'test2/example_pkg',
1431N/A 'set name=pkg.fmri value=pkg://test2/example_pkg@1.0,5.11-0:')
1325N/A ])
1325N/A
941N/A def setUp(self):
1715N/A pkg5unittest.ManyDepotTestCase.setUp(self, ["test1", "test2",
1895N/A "test3"], debug_features=["headers"], start_depots=True)
1081N/A
1081N/A self.durl1 = self.dcs[1].get_depot_url()
1081N/A self.durl2 = self.dcs[2].get_depot_url()
1081N/A self.durl3 = self.dcs[3].get_depot_url()
2028N/A self.pkgsend_bulk(self.durl2, self.example_pkg10,
2028N/A refresh_index=True)
2028N/A self.wait_repo(self.dcs[2].get_repodir())
1081N/A
1431N/A self.image_create(self.durl1, prefix="test1")
1081N/A self.pkg("set-publisher -O " + self.durl2 + " test2")
941N/A
1081N/A def _check(self, proposed_answer, correct_answer):
1081N/A if correct_answer == proposed_answer:
1081N/A return True
1081N/A else:
1081N/A self.debug("Proposed Answer: " + str(proposed_answer))
1081N/A self.debug("Correct Answer : " + str(correct_answer))
1081N/A if isinstance(correct_answer, set) and \
1081N/A isinstance(proposed_answer, set):
1728N/A self.debug("Missing: " +
1728N/A str(correct_answer - proposed_answer))
1728N/A self.debug("Extra : " +
1728N/A str(proposed_answer - correct_answer))
1728N/A self.assertEqual(correct_answer, proposed_answer)
941N/A
1628N/A @staticmethod
1628N/A def _extract_action_from_res(it, err):
1628N/A res = []
1628N/A if err:
1628N/A try:
1628N/A for query_num, auth, (version, return_type,
1628N/A (pkg_name, piece, act)) in it:
1628N/A res.append((fmri.PkgFmri(str(
1628N/A pkg_name)).get_short_fmri(), piece,
1628N/A TestApiSearchBasics._replace_act(
1628N/A act)),)
3171N/A except err as e:
1628N/A return res
1628N/A else:
1628N/A raise RuntimeError(
3158N/A "Didn't get expected error:{0}".format(err))
1628N/A else:
1628N/A return TestApiSearchBasics._extract_action_from_res(it)
3234N/A
1628N/A
1081N/A def _search_op(self, api_obj, remote, token, test_value,
1081N/A case_sensitive=False, return_actions=True, num_to_return=None,
1628N/A start_point=None, servers=None, expected_err=None):
1081N/A search_func = api_obj.local_search
1081N/A query = api.Query(token, case_sensitive, return_actions,
1081N/A num_to_return, start_point)
1325N/A if remote:
1325N/A search_func = api_obj.remote_search
1628N/A res = set(self._extract_action_from_res(
1628N/A search_func([query], servers=servers),
1628N/A expected_err))
1325N/A else:
1325N/A res = set(TestApiSearchBasics._extract_action_from_res(
1325N/A search_func([query])))
1081N/A self._check(set(res), test_value)
1081N/A
941N/A def test_bug_2955(self):
941N/A """See http://defect.opensolaris.org/bz/show_bug.cgi?id=2955"""
1895N/A
1895N/A api_obj = self.get_img_api_obj()
1886N/A self._api_install(api_obj, ["example_pkg"])
1715N/A
1325N/A # Test for bug 10690 by checking whether the fmri names
1325N/A # for packages installed from the non-preferred publisher
1325N/A # are parsed correctly. Specifically, test whether the name
1325N/A # alone is searchable, as well as the publisher/name
1325N/A # combination.
1325N/A self._search_op(api_obj, False, "set::test2/example_pkg",
1325N/A self.res_alternate_server_local)
1325N/A self._search_op(api_obj, False, "set::example_pkg",
1325N/A self.res_alternate_server_local)
1325N/A self._search_op(api_obj, False, "set::test2/*",
1325N/A self.res_alternate_server_local)
941N/A api_obj.rebuild_search_index()
1325N/A self._search_op(api_obj, False, "set::test2/example_pkg",
1325N/A self.res_alternate_server_local)
1325N/A self._search_op(api_obj, False, "set::example_pkg",
1325N/A self.res_alternate_server_local)
1325N/A self._search_op(api_obj, False, "set::test2/*",
1325N/A self.res_alternate_server_local)
1886N/A self._api_uninstall(api_obj, ["example_pkg"])
941N/A
1081N/A def test_bug_8318(self):
1431N/A
1895N/A api_obj = self.get_img_api_obj()
1081N/A self._search_op(api_obj, True,
1081N/A "this_should_not_match_any_token", set())
1081N/A self._search_op(api_obj, True, "example_path",
1081N/A set(), servers=[{"origin": self.durl1}])
1081N/A self._search_op(api_obj, True, "example_path",
1081N/A set(), servers=[{"origin": self.durl3}])
3293N/A num_expected = { 1: 6, 2: 8, 3: 0 }
1081N/A for d in range(1,(len(self.dcs) + 1)):
1081N/A try:
1081N/A pub = api_obj.img.get_publisher(
1081N/A origin=self.dcs[d].get_depot_url())
1081N/A c_uuid = pub.client_uuid
1081N/A except api_errors.UnknownPublisher:
1081N/A c_uuid = None
3339N/A lfh = open(self.dcs[d].get_logpath(), "r")
1081N/A found = 0
1081N/A for line in lfh:
1081N/A if "X-IPKG-UUID:" in line:
1081N/A tmp = line.split()
1081N/A s_uuid = tmp[1]
1081N/A if s_uuid != c_uuid:
1081N/A raise RuntimeError(
3158N/A "Found uuid:{0} doesn't "
3158N/A "match expected uuid:{1}, "
3158N/A "d:{2}, durl:{3}".format(
3158N/A s_uuid, c_uuid, d,
1081N/A self.dcs[d].get_depot_url()))
1081N/A found += 1
3339N/A lfh.close()
1081N/A if found != num_expected[d]:
3158N/A raise RuntimeError("d:{0}, found {1} instances of"
3158N/A " a client uuid, expected to find {2}.".format(
3158N/A d, found, num_expected[d]))
1081N/A
1628N/A def test_bug_12739(self):
1628N/A
1895N/A api_obj = self.get_img_api_obj()
1628N/A self._search_op(api_obj, True, "example_dir",
1628N/A set([("pkg:/example_pkg@1.0-0", "basename",
1628N/A "dir group=bin mode=0755 owner=root "
1628N/A "path=bin/example_dir")]))
1628N/A self.dcs[1].stop()
1628N/A self._search_op(api_obj, True, "example_dir",
1628N/A set([("pkg:/example_pkg@1.0-0", "basename",
1628N/A "dir group=bin mode=0755 owner=root "
1628N/A "path=bin/example_dir")]),
1628N/A expected_err=api_errors.ProblematicSearchServers)
1628N/A self.pkg("search example_dir", exit=3)
1895N/A
1895N/A
941N/Aif __name__ == "__main__":
941N/A unittest.main()