7314 Refactor t_pkg_search
authorBrock Pytlik <bpytlik@sun.com>
Tue, 09 Jun 2009 11:11:57 -0700
changeset 1127 69d88cfd7f9e
parent 1126 94bd1df83824
child 1128 c2bf73e8e04d
7314 Refactor t_pkg_search 9288 search tests shouldn't send packages to persistent depos if they're already there
src/tests/baseline.txt
src/tests/cli/t_api_search.py
src/tests/cli/t_pkg_search.py
--- a/src/tests/baseline.txt	Tue Jun 09 09:41:30 2009 -0700
+++ b/src/tests/baseline.txt	Tue Jun 09 11:11:57 2009 -0700
@@ -214,31 +214,33 @@
 cli.t_api.py TestPkgApi.test_publisher_apis|pass
 cli.t_api.py TestPkgApi.test_reset|pass
 cli.t_api_info.py TestApiInfo.test_info_local_remote|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_2849|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_2863|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_2989_1|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_2989_2|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_2989_3|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_2989_4|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_3046|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_4048_1|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_4048_2|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_4239|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_7358_1|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_7358_2|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_7628|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_8318|pass
-cli.t_api_search.py TestApiSearchBasics.test_bug_983|pass
-cli.t_api_search.py TestApiSearchBasics.test_degraded_local|pass
-cli.t_api_search.py TestApiSearchBasics.test_local_0|pass
-cli.t_api_search.py TestApiSearchBasics.test_local_case_sensitive|pass
-cli.t_api_search.py TestApiSearchBasics.test_local_image_update|pass
-cli.t_api_search.py TestApiSearchBasics.test_low_mem|pass
-cli.t_api_search.py TestApiSearchBasics.test_mismatched_versions|pass
-cli.t_api_search.py TestApiSearchBasics.test_missing_files|pass
-cli.t_api_search.py TestApiSearchBasics.test_remote|pass
-cli.t_api_search.py TestApiSearchBasics.test_repeated_install_uninstall|pass
-cli.t_api_search.py TestApiSearchBasics.test_weird_patterns|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_010_remote|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_020_local_0|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_030_degraded_local|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_040_repeated_install_uninstall|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_050_local_case_sensitive|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_060_missing_files|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_070_mismatched_versions|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_080_weird_patterns|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_090_bug_7660|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_100_bug_6712_i386|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_110_bug_6712_sparc|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_120_bug_3046|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_bug_2849|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_bug_2863|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_bug_2989_1|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_bug_2989_2|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_bug_2989_3|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_bug_2989_4|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_bug_4239|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_bug_7628|pass
+cli.t_api_search.py TestApiSearchBasicsPersistentDepot.test_bug_983|pass
+cli.t_api_search.py TestApiSearchBasicsRestartingDepot.test_bug_4048_1|pass
+cli.t_api_search.py TestApiSearchBasicsRestartingDepot.test_bug_4048_2|pass
+cli.t_api_search.py TestApiSearchBasicsRestartingDepot.test_bug_7358_1|pass
+cli.t_api_search.py TestApiSearchBasicsRestartingDepot.test_bug_7358_2|pass
+cli.t_api_search.py TestApiSearchBasicsRestartingDepot.test_bug_8318|pass
+cli.t_api_search.py TestApiSearchBasicsRestartingDepot.test_local_image_update|pass
 cli.t_api_search.py TestApiSearchMulti.test_bug_2955|pass
 cli.t_api_search.py TestApiSearchMulti.test_bug_8318|pass
 cli.t_fix.py TestFix.test_fix1|pass
@@ -431,34 +433,11 @@
 cli.t_pkg_refresh.py TestPkgRefreshMulti.test_set_publisher_induces_full_refresh|pass
 cli.t_pkg_refresh.py TestPkgRefreshMulti.test_specific_refresh|pass
 cli.t_pkg_search.py TestPkgSearchBasics.test_bug_1873|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_2849|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_2863|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_2989_1|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_2989_2|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_2989_3|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_2989_4|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_3046|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_4048_1|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_4048_2|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_4239|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_6712_i386|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_6712_sparc|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_7660|pass
 cli.t_pkg_search.py TestPkgSearchBasics.test_bug_7835|pass
 cli.t_pkg_search.py TestPkgSearchBasics.test_bug_8098|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_bug_983|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_degraded_search|pass
 cli.t_pkg_search.py TestPkgSearchBasics.test_local_0|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_local_case_sensitive|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_local_image_update|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_low_mem|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_mismatched_versions|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_missing_files|pass
 cli.t_pkg_search.py TestPkgSearchBasics.test_pkg_search_cli|pass
 cli.t_pkg_search.py TestPkgSearchBasics.test_remote|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_repeated_install_uninstall|pass
-cli.t_pkg_search.py TestPkgSearchBasics.test_weird_patterns|pass
-cli.t_pkg_search.py TestPkgSearchMulti.test_bug_2955|pass
 cli.t_pkg_uninstall.py TestCommandLine.test_dependencies|pass
 cli.t_pkg_uninstall.py TestCommandLine.test_pkg_bogus_opts|pass
 cli.t_pkg_uninstall.py TestCommandLine.test_rmdir_cwd|pass
--- a/src/tests/cli/t_api_search.py	Tue Jun 09 09:41:30 2009 -0700
+++ b/src/tests/cli/t_api_search.py	Tue Jun 09 11:11:57 2009 -0700
@@ -84,8 +84,7 @@
 
         bad_pkg10 = """
             open [email protected],5.11-0
-            add dir path=foo/ mode=0755 owner=root group=bin
-            add dir path=/ mode=0755 owner=root group=bin
+            add dir path=badfoo/ mode=0755 owner=root group=bin
             close """
 
         space_pkg10 = """
@@ -119,6 +118,22 @@
             add set name=info.classification value="org.opensolaris.category.2008:TestBad1:TestBad2"
             close """
 
+        fat_pkg10 = """
+open [email protected],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=fmri value=pkg:/[email protected],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"
+"""
+        bogus_fmri = fmri.PkgFmri("[email protected],5.11-0:20090326T233451Z")
+
         res_remote_path = set([
             ("pkg:/[email protected]", "basename","file 820157a2043e3135f342b238129b556aade20347 chash=bfa46fc98d1ca97f1260090797d35a35e76096a3 group=bin mode=0555 owner=root path=bin/example_path pkg.csize=38 pkg.size=18")
         ])
@@ -135,26 +150,36 @@
             ("pkg:/[email protected]", "4851433", 'set name=com.sun.service.bug_ids value="4641790 4725245 4817791 4851433 4897491 4913776 6178339 6556919 6627937"')
         ])
 
+        res_remote_bug_id_4725245 = set([
+            ("pkg:/[email protected]", "4725245", 'set name=com.sun.service.bug_ids value="4641790 4725245 4817791 4851433 4897491 4913776 6178339 6556919 6627937"')
+        ])
+
+
         res_remote_inc_changes = set([
             ("pkg:/[email protected]", "6556919", 'set name=com.sun.service.incorporated_changes value="6556919 6627937"'),
             ("pkg:/[email protected]", "6556919", 'set name=com.sun.service.bug_ids value="4641790 4725245 4817791 4851433 4897491 4913776 6178339 6556919 6627937"')
-              
         ])
 
         res_remote_random_test = set([
             ("pkg:/[email protected]", "42", "set name=com.sun.service.random_test value=42 value=79")
         ])
 
+        res_remote_random_test_79 = set([
+            ("pkg:/[email protected]", "79", "set name=com.sun.service.random_test value=42 value=79")
+        ])
+
         res_remote_keywords = set([
             ("pkg:/[email protected]", "separator", 'set name=com.sun.service.keywords value="sort null -n -m -t sort 0x86 separator"')
         ])
 
+        res_remote_keywords_sort_phrase = set([
+            ("pkg:/[email protected]", "sort 0x86", 'set name=com.sun.service.keywords value="sort null -n -m -t sort 0x86 separator"')
+        ])
+
         res_remote_wildcard = res_remote_path.union(set([
             ('pkg:/[email protected]', 'basename', 'dir group=bin mode=0755 owner=root path=bin/example_dir')
         ]))
 
-        headers = ""
-
         res_remote_glob = set([
             ('pkg:/[email protected]', 'path', 'dir group=bin mode=0755 owner=root path=bin/example_dir'),
             ('pkg:/[email protected]', 'basename', 'dir group=bin mode=0755 owner=root path=bin/example_dir'),
@@ -253,6 +278,32 @@
             ('pkg:/[email protected]', '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:/[email protected]', 'i386', 'set name=description value="i386 variant" variant.arch=i386'),
+            ('pkg:/[email protected]', 'variant', 'set name=description value="i386 variant" variant.arch=i386'),
+            ('pkg:/[email protected]', 'i386', 'set name=variant.arch value=sparc value=i386'),
+        ])
+
+        res_fat10_sparc = set([
+            ('pkg:/[email protected]', 'sparc', 'set name=description value="sparc variant" variant.arch=sparc'),
+            ('pkg:/[email protected]', 'sparc', 'set name=variant.arch value=sparc value=i386'),
+            ('pkg:/[email protected]', 'variant', 'set name=description value="sparc variant" variant.arch=sparc')
+        ])
+
+        res_remote_fat10_star = res_fat10_sparc | res_fat10_i386
+
+        res_local_fat10_i386_star = res_fat10_i386.union(set([
+            ('pkg:/[email protected]', 'test', 'set name=publisher value=test'),
+            ('pkg:/[email protected]', 'fat', ''),
+            ('pkg:/[email protected]', 'sparc', 'set name=variant.arch value=sparc value=i386')
+        ]))
+
+        res_local_fat10_sparc_star = res_fat10_sparc.union(set([
+            ('pkg:/[email protected]', 'test', 'set name=publisher value=test'),
+            ('pkg:/[email protected]', 'fat', ''),
+            ('pkg:/[email protected]', 'i386', 'set name=variant.arch value=sparc value=i386')
+        ]))
+        
         res_space_with_star = set([
             ('pkg:/[email protected]', 'basename', 'file 820157a2043e3135f342b238129b556aade20347 chash=bfa46fc98d1ca97f1260090797d35a35e76096a3 group=sys mode=0444 owner=nobody path="unique/with a space" pkg.csize=38 pkg.size=18')
         ])
@@ -310,6 +361,47 @@
             ('pkg:/[email protected]', 'gmake', 'set name=description value="gmake - GNU make"')
         ])
 
