← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:bug-search-feed-feature-rule into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:bug-search-feed-feature-rule into launchpad:master.

Commit message:
Add bugs.search_feed.disabled feature rule

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/430563

`config.launchpad.is_bug_search_feed_active` was implemented before feature rules existed, and it makes more sense as a feature rule.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:bug-search-feed-feature-rule into launchpad:master.
diff --git a/lib/lp/bugs/stories/feeds/xx-bug-atom.rst b/lib/lp/bugs/stories/feeds/xx-bug-atom.rst
index 0d9b210..6ab7aae 100644
--- a/lib/lp/bugs/stories/feeds/xx-bug-atom.rst
+++ b/lib/lp/bugs/stories/feeds/xx-bug-atom.rst
@@ -549,6 +549,13 @@ performance problem in production.
     # Restore the config.
     >>> config_data = config.pop("bug_search_feed_data")
 
+    >>> from lp.services.features.testing import FeatureFixture
+    >>> with FeatureFixture({"bugs.search_feed.disabled": "true"}):
+    ...     browser.open(url)
+    Traceback (most recent call last):
+    ...
+    zope.security.interfaces.Unauthorized: Bug search feed deactivated
+
 The bug search feed can be tested after setting is_bug_search_feed_active
 to True.
 
diff --git a/lib/lp/bugs/stories/feeds/xx-bug-html.rst b/lib/lp/bugs/stories/feeds/xx-bug-html.rst
index d6cd0e4..0ee7850 100644
--- a/lib/lp/bugs/stories/feeds/xx-bug-html.rst
+++ b/lib/lp/bugs/stories/feeds/xx-bug-html.rst
@@ -222,6 +222,13 @@ performance problem in production.
     ...
     zope.security.interfaces.Unauthorized: Bug search feed deactivated
 
+    >>> from lp.services.features.testing import FeatureFixture
+    >>> with FeatureFixture({"bugs.search_feed.disabled": "true"}):
+    ...     browser.open(url)
+    Traceback (most recent call last):
+    ...
+    zope.security.interfaces.Unauthorized: Bug search feed deactivated
+
 The bug search feed can be tested after setting is_bug_search_feed_active
 to True.
 
diff --git a/lib/lp/services/config/schema-lazr.conf b/lib/lp/services/config/schema-lazr.conf
index 82fdc73..45fc442 100644
--- a/lib/lp/services/config/schema-lazr.conf
+++ b/lib/lp/services/config/schema-lazr.conf
@@ -1173,6 +1173,7 @@ bzr_imports_root_url: http://escudero.ubuntu.com:680/
 
 # This key allows us to selectively disable the bug search feeds
 # because of performance concerns.
+# Deprecated in favour of the bugs.search_feed.disabled feature rule.
 # datatype: boolean
 is_bug_search_feed_active: True
 
diff --git a/lib/lp/services/feeds/browser.py b/lib/lp/services/feeds/browser.py
index e656fee..80a37af 100644
--- a/lib/lp/services/feeds/browser.py
+++ b/lib/lp/services/feeds/browser.py
@@ -44,6 +44,7 @@ from lp.registry.interfaces.pillar import IPillarNameSet
 from lp.registry.interfaces.product import IProduct
 from lp.registry.interfaces.projectgroup import IProjectGroup
 from lp.services.config import config
+from lp.services.features import getFeatureFlag
 from lp.services.feeds.interfaces.application import IFeedsApplication
 from lp.services.webapp import (
     Navigation,
@@ -126,7 +127,10 @@ class FeedsNavigation(Navigation):
                 raise NotFound(self, "", self.request)
             bug_id = stack.pop()
             if bug_id.startswith("+"):
-                if config.launchpad.is_bug_search_feed_active:
+                if (
+                    config.launchpad.is_bug_search_feed_active
+                    and not getFeatureFlag("bugs.search_feed.disabled")
+                ):
                     return getUtility(IBugTaskSet)
                 else:
                     raise Unauthorized("Bug search feed deactivated")
diff --git a/lib/lp/services/feeds/stories/xx-navigation.rst b/lib/lp/services/feeds/stories/xx-navigation.rst
index f64780c..2b13322 100644
--- a/lib/lp/services/feeds/stories/xx-navigation.rst
+++ b/lib/lp/services/feeds/stories/xx-navigation.rst
@@ -70,12 +70,6 @@ has to be refreshed.
 XXX: statik 2007-10-18 bug=154114: We don't yet normalize case in
 query strings.
 
-    >>> from lp.services.config import config
-    >>> bug_search_feed_data = """
-    ...     [launchpad]
-    ...     is_bug_search_feed_active: True
-    ...     """
-    >>> config.push("bug_search_feed_data", bug_search_feed_data)
     >>> browser.open(
     ...     "http://feeds.launchpad.test/bugs/+bugs.atom?";
     ...     "field.scope=all&search=Search+Bug+Reports&aaa=foo"
@@ -149,10 +143,6 @@ These html feeds should only exist on feeds.launchpad.test:
     ...     "field.scope=all&field.scope.target="
     ... )
 
-Revert configuration change after tests are finished.
-
-    >>> config_data = config.pop("bug_search_feed_data")
-
 
 Favicon
 -------
diff --git a/lib/lp/services/feeds/stories/xx-security.rst b/lib/lp/services/feeds/stories/xx-security.rst
index eb999cd..6184af3 100644
--- a/lib/lp/services/feeds/stories/xx-security.rst
+++ b/lib/lp/services/feeds/stories/xx-security.rst
@@ -33,12 +33,6 @@ There should be zero entries in these feeds, since all the bugs are private.
     >>> BeautifulSoup(browser.contents, "xml")("entry")
     []
 
-    >>> from lp.services.config import config
-    >>> bug_search_feed_data = """
-    ...     [launchpad]
-    ...     is_bug_search_feed_active: True
-    ...     """
-    >>> config.push("bug_search_feed_data", bug_search_feed_data)
     >>> browser.open(
     ...     "http://feeds.launchpad.test/bugs/+bugs.atom?";
     ...     "field.searchtext=&search=Search+Bug+Reports&"
@@ -95,7 +89,3 @@ these HTML feeds, since all the bugs are private.
     ...
     >>> BeautifulSoup(browser.contents, "xml")("entry")
     []
-
-Revert configuration change after tests are finished.
-
-    >>> config_data = config.pop("bug_search_feed_data")