t_api_search.py revision 1886
#
# 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
#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
import testutils
if __name__ == "__main__":
import pkg5unittest
import copy
import difflib
import os
import re
import shutil
import sys
import tempfile
import time
import unittest
import urllib2
API_VERSION = 37
PKG_CLIENT_NAME = "pkg"
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.6/vendor-packages/OpenSSL
add file tmp/example_file mode=0555 owner=root group=bin path=/bin/example_path
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 signature pkg.sig_bit1=sig_bit_val1 pkg.sig_bit2=sig_bit_val2
add set name=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 """
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.6/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", "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"')
])
]))
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')
]) | 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 tmp/example_file elfarch=i386 elfbits=32 elfhash=68cca393e816e6adcbac1e8ffe9c618de70413e0 group=bin mode=0555 owner=root path=usr/bin/gmake 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 a686473102ba73bd7920fc0ab1d97e00a24ed704 chash=f88920ce1f61db185d127ccb32dc8cf401ae7a83 elfarch=i386 elfbits=32 elfhash=68cca393e816e6adcbac1e8ffe9c618de70413e0 group=bin mode=0555 owner=root path=usr/bin/gmake pkg.csize=30 pkg.size=12'),
('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')
]) | 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')
])
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=smf.fmri value=svc:/milestone/multi-user-server:default')
])
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 _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, e:
pass
start_point=None):
start_point=None):
res = []
try:
for i in tmp:
except api_errors.SlowSearchUsed:
if return_actions:
else:
"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:smf.fmri:%s" % svc_name,
"set:smf.fmri:%s" % svc_name,
"smf.fmri:%s" %svc_name,
":set:smf.fmri:%s" % svc_name,
"%s *milestone*" % svc_name,
"example_pkg:set:smf.fmri:%s example_pkg:set:smf.fmri:%s" %
"%s example_pkg:set:smf.fmri:%s" %
# Test that a single escaped colon doesn't cause a traceback.
# 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.
"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:smf.fmri:%s" % svc_name,
"set:smf.fmri:%s" % svc_name,
"smf.fmri:%s" %svc_name,
":set:smf.fmri:%s" % svc_name,
"%s *milestone*" % svc_name,
"example_pkg:set:smf.fmri:%s example_pkg:set:smf.fmri:%s" %
"%s example_pkg:set:smf.fmri:%s" %
# 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.
# This finds something because the client side
# manifest has had the name of the package inserted
# into it.
"::com.sun.service.info_url:",
"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())
["(4851433 AND 4725245) OR :file::%sbin/example_path" % ip],
[":::%sbin/example_path OR (4851433 AND 4725245)" % ip],
["<::path:%sbin/example_path> OR <(a AND b)>" % ip],
["<(a AND b)> OR <%sbin/example_path>" % ip],
# 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):
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, e:
else:
raise RuntimeError("Didn't raise expected exception.")
if expected_code != e.code:
raise RuntimeError("Got wrong code, expected %s got "
if expected_str not in err:
raise RuntimeError("Got unexpected error message of:\n"
"%s" % err)
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."""
"""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"""
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"""
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."""
"TMP")
def test_100_bug_6712_i386(self):
"""Install one package, and run the search suite."""
additional_args="--variant variant.arch=i386")
def test_110_bug_6712_sparc(self):
"""Install one package, and run the search suite."""
additional_args="--variant variant.arch=sparc")
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
# 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."""
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."""
expected_string = _("%(name)s had a bad value of '%(bv)s'") % {
"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."""
expected_string = _("%(name)s had a bad value of '%(bv)s'") % {
"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."""
expected_string = _("%(name)s had a bad value of '%(bv)s'") % {
"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."""
expected_string = _("%(name)s had a bad value of '%(bv)s'") % {
"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."""
expected_string = _("%(name)s had a bad value of '%(bv)s'") % {
"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."""
expected_string = _("%(name)s had a bad value of '%(bv)s'") % {
"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."""
expected_string = _("%(name)s had a bad value of '%(bv)s'") % {
"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."""
expected_string = _("%(name)s had a bad value of '%(bv)s'") % {
"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."""
expected_string = _("%(name)s had a bad value of '%(bv)s'") % {
"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):
# XXX wait for depot to be ready.
def test_local_image_update(self):
"""Test that the index gets updated by image-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_4048_1(self):
"""Checks whether the server deals with partial indexing."""
offset = 2
"depot_logfile%d" % offset)
# This should do something other than sleep for 1 sec
def test_bug_4048_2(self):
"""Checks whether the server deals with partial indexing."""
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.
def __wait_for_indexing(self, d):
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 = []
# XXX wait for depot to be ready.
found = 0
num_expected = 6
if "X-IPKG-UUID:" in line:
raise RuntimeError("Uuid found:%s not "
"found in list of possible "
found += 1
if found != num_expected:
raise RuntimeError(("Found %s instances of a "
"client uuid, expected to find %s.") %
(found, num_expected))
def test_bug_9729_1(self):
"""Test that installing more than
indexer.MAX_ADDED_NUMBER_PACKAGES packages at a time doesn't
cause any type of indexing error."""
pkg_list = []
"open pkg%s@1.0,5.11-0\nclose\n" % i)
def test_bug_9729_2(self):
"""Test that installing more than
indexer.MAX_ADDED_NUMBER_PACKAGES packages one after another
doesn't cause any type of indexing error."""
def _remove_extra_info(v):
pkg_list = []
"open pkg%s@1.0,5.11-0\nclose\n" % 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%s@2.0,5.11-0\nclose\n" % i)
# Now check that image update also handles fast_add
# appropriately when a large number of packages have changed.
"open pkg%s@2.0,5.11-0\nclose\n" % i)
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.
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, e:
return res
else:
raise RuntimeError(
"Didn't get expected error:%s" % err)
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:%s doesn't "
"match expected uuid:%s, "
"d:%s, durl:%s" %
found += 1
if found != num_expected[d]:
raise RuntimeError("d:%s, found %s instances of"
" a client uuid, expected to find %s." %
(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__":