+        res_local_pkg_ret_pkg = set([
+            "pkg:/[email protected]"
+        ])
+
+        res_remote_pkg_ret_pkg = set([
+            "pkg:/[email protected]"
+        ])
+
+        res_remote_file = set([
+            ('pkg:/[email protected]',
+             'path',
+             'file 820157a2043e3135f342b238129b556aade20347 chash=bfa46fc98d1ca97f1260090797d35a35e76096a3 group=bin mode=0555 owner=root path=bin/example_path pkg.csize=38 pkg.size=18'),
+            ('pkg:/[email protected]',
+             '820157a2043e3135f342b238129b556aade20347',
+             'file 820157a2043e3135f342b238129b556aade20347 chash=bfa46fc98d1ca97f1260090797d35a35e76096a3 group=bin mode=0555 owner=root path=bin/example_path pkg.csize=38 pkg.size=18')
+        ]) | res_remote_path
+        
+        res_remote_url = set([
+            ('pkg:/[email protected]',
+            'http://service.opensolaris.com/xml/pkg/[email protected],5.11-1:20080514I120000Z',
+            'set name=com.sun.service.info_url value=http://service.opensolaris.com/xml/pkg/[email protected],5.11-1:20080514I120000Z')
+        ])
+
+        res_remote_path_extra = set([
+            ('pkg:/[email protected]',
+             'basename',
+             'file 820157a2043e3135f342b238129b556aade20347 chash=bfa46fc98d1ca97f1260090797d35a35e76096a3 group=bin mode=0555 owner=root path=bin/example_path pkg.csize=38 pkg.size=18'),
+            ('pkg:/[email protected]',
+             'path',
+             'file 820157a2043e3135f342b238129b556aade20347 chash=bfa46fc98d1ca97f1260090797d35a35e76096a3 group=bin mode=0555 owner=root path=bin/example_path pkg.csize=38 pkg.size=18'),
+            ('pkg:/[email protected]',
+             '820157a2043e3135f342b238129b556aade20347',
+             'file 820157a2043e3135f342b238129b556aade20347 chash=bfa46fc98d1ca97f1260090797d35a35e76096a3 group=bin mode=0555 owner=root path=bin/example_path pkg.csize=38 pkg.size=18')
+        ])
+
+        res_bad_pkg = set([
+            ('pkg:/[email protected]', 'basename',
+             'dir group=bin mode=0755 owner=root path=badfoo/')
+        ])
+        
+        debug_features = None
 
         def setUp(self):
                 for p in self.misc_files:
@@ -319,7 +411,7 @@
                         f.write(p + "\n")
                         f.close()
                 testutils.SingleDepotTestCase.setUp(self,
-                    debug_features=["headers"])
+                    debug_features=self.debug_features)
                 tp = self.get_test_prefix()
                 self.testdata_dir = os.path.join(tp, "search_results")
                 os.mkdir(self.testdata_dir)
@@ -362,7 +454,15 @@
                     (pkg_name, piece, act))
                     in it
                 )
-                        
+
+        @staticmethod
+        def _extract_package_from_res(it):
+                return (
+                    (fmri.PkgFmri(str(pkg_name)).get_short_fmri())
+                    for query_num, auth, (version, return_type, pkg_name)
+                    in it
+                )
+
         def _search_op(self, api_obj, remote, token, test_value,
             case_sensitive=False, return_actions=True, num_to_return=None,
             start_point=None, servers=None):
@@ -372,7 +472,12 @@
                             servers=servers)
                 query = api.Query(token, case_sensitive, return_actions,
                     num_to_return, start_point)
-                res = set(self._extract_action_from_res(search_func([query])))
+                res = search_func([query])
+                if return_actions:
+                        res = self._extract_action_from_res(res)
+                else:
+                        res = self._extract_package_from_res(res)
+                res = set(res)
                 self._check(set(res), test_value)
 
         def _search_op_slow(self, api_obj, remote, token, test_value,
@@ -385,17 +490,21 @@
                     num_to_return, start_point)
                 tmp = search_func([query])
                 res = []
+                ssu = False
                 try:
                         for i in tmp:
                                 res.append(i)
                 except api_errors.SlowSearchUsed:
-                        pass
-                res = self._extract_action_from_res(res)
+                        ssu = True
+                self.assert_(ssu)
+                if return_actions:
+                        res = self._extract_action_from_res(res)
+                else:
+                        res = self._extract_package_from_res(res)
+                res = set(res)
                 self._check(set(res), test_value)
 
-
-                
-        def _run_remote_tests(self, api_obj):
+        def _run_full_remote_tests(self, api_obj):
                 # Set to 1 since searches can't currently be performed
                 # package name unless it's set inside the
                 # manifest which happens at install time on
@@ -403,19 +512,62 @@
                 self._search_op(api_obj, True, "example_pkg", set())
                 self._search_op(api_obj, True, "example_path",
                     self.res_remote_path)
+                self._search_op(api_obj, True, "(example_path)",
+                    self.res_remote_path)
+                self._search_op(api_obj, True, "<exam*:::>",
+                    self.res_remote_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, True, "::com.sun.service.info_url:",
+                    self.res_remote_url)
+                self._search_op(api_obj, True, ":::e* AND *path",
+                    self.res_remote_path)
+                self._search_op(api_obj, True, "e* AND *path",
+                    self.res_remote_path)
+                self._search_op(api_obj, True, "<e*>",
+                    self.res_remote_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, True, "<e*> AND <e*>",
+                    self.res_remote_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, True, "<e*> OR <e*>",
+                    self.res_remote_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, True, "<exam:::>",
+                    self.res_remote_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, True, "exam:::e*path",
+                    self.res_remote_path)
+                self._search_op(api_obj, True, "exam:::e*path AND e*:::",
+                    self.res_remote_path)
+                self._search_op(api_obj, True, "e*::: AND exam:::*path",
+                    self.res_remote_path_extra)
                 self._search_op(api_obj, True, "example*",
                     self.res_remote_wildcard)
                 self._search_op(api_obj, True, "/bin", self.res_remote_bin)
                 self._search_op(api_obj, True, "4851433",
                     self.res_remote_bug_id)
+                self._search_op(api_obj, True, "<4851433> AND <4725245>",
+                    self.res_remote_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, True, "4851433 AND 4725245",
+                    self.res_remote_bug_id)
+                self._search_op(api_obj, True,
+                    "4851433 AND 4725245 OR example_path",
+                    self.res_remote_bug_id)
+                self._search_op(api_obj, True,
+                    "4851433 AND (4725245 OR example_path)",
+                    self.res_remote_bug_id)
+                self._search_op(api_obj, True,
+                    "(4851433 AND 4725245) OR example_path",
+                    self.res_remote_bug_id | self.res_remote_path)
+                self._search_op(api_obj, True, "4851433 OR 4725245",
+                    self.res_remote_bug_id | self.res_remote_bug_id_4725245)
                 self._search_op(api_obj, True, "6556919",
                     self.res_remote_inc_changes)
                 self._search_op(api_obj, True, "6556?19",
                     self.res_remote_inc_changes)
                 self._search_op(api_obj, True, "42",
-                    self.res_remote_random_test) 
+                    self.res_remote_random_test)
+                self._search_op(api_obj, True, "79",
+                    self.res_remote_random_test_79)
                 self._search_op(api_obj, True, "separator",
                     self.res_remote_keywords)
+                self._search_op(api_obj, True, "\"sort 0x86\"",
+                    self.res_remote_keywords_sort_phrase)
                 self._search_op(api_obj, True, "*example*",
                     self.res_remote_glob)
                 self._search_op(api_obj, True, "fooo", self.res_remote_foo)
@@ -435,8 +587,63 @@
                 # to that bug. Exit status of 1 is expected because the
                 # token isn't in the packages.
                 self._search_op(api_obj, True, "a_non_existent_token", set())
-                
-        def _run_local_tests(self, api_obj):
+
+                self._search_op(api_obj, True, "42 AND 4641790", set())
+                self.assertRaises(api_errors.BooleanQueryException,
+                    self._search_op, api_obj, True, "<e*> AND e*", set())
+                self.assertRaises(api_errors.BooleanQueryException,
+                    self._search_op, api_obj, True, "e* AND <e*>", set())
+                self.assertRaises(api_errors.BooleanQueryException,
+                    self._search_op, api_obj, True, "<e*> OR e*", set())
+                self.assertRaises(api_errors.BooleanQueryException,
+                    self._search_op, api_obj, True, "e* OR <e*>", set())
+
+        def _run_remote_tests(self, api_obj):
+                # Set to 1 since searches can't currently be performed
+                # package name unless it's set inside the
+                # manifest which happens at install time on
+                # the client side.
+                self._search_op(api_obj, True, "example_pkg", set())
+                self._search_op(api_obj, True, "example_path",
+                    self.res_remote_path)
+                self._search_op(api_obj, True, "::com.sun.service.info_url:",
+                    self.res_remote_url)
+                self._search_op(api_obj, True, "<e*>",
+                    self.res_remote_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, True, "<exam:::>",
+                    self.res_remote_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, True, "exam:::e*path",
+                    self.res_remote_path)
+                self._search_op(api_obj, True, "example*",
+                    self.res_remote_wildcard)
+                self._search_op(api_obj, True, "/bin", self.res_remote_bin)
+                self._search_op(api_obj, True, "4851433",
+                    self.res_remote_bug_id)
+                self._search_op(api_obj, True, "4725245",
+                    self.res_remote_bug_id_4725245)
+                self._search_op(api_obj, True, "6556919",
+                    self.res_remote_inc_changes)
+                self._search_op(api_obj, True, "42",
+                    self.res_remote_random_test)
+                self._search_op(api_obj, True, "79",
+                    self.res_remote_random_test_79)
+                self._search_op(api_obj, True, "separator",
+                    self.res_remote_keywords)
+                self._search_op(api_obj, True, "\"sort 0x86\"",
+                    self.res_remote_keywords_sort_phrase)
+                self._search_op(api_obj, True, "*example*",
+                    self.res_remote_glob)
+                self._search_op(api_obj, True, "fooo", self.res_remote_foo)
+                self._search_op(api_obj, True, "bar", self.res_remote_bar)
+                self._search_op(api_obj, True, "OpEnSsL",
+                    self.res_remote_openssl)
+
+                # These tests are included because a specific bug
+                # was found during development. This prevents regression back
+                # to that bug.
+                self._search_op(api_obj, True, "a_non_existent_token", set())
+
+        def _run_full_local_tests(self, api_obj):
                 outfile = os.path.join(self.testdata_dir, "res")
 
                 # This finds something because the client side
@@ -447,19 +654,62 @@
                     self.res_local_pkg)
                 self._search_op(api_obj, False, "example_path",
                     self.res_local_path)
+                self._search_op(api_obj, False, "(example_path)",
+                    self.res_local_path)
+                self._search_op(api_obj, False, "<exam*:::>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, False, "::com.sun.service.info_url:",
+                    self.res_remote_url)
+                self._search_op(api_obj, False, ":::e* AND *path",
+                    self.res_local_path)
+                self._search_op(api_obj, False, "e* AND *path",
+                    self.res_local_path)
+                self._search_op(api_obj, False, "<e*>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, False, "<e*> AND <e*>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, False, "<e*> OR <e*>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, False, "<exam:::>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, False, "exam:::e*path",
+                    self.res_local_path)
+                self._search_op(api_obj, False, "exam:::e*path AND e*:::",
+                    self.res_local_path)
+                self._search_op(api_obj, False, "e*::: AND exam:::*path",
+                    self.res_remote_path_extra)
                 self._search_op(api_obj, False, "example*",
                     self.res_local_wildcard)
                 self._search_op(api_obj, False, "/bin", self.res_local_bin)
                 self._search_op(api_obj, False, "4851433",
                     self.res_local_bug_id)
+                self._search_op(api_obj, False, "<4851433> AND <4725245>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, False, "4851433 AND 4725245",
+                    self.res_local_bug_id)
+                self._search_op(api_obj, False,
+                    "4851433 AND 4725245 OR example_path",
+                    self.res_local_bug_id)
+                self._search_op(api_obj, False,
+                    "4851433 AND (4725245 OR example_path)",
+                    self.res_local_bug_id)
+                self._search_op(api_obj, False,
+                    "(4851433 AND 4725245) OR example_path",
+                    self.res_local_bug_id | self.res_local_path)
+                self._search_op(api_obj, False, "4851433 OR 4725245",
+                    self.res_local_bug_id | self.res_remote_bug_id_4725245)
                 self._search_op(api_obj, False, "6556919",
                     self.res_local_inc_changes)
                 self._search_op(api_obj, False, "65569??",
                     self.res_local_inc_changes)
                 self._search_op(api_obj, False, "42",
                     self.res_local_random_test)
