t_api_search.py revision 3402
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
from . import testutils
if __name__ == "__main__":
import pkg5unittest
import copy
import os
import shutil
import tempfile
import time
import unittest
# Tests in this suite use the read only data directory.
example_pkg10 = """
open example_pkg@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/bin
add dir mode=0755 owner=root group=bin path=/bin/example_dir
add dir mode=0755 owner=root group=bin path=/usr/lib/python2.7/vendor-packages/OpenSSL
add file tmp/example_file mode=0555 owner=root group=bin path=/bin/example_path
add link path=/bin/exlink target=/bin/example_path mediator=example mediator-version=7.0 mediator-implementation=unladen-swallow
add set name=com.sun.service.incorporated_changes value="6556919 6627937"
add set name=com.sun.service.random_test value=42 value=79
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
add set name=com.sun.service.keywords value="sort null -n -m -t sort 0x86 separator"
add set name=com.sun.service.info_url value=http://service.opensolaris.com/xml/pkg/SUNWcsu@0.5.11,5.11-1:20080514I120000Z
add set name=description value='FOOO bAr O OO OOO' value="whee fun"
add set name='weirdness' value='] [ * ?'
add set name=org.opensolaris.smf.fmri value=svc:/milestone/multi-user-server:default
close """
example_pkg11 = """
open example_pkg@1.1,5.11-0
add dir mode=0755 owner=root group=bin path=/bin
add file tmp/example_file mode=0555 owner=root group=bin path=/bin/example_path11
close """
incorp_pkg10 = """
open incorp_pkg@1.0,5.11-0
add depend fmri=example_pkg@1.0,5.11-0 type=incorporate
close """
incorp_pkg11 = """
open incorp_pkg@1.1,5.11-0
add depend fmri=example_pkg@1.1,5.11-0 type=incorporate
close """
another_pkg10 = """
open another_pkg@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/bazbin
close """
bad_pkg10 = """
open bad_pkg@1.0,5.11-0
add dir path=badfoo/ mode=0755 owner=root group=bin
close """
space_pkg10 = """
open space_pkg@1.0,5.11-0
add file tmp/example_file mode=0444 owner=nobody group=sys path='unique/with a space'
add dir mode=0755 owner=root group=bin path=unique_dir
close """
cat_pkg10 = """
open cat@1.0,5.11-0
add set name=info.classification value=org.opensolaris.category.2008:System/Security value=org.random:Other/Category
close """
cat2_pkg10 = """
open cat2@1.0,5.11-0
add set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video" value=Developer/C
close """
cat3_pkg10 = """
open cat3@1.0,5.11-0
close """
bad_cat_pkg10 = """
open badcat@1.0,5.11-0
close """
bad_cat2_pkg10 = """
open badcat2@1.0,5.11-0
add set name=info.classification value="org.opensolaris.category.2008:TestBad1:TestBad2"
close """
fat_pkg10 = """
open fat@1.0,5.11-0
add set name=variant.arch value=sparc value=i386
add set name=description value="i386 variant" variant.arch=i386
add set name=description value="sparc variant" variant.arch=sparc
close """
bogus_pkg10 = """
set name=pkg.fmri value=pkg:/bogus_pkg@1.0,5.11-0:20090326T233451Z
set name=description value=""validation with simple chains of constraints ""
set name=pkg.description value="pseudo-hashes as arrays tied to a "type" (list of fields)"
depend fmri=XML-Atom-Entry
set name=com.sun.service.incorporated_changes value="6556919 6627937"
"""
hierarchical_named_pkg = """
close """
bug_8492_manf_1 = """
open b1@1.0,5.11-0
add set description="Image Packaging System"
close """
bug_8492_manf_2 = """
open b2@1.0,5.11-0
add set description="Image Packaging System"
close """
require_any_manf = """
open ra@1.0,5.11-0
add depend type=require-any fmri=another_pkg@1.0,5.11-0 fmri=pkg:/space_pkg@1.0,5.11-0
close
"""
res_8492_1 = set([('pkg:/b1@1.0-0', 'Image Packaging System', 'set name=description value="Image Packaging System"')])
res_8492_2 = set([('pkg:/b2@1.0-0', 'Image Packaging System', 'set name=description value="Image Packaging System"')])
'set name=pkg.fmri value=pkg://test/example_pkg@1.0,5.11-0:')
res_remote_pkg = set([
])
res_remote_path = set([
("pkg:/example_pkg@1.0-0", "basename","file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin mode=0555 owner=root path=bin/example_path pkg.csize=30 pkg.size=12"),
])
("pkg:/example_pkg@1.0-0", "path","file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin mode=0555 owner=root path=bin/example_path pkg.csize=30 pkg.size=12")
])
res_remote_bin = set([
("pkg:/example_pkg@1.0-0", "path", "dir group=bin mode=0755 owner=root path=bin")
])
("pkg:/example_pkg@1.0-0", "basename", "dir group=bin mode=0755 owner=root path=usr/lib/python2.7/vendor-packages/OpenSSL")
])
res_remote_bug_id = set([
("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')
])
("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')
])
("pkg:/example_pkg@1.0-0", "6556919 6627937", 'set name=com.sun.service.incorporated_changes value="6556919 6627937"'),
("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')
])
("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")
])
("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")
])
("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")
])
("pkg:/example_pkg@1.0-0", "42", "set name=com.sun.service.random_test value=42 value=79")
])
("pkg:/example_pkg@1.0-0", "79", "set name=com.sun.service.random_test value=42 value=79")
])
("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"')
])
("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")
]))
res_remote_glob = set([
('pkg:/example_pkg@1.0-0', 'path', 'file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin mode=0555 owner=root path=bin/example_path pkg.csize=30 pkg.size=12'),
("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")
]) | res_remote_path
res_remote_foo = set([
('pkg:/example_pkg@1.0-0', 'FOOO bAr O OO OOO', 'set name=description value="FOOO bAr O OO OOO" value="whee fun"')
])
res_remote_weird = set([
('pkg:/example_pkg@1.0-0', '] [ * ?', 'set name=weirdness value="] [ * ?"')
])
'set name=pkg.fmri value=pkg://test/example_pkg@1.0,5.11-0:')
res_local_pkg = set([
])
("pkg:/example_pkg@1.1-0", "basename", "file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin mode=0555 owner=root path=bin/example_path11 pkg.csize=30 pkg.size=12")
])
("pkg:/example_pkg@1.1-0", "path", "dir group=bin mode=0755 owner=root path=bin")
])
("pkg:/example_pkg@1.1-0", "test/example_pkg", "set name=pkg.fmri value=pkg://test/example_pkg@1.1,5.11-0:")
])
("pkg:/example_pkg@1.1-0", "basename", "file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin mode=0555 owner=root path=bin/example_path11 pkg.csize=30 pkg.size=12"),
res_cat_pkg10 = set([
('pkg:/cat@1.0-0', 'System/Security', 'set name=info.classification value=org.opensolaris.category.2008:System/Security value=org.random:Other/Category')
])
res_cat_pkg10_2 = set([
('pkg:/cat@1.0-0', 'Other/Category', 'set name=info.classification value=org.opensolaris.category.2008:System/Security value=org.random:Other/Category')
])
res_cat2_pkg10 = set([
('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')
])
res_cat2_pkg10_2 = set([
('pkg:/cat2@1.0-0', 'Developer/C', 'set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video" value=Developer/C')
])
res_cat3_pkg10 = set([
('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')
])
res_fat10_i386 = set([
('pkg:/fat@1.0-0', 'i386 variant', 'set name=description value="i386 variant" variant.arch=i386'),
('pkg:/fat@1.0-0', 'i386 variant', 'set name=description value="i386 variant" variant.arch=i386'),
('pkg:/fat@1.0-0', 'i386', 'set name=variant.arch value=sparc value=i386'),
])
res_fat10_sparc = set([
('pkg:/fat@1.0-0', 'sparc variant', 'set name=description value="sparc variant" variant.arch=sparc'),
('pkg:/fat@1.0-0', 'sparc', 'set name=variant.arch value=sparc value=i386')
])
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:')])
('pkg:/fat@1.0-0', 'sparc', 'set name=variant.arch value=sparc value=i386')
])).union(fat_10_fmri_string)
('pkg:/fat@1.0-0', 'i386', 'set name=variant.arch value=sparc value=i386')
])).union(fat_10_fmri_string)
('pkg:/space_pkg@1.0-0', 'basename', 'file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=sys mode=0444 owner=nobody path="unique/with a space" pkg.csize=30 pkg.size=12')
])
('pkg:/space_pkg@1.0-0', 'basename', 'file a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=sys mode=0444 owner=nobody path="unique/with a space" 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.csize=30 pkg.size=12')
])
res_space_unique = set([
('pkg:/space_pkg@1.0-0', 'basename', 'dir group=bin mode=0755 owner=root path=unique_dir')
])
# This is a copy of the 3.81%2C5.11-0.89%3A20080527T163123Z version of
# SUNWgmake from ipkg with the file and liscense actions changed so
bug_983_manifest = """
open SUNWgmake@3.81,5.11-0.89
add dir group=sys mode=0755 owner=root path=usr
add 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
add file tmp/example_file group=bin mode=0444 owner=root path=usr/share/info/make.info-1 pkg.size=12
add file tmp/example_file group=bin mode=0444 owner=root path=usr/share/info/make.info-2 pkg.size=12
add file tmp/example_file group=bin mode=0444 owner=root path=usr/share/man/man1/gmake.1 pkg.size=12
add license tmp/example_file license=SUNWgmake.copyright pkg.size=12 transaction_id=1211931083_pkg%3A%2FSUNWgmake%403.81%2C5.11-0.89%3A20080527T163123Z
add depend fmri=pkg:/SUNWcsl@0.5.11-0.89 type=require
add depend fmri=SUNWtestbar@0.5.11-0.111 type=require
add depend fmri=SUNWtestfoo@0.5.11-0.111 type=incorporate
add set name=description value="gmake - GNU make"
add 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
close
"""
res_bug_983 = set([
('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.csize=1358 pkg.size=3948'),
('pkg:/SUNWgmake@3.81-0.89', 'gmake - GNU make', 'set name=description value="gmake - GNU make"')
])
('pkg:/SUNWgmake@3.81-0.89', 'require', 'depend fmri=pkg:/SUNWcsl@0.5.11-0.89 type=require')
])
('pkg:/SUNWgmake@3.81-0.89', 'require', 'depend fmri=SUNWtestbar@0.5.11-0.111 type=require')
])
('pkg:/SUNWgmake@3.81-0.89', 'incorporate', 'depend fmri=SUNWtestfoo@0.5.11-0.111 type=incorporate')
])
"pkg:/example_pkg@1.0-0"
])
"pkg:/example_pkg@1.0-0"
])
res_remote_file = set([
("pkg:/example_pkg@1.0-0",
"path",
"file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
"chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
"mode=0555 owner=root path=bin/example_path pkg.csize=30 "
"pkg.size=12"),
("pkg:/example_pkg@1.0-0",
"a686473102ba73bd7920fc0ab1d97e00a24ed704",
"file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
"chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
"mode=0555 owner=root path=bin/example_path pkg.csize=30 "
"pkg.size=12"),
("pkg:/example_pkg@1.0-0",
"hash",
"file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
"chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
"mode=0555 owner=root path=bin/example_path pkg.csize=30 "
"pkg.size=12")
]) | res_remote_path
res_remote_url = set([
('pkg:/example_pkg@1.0-0',
'set name=com.sun.service.info_url value=http://service.opensolaris.com/xml/pkg/SUNWcsu@0.5.11,5.11-1:20080514I120000Z'),
])
("pkg:/example_pkg@1.0-0",
"basename",
"file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
"chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
"mode=0555 owner=root path=bin/example_path pkg.csize=30 "
"pkg.size=12"),
("pkg:/example_pkg@1.0-0",
"path",
"file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
"chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
"mode=0555 owner=root path=bin/example_path pkg.csize=30 "
"pkg.size=12"),
("pkg:/example_pkg@1.0-0",
"a686473102ba73bd7920fc0ab1d97e00a24ed704",
"file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
"chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
"mode=0555 owner=root path=bin/example_path pkg.csize=30 "
"pkg.size=12"),
("pkg:/example_pkg@1.0-0",
"hash",
"file a686473102ba73bd7920fc0ab1d97e00a24ed704 "
"chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 group=bin "
"mode=0555 owner=root path=bin/example_path pkg.csize=30 "
"pkg.size=12")
])
res_bad_pkg = set([
('pkg:/bad_pkg@1.0-0', 'basename',
'dir group=bin mode=0755 owner=root path=badfoo/')
])
("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:")
])
"VERSION: 2\n",
"pkg22@1.0,5.11",
"pkg21@1.0,5.11"
])
"VERSION: 2\n",
])
"VERSION: 2\n",
"pkg0@2.0,5.11",
"pkg22@1.0,5.11",
"pkg21@1.0,5.11",
"pkg1@2.0,5.11"
])
"VERSION: 2\n",
"pkg0@1.0,5.11",
"pkg1@1.0,5.11"
])
res_smf_svc = set([
('pkg:/example_pkg@1.0-0',
'svc:/milestone/multi-user-server:default',
'set name=org.opensolaris.smf.fmri value=svc:/milestone/multi-user-server:default')
])
('pkg:/example_pkg@1.0-0', 'path',
'dir group=bin mode=0755 owner=root path=bin/example_dir')])
debug_features = []
# We wire the contents of the example file to a well known string
# so that the hash is also well known.
"search_results")
if correct_answer == proposed_answer:
return True
else:
def _get_repo_index_dir(self):
return rstore.index_root
def _get_repo_writ_dir(self):
return rstore.writable_root
def _get_repo_catalog(self):
def _replace_act(act):
else:
def _extract_action_from_res(it):
return (
in it
)
def _extract_package_from_res(it):
return (
in it
)
def _get_lines(fp):
return lines
if remote:
# servers may not be ready immediately - retry search
# operation for 5 seconds
try:
if return_actions:
else:
break
except api_errors.ProblematicSearchServers as e:
pass
start_point=None):
start_point=None):
res = []
try:
for i in tmp:
except api_errors.SlowSearchUsed:
if return_actions:
else:
self._search_op(api_obj, True, ":link:mediator:example OR :link:mediator-version:7.0 OR :link:mediator-implementation:unladen-swallow",
"4851433 AND 4725245 OR example_path",
"4851433 AND (4725245 OR example_path)",
"(4851433 AND 4725245) OR example_path",
# Test for bug 11235, case insensitive phrase search, and bug
# 11354, mangled fields during phrase search.
# These tests are included because a specific bug
# was found during development. This prevents regression back
# to that bug. Exit status of 1 is expected because the
# token isn't in the packages.
# Test for bug 15284, \ not being treated as an escape character
# for : as well as testing that \: when used with field queries
# works as expected.
svc_name = "svc\:/milestone/multi-user-server\:default"
"example_pkg:set:org.opensolaris.smf.fmri:{0} example_pkg:set:org.opensolaris.smf.fmri:{1}".format(
"{0} example_pkg:set:org.opensolaris.smf.fmri:{1}".format(
# Test that a single escaped colon doesn't cause a traceback.
# Test that doing a search restricted to dir actions works
# correctly. This is a test for bug 17645.
# These tests are included because a specific bug
# was found during development. This prevents regression back
# to that bug.
# This finds something because the client side
# manifest has had the name of the package inserted
# into it.
self._search_op(api_obj, True, ":link:mediator:example OR :link:mediator-version:7.0 OR :link:mediator-implementation:unladen-swallow",
"4851433 AND 4725245 OR example_path",
"4851433 AND (4725245 OR example_path)",
"(4851433 AND 4725245) OR example_path",
# Test for bug 11235, case insensitive phrase search, and bug
# 11354, mangled fields during phrase search.
# These tests are included because a specific bug
# was found during development. These tests prevent regression
# back to that bug. Exit status of 1 is expected because the
# token isn't in the packages.
# Test for bug 15284, \ not being treated as an escape character
# for : as well as testing that \: when used with field queries
# works as expected.
svc_name = "svc\:/milestone/multi-user-server\:default"
"example_pkg:set:org.opensolaris.smf.fmri:{0} example_pkg:set:org.opensolaris.smf.fmri:{1}".format(
"{0} example_pkg:set:org.opensolaris.smf.fmri:{1}".format(
# Test that a single escaped colon doesn't cause a traceback.
# This finds something because the client side
# manifest has had the name of the package inserted
# into it.
# These tests are included because a specific bug
# was found during development. These tests prevent regression
# back to that bug.
# Test that doing a search restricted to dir actions works
# correctly. This is a test for bug 17645.
# This finds something because the client side
# manifest has had the name of the package inserted
# into it.
"::com.sun.service.info_url:",
"::mediator-implementation:unladen*",
":link:mediator:example OR :link:mediator-version:7.0",
":link:mediator:example OR :link:mediator-version:7.0 OR :link:mediator-implementation:unladen-swallow",
"4851433 AND 4725245 OR example_path",
"4851433 AND (4725245 OR example_path)",
"(4851433 AND 4725245) OR example_path",
# These tests are included because a specific bug
# was found during development. These tests prevent regression
# back to that bug. Exit status of 1 is expected because the
# token isn't in the packages.
set())
# The tests below here are for testing that multiple queries
# to search return the results from both queries (bug 10365)
["<(a AND b)>", "example_path"],
["example_path", "<(a AND b)>"],
# This finds something because the client side
# manifest has had the name of the package inserted
# into it.
tmp_file = "full_fmri_list.hash"
# Overwrite the existing version number.
# By definition, the version 0 is never used.
def _get_index_dirs(self):
"cache", "index")
return index_dir, index_dir_tmp
# Overwrite the existing version number.
# By definition, the version 0 is never used.
# Overwrite the existing version number.
# By definition, the version 0 is never used.
# Overwrite the existing version number.
# By definition, the version 0 is never used.
for l in lst[2:]:
def _overwrite_hash(ffh_path):
def _check_no_index(self):
try:
except ex_type as e:
else:
raise RuntimeError("Didn't raise expected exception.")
if expected_code != e.code:
raise RuntimeError("Got wrong code, expected {0} got "
if expected_str not in err:
raise RuntimeError("Got unexpected error message of:\n"
# Ensures indexing is done for every pkgsend.
def test_010_remote(self):
"""Test remote search."""
# This should be a full test to test all functionality.
def test_020_local_0(self):
"""Install one package, and run the search suite."""
def test_030_degraded_local(self):
"""Install one package, and run the search suite."""
"cache", "index")
"""Install and uninstall a package. Checking search both
after each change to the image."""
# During development, the index could become corrupted by
# repeated installing and uninstalling a package. This
# tests if that has been fixed.
repeat = 3
"""Test local case sensitive search"""
True)
def test_060_missing_files(self):
"""Test to check for stack trace when files missing.
Bug 2753"""
"cache", "index")
orig_fn = d.get_file_name()
"exam:::example_pkg", [])
if first:
# Run the shell version once to check that no
# stack trace happens.
exit=1)
"""Test to check for stack trace when files missing.
Bug 2753"""
"cache", "index")
orig_fn = d.get_file_name()
"exam:::example_pkg", [])
if first:
# Run the shell version once to check that no
# stack trace happens.
exit=1)
# Run the shell version of the test to check for a stack trace.
def test_080_weird_patterns(self):
"""Test strange patterns to ensure they're handled correctly"""
def test_090_bug_7660(self):
"""Test that installing a package doesn't prevent searching on
package names from working on previously installed packages."""
"cache", "index", "TMP")
def test_100_bug_6712_i386(self):
"""Install one package, and run the search suite."""
def test_110_bug_6712_sparc(self):
"""Install one package, and run the search suite."""
def test_120_bug_3046(self):
"""Checks if directories ending in / break the indexer."""
def test_130_bug_1059(self):
"""Checks whether the fallback of removing the image root works.
Also tests whether multiple queries submitted via the api work.
"""
ip += "/"
# Do remote searches
# Do local searches
"cache", "index")
# Do slow local searches
def test_bug_2849(self):
"""Checks if things with spaces break the indexer."""
# Need to add install of subsequent package and
# local side search as well as remote
def test_bug_2863(self):
"""Check that disabling indexing works as expected"""
# Running empty test because search will notice the index
# does not match the installed packages and complain.
# Running empty test because search will notice the index
# does not match the installed packages and complain.
# Running empty test because search will notice the index
# does not match the installed packages and complain.
def test_bug_2989_1(self):
for f in self._dir_restore_functions:
def test_bug_2989_2(self):
for f in self._dir_restore_functions:
def test_bug_2989_3(self):
for f in self._dir_restore_functions:
def test_bug_2989_4(self):
for f in self._dir_restore_functions:
def test_bug_4239(self):
"""Tests whether categories are indexed and searched for
correctly."""
"'Applications/Sound and Video'",
# This is a test for bug 11002 which ensures that the
# unquoting is being performed correctly.
"'Applications/Sound%20and%20Video'",
def test_bug_7628(self):
"""Checks whether incremental update generates wrong
additional lines."""
# Since the server now adds a set action for the FMRI to
# manifests during publication, there should be one
# additional line for the token file.
def test_bug_983(self):
"""Test for known bug 983."""
def test_bug_7534(self):
"""Tests that an automatic reindexing is detected by the test
suite."""
"cache", "index")
def test_bug_8492(self):
"""Tests that field queries and phrase queries work together.
"""
def test_bug_9845_01(self):
"""Test that a corrupt query doesn't break the server."""
expected_string = _("A query is expected to have five fields: "
"case sensitivity, return type, number of results to "
"return, the number at which to start returning results, "
"and the text of the query. The query provided lacked at "
"least one of those fields:")
expected_code = 404
q_str = "foo"
def test_bug_9845_02(self):
"""Test that a corrupt case_sensitive value doesn't break the "
server."""
name="case_sensitive",
bv="FAlse"
)
expected_code = 404
q_str = "FAlse_2_None_None_foo"
def test_bug_9845_03(self):
"""Test that a corrupt return_type value doesn't break the "
server."""
name="return_type",
bv="3"
)
expected_code = 404
q_str = "False_3_None_None_foo"
def test_bug_9845_04(self):
"""Test that a corrupt return_type value doesn't break the "
server."""
name="return_type",
bv="A"
)
expected_code = 404
q_str = "False_A_None_None_foo"
def test_bug_9845_05(self):
"""Test that a corrupt num_to_return value doesn't break the "
server."""
name="num_to_return",
bv="NOne"
)
expected_code = 404
q_str = "False_2_NOne_None_foo"
def test_bug_9845_06(self):
"""Test that a corrupt start_point value doesn't break the "
server."""
name="start_point",
bv="NOne"
)
expected_code = 404
q_str = "False_2_None_NOne_foo"
def test_bug_9845_07(self):
"""Test that a corrupt case_sensitive value doesn't break the "
server."""
name="case_sensitive",
bv=""
)
expected_code = 404
q_str = "_2_None_None_foo"
def test_bug_9845_08(self):
"""Test that a missing return_type value doesn't break the "
server."""
name="return_type",
bv=""
)
expected_code = 404
q_str = "False__None_None_foo"
def test_bug_9845_09(self):
"""Test that a missing num_to_return value doesn't break the "
server."""
name="num_to_return",
bv=""
)
expected_code = 404
q_str = "False_2__None_foo"
def test_bug_9845_10(self):
"""Test that a missing start_point value doesn't break the "
server."""
name="start_point",
bv=""
)
expected_code = 404
q_str = "False_2_None__foo"
def test_bug_9845_11(self):
"""Test that missing query text doesn't break the server."""
expected_string = _("Could not parse query.")
expected_code = 400
q_str = "False_2_None_None_"
def test_bug_14177(self):
# Ensures indexing is done for every pkgsend.
def test_local_image_update(self):
"""Test that the index gets updated by update and
that rebuilding the index works after updating the
image. Specifically, this tests that rebuilding indexes with
gaps in them works correctly."""
def test_bug_6177(self):
res_both_actions = set([
('pkg:/example_pkg@1.1-0', 'path',
'dir group=bin mode=0755 owner=root path=bin'),
('pkg:/example_pkg@1.0-0', 'path',
'dir group=bin mode=0755 owner=root path=bin')
])
res_10_action = set([
('pkg:/example_pkg@1.0-0', 'path',
'dir group=bin mode=0755 owner=root path=bin')
])
res_11_action = set([
('pkg:/example_pkg@1.1-0', 'path',
'dir group=bin mode=0755 owner=root path=bin')
])
res_both_packages = set([
"pkg:/example_pkg@1.1-0",
"pkg:/example_pkg@1.0-0"
])
res_10_package = set([
"pkg:/example_pkg@1.0-0"
])
res_11_package = set([
"pkg:/example_pkg@1.1-0"
])
# Test that if a package is installed, its version and newer
# versions are shown.
# Check that after uninstall, back to returning all versions.
# Test that if a package is installed, its version and newer
# versions are shown. Older versions should not be shown.
# Check that after uninstall, back to returning all versions.
# Check that only the incorporated package is returned.
# Should now show the 1.1 version of example_pkg since the
# version has been upgraded.
# Should now show both again since the incorporation has been
# removed.
# Check that installed and incorporated work correctly together.
["incorp_pkg@1.0", "example_pkg@1.0"])
# And that it works after the incorporation has been changed.
"main_dict.ascii.v1")
def test_bug_7358_1(self):
"""Move files so that an inconsistent index is created and
check that the server rebuilds the index when possible, and
doesn't stack trace when it can't write to the directory."""
# Check when depot is empty.
# Since the depot is empty, should return no results but
# not error.
# Check when depot contains a package.
def test_bug_7358_2(self):
"""Does same check as 7358_1 except it checks for interactions
with writable root."""
"writ_root")
# Check when depot is empty.
# Since the depot is empty, should return no results but
# not error.
# Check when depot contains a package.
def test_bug_8318(self):
uuids = []
found = 0
num_expected = 7
if "X-IPKG-UUID:" in line:
raise RuntimeError("Uuid found:{0} not "
"found in list of possible "
found += 1
if found != num_expected:
raise RuntimeError(("Found {0} instances of a "
"client uuid, expected to find {1}.").format(
def test_bug_9729_1(self):
"""Test that installing more than
indexer.MAX_FAST_INDEXED_PKGS packages at a time doesn't
cause any type of indexing error."""
pkg_list = []
"open pkg{0}@1.0,5.11-0\nclose\n".format(i))
def test_bug_9729_2(self):
"""Test that installing more than
indexer.MAX_FAST_INDEXED_PKGS packages one after another
doesn't cause any type of indexing error."""
def _remove_extra_info(v):
pkg_list = []
"open pkg{0}@1.0,5.11-0\nclose\n".format(i))
"fast_add.v1")
"fast_remove.v1")
for p in pkg_list:
# Test for bug 11104. The fast_add.v1 file was not being updated
# correctly by install or image update, it was growing with
# each modification.
# Now check that image update also handles fast_add
# appropriately when a small number of packages have changed.
"open pkg{0}@2.0,5.11-0\nclose\n".format(i))
# Check that a local search actually works.
# Now check that image update also handles fast_add
# appropriately when a large number of packages have changed.
"open pkg{0}@2.0,5.11-0\nclose\n".format(i))
# Check that a local search actually works.
def test_bug_13485(self):
"""Test that indexer.Indexer's check_for_updates function works
as excepted. This needs to be a separate test because other
tests are likely to conintue working while reindexing more
frequently than they should."""
# Check that an empty index works correctly.
# Check that after publishing one package, no packages need
# indexing.
# Check that publishing a second package also works.
# Check that a package that was publisher but not index is
# reported.
def test_bug_17672(self):
expected_result = set([
('pkg:/ra@1.0-0', 'require-any',
'depend fmri=another_pkg@1.0,5.11-0 ' +
'fmri=pkg:/space_pkg@1.0,5.11-0 type=require-any')
])
example_pkg10 = """
open example_pkg@1.0,5.11-0
add dir mode=0755 owner=root group=bin path=/bin/example_dir
close """
('pkg:/example_pkg@1.0-0', 'test2/example_pkg',
'set name=pkg.fmri value=pkg://test2/example_pkg@1.0,5.11-0:')
])
if correct_answer == proposed_answer:
return True
else:
res = []
if err:
try:
act)),)
except err as e:
return res
else:
raise RuntimeError(
else:
if remote:
else:
search_func([query])))
def test_bug_2955(self):
# Test for bug 10690 by checking whether the fmri names
# for packages installed from the non-preferred publisher
# are parsed correctly. Specifically, test whether the name
# combination.
def test_bug_8318(self):
"this_should_not_match_any_token", set())
try:
except api_errors.UnknownPublisher:
c_uuid = None
found = 0
if "X-IPKG-UUID:" in line:
raise RuntimeError(
"Found uuid:{0} doesn't "
"match expected uuid:{1}, "
"d:{2}, durl:{3}".format(
found += 1
if found != num_expected[d]:
raise RuntimeError("d:{0}, found {1} instances of"
" a client uuid, expected to find {2}.".format(
d, found, num_expected[d]))
def test_bug_12739(self):
"dir group=bin mode=0755 owner=root "
"path=bin/example_dir")]))
"dir group=bin mode=0755 owner=root "
"path=bin/example_dir")]),
if __name__ == "__main__":