15822242 update-refresh.sh produces noise via cron email s12b13
authorthejaswini.k@oracle.com
Wed, 09 Jan 2013 10:30:32 +0530
changeset 2847 5c572d3a1276
parent 2844 3f428f7cb353
child 2848 6c8965cbcdee
15822242 update-refresh.sh produces noise via cron email 15744194 search -s with a url shouldn't look at other urls 15807844 pkg search for temporary sources fails without configured publisher 15847480 Space required after line 2779 in api_errors.py
src/modules/client/api.py
src/modules/client/api_errors.py
src/modules/client/transport/transport.py
src/svc/pkg-update.xml
src/tests/cli/t_pkg_search.py
--- a/src/modules/client/api.py	Fri Dec 21 14:37:56 2012 +1300
+++ b/src/modules/client/api.py	Wed Jan 09 10:30:32 2013 +0530
@@ -4352,16 +4352,20 @@
 
                 slist = []
                 for entry in servers:
-                        descriptive_name = None
                         if isinstance(entry, dict):
                                 origin = entry["origin"]
                                 try:
                                         pub = self._img.get_publisher(
                                             origin=origin)
+                                        pub_uri = publisher.RepositoryURI(
+                                            origin)
+                                        repo = publisher.Repository(
+                                            origins=[pub_uri])
                                 except apx.UnknownPublisher:
                                         pub = publisher.RepositoryURI(origin)
-                                        descriptive_name = origin
-                                slist.append((pub, None, descriptive_name))
+                                        repo = publisher.Repository(
+                                            origins=[pub])
+                                slist.append((pub, repo, origin))
                                 continue
 
                         # Must be a publisher object.
--- a/src/modules/client/api_errors.py	Fri Dec 21 14:37:56 2012 +1300
+++ b/src/modules/client/api_errors.py	Wed Jan 09 10:30:32 2013 +0530
@@ -2800,7 +2800,7 @@
                             img_linked
 
                 if lin_malformed is not None:
-                        err = _("Invalid linked image name '%s'."
+                        err = _("Invalid linked image name '%s'. "
                             "Linked image names have the following format "
                             "'<linked_image plugin>:<linked_image name>'") % \
                             lin_malformed
--- a/src/modules/client/transport/transport.py	Fri Dec 21 14:37:56 2012 +1300
+++ b/src/modules/client/transport/transport.py	Wed Jan 09 10:30:32 2013 +0530
@@ -632,10 +632,16 @@
                 # of origins for a publisher without incurring the significant
                 # overhead of performing file-based search unless the network-
                 # based resource is unavailable.
+                no_result_url = None
                 for d, retries, v in self.__gen_repo(pub, retry_count,
                     origin_only=True, prefer_remote=True, alt_repo=alt_repo,
                     operation="search", versions=[0, 1]):
 
+                        if retries == 1:
+                                no_result_url = None
+                        elif retries > 1 and no_result_url:
+                                continue
+
                         try:
                                 fobj = d.do_search(data, header,
                                     ccancel=ccancel, pub=pub)
@@ -663,7 +669,7 @@
                                         raise apx.UnsupportedSearchError(e.url,
                                             "search/1")
                                 elif e.code == httplib.NO_CONTENT:
-                                        raise apx.NegativeSearchResult(e.url)
+                                        no_result_url = e.url
                                 elif e.code in (httplib.BAD_REQUEST,
                                     errno.EINVAL):
                                         raise apx.MalformedSearchRequest(e.url)
@@ -678,8 +684,10 @@
                                         fobj = None
                                 else:
                                         raise
-
-                raise failures
+                if no_result_url:
+                        raise apx.NegativeSearchResult(no_result_url)
+                else:
+                        raise failures
 
         def get_ca_dir(self):
                 """Return the path to the directory that contains CA
--- a/src/svc/pkg-update.xml	Fri Dec 21 14:37:56 2012 +1300
+++ b/src/svc/pkg-update.xml	Wed Jan 09 10:30:32 2013 +0530
@@ -76,6 +76,14 @@
 		<propval name='duration' type='astring' value='transient' />
 	</property_group>
 
+	<!--
+        Create a property group to allow the update service to
+        record the time it last ran.
+        See /usr/lib/update-manager/update-refresh.sh
+	-->
+	<property_group name='update' type='application'>
+	</property_group>
+
 	<stability value='Unstable' />
 
 	<template>
--- a/src/tests/cli/t_pkg_search.py	Fri Dec 21 14:37:56 2012 +1300
+++ b/src/tests/cli/t_pkg_search.py	Wed Jan 09 10:30:32 2013 +0530
@@ -951,6 +951,67 @@
                 # Test rebuilding the index with a missing manifest.
                 self.pkg("rebuild-index")
 
+        def test_15807844(self):
+                """ Check that pkg search for temporary sources is successful
+                when there no publishers configured in the image."""
+
+                rurl = self.dc.get_repo_url()
+                self.pkgsend_bulk(rurl, self.example_pkg10)
+                self.image_create()
+                expected = \
+                "INDEX ACTION VALUE PACKAGE\n" \
+                "basename file bin/example_path pkg:/[email protected]\n"
+                self.pkg("search -s %s example_path" % self.rurl)
+                actual = self.reduceSpaces(self.output)
+                expected = self.reduceSpaces(expected)
+                self.assertEqualDiff(expected, actual)
+                self.pkg("search example_path", exit=1)
+
+
+class TestSearchMultiPublisher(pkg5unittest.ManyDepotTestCase):
+
+        same_pub1 = """
+            open [email protected],5.11-0
+            add dir mode=0755 owner=root group=bin path=/bin
+            add file tmp/samepub_file1 mode=0555 owner=root group=bin path=/bin/samepub_file1
+            close """
+
+        same_pub2 = """
+            open [email protected],5.11-0
+            add dir mode=0755 owner=root group=bin path=/bin
+            add file tmp/samepub_file2 mode=0555 owner=root group=bin path=/bin/samepub_file2
+            close """
+
+        misc_files = {
+            "tmp/samepub_file1": "magic",
+            "tmp/samepub_file2": "magic",
+        }
+
+        def setUp(self):
+                pkg5unittest.ManyDepotTestCase.setUp(self,["samepub", "samepub"],
+                    start_depots=True)
+                self.make_misc_files(self.misc_files)
+                self.durl1 = self.dcs[1].get_depot_url()
+                self.pkgsend_bulk(self.durl1, self.same_pub1, refresh_index=True)
+                self.durl2 = self.dcs[2].get_depot_url()
+                self.pkgsend_bulk(self.durl2, self.same_pub2, refresh_index=True)
+
+        def test_7140657(self):
+                """ Check that pkg search with -s works as intended when there are
+                two repositories with same publisher name configured."""
+
+                self.image_create(self.durl1, prefix="samepub")
+                self.pkg("set-publisher -g %s samepub" % self.durl2)
+                self.pkg("search -s %s samepub_file1" % self.durl1)
+
+                result_same_pub = \
+                "INDEX ACTION VALUE PACKAGE\n" \
+                "basename file bin/samepub_file1 pkg:/[email protected]\n"
+
+                actual = self.reduceSpaces(self.output)
+                expected = self.reduceSpaces(result_same_pub)
+                self.assertEqualDiff(expected, actual)
+                self.pkg("search -s %s samepub_file1" % self.durl2, exit=1)
 
 if __name__ == "__main__":
         unittest.main()