+                self._search_op(api_obj, False, "79",
+                    self.res_remote_random_test_79)
                 self._search_op(api_obj, False, "separator",
                     self.res_local_keywords)
+                self._search_op(api_obj, False, "\"sort 0x86\"",
+                    self.res_remote_keywords_sort_phrase)
                 self._search_op(api_obj, False, "*example*",
                     self.res_local_glob)
                 self._search_op(api_obj, False, "fooo", self.res_local_foo)
@@ -473,12 +723,67 @@
                     self.res_local_openssl)
                 self._search_op(api_obj, False, "OpEnS*",
                     self.res_local_openssl)
-
                 # 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.
                 self._search_op(api_obj, False, "a_non_existent_token", set())
+                self._search_op(api_obj, False, "42 AND 4641790", set())
+                self.assertRaises(api_errors.BooleanQueryException,
+                    self._search_op, api_obj, False, "<e*> AND e*", set())
+                self.assertRaises(api_errors.BooleanQueryException,
+                    self._search_op, api_obj, False, "e* AND <e*>", set())
+                self.assertRaises(api_errors.BooleanQueryException,
+                    self._search_op, api_obj, False, "<e*> OR e*", set())
+                self.assertRaises(api_errors.BooleanQueryException,
+                    self._search_op, api_obj, False, "e* OR <e*>", set())
+
+        def _run_local_tests(self, api_obj):
+                outfile = os.path.join(self.testdata_dir, "res")
+
+                # This finds something because the client side
+                # manifest has had the name of the package inserted
+                # into it.
+
+                self._search_op(api_obj, False, "example_pkg",
+                    self.res_local_pkg)
+                self._search_op(api_obj, False, "example_path",
+                    self.res_local_path)
+                self._search_op(api_obj, False, "::com.sun.service.info_url:",
+                    self.res_remote_url)
+                self._search_op(api_obj, False, "<e*>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, False, "<exam:::>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op(api_obj, False, "exam:::e*path",
+                    self.res_local_path)
+                self._search_op(api_obj, False, "example*",
+                    self.res_local_wildcard)
+                self._search_op(api_obj, False, "/bin", self.res_local_bin)
+                self._search_op(api_obj, False, "4851433",
+                    self.res_local_bug_id)
+                self._search_op(api_obj, False, "4725245",
+                    self.res_remote_bug_id_4725245)
+                self._search_op(api_obj, False, "6556919",
+                    self.res_local_inc_changes)
+                self._search_op(api_obj, False, "42",
+                    self.res_local_random_test)
+                self._search_op(api_obj, False, "79",
+                    self.res_remote_random_test_79)
+                self._search_op(api_obj, False, "separator",
+                    self.res_local_keywords)
+                self._search_op(api_obj, False, "\"sort 0x86\"",
+                    self.res_remote_keywords_sort_phrase)
+                self._search_op(api_obj, False, "*example*",
+                    self.res_local_glob)
+                self._search_op(api_obj, False, "fooo", self.res_local_foo)
+                self._search_op(api_obj, False, "bar", self.res_local_bar)
+                self._search_op(api_obj, False, "OpEnSsL",
+                    self.res_local_openssl)
+                # These tests are included because a specific bug
+                # was found during development. These tests prevent regression
+                # back to that bug.
+                self._search_op(api_obj, False, "a_non_existent_token", set())
 
         def _run_degraded_local_tests(self, api_obj):
                 outfile = os.path.join(self.testdata_dir, "res")
@@ -491,19 +796,63 @@
                     self.res_local_pkg)
                 self._search_op_slow(api_obj, False, "example_path",
                     self.res_local_path)
+                self._search_op_slow(api_obj, False, "(example_path)",
+                    self.res_local_path)
+                self._search_op_slow(api_obj, False, "<exam*:::>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op_slow(api_obj, False,
+                    "::com.sun.service.info_url:",
+                    self.res_remote_url)
+                self._search_op_slow(api_obj, False, ":::e* AND *path",
+                    self.res_local_path)
+                self._search_op_slow(api_obj, False, "e* AND *path",
+                    self.res_local_path)
+                self._search_op_slow(api_obj, False, "<e*>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op_slow(api_obj, False, "<e*> AND <e*>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op_slow(api_obj, False, "<e*> OR <e*>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op_slow(api_obj, False, "<exam:::>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op_slow(api_obj, False, "exam:::e*path",
+                    self.res_local_path)
+                self._search_op_slow(api_obj, False, "exam:::e*path AND e*:::",
+                    self.res_local_path)
+                self._search_op_slow(api_obj, False, "e*::: AND exam:::*path",
+                    self.res_remote_path_extra)
                 self._search_op_slow(api_obj, False, "example*",
                     self.res_local_wildcard)
                 self._search_op_slow(api_obj, False, "/bin", self.res_local_bin)
                 self._search_op_slow(api_obj, False, "4851433",
                     self.res_local_bug_id)
+                self._search_op_slow(api_obj, False, "<4851433> AND <4725245>",
+                    self.res_local_pkg_ret_pkg, return_actions=False)
+                self._search_op_slow(api_obj, False, "4851433 AND 4725245",
+                    self.res_local_bug_id)
+                self._search_op_slow(api_obj, False,
+                    "4851433 AND 4725245 OR example_path",
+                    self.res_local_bug_id)
+                self._search_op_slow(api_obj, False,
+                    "4851433 AND (4725245 OR example_path)",
+                    self.res_local_bug_id)
+                self._search_op_slow(api_obj, False,
+                    "(4851433 AND 4725245) OR example_path",
+                    self.res_local_bug_id | self.res_local_path)
+                self._search_op_slow(api_obj, False, "4851433 OR 4725245",
+                    self.res_local_bug_id | self.res_remote_bug_id_4725245)
                 self._search_op_slow(api_obj, False, "6556919",
                     self.res_local_inc_changes)
                 self._search_op_slow(api_obj, False, "65569??",
                     self.res_local_inc_changes)
                 self._search_op_slow(api_obj, False, "42",
                     self.res_local_random_test)
+                self._search_op_slow(api_obj, False, "79",
+                    self.res_remote_random_test_79)
                 self._search_op_slow(api_obj, False, "separator",
                     self.res_local_keywords)
+                self._search_op_slow(api_obj, False, "\"sort 0x86\"",
+                    self.res_remote_keywords_sort_phrase)
                 self._search_op_slow(api_obj, False, "*example*",
                     self.res_local_glob)
                 self._search_op_slow(api_obj, False, "fooo", self.res_local_foo)
@@ -517,7 +866,6 @@
                     self.res_local_openssl)
                 self._search_op_slow(api_obj, False, "OpEnS*",
                     self.res_local_openssl)
-
                 # 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
@@ -525,7 +873,6 @@
                 self._search_op_slow(api_obj, False, "a_non_existent_token",
                     set())
 
-                
         def _run_local_tests_example11_installed(self, api_obj):
                 outfile = os.path.join(self.testdata_dir, "res")
 
@@ -664,7 +1011,21 @@
                 api_obj.execute_plan()
                 api_obj.reset()
 
-        def test_remote(self):
+
+class TestApiSearchBasicsPersistentDepot(TestApiSearchBasics):
+        # Only start/stop the depot once (instead of for every test)
+        persistent_depot = True
+
+        def __init__(self, *args, **kwargs):
+                TestApiSearchBasics.__init__(self, *args, **kwargs)
+                self.sent_pkgs = set()
+        
+        def pkgsend_bulk(self, durl, pkg, optional=True):
+                if pkg not in self.sent_pkgs or optional == False:
+                        self.sent_pkgs.add(pkg)
+                        TestApiSearchBasics.pkgsend_bulk(self, durl, pkg)
+        
+        def test_010_remote(self):
                 """Test remote search."""
                 durl = self.dc.get_depot_url()
                 self.pkgsend_bulk(durl, self.example_pkg10)
@@ -672,10 +1033,12 @@
                 progresstracker = progress.NullProgressTracker()
                 api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
                     progresstracker, lambda x: False, PKG_CLIENT_NAME)
-                
-                self._run_remote_tests(api_obj)
-                
-        def test_local_0(self):
+                time.sleep(1)
+                # This should be a full test to test all functionality.
+                self._run_full_remote_tests(api_obj)
+                self._search_op(api_obj, True, ":file::", self.res_remote_file)
+
+        def test_020_local_0(self):
                 """Install one package, and run the search suite."""
                 durl = self.dc.get_depot_url()
                 self.pkgsend_bulk(durl, self.example_pkg10)
@@ -686,12 +1049,12 @@
 
                 self._do_install(api_obj, ["example_pkg"])
 
-                self._run_local_tests(api_obj)
+                self._run_full_local_tests(api_obj)
 
-        def test_degraded_local(self):
+        def test_030_degraded_local(self):
                 """Install one package, and run the search suite."""
                 durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
+                fmris = self.pkgsend_bulk(durl, self.example_pkg10)
                 self.image_create(durl)
                 progresstracker = progress.NullProgressTracker()
                 api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
@@ -704,8 +1067,7 @@
 
                 self._run_degraded_local_tests(api_obj)
 
-                
-        def test_repeated_install_uninstall(self):
+        def test_040_repeated_install_uninstall(self):
                 """Install and uninstall a package. Checking search both
                 after each change to the image."""
                 # During development, the index could become corrupted by
@@ -730,11 +1092,8 @@
                         api_obj.reset()
                         self._run_local_empty_tests(api_obj)
 
-        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_050_local_case_sensitive(self):
+                """Test local case sensitive search"""
                 durl = self.dc.get_depot_url()
                 self.pkgsend_bulk(durl, self.example_pkg10)
                 self.image_create(durl)
@@ -743,47 +1102,14 @@
                     progresstracker, lambda x: False, PKG_CLIENT_NAME)
 
                 self._do_install(api_obj, ["example_pkg"])
-
-                self.pkgsend_bulk(durl, self.example_pkg11)
-                api_obj.refresh(immediate=True)
-
-                self._do_image_update(api_obj)
-
-                self._run_local_tests_example11_installed(api_obj)
-
-                api_obj.rebuild_search_index()
-
-                self._run_local_tests_example11_installed(api_obj)
-
-        def test_bug_983(self):
-                """Test for known bug 983."""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.bug_983_manifest)
-                self.image_create(durl)
-                progresstracker = progress.NullProgressTracker()
-                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
-                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
+                self._search_op(api_obj, False, "fooo", set(), True)
+                self._search_op(api_obj, False, "fo*", set(), True)
+                self._search_op(api_obj, False, "bar", set(), True)
+                self._search_op(api_obj, False, "FOOO", self.res_local_foo,
+                    True)
+                self._search_op(api_obj, False, "bAr", self.res_local_bar, True)
 
-                self._search_op(api_obj, True, "gmake", self.res_bug_983)
-
-        def test_low_mem(self):
-                """Test to check codepath used in low memory situations."""
-                os.environ["PKG_INDEX_MAX_RAM"] = "0"
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.pkgsend_bulk(durl, self.bug_983_manifest)
-                self.pkgsend_bulk(durl, self.bug_983_manifest)
-
-                self.image_create(durl)
-                progresstracker = progress.NullProgressTracker()
-                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
-                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
-
-                self._run_remote_tests(api_obj)
-                self._search_op(api_obj, True, "gmake", self.res_bug_983)
-
-        def test_missing_files(self):
-                # working on this test case
+        def test_060_missing_files(self):
                 """Test to check for stack trace when files missing.
                 Bug 2753"""
                 durl = self.dc.get_depot_url()
