launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #11552
lp:~stevenk/launchpad/destroy-populate-project-sharing-policies into lp:launchpad
Steve Kowalik has proposed merging lp:~stevenk/launchpad/destroy-populate-project-sharing-policies into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1044371 in Launchpad itself: "Remove the garbo job that populates sharing policies"
https://bugs.launchpad.net/launchpad/+bug/1044371
For more details, see:
https://code.launchpad.net/~stevenk/launchpad/destroy-populate-project-sharing-policies/+merge/122442
PopulateProjectSharingPolicies is done. To thank it for its work, kick it and its tests out of the codebase.
--
https://code.launchpad.net/~stevenk/launchpad/destroy-populate-project-sharing-policies/+merge/122442
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~stevenk/launchpad/destroy-populate-project-sharing-policies into lp:launchpad.
=== modified file 'lib/lp/scripts/garbo.py'
--- lib/lp/scripts/garbo.py 2012-08-31 01:27:57 +0000
+++ lib/lp/scripts/garbo.py 2012-09-03 05:40:39 +0000
@@ -27,14 +27,7 @@
import iso8601
from psycopg2 import IntegrityError
import pytz
-from storm.expr import (
- And,
- Exists,
- In,
- Not,
- Select,
- Update,
- Or)
+from storm.expr import In
from storm.locals import (
Max,
Min,
@@ -56,10 +49,8 @@
BugWatchScheduler,
MAX_SAMPLE_SIZE,
)
-from lp.code.enums import BranchVisibilityRule
from lp.code.interfaces.revision import IRevisionSet
from lp.code.model.branchnamespace import BRANCH_POLICY_ALLOWED_TYPES
-from lp.code.model.branchvisibilitypolicy import BranchVisibilityTeamPolicy
from lp.code.model.codeimportevent import CodeImportEvent
from lp.code.model.codeimportresult import CodeImportResult
from lp.code.model.revision import (
@@ -73,7 +64,6 @@
IAccessPolicyGrantSource,
IAccessPolicySource,
)
-from lp.registry.model.commercialsubscription import CommercialSubscription
from lp.registry.model.person import Person
from lp.registry.model.product import Product
from lp.services.config import config
@@ -1010,59 +1000,6 @@
transaction.commit()
-class PopulateProjectSharingPolicies(TunableLoop):
- """Sets bug and branch sharing policies for non commercial projects."""
-
- maximum_chunk_size = 5000
-
- def __init__(self, log, abort_time=None):
- super(PopulateProjectSharingPolicies, self).__init__(log, abort_time)
- self.store = IMasterStore(Product)
-
- def getProducts(self):
- """ Load the products to process.
-
- We only want products which:
- - are non-commercial products which have neither bug nor
- branch sharing policy set
- - have private_bugs = false
- - have no branch visibility policies other than public
- """
- return self.store.find(
- Product.id,
- Not(
- Or(
- Exists(Select(1, tables=[CommercialSubscription],
- where=And(
- CommercialSubscription.product == Product.id,
- CommercialSubscription.date_expires > datetime.now(
- pytz.UTC)))),
- Product.private_bugs == True,
- Exists(Select(1, tables=[BranchVisibilityTeamPolicy],
- where=And(
- BranchVisibilityTeamPolicy.product == Product.id,
- BranchVisibilityTeamPolicy.rule !=
- BranchVisibilityRule.PUBLIC))),
- )),
- And(Product.bug_sharing_policy == None,
- Product.branch_sharing_policy == None)).order_by(Product.id)
-
- def isDone(self):
- return self.getProducts().is_empty()
-
- def __call__(self, chunk_size):
- products_to_process = self.getProducts()[:chunk_size]
- changes = {
- Product.bug_sharing_policy: 1,
- Product.branch_sharing_policy: 1
- }
- expr = Update(
- changes,
- where=Product.id.is_in(products_to_process))
- self.store.execute(expr, noresult=True)
- transaction.commit()
-
-
class UnusedAccessPolicyPruner(TunableLoop):
"""Deletes unused AccessPolicy and AccessPolicyGrants for products."""
@@ -1360,7 +1297,6 @@
UnusedSessionPruner,
DuplicateSessionPruner,
BugHeatUpdater,
- PopulateProjectSharingPolicies,
]
experimental_tunable_loops = []
=== modified file 'lib/lp/scripts/tests/test_garbo.py'
--- lib/lp/scripts/tests/test_garbo.py 2012-08-29 21:45:07 +0000
+++ lib/lp/scripts/tests/test_garbo.py 2012-09-03 05:40:39 +0000
@@ -19,7 +19,6 @@
In,
Min,
Not,
- Or,
SQL,
)
from storm.locals import (
@@ -44,10 +43,7 @@
BranchFormat,
RepositoryFormat,
)
-from lp.code.enums import (
- BranchVisibilityRule,
- CodeImportResultStatus,
- )
+from lp.code.enums import CodeImportResultStatus
from lp.code.interfaces.codeimportevent import ICodeImportEventSet
from lp.code.model.branchjob import (
BranchJob,
@@ -62,8 +58,6 @@
)
from lp.registry.interfaces.accesspolicy import IAccessPolicySource
from lp.registry.interfaces.person import IPersonSet
-from lp.registry.interfaces.product import IProductSet
-from lp.registry.model.product import Product
from lp.scripts.garbo import (
AntiqueSessionPruner,
BulkPruner,
@@ -114,10 +108,7 @@
TestCase,
TestCaseWithFactory,
)
-from lp.testing.dbuser import (
- dbuser,
- switch_dbuser,
- )
+from lp.testing.dbuser import switch_dbuser
from lp.testing.layers import (
DatabaseLayer,
LaunchpadScriptLayer,
@@ -1031,62 +1022,6 @@
self.runHourly()
self.assertNotEqual(old_update, naked_bug.heat_last_updated)
- def test_PopulateProjectSharingPolicies(self):
- # Non commercial projects have their bug and branch sharing policies
- # set.
- with dbuser('testadmin'):
- non_commercial_products = [
- self.factory.makeLegacyProduct()
- for i in range(10)]
- commercial_project = self.factory.makeLegacyProduct()
- self.factory.makeCommercialSubscription(commercial_project)
- configured_project = self.factory.makeProduct(
- bug_sharing_policy=BugSharingPolicy.PROPRIETARY)
- removeSecurityProxy(
- configured_project).branch_sharing_policy = None
- private_project = self.factory.makeLegacyProduct(private_bugs=True)
- project_with_bvp = self.factory.makeLegacyProduct()
- project_with_bvp.setBranchVisibilityTeamPolicy(
- None, BranchVisibilityRule.FORBIDDEN)
-
-
- def get_non_migrated_products():
- return IMasterStore(Product).find(
- Product,
- Or(
- Product.bug_sharing_policy == None,
- Product.branch_sharing_policy == None))
-
- self.runHourly()
-
- # Check only the expected projects have been migrated.
- # landscape and launchpad are projects in the test database which have
- # non public branch visibility policies so are also not migrated.
- product_set = getUtility(IProductSet)
- landscape = product_set.getByName('landscape')
- launchpad = product_set.getByName('launchpad')
- self.assertContentEqual(
- [commercial_project, configured_project, private_project,
- project_with_bvp, landscape, launchpad],
- get_non_migrated_products())
- # The non migrated projects still have their original policies.
- self.assertIsNone(commercial_project.bug_sharing_policy)
- self.assertIsNone(commercial_project.branch_sharing_policy)
- self.assertIsNone(private_project.bug_sharing_policy)
- self.assertIsNone(private_project.branch_sharing_policy)
- self.assertIsNone(project_with_bvp.bug_sharing_policy)
- self.assertIsNone(project_with_bvp.branch_sharing_policy)
- self.assertIsNone(configured_project.branch_sharing_policy)
- self.assertEquals(
- BugSharingPolicy.PROPRIETARY,
- configured_project.bug_sharing_policy)
- # The migrated projects have the expected policies.
- for product in non_commercial_products:
- self.assertEqual(
- BranchSharingPolicy.PUBLIC, product.branch_sharing_policy)
- self.assertEqual(
- BugSharingPolicy.PUBLIC, product.bug_sharing_policy)
-
def getAccessPolicyTypes(self, pillar):
return [
ap.type
Follow ups