@@ -797,6 +1123,8 @@
                 
                 index_dir = os.path.join(self.img_path, "var","pkg","index")
 
+                first = True
+                
                 for d in query_parser.TermQuery._global_data_dict.values():
                         orig_fn = d.get_file_name()
                         orig_path = os.path.join(index_dir, orig_fn)
@@ -806,11 +1134,17 @@
                         self.assertRaises(api_errors.InconsistentIndexException,
                             self._search_op, api_obj, False,
                             "exam:::example_pkg", [])
+                        if first:
+                                # Run the shell version once to check that no
+                                # stack trace happens.
+                                self.pkg("search -l 'exam:::example_pkg'",
+                                    exit=1)
+                                first = False
                         portable.rename(dest_path, orig_path)
-                        self._search_op(api_obj, False, "example_pkg",
+                        self._search_op(api_obj, False, "exam:::example_pkg",
                             self.res_local_pkg)
-                        
-        def test_mismatched_versions(self):
+
+        def test_070_mismatched_versions(self):
                 """Test to check for stack trace when files missing.
                 Bug 2753"""
                 durl = self.dc.get_depot_url()
@@ -823,6 +1157,8 @@
                 
                 index_dir = os.path.join(self.img_path, "var","pkg","index")
 
+                first = True
+
                 for d in query_parser.TermQuery._global_data_dict.values():
                         orig_fn = d.get_file_name()
                         orig_path = os.path.join(index_dir, orig_fn)
@@ -834,6 +1170,12 @@
                         self.assertRaises(api_errors.InconsistentIndexException,
                             self._search_op, api_obj, False,
                             "exam:::example_pkg", [])
+                        if first:
+                                # Run the shell version once to check that no
+                                # stack trace happens.
+                                self.pkg("search -l 'exam:::example_pkg'",
+                                    exit=1)
+                                first = False
                         portable.rename(dest_path, orig_path)
                         self._search_op(api_obj, False, "example_pkg",
                             self.res_local_pkg)
@@ -853,13 +1195,193 @@
                 self._overwrite_hash(ffh_path)
                 self.assertRaises(api_errors.IncorrectIndexFileHash,
                     self._search_op, api_obj, False, "example_pkg", set())
+                # Run the shell version of the test to check for a stack trace.
+                self.pkg("search -l 'exam:::example_pkg'", exit=1)
                 portable.rename(dest_path, ffh_path)
                 self._search_op(api_obj, False, "example_pkg",
                     self.res_local_pkg)
                 self._overwrite_hash(ffh_path)
                 self._do_uninstall(api_obj, ["example_pkg"])
                 self._search_op(api_obj, False, "example_pkg", set())
+
+        def test_080_weird_patterns(self):
+                """Test strange patterns to ensure they're handled correctly"""
+                durl = self.dc.get_depot_url()
+                self.pkgsend_bulk(durl, self.example_pkg10)
+                self.image_create(durl)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
+
+                self._search_op(api_obj, True, "[*]", self.res_remote_star)
+                self._search_op(api_obj, True, "[?]", self.res_remote_mark)
+                self._search_op(api_obj, True, "[[]",
+                    self.res_remote_left_brace)
+                self._search_op(api_obj, True, "[]]",
+                    self.res_remote_right_brace)
+                self._search_op(api_obj, True, "FO[O]O", self.res_remote_foo)
+                self._search_op(api_obj, True, "FO[?O]O", self.res_remote_foo)
+                self._search_op(api_obj, True, "FO[*O]O", self.res_remote_foo)
+                self._search_op(api_obj, True, "FO[]O]O", self.res_remote_foo)
+
+        def test_090_bug_7660(self):
+                """Test that installing a package doesn't prevent searching on
+                package names from working on previously installed packages."""
+                durl = self.dc.get_depot_url()
+                self.pkgsend_bulk(durl, self.example_pkg10)
+                self.pkgsend_bulk(durl, self.fat_pkg10)
+                self.image_create(durl)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: True, PKG_CLIENT_NAME)
+
+                tmp_dir = os.path.join(self.img_path, "var", "pkg", "index",
+                    "TMP")
+                self._do_install(api_obj, ["example_pkg"])
+                api_obj.rebuild_search_index()
+                self._do_install(api_obj, ["fat"])
+                self.assert_(not os.path.exists(tmp_dir))
+                self._run_local_tests(api_obj)
+
+        def test_100_bug_6712_i386(self):
+                """Install one package, and run the search suite."""
+                durl = self.dc.get_depot_url()
+                self.pkgsend_bulk(durl, self.fat_pkg10)
+
+                self.image_create(durl,
+                    additional_args="--variant variant.arch=i386")
+
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: True, PKG_CLIENT_NAME)
+
+                remote = True
+
+                self._search_op(api_obj, remote, "fat:::*",
+                    self.res_remote_fat10_star)
+                self._do_install(api_obj, ["fat"])
+                remote = False
+                self._search_op(api_obj, remote, "fat:::*",
+                    self.res_local_fat10_i386_star)
+
+        def test_110_bug_6712_sparc(self):
+                """Install one package, and run the search suite."""
+                durl = self.dc.get_depot_url()
+                self.pkgsend_bulk(durl, self.fat_pkg10)
                 
+                self.image_create(durl,
+                    additional_args="--variant variant.arch=sparc")
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: True, PKG_CLIENT_NAME)
+
+                remote = True
+
+                self._search_op(api_obj, remote, "fat:::*",
+                    self.res_remote_fat10_star)
+                self._do_install(api_obj, ["fat"])
+                remote = False
+                self._search_op(api_obj, remote, "fat:::*",
+                    self.res_local_fat10_sparc_star)
+
+        def test_120_bug_3046(self):
+                """Checks if directories ending in / break the indexer."""
+                # Need to move to t_api_search
+                durl = self.dc.get_depot_url()
+                self.pkgsend_bulk(durl, self.bad_pkg10)
+                self.image_create(durl)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: True, PKG_CLIENT_NAME)
+
+                self._search_op(api_obj, True, "foo", set())
+                self._search_op(api_obj, True, "/", set())
+
+        def test_bug_2849(self):
+                """Checks if things with spaces break the indexer."""
+                durl = self.dc.get_depot_url()
+                self.pkgsend_bulk(durl, self.space_pkg10)
+                self.image_create(durl)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
+
+                self._do_install(api_obj, ["space_pkg"])
+                time.sleep(1)
+
+                self.pkgsend_bulk(durl, self.space_pkg10, optional=False)
+                api_obj.refresh(immediate=True)
+
+                self._do_install(api_obj, ["space_pkg"])
+
+                remote = False
+                self._search_op(api_obj, remote, 'with', set())
+                self._search_op(api_obj, remote, 'with*',
+                    self.res_space_with_star)
+                self._search_op(api_obj, remote, '*space',
+                    self.res_space_space_star)
+                self._search_op(api_obj, remote, 'space', set())
+                self._search_op(api_obj, remote, 'unique_dir',
+                    self.res_space_unique)
+                remote = True
+                self._search_op(api_obj, remote, 'with', set())
+                self._search_op(api_obj, remote, 'with*',
+                    self.res_space_with_star)
+                self._search_op(api_obj, remote, '*space',
+                    self.res_space_space_star)
+                self._search_op(api_obj, remote, 'space', set())
+                self.pkgsend_bulk(durl, self.space_pkg10, optional=False)
+                # Need to add install of subsequent package and
+                # local side search as well as remote
+                self._search_op(api_obj, remote, 'with', set())
+                self._search_op(api_obj, remote, 'with*',
+                    self.res_space_with_star)
+                self._search_op(api_obj, remote, '*space',
+                    self.res_space_space_star)
+                self._search_op(api_obj, remote, 'space', set())
+                self._search_op(api_obj, remote, 'unique_dir',
+                    self.res_space_unique)
+
+        def test_bug_2863(self):
+                """Check that disabling indexing works as expected"""
+                durl = self.dc.get_depot_url()
+                self.pkgsend_bulk(durl, self.example_pkg10)
+                self.image_create(durl)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
+
+                self._check_no_index()
+                self._do_install(api_obj, ["example_pkg"], update_index=False)
+                self._check_no_index()
+                api_obj.rebuild_search_index()
+                self._run_local_tests(api_obj)
+                self._do_uninstall(api_obj, ["example_pkg"], update_index=False)
+                # Running empty test because search will notice the index
+                # does not match the installed packages and complain.
+                self.assertRaises(api_errors.IncorrectIndexFileHash,
+                    self._search_op, api_obj, False, "example_pkg", set())
+                api_obj.rebuild_search_index()
+                self._run_local_empty_tests(api_obj)
+                self._do_install(api_obj, ["example_pkg"])
+                self._run_local_tests(api_obj)
+                self.pkgsend_bulk(durl, self.example_pkg11)
+                api_obj.refresh(immediate=True)
+                self._do_image_update(api_obj, update_index=False)
+                # Running empty test because search will notice the index
+                # does not match the installed packages and complain.
+                self.assertRaises(api_errors.IncorrectIndexFileHash,
+                    self._search_op, api_obj, False, "example_pkg", set())
+                api_obj.rebuild_search_index()
+                self._run_local_tests_example11_installed(api_obj)
+                self._do_uninstall(api_obj, ["example_pkg"], update_index=False)
+                # Running empty test because search will notice the index
+                # does not match the installed packages and complain.
+                self.assertRaises(api_errors.IncorrectIndexFileHash,
+                    self._search_op, api_obj, False, "example_pkg", set())
+                api_obj.rebuild_search_index()
+                self._run_local_empty_tests(api_obj)
+
         def test_bug_2989_1(self):
                 durl = self.dc.get_depot_url()
                 self.pkgsend_bulk(durl, self.example_pkg10)
@@ -931,7 +1453,7 @@
                         self._do_install(api_obj, ["example_pkg"])
 
                         f(index_dir, index_dir_tmp)
-                        
+
                         self._do_uninstall(api_obj, ["example_pkg"])
 
                         self.image_destroy()
@@ -963,185 +1485,11 @@
 
                         self.image_destroy()
 
-        def test_local_case_sensitive(self):
-                """Test local case sensitive search"""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.image_create(durl)
-                progresstracker = progress.NullProgressTracker()
-                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
-                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
-
-                self._do_install(api_obj, ["example_pkg"])
-                self._search_op(api_obj, False, "fooo", set(), True)
-                self._search_op(api_obj, False, "fo*", set(), True)
-                self._search_op(api_obj, False, "bar", set(), True)
-                self._search_op(api_obj, False, "FOOO", self.res_local_foo,
-                    True)
-                self._search_op(api_obj, False, "bAr", self.res_local_bar, True)
-
-        def test_weird_patterns(self):
-                """Test strange patterns to ensure they're handled correctly"""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.image_create(durl)
-                progresstracker = progress.NullProgressTracker()
-                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
-                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
-
-                self._search_op(api_obj, True, "[*]", self.res_remote_star)
-                self._search_op(api_obj, True, "[?]", self.res_remote_mark)
-                self._search_op(api_obj, True, "[[]",
-                    self.res_remote_left_brace)
-                self._search_op(api_obj, True, "[]]",
-                    self.res_remote_right_brace)
-                self._search_op(api_obj, True, "FO[O]O", self.res_remote_foo)
-                self._search_op(api_obj, True, "FO[?O]O", self.res_remote_foo)
-                self._search_op(api_obj, True, "FO[*O]O", self.res_remote_foo)
-                self._search_op(api_obj, True, "FO[]O]O", self.res_remote_foo)
-
-        def test_bug_2849(self):
-                """Checks if things with spaces break the indexer."""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.space_pkg10)
-                self.image_create(durl)
-                progresstracker = progress.NullProgressTracker()
-                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
-                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
-
-                self._do_install(api_obj, ["space_pkg"])
-                time.sleep(1)
-                
-                self.pkgsend_bulk(durl, self.space_pkg10)
-                api_obj.refresh(immediate=True)
-
-                self.pkg("refresh")
-                self._do_install(api_obj, ["space_pkg"])
-                
-                remote = False
-                self._search_op(api_obj, remote, 'with', set())
-                self._search_op(api_obj, remote, 'with*',
-                    self.res_space_with_star)
-                self._search_op(api_obj, remote, '*space',
-                    self.res_space_space_star)
-                self._search_op(api_obj, remote, 'space', set())
-                self._search_op(api_obj, remote, 'unique_dir',
-                    self.res_space_unique)
-                remote = True
-                self._search_op(api_obj, remote, 'with', set())
-                self._search_op(api_obj, remote, 'with*',
-                    self.res_space_with_star)
-                self._search_op(api_obj, remote, '*space',
-                    self.res_space_space_star)
-                self._search_op(api_obj, remote, 'space', set())
-                self.pkgsend_bulk(durl, self.space_pkg10)
-                self._search_op(api_obj, remote, 'with', set())
-                self._search_op(api_obj, remote, 'with*',
-                    self.res_space_with_star)
-                self._search_op(api_obj, remote, '*space',
-                    self.res_space_space_star)
-                self._search_op(api_obj, remote, 'space', set())
-                self._search_op(api_obj, remote, 'unique_dir',
-                    self.res_space_unique)
-
-        def test_bug_2863(self):
-                """Test local case sensitive search"""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.image_create(durl)
-                progresstracker = progress.NullProgressTracker()
-                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
-                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
-
-                self._check_no_index()
-                self._do_install(api_obj, ["example_pkg"], update_index=False)
-                self._check_no_index()
-                api_obj.rebuild_search_index()
-                self._run_local_tests(api_obj)
-                self._do_uninstall(api_obj, ["example_pkg"], update_index=False)
-                # Running empty test because search will notice the index
-                # does not match the installed packages and complain.
-                self.assertRaises(api_errors.IncorrectIndexFileHash,
-                    self._search_op, api_obj, False, "example_pkg", set())
-                api_obj.rebuild_search_index()
-                self._run_local_empty_tests(api_obj)
-                self._do_install(api_obj, ["example_pkg"])
-                self._run_local_tests(api_obj)
-                self.pkgsend_bulk(durl, self.example_pkg11)
-                api_obj.refresh(immediate=True)
-                self._do_image_update(api_obj, update_index=False)
-                # Running empty test because search will notice the index
-                # does not match the installed packages and complain.
-                self.assertRaises(api_errors.IncorrectIndexFileHash,
-                    self._search_op, api_obj, False, "example_pkg", set())
-                api_obj.rebuild_search_index()
-                self._run_local_tests_example11_installed(api_obj)
-                self._do_uninstall(api_obj, ["example_pkg"], update_index=False)
-                # Running empty test because search will notice the index
-                # does not match the installed packages and complain.
-                self.assertRaises(api_errors.IncorrectIndexFileHash,
-                    self._search_op, api_obj, False, "example_pkg", set())
-                api_obj.rebuild_search_index()
-                self._run_local_empty_tests(api_obj)
-
-        def test_bug_4048_1(self):
-                """Checks whether the server deals with partial indexing."""
-                durl = self.dc.get_depot_url()
-                depotpath = self.dc.get_repodir()
-                tmp_dir = os.path.join(depotpath, "index", "TMP")
-                os.mkdir(tmp_dir)
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.image_create(durl)
-                progresstracker = progress.NullProgressTracker()
-                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
-                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
-                self._run_remote_empty_tests(api_obj)
-                os.rmdir(tmp_dir)
-                offset = 2
-                depot_logfile = os.path.join(self.get_test_prefix(),
-                    self.id(), "depot_logfile%d" % offset)
-                tmp_dc = self.start_depot(12000 + offset, depotpath,
-                    depot_logfile, refresh_index=True)
-                time.sleep(1)
-                self._run_remote_tests(api_obj)
-                tmp_dc.kill()
-
-        def test_bug_4048_2(self):
-                """Checks whether the server deals with partial indexing."""
-                durl = self.dc.get_depot_url()
-                depotpath = self.dc.get_repodir()
-                tmp_dir = os.path.join(depotpath, "index", "TMP")
-                os.mkdir(tmp_dir)
-                self.pkgsend_bulk(durl, self.space_pkg10)
-                self.image_create(durl)
-                progresstracker = progress.NullProgressTracker()
-                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
-                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
-                self._run_remote_empty_tests(api_obj)
-                os.rmdir(tmp_dir)
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                time.sleep(1)
-                self._run_remote_tests(api_obj)
-                self._search_op(api_obj, True, "unique_dir",
-                    self.res_space_unique)
-                self._search_op(api_obj, True, "with*",
-                    self.res_space_with_star)
 
         def test_bug_4239(self):
                 """Tests whether categories are indexed and searched for
                 correctly."""
 
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.cat_pkg10)
-                self.pkgsend_bulk(durl, self.cat2_pkg10)
-                self.pkgsend_bulk(durl, self.cat3_pkg10)
-                self.pkgsend_bulk(durl, self.bad_cat_pkg10)
-                self.pkgsend_bulk(durl, self.bad_cat2_pkg10)
-                self.image_create(durl)
-                progresstracker = progress.NullProgressTracker()
-                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
-                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
-
                 def _run_cat_tests(self, remote):
                         self._search_op(api_obj, remote, "System",
                             self.res_cat_pkg10, case_sensitive=False)
@@ -1161,7 +1509,7 @@
                             self.res_cat2_pkg10, case_sensitive=False)
                         self._search_op(api_obj, True, "Sound",
                             self.res_cat2_pkg10, case_sensitive=False)
-                        self._search_op(api_obj, remote, "'Sound and Video'",
+                        self._search_op(api_obj, remote, "Sound and Video",
                             self.res_cat2_pkg10, case_sensitive=False)
                         self._search_op(api_obj, remote, "Sound*",
                             self.res_cat2_pkg10, case_sensitive=False)
@@ -1188,6 +1536,17 @@
                             "foo/bar/baz/bill/beam/asda", self.res_cat3_pkg10,
                             case_sensitive=False)
 
+                durl = self.dc.get_depot_url()
+                self.pkgsend_bulk(durl, self.cat_pkg10)
+                self.pkgsend_bulk(durl, self.cat2_pkg10)
+                self.pkgsend_bulk(durl, self.cat3_pkg10)
+                self.pkgsend_bulk(durl, self.bad_cat_pkg10)
+                self.pkgsend_bulk(durl, self.bad_cat2_pkg10)
+                self.image_create(durl)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
+
                 remote = True
                 _run_cat_tests(self, remote)
                 _run_cat2_tests(self, remote)
@@ -1199,16 +1558,131 @@
 
                 self._do_install(api_obj, ["cat2"])
                 _run_cat2_tests(self, remote)
-                
+
                 self._do_install(api_obj, ["cat3"])
                 _run_cat3_tests(self, remote)
-                
+
                 self._do_install(api_obj, ["badcat"])
                 self._do_install(api_obj, ["badcat2"])
                 _run_cat_tests(self, remote)
                 _run_cat2_tests(self, remote)
                 _run_cat3_tests(self, remote)
 
+        def test_bug_7628(self):
+                """Checks whether incremental update generates wrong
+                additional lines."""
+                durl = self.dc.get_depot_url()
+                depotpath = self.dc.get_repodir()
+                ind_dir = os.path.join(depotpath, "index")
+                tok_file = os.path.join(ind_dir, ss.BYTE_OFFSET_FILE)
+                main_file = os.path.join(ind_dir, ss.MAIN_FILE)
+                self.pkgsend_bulk(durl, self.example_pkg10)
+                time.sleep(1)
+                fh = open(tok_file)
+                tok_1 = fh.readlines()
+                tok_len = len(tok_1)
+                fh.close()
+                fh = open(main_file)
+                main_1 = fh.readlines()
+                main_len = len(main_1)
+                self.pkgsend_bulk(durl, self.example_pkg10, optional=False)
+                time.sleep(1)
+                fh = open(tok_file)
+                tok_2 = fh.readlines()
+                new_tok_len = len(tok_2)
+                fh.close()
+                fh = open(main_file)
+                main_2 = fh.readlines()
+                new_main_len = len(main_2)
+                fh.close()
+                self.assert_(new_tok_len == tok_len)
+                self.assert_(new_main_len == main_len)
+
+        def test_bug_983(self):
+                """Test for known bug 983."""
+                durl = self.dc.get_depot_url()
+                self.pkgsend_bulk(durl, self.bug_983_manifest)
+                self.image_create(durl)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
+
+                self._search_op(api_obj, True, "gmake", self.res_bug_983)
+                
+class TestApiSearchBasicsRestartingDepot(TestApiSearchBasics):        
+        def setUp(self):
+                self.debug_features = ["headers"]
+                TestApiSearchBasics.setUp(self)
+
+        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."""
+                durl = self.dc.get_depot_url()
+                self.pkgsend_bulk(durl, self.example_pkg10)
+                self.image_create(durl)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
+
+                self._do_install(api_obj, ["example_pkg"])
+
+                self.pkgsend_bulk(durl, self.example_pkg11)
+                api_obj.refresh(immediate=True)
+
+                self._do_image_update(api_obj)
+
+                self._run_local_tests_example11_installed(api_obj)
+
+                api_obj.rebuild_search_index()
+
+                self._run_local_tests_example11_installed(api_obj)
+
+        def test_bug_4048_1(self):
+                """Checks whether the server deals with partial indexing."""
+                durl = self.dc.get_depot_url()
+                depotpath = self.dc.get_repodir()
+                tmp_dir = os.path.join(depotpath, "index", "TMP")
+                os.mkdir(tmp_dir)
+                self.pkgsend_bulk(durl, self.example_pkg10)
+                self.image_create(durl)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
+                self._run_remote_empty_tests(api_obj)
+                os.rmdir(tmp_dir)
+                offset = 2
+                depot_logfile = os.path.join(self.get_test_prefix(),
+                    self.id(), "depot_logfile%d" % offset)
+                tmp_dc = self.start_depot(12000 + offset, depotpath,
+                    depot_logfile, refresh_index=True)
+                time.sleep(1)
+                # This should do something other than sleep for 1 sec
+                self._run_remote_tests(api_obj)
+                tmp_dc.kill()
+
+        def test_bug_4048_2(self):
+                """Checks whether the server deals with partial indexing."""
+                durl = self.dc.get_depot_url()
+                depotpath = self.dc.get_repodir()
+                tmp_dir = os.path.join(depotpath, "index", "TMP")
+                os.mkdir(tmp_dir)
+                self.pkgsend_bulk(durl, self.space_pkg10)
+                self.image_create(durl)
+                progresstracker = progress.NullProgressTracker()
+                api_obj = api.ImageInterface(self.get_img_path(), API_VERSION,
+                    progresstracker, lambda x: False, PKG_CLIENT_NAME)
+                self._run_remote_empty_tests(api_obj)
+                os.rmdir(tmp_dir)
+                self.pkgsend_bulk(durl, self.example_pkg10)
+                time.sleep(1)
+                self._run_remote_tests(api_obj)
+                self._search_op(api_obj, True, "unique_dir",
+                    self.res_space_unique)
+                self._search_op(api_obj, True, "with*",
+                    self.res_space_with_star)
+
         def __corrupt_depot(self, ind_dir):
                 self.dc.stop()
                 if os.path.exists(os.path.join(ind_dir, ss.MAIN_FILE)):
@@ -1285,36 +1759,6 @@
                 self.__wait_for_indexing(os.path.join(writ_dir, "TMP"))
                 self.assert_(not os.path.isdir(ind_dir))
                 self._run_remote_tests(api_obj)
-
-        def test_bug_7628(self):
-                """Checks whether incremental update generates wrong
-                additional lines."""
-                durl = self.dc.get_depot_url()
-                depotpath = self.dc.get_repodir()
-                ind_dir = os.path.join(depotpath, "index")
-                tok_file = os.path.join(ind_dir, ss.BYTE_OFFSET_FILE)
-                main_file = os.path.join(ind_dir, ss.MAIN_FILE)
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                time.sleep(1)
-                fh = open(tok_file)
-                tok_1 = fh.readlines()
-                tok_len = len(tok_1)
-                fh.close()
-                fh = open(main_file)
-                main_1 = fh.readlines()
-                main_len = len(main_1)
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                time.sleep(1)
-                fh = open(tok_file)
-                tok_2 = fh.readlines()
-                new_tok_len = len(tok_2)
-                fh.close()
-                fh = open(main_file)
-                main_2 = fh.readlines()
-                new_main_len = len(main_2)
-                fh.close()
-                self.assert_(new_tok_len == tok_len)
-                self.assert_(new_main_len == main_len)
                 
         def test_bug_8318(self):
                 durl = self.dc.get_depot_url()
@@ -1347,7 +1791,7 @@
                         raise RuntimeError(("Found %s instances of a "
                             "client uuid, expected to find %s.") %
                             (found, num_expected))
-                   
+
 
 class TestApiSearchMulti(testutils.ManyDepotTestCase):
 
--- a/src/tests/cli/t_pkg_search.py	Tue Jun 09 09:41:30 2009 -0700
+++ b/src/tests/cli/t_pkg_search.py	Tue Jun 09 11:11:57 2009 -0700
@@ -61,60 +61,6 @@
             add set name='weirdness' value='] [ * ?'
             close """
 
-        example_pkg11 = """
-            open [email protected],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 """
-
-        another_pkg10 = """
-            open [email protected],5.11-0
-            add dir mode=0755 owner=root group=bin path=/bin
-            add dir mode=0755 owner=root group=bin path=/bin/another_dir
-            add file /tmp/example_file mode=0555 owner=root group=bin path=/bin/another_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 4725245 4817791 4851433 4897491 4913776 6178339 6556919 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/[email protected],5.11-1:20080514I120000Z
-            close """
-
-        bad_pkg10 = """
-            open [email protected],5.11-0
-            add dir path=foo/ mode=0755 owner=root group=bin
-            close """
-
-        space_pkg10 = """
-            open [email protected],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 [email protected],5.11-0
-            add set name=info.classification value=org.opensolaris.category.2008:System/Security
-            close """
-
-        cat2_pkg10 = """
-            open [email protected],5.11-0
-            add set name=info.classification value="org.opensolaris.category.2008:Applications/Sound and Video"
-            close """
-
-        cat3_pkg10 = """
-            open [email protected],5.11-0
-            add set name=info.classification value="org.opensolaris.category.2008:foo/bar/baz/bill/beam/asda"
-            close """
-
-        bad_cat_pkg10 = """
-            open [email protected],5.11-0
-            add set name=info.classification value="TestBad1/TestBad2"
-            close """
-
-        bad_cat2_pkg10 = """
-            open [email protected],5.11-0
-            add set name=info.classification value="org.opensolaris.category.2008:TestBad1:TestBad2"
-            close """
-
         fat_pkg10 = """
 open [email protected],5.11-0
 add set name=variant.arch value=sparc value=i386
@@ -212,26 +158,6 @@
             "description set       bAr                       pkg:/[email protected]\n"
         ])
 
-        res_remote_star = set([
-            headers,
-            "weirdness  set       *                         pkg:/[email protected]\n"
-        ])
-
-        res_remote_mark = set([
-            headers,
-            "weirdness  set       ?                         pkg:/[email protected]\n"
-        ])
-
-        res_remote_left_brace = set([
-            headers,
-            "weirdness  set       [                         pkg:/[email protected]\n"
-        ])
-
-        res_remote_right_brace = set([
-            headers,
-            "weirdness  set       ]                         pkg:/[email protected]\n"
-        ])
-        
         local_fmri_string = \
             "fmri       set       example_pkg               pkg:/[email protected]\n"
 
@@ -285,72 +211,6 @@
 
         res_local_degraded_openssl = res_local_openssl.union(degraded_warning)
 
-        res_local_path_example11 = set([
-            headers,
-            "basename   file      bin/example_path11        pkg:/[email protected]\n"
-        ])
-
-        res_local_bin_example11 = set([
-            headers,
-            "path       dir       bin                       pkg:/[email protected]\n"
-        ])
-
-        res_local_wildcard_example11 = set([
-            headers,
-            "basename   file      bin/example_path11        pkg:/[email protected]\n",
-            "fmri       set       example_pkg               pkg:/[email protected]\n"
-       ])
-
-        res_local_pkg_example11 = set([
-            headers,
-            "fmri       set       example_pkg               pkg:/[email protected]\n"
-        ])
-
-        res_cat_pkg10 = set([
-            headers,
-            "info.classification set       System/Security           pkg:/[email protected]\n"
-        ])
-
-        res_cat2_pkg10 = set([
-            headers,
-            "info.classification set       Applications/Sound and Video pkg:/[email protected]\n"
-        ])
-
-        res_cat3_pkg10 = set([
-            headers,
-            "info.classification set       foo/bar/baz/bill/beam/asda pkg:/[email protected]\n"
-        ])
-
-        res_fat10_i386 = set([
-            headers,
-            "description set       i386                      pkg:/[email protected]\n",
-            "variant.arch set       i386                      pkg:/[email protected]\n",
-            "description set       variant                   pkg:/[email protected]\n"
-
-        ])
-
-        res_fat10_sparc = set([
-            headers,
-            "description set       sparc                     pkg:/[email protected]\n",
-            "variant.arch set       sparc                     pkg:/[email protected]\n",
-            "description set       variant                   pkg:/[email protected]\n"
-
-        ])
-
-        res_remote_fat10_star = res_fat10_sparc | res_fat10_i386
-
-        res_local_fat10_i386_star = res_fat10_i386.union(set([
-            "variant.arch set       sparc                     pkg:/[email protected]\n",
-            "publisher  set       test                      pkg:/[email protected]\n",
-            "fmri       set       fat                       pkg:/[email protected]\n"
-        ]))
-
-        res_local_fat10_sparc_star = res_fat10_sparc.union(set([
-            "variant.arch set       i386                      pkg:/[email protected]\n",
-            "publisher  set       test                      pkg:/[email protected]\n",
-            "fmri       set       fat                       pkg:/[email protected]\n"
-        ]))
-
         res_bogus_name_result = set([
             headers,
             'fmri       set       bogus_pkg                 pkg:/[email protected]\n'
@@ -363,51 +223,6 @@
 
         misc_files = ['/tmp/example_file']
 
-        # 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
-        # that they all take /tmp/example file when sending.
-        bug_983_manifest = """
-open [email protected],5.11-0.89
-add dir group=sys mode=0755 owner=root path=usr
-add dir group=bin mode=0755 owner=root path=usr/bin
-add dir group=bin mode=0755 owner=root path=usr/gnu
-add dir group=bin mode=0755 owner=root path=usr/gnu/bin
-add link path=usr/gnu/bin/make target=../../bin/gmake
-add dir group=sys mode=0755 owner=root path=usr/gnu/share
-add dir group=bin mode=0755 owner=root path=usr/gnu/share/man
-add dir group=bin mode=0755 owner=root path=usr/gnu/share/man/man1
-add link path=usr/gnu/share/man/man1/make.1 target=../../../../share/man/man1/gmake.1
-add dir group=bin mode=0755 owner=root path=usr/sfw
-add dir group=bin mode=0755 owner=root path=usr/sfw/bin
-add link path=usr/sfw/bin/gmake target=../../bin/gmake
-add dir group=bin mode=0755 owner=root path=usr/sfw/share
-add dir group=bin mode=0755 owner=root path=usr/sfw/share/man
-add dir group=bin mode=0755 owner=root path=usr/sfw/share/man/man1
-add link path=usr/sfw/share/man/man1/gmake.1 target=../../../../share/man/man1/gmake.1
-add dir group=sys mode=0755 owner=root path=usr/share
-add dir group=bin mode=0755 owner=root path=usr/share/info
-add dir group=bin mode=0755 owner=root path=usr/share/man
-add dir group=bin mode=0755 owner=root path=usr/share/man/man1
-add file /tmp/example_file elfarch=i386 elfbits=32 elfhash=68cca393e816e6adcbac1e8ffe9c618de70413e0 group=bin mode=0555 owner=root path=usr/bin/gmake pkg.size=18
-add file /tmp/example_file group=bin mode=0444 owner=root path=usr/share/info/make.info pkg.size=18
-add file /tmp/example_file group=bin mode=0444 owner=root path=usr/share/info/make.info-1 pkg.size=18
-add file /tmp/example_file group=bin mode=0444 owner=root path=usr/share/info/make.info-2 pkg.size=18
-add file /tmp/example_file group=bin mode=0444 owner=root path=usr/share/man/man1/gmake.1 pkg.size=18
-add license /tmp/example_file license=SUNWgmake.copyright pkg.size=18 transaction_id=1211931083_pkg%3A%2FSUNWgmake%403.81%2C5.11-0.89%3A20080527T163123Z
-add depend fmri=pkg:/[email protected] type=require
-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([
-            headers,
-            "basename   link      usr/sfw/bin/gmake         pkg:/[email protected]\n",
-            "basename   file      usr/bin/gmake             pkg:/[email protected]\n",
-            "description set       gmake                     pkg:/[email protected]\n"
-
-        ])
-
         res_local_pkg_ret_pkg = set([
             pkg_headers,
             "pkg:/[email protected]\n"
@@ -449,8 +264,6 @@
                 tp = self.get_test_prefix()
                 self.testdata_dir = os.path.join(tp, "search_results")
                 os.mkdir(self.testdata_dir)
-                self._dir_restore_functions = [self._restore_dir,
-                    self._restore_dir_preserve_hash]
                 self.init_mem_setting = None
 
         def tearDown(self):
@@ -459,17 +272,6 @@
                         os.remove(p)
                 shutil.rmtree(self.testdata_dir)
 
-        def _set_low_mem(self):
-                self.init_mem_setting = \
-                    os.environ.get("PKG_INDEX_MAX_RAM", None)
-                os.environ["PKG_INDEX_MAX_RAM"] = "0"
-
-        def _unset_low_mem(self):
-                if self.init_mem_setting is not None:
-                        os.environ["PKG_INDEX_MAX_RAM"] = self.init_mem_setting
-                else:
-                        del os.environ["PKG_INDEX_MAX_RAM"]
-
         def _check(self, proposed_answer, correct_answer):
                 if correct_answer == proposed_answer:
                         return True
@@ -536,7 +338,8 @@
                     self.res_remote_bug_id)
                 self._search_op(True, "'(4851433 AND 4725245) OR example_path'",
                     self.res_remote_bug_id | self.res_remote_path)
-                self._search_op(True, "4851433 OR 4725245", self.res_remote_bug_id | self.res_remote_bug_id_4725245)
+                self._search_op(True, "4851433 OR 4725245",
+                    self.res_remote_bug_id | self.res_remote_bug_id_4725245)
                 self._search_op(True, "6556919", self.res_remote_inc_changes)
                 self._search_op(True, "6556?19", self.res_remote_inc_changes)
                 self._search_op(True, "42", self.res_remote_random_test)
@@ -639,22 +442,6 @@
                 self.pkg("search -a -l '<e*> OR e*'", exit=1)
                 self.pkg("search -a -l 'e* OR <e*>'", exit=1)
 
-        def _run_local_tests_example11_installed(self):
-                outfile = os.path.join(self.testdata_dir, "res")
-
-                # This finds something because the client side
-                # manifest has had the name of the package inserted
-                # into it.
-
-                self._search_op(False, "example_pkg",
-                    self.res_local_pkg_example11)
-                self.pkg("search -a -l example_path", exit=1)
-                self._search_op(False, "example_path11",
-                    self.res_local_path_example11)
-                self._search_op(False, "example*",
-                    self.res_local_wildcard_example11)
-                self._search_op(False, "/bin", self.res_local_bin_example11)
-
         def _run_local_empty_tests(self):
                 self.pkg("search -a -l example_pkg", exit=1)
                 self.pkg("search -a -l example_path", exit=1)
@@ -668,93 +455,11 @@
                 self.pkg("search -a -r /bin", exit=1)
                 self.pkg("search -a -r *unique*", exit=1)
 
-        @staticmethod
-        def _restore_dir(index_dir, index_dir_tmp):
-                shutil.rmtree(index_dir)
-                shutil.move(index_dir_tmp, index_dir)
-
-        @staticmethod
-        def _restore_dir_preserve_hash(index_dir, index_dir_tmp):
-                tmp_file = "full_fmri_list.hash"
-                portable.remove(os.path.join(index_dir_tmp, tmp_file))
-                shutil.move(os.path.join(index_dir, tmp_file),
-                            index_dir_tmp)
-                fh = open(os.path.join(index_dir_tmp, ss.MAIN_FILE), "r")
-                fh.seek(0)
-                fh.seek(9)
-                ver = fh.read(1)
-                fh.close()
-                fh = open(os.path.join(index_dir_tmp, tmp_file), "r+")
-                fh.seek(0)
-                fh.seek(9)
-                # Overwrite the existing version number.
-                # By definition, the version 0 is never used.
-                fh.write("%s" % ver)
-                shutil.rmtree(index_dir)
-                shutil.move(index_dir_tmp, index_dir)
-
         def _get_index_dirs(self):
                 index_dir = os.path.join(self.img_path, "var","pkg","index")
                 index_dir_tmp = index_dir + "TMP"
                 return index_dir, index_dir_tmp
 
-        @staticmethod
-        def _overwrite_version_number(file_path):
-                fh = open(file_path, "r+")
-                fh.seek(0)
-                fh.seek(9)
-                # Overwrite the existing version number.
-                # By definition, the version 0 is never used.
-                fh.write("0")
-                fh.close()
-
-        @staticmethod
-        def _overwrite_on_disk_format_version_number(file_path):
-                fh = open(file_path, "r+")
-                fh.seek(0)
-                fh.seek(16)
-                # Overwrite the existing version number.
-                # By definition, the version 0 is never used.
-                fh.write("9")
-                fh.close()
-
-        @staticmethod
-        def _overwrite_on_disk_format_version_number_with_letter(file_path):
-                fh = open(file_path, "r+")
-                fh.seek(0)
-                fh.seek(16)
-                # Overwrite the existing version number.
-                # By definition, the version 0 is never used.
-                fh.write("a")
-                fh.close()
-
-        @staticmethod
-        def _replace_on_disk_format_version(dir):
-                file_path = os.path.join(dir, ss.BYTE_OFFSET_FILE)
-                fh = open(file_path, "r")
-                lst = fh.readlines()
-                fh.close()
-                fh = open(file_path, "w")
-                fh.write(lst[0])
-                for l in lst[2:]:
-                        fh.write(l)
-                fh.close()
-
-        @staticmethod
-        def _overwrite_hash(ffh_path):
-                fh = open(ffh_path, "r+")
-                fh.seek(0)
-                fh.seek(20)
-                fh.write("*")
-                fh.close()
-
-        def _check_no_index(self):
-                ind_dir, ind_dir_tmp = self._get_index_dirs()
-                if os.listdir(ind_dir):
-                        self.assert_(0)
-                if os.path.exists(ind_dir_tmp):
-                        self.assert_(0)
-
 	def test_pkg_search_cli(self):
 		"""Test search cli options."""
 
@@ -769,6 +474,8 @@
 
         def test_remote(self):
                 """Test remote search."""
+                # Need to retain to check that default search does remote, not
+                # local search, and that -r and -s work as expected
                 durl = self.dc.get_depot_url()
                 self.pkgsend_bulk(durl, self.example_pkg10)
 
@@ -776,9 +483,13 @@
                 self._run_remote_tests()
                 self._search_op(True, "':file::'", self.res_remote_file)
                 self.pkg("search '*'")
+                self.pkg("search -r '*'")
+                self.pkg("search -s %s '*'" % durl)
+                self.pkg("search -l '*'", exit=1)
                 
         def test_local_0(self):
                 """Install one package, and run the search suite."""
+                # Need to retain that -l works as expected
                 durl = self.dc.get_depot_url()
                 self.pkgsend_bulk(durl, self.example_pkg10)
                 
@@ -788,148 +499,11 @@
 
                 self._run_local_tests()
 
-        def test_repeated_install_uninstall(self):
-                """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
-
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.image_create(durl)
-
-                self.pkg("install example_pkg")
-                self.pkg("uninstall example_pkg")
-
-                for i in range(1, repeat):
-                        self.pkg("install example_pkg")
-                        self._run_local_tests()
-                        self.pkg("uninstall example_pkg")
-                        self._run_local_empty_tests()
-
-        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."""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.image_create(durl)
-
-                self.pkg("install example_pkg")
-
-                self.pkgsend_bulk(durl, self.example_pkg11)
-
-                self.pkg("refresh")
-                self.pkg("image-update")
-
-                self._run_local_tests_example11_installed()
-
-                self.pkg("rebuild-index")
-
-                self._run_local_tests_example11_installed()
-
-        def test_bug_983(self):
-                """Test for known bug 983."""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.bug_983_manifest)
-                self.image_create(durl)
-
-                self._search_op(True, "gmake", self.res_bug_983)
-
-        def test_low_mem(self):
-                """Test to check codepath used in low memory situations."""
-                self._set_low_mem()
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.pkgsend_bulk(durl, self.bug_983_manifest)
-                self.pkgsend_bulk(durl, self.bug_983_manifest)
-
-                self.image_create(durl)
-
-                self._run_remote_tests()
-                self._search_op(True, "gmake", self.res_bug_983)
-                self._unset_low_mem()
-
-        def test_missing_files(self):
-                """Test to check for stack trace when files missing.
-                Bug 2753"""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-
-                self.image_create(durl)
-                self.pkg("install example_pkg")
-                
-                index_dir = os.path.join(self.img_path, "var","pkg","index")
-
-                for d in query_parser.TermQuery._global_data_dict.values():
-                        orig_fn = d.get_file_name()
-                        orig_path = os.path.join(index_dir, orig_fn)
-                        dest_fn = orig_fn + "TMP"
-                        dest_path = os.path.join(index_dir, dest_fn)
-                        portable.rename(orig_path, dest_path)
-                        self.pkg("search -l 'exam:::example_pkg'", exit=1)
-                        portable.rename(dest_path, orig_path)
-                        self.pkg("search -l example_pkg")
-                        
-        def test_mismatched_versions(self):
-                """Test to check for stack trace when files missing.
-                Bug 2753"""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-
-                self.image_create(durl)
-                self.pkg("install example_pkg")
-                
-                index_dir = os.path.join(self.img_path, "var","pkg","index")
-
-                for d in query_parser.TermQuery._global_data_dict.values():
-                        orig_fn = d.get_file_name()
-                        orig_path = os.path.join(index_dir, orig_fn)
-                        dest_fn = orig_fn + "TMP"
-                        dest_path = os.path.join(index_dir, dest_fn)
-                        shutil.copy(orig_path, dest_path)
-                        self._overwrite_version_number(orig_path)
-                        self.pkg("search -l 'exam:::example_pkg'", exit=1)
-                        portable.rename(dest_path, orig_path)
-                        self.pkg("search -l example_pkg")
-                        self._overwrite_version_number(orig_path)
-                        self.pkg("uninstall example_pkg")
-                        self.pkg("search -l example_pkg", exit=1)
-                        self._overwrite_version_number(orig_path)
-                        self.pkg("install example_pkg")
-                        self.pkg("search -l example_pkg")
-                        
-                ffh = ss.IndexStoreSetHash(ss.FULL_FMRI_HASH_FILE)
-                ffh_path = os.path.join(index_dir, ffh.get_file_name())
-                dest_path = ffh_path + "TMP"
-                shutil.copy(ffh_path, dest_path)
-                self._overwrite_hash(ffh_path)
-                self.pkg("search -l example_pkg", exit=1)
-                portable.rename(dest_path, ffh_path)
-                self.pkg("search -l example_pkg")
-                self._overwrite_hash(ffh_path)
-                self.pkg("uninstall example_pkg")
-                self.pkg("search -l example_pkg", exit=1)
-                
-        def test_degraded_search(self):
-                """Test to check for stack trace when files missing.
-                Bug 2753"""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-
-                self.image_create(durl)
-                self.pkg("install example_pkg")
-                
-                index_dir = os.path.join(self.img_path, "var","pkg","index")
-                shutil.rmtree(index_dir)
-                self._run_local_tests()
-
         def test_bug_1873(self):
                 """Test to see if malformed actions cause tracebacks during
                 indexing for client or server."""
+                # Can't be moved to api search since this is to test for
+                # tracebacks
                 durl = self.dc.get_depot_url()
                 depotpath = self.dc.get_repodir()
                 server_manifest_path = os.path.join(depotpath, "pkg",
@@ -977,345 +551,11 @@
                 self._search_op(False, "6627937",
                     set(self.res_bogus_number_result))
 
-        def test_bug_2989_1(self):
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-
-                for f in self._dir_restore_functions:
-                        self.image_create(durl)
-
-                        self.pkg("rebuild-index")
-
-                        index_dir, index_dir_tmp = self._get_index_dirs()
-
-                        shutil.copytree(index_dir, index_dir_tmp)
-                
-                        self.pkg("install example_pkg")
-
-                        f(index_dir, index_dir_tmp)
-
-                        self.pkg("uninstall example_pkg")
-
-                        self.image_destroy()
-
-        def test_bug_2989_2(self):
-                # The low mem setting is to test for bug 6949
-                self._set_low_mem()
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.pkgsend_bulk(durl, self.another_pkg10)
-
-                for f in self._dir_restore_functions:
-
-                        self.image_create(durl)
-                        self.pkg("install example_pkg")
-
-                        index_dir, index_dir_tmp = self._get_index_dirs()
-                
-                        shutil.copytree(index_dir, index_dir_tmp)
-
-                        self.pkg("install another_pkg")
-
-                        f(index_dir, index_dir_tmp)
-
-                        self.pkg("uninstall another_pkg")
-
-                        self.image_destroy()
-                self._unset_low_mem()
-                
-        def test_bug_2989_3(self):
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.pkgsend_bulk(durl, self.example_pkg11)
-
-                for f in self._dir_restore_functions:
-                
-                        self.image_create(durl)
-                        self.pkg("install [email protected],5.11-0")
-
-                        index_dir, index_dir_tmp = self._get_index_dirs()
-
-                        shutil.copytree(index_dir, index_dir_tmp)
-
-                        self.pkg("install example_pkg")
-
-                        f(index_dir, index_dir_tmp)
-                        
-                        self.pkg("uninstall example_pkg")
-
-                        self.image_destroy()
-
-        def test_bug_2989_4(self):
-                # The low mem setting is to test for bug 6949
-                self._set_low_mem()
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.another_pkg10)
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.pkgsend_bulk(durl, self.example_pkg11)
-
-                for f in self._dir_restore_functions:
-                
-                        self.image_create(durl)
-                        self.pkg("install another_pkg")
-                
-                        index_dir, index_dir_tmp = self._get_index_dirs()
-                        
-                        shutil.copytree(index_dir, index_dir_tmp)
-
-                        self.pkg("install [email protected],5.11-0")
-
-                        f(index_dir, index_dir_tmp)
-
-                        self.pkg("image-update")
-
-                        self.image_destroy()
-                self._unset_low_mem()
-
-        def test_local_case_sensitive(self):
-                """Test local case sensitive search"""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-
-                self.image_create(durl)
-                self.pkg("install example_pkg")
-                self.pkg("search -l -I fooo", exit=1)
-                self.pkg("search -l -I fo*", exit=1)
-                self.pkg("search -l -I bar", exit=1)
-                self._search_op(False, "FOOO", self.res_local_foo, True)
-                self._search_op(False, "bAr", self.res_local_bar, True)
-
-        def test_weird_patterns(self):
-                """Test strange patterns to ensure they're handled correctly"""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-
-                self.image_create(durl)
-                self._search_op(True, "[*]", self.res_remote_star)
-                self._search_op(True, "[?]", self.res_remote_mark)
-                self._search_op(True, "[[]", self.res_remote_left_brace)
-                self._search_op(True, "[]]", self.res_remote_right_brace)
-                self._search_op(True, "FO[O]O", self.res_remote_foo)
-                self._search_op(True, "FO[?O]O", self.res_remote_foo)
-                self._search_op(True, "FO[*O]O", self.res_remote_foo)
-                self._search_op(True, "FO[]O]O", self.res_remote_foo)
-
-        def test_bug_3046(self):
-                """Checks if directories ending in / break the indexer."""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.bad_pkg10)
-                self.image_create(durl)
-                self.pkg("search -r foo")
-                self.pkg("search -r /", exit=1)
-
-        def test_bug_2849(self):
-                """Checks if things with spaces break the indexer."""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.space_pkg10)
-                self.image_create(durl)
-
-                self.pkg("install space_pkg")
-                time.sleep(1)
-                
-                self.pkgsend_bulk(durl, self.space_pkg10)
-
-                self.pkg("refresh")
-                self.pkg("install space_pkg")
-
-                self.pkg("search -l with", exit=1)
-                self.pkg("search -l with*")
-                self.pkg("search -l *space")
-                self.pkg("search -l unique_dir")
-                self.pkg("search -r with", exit=1)
-                self.pkg("search -r with*")
-                self.pkg("search -r *space")
-                self.pkgsend_bulk(durl, self.space_pkg10)
-                self.pkg("install space_pkg")
-                self.pkg("search -l with", exit=1)
-                self.pkg("search -l with*")
-                self.pkg("search -l *space")
-                self.pkg("search -l unique_dir")
-
-        def test_bug_2863(self):
-                """Test local case sensitive search"""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-
-                self.image_create(durl)
-                self._check_no_index()
-                self.pkg("install --no-index example_pkg")
-                self._check_no_index()
-                self.pkg("rebuild-index")
-                self._run_local_tests()
-                self.pkg("uninstall --no-index example_pkg")
-                # Running empty test because search will notice the index
-                # does not match the installed packages and complain.
-                self._run_local_empty_tests()
-                self.pkg("rebuild-index") 
-                self._run_local_empty_tests()
-                self.pkg("install example_pkg")
-                self._run_local_tests()
-                self.pkgsend_bulk(durl, self.example_pkg11)
-                self.pkg("refresh")
-                self.pkg("image-update --no-index")
-                # Running empty test because search will notice the index
-                # does not match the installed packages and complain.
-                self._run_local_empty_tests()
-                self.pkg("rebuild-index")
-                self._run_local_tests_example11_installed()
-                self.pkg("uninstall --no-index example_pkg")
-                # Running empty test because search will notice the index
-                # does not match the installed packages and complain.
-                self._run_local_empty_tests()
-                self.pkg("rebuild-index")
-                self._run_local_empty_tests()
-
-        def test_bug_4048_1(self):
-                """Checks whether the server deals with partial indexing."""
-                durl = self.dc.get_depot_url()
-                depotpath = self.dc.get_repodir()
-                tmp_dir = os.path.join(depotpath, "index", "TMP")
-                os.mkdir(tmp_dir)
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.image_create(durl)
-                self._run_remote_empty_tests()
-                os.rmdir(tmp_dir)
-                offset = 2
-                depot_logfile = os.path.join(self.get_test_prefix(),
-                    self.id(), "depot_logfile%d" % offset)
-                tmp_dc = self.start_depot(12000 + offset, depotpath,
-                    depot_logfile, refresh_index=True)
-                self._run_remote_tests()
-                tmp_dc.kill()
-
-        def test_bug_4048_2(self):
-                """Checks whether the server deals with partial indexing."""
-                durl = self.dc.get_depot_url()
-                depotpath = self.dc.get_repodir()
-                tmp_dir = os.path.join(depotpath, "index", "TMP")
-                os.mkdir(tmp_dir)
-                self.pkgsend_bulk(durl, self.space_pkg10)
-                self.image_create(durl)
-                self._run_remote_empty_tests()
-                os.rmdir(tmp_dir)
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self._run_remote_tests()
-                self.pkg("search -r unique_dir")
-                self.pkg("search -r with*")
-
-        def test_bug_4239(self):
-                """Tests whether categories are indexed and searched for
-                correctly."""
-
-                def _run_cat_tests(self, remote):
-                        self._search_op(remote, "System",
-                            self.res_cat_pkg10, case_sensitive=False)
-                        self._search_op(remote, "Security",
-                            self.res_cat_pkg10, case_sensitive=False)
-                        self._search_op(remote, "System/Security",
-                            self.res_cat_pkg10, case_sensitive=False)
-
-                def _run_cat2_tests(self, remote):
-                        self._search_op(remote, "Applications",
-                            self.res_cat2_pkg10, case_sensitive=False)
-                        self.pkg("search -r Sound")
-                        self._search_op(remote, "'\"Sound and Video\"'",
-                            self.res_cat2_pkg10, case_sensitive=False)
-                        self._search_op(remote, "Sound*",
-                            self.res_cat2_pkg10, case_sensitive=False)
-                        self._search_op(remote, "*Video",
-                            self.res_cat2_pkg10, case_sensitive=False)
-                        self._search_op(remote,
-                            "'\"Applications/Sound and Video\"'",
-                            self.res_cat2_pkg10, case_sensitive=False)
-                def _run_cat3_tests(self, remote):
-                        self._search_op(remote, "foo",
-                            self.res_cat3_pkg10,case_sensitive=False)
-                        self._search_op(remote, "baz",
-                            self.res_cat3_pkg10, case_sensitive=False)
-                        self._search_op(remote, "asda",
-                            self.res_cat3_pkg10, case_sensitive=False)
-                        self._search_op(remote, "foo/bar/baz/bill/beam/asda",
-                            self.res_cat3_pkg10, case_sensitive=False)
-
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.cat_pkg10)
-                self.pkgsend_bulk(durl, self.cat2_pkg10)
-                self.pkgsend_bulk(durl, self.cat3_pkg10)
-                self.pkgsend_bulk(durl, self.bad_cat_pkg10)
-                self.pkgsend_bulk(durl, self.bad_cat2_pkg10)
-                self.image_create(durl)
-
-                remote = True
-                _run_cat_tests(self, remote)
-                _run_cat2_tests(self, remote)
-                _run_cat3_tests(self, remote)
-
-                remote = False
-                self.pkg("install cat")
-                _run_cat_tests(self, remote)
-
-                self.pkg("install cat2")
-                _run_cat2_tests(self, remote)
-                
-                self.pkg("install cat3")
-                _run_cat3_tests(self, remote)
-                
-                self.pkg("install badcat")
-                self.pkg("install badcat2")
-                _run_cat_tests(self, remote)
-                _run_cat2_tests(self, remote)
-                _run_cat3_tests(self, remote)
-
-        def test_bug_6712_i386(self):
-                """Install one package, and run the search suite."""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.fat_pkg10)
-                
-                self.image_create(durl,
-                    additional_args="--variant variant.arch=i386")
-
-                remote = True
-                
-                self._search_op(remote, "'*'", self.res_remote_fat10_star)
-
-                self.pkg("install fat")
-                remote = False
-                self._search_op(remote, "'*'", self.res_local_fat10_i386_star)
-
-        def test_bug_6712_sparc(self):
-                """Install one package, and run the search suite."""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.fat_pkg10)
-                
-                self.image_create(durl,
-                    additional_args="--variant variant.arch=sparc")
-
-                remote = True
-                
-                self._search_op(remote, "'*'", self.res_remote_fat10_star)
-
-                self.pkg("install fat")
-                remote = False
-                self._search_op(remote, "'*'", self.res_local_fat10_sparc_star)
-
-        def test_bug_7660(self):
-                """Test that installing a package doesn't prevent searching on
-                package names from working on previously installed packages."""
-                durl = self.dc.get_depot_url()
-                self.pkgsend_bulk(durl, self.example_pkg10)
-                self.pkgsend_bulk(durl, self.fat_pkg10)
-                self.image_create(durl)
-                tmp_dir = os.path.join(self.img_path, "var", "pkg", "index",
-                    "TMP")
-                self.pkg("install example_pkg")
-                self.pkg("rebuild-index")
-                self.pkg("install fat")
-                self.assert_(not os.path.exists(tmp_dir))
-                self._run_local_tests()
-
         def test_bug_7835(self):
                 """Check that installing a package without in a non-empty
                 image without an index doesn't build an index."""
+                # This test can't be moved to t_api_search until bug 8497 has
+                # been resolved.
                 durl = self.dc.get_depot_url()
                 self.pkgsend_bulk(durl, self.fat_pkg10)
                 self.pkgsend_bulk(durl, self.example_pkg10)
@@ -1367,27 +607,5 @@
                     "%s/search/1/False_2_None_None_foo%%20%%3Cbar%%3E" % durl)
 
 
-class TestPkgSearchMulti(testutils.ManyDepotTestCase):
-
-        example_pkg10 = """
-            open [email protected],5.11-0
-            close """
-
-        def setUp(self):
-                testutils.ManyDepotTestCase.setUp(self, 2)
-
-                durl1 = self.dcs[1].get_depot_url()
-                durl2 = self.dcs[2].get_depot_url()
-                self.pkgsend_bulk(durl2, self.example_pkg10)
-
-                self.image_create(durl1, prefix = "test1")
-                self.pkg("set-publisher -O " + durl2 + " test2")
-
-        def test_bug_2955(self):
-                """See http://defect.opensolaris.org/bz/show_bug.cgi?id=2955"""
-                self.pkg("install example_pkg")
-                self.pkg("rebuild-index")
-                self.pkg("uninstall example_pkg")
-
 if __name__ == "__main__":
         unittest.main()