Merge ~cjwatson/launchpad:rename-database-policies into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: ba00b0bdd1f0b378747e1fb45b96af552f9e217c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:rename-database-policies
Merge into: launchpad:master
Diff against target: 701 lines (+111/-112)
15 files modified
cronscripts/rosetta-export-queue.py (+2/-2)
lib/lp/archivepublisher/scripts/generate_contents_files.py (+2/-2)
lib/lp/registry/model/person.py (+3/-3)
lib/lp/services/database/doc/db-policy.txt (+20/-20)
lib/lp/services/database/policy.py (+12/-13)
lib/lp/services/librarian/tests/test_client.py (+5/-5)
lib/lp/services/webapp/adapter.py (+2/-2)
lib/lp/services/webapp/database.zcml (+2/-2)
lib/lp/services/webapp/doc/webapp-publication.txt (+2/-2)
lib/lp/services/webapp/login.py (+7/-7)
lib/lp/services/webapp/tests/test_dbpolicy.py (+30/-30)
lib/lp/services/webapp/tests/test_login.py (+15/-15)
lib/lp/soyuz/stories/soyuz/xx-private-builds.txt (+2/-2)
lib/lp/testing/factory.py (+2/-2)
lib/lp/translations/scripts/po_export_queue.py (+5/-5)
Reviewer Review Type Date Requested Status
Jürgen Gmach Approve
Review via email: mp+411256@code.launchpad.net

Commit message

Rename database policies to use primary/standby terminology

To post a comment you must log in.
Revision history for this message
Jürgen Gmach (jugmac00) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cronscripts/rosetta-export-queue.py b/cronscripts/rosetta-export-queue.py
2index b9fb461..6427347 100755
3--- a/cronscripts/rosetta-export-queue.py
4+++ b/cronscripts/rosetta-export-queue.py
5@@ -5,7 +5,7 @@
6
7 import _pythonpath # noqa: F401
8
9-from lp.services.database.policy import SlaveDatabasePolicy
10+from lp.services.database.policy import StandbyDatabasePolicy
11 from lp.services.scripts.base import LaunchpadCronScript
12 from lp.translations.scripts.po_export_queue import process_queue
13
14@@ -14,7 +14,7 @@ class RosettaExportQueue(LaunchpadCronScript):
15 """Translation exports."""
16
17 def main(self):
18- with SlaveDatabasePolicy():
19+ with StandbyDatabasePolicy():
20 process_queue(self.txn, self.logger)
21
22
23diff --git a/lib/lp/archivepublisher/scripts/generate_contents_files.py b/lib/lp/archivepublisher/scripts/generate_contents_files.py
24index 2fa9d60..14e6416 100644
25--- a/lib/lp/archivepublisher/scripts/generate_contents_files.py
26+++ b/lib/lp/archivepublisher/scripts/generate_contents_files.py
27@@ -24,7 +24,7 @@ from lp.services.command_spawner import (
28 from lp.services.config import config
29 from lp.services.database.policy import (
30 DatabaseBlockedPolicy,
31- SlaveOnlyDatabasePolicy,
32+ StandbyOnlyDatabasePolicy,
33 )
34 from lp.services.osutils import ensure_directory_exists
35 from lp.services.scripts.base import (
36@@ -304,5 +304,5 @@ class GenerateContentsFiles(LaunchpadCronScript):
37 def main(self):
38 """See `LaunchpadScript`."""
39 # This code has no need to alter the database.
40- with SlaveOnlyDatabasePolicy():
41+ with StandbyOnlyDatabasePolicy():
42 self.process()
43diff --git a/lib/lp/registry/model/person.py b/lib/lp/registry/model/person.py
44index 79d793e..0d4f5f9 100644
45--- a/lib/lp/registry/model/person.py
46+++ b/lib/lp/registry/model/person.py
47@@ -251,7 +251,7 @@ from lp.services.database.datetimecol import UtcDateTimeCol
48 from lp.services.database.decoratedresultset import DecoratedResultSet
49 from lp.services.database.enumcol import EnumCol
50 from lp.services.database.interfaces import IStore
51-from lp.services.database.policy import MasterDatabasePolicy
52+from lp.services.database.policy import PrimaryDatabasePolicy
53 from lp.services.database.sqlbase import (
54 convert_storm_clause_to_string,
55 cursor,
56@@ -3332,10 +3332,10 @@ class PersonSet:
57 "OpenID identifier must not be empty.")
58
59 # Load the EmailAddress, Account and OpenIdIdentifier records
60- # from the master (if they exist). We use the master to avoid
61+ # from the primary (if they exist). We use the primary to avoid
62 # possible replication lag issues but this might actually be
63 # unnecessary.
64- with MasterDatabasePolicy():
65+ with PrimaryDatabasePolicy():
66 identifier = IStore(OpenIdIdentifier).find(
67 OpenIdIdentifier, identifier=openid_identifier).one()
68 email = getUtility(IEmailAddressSet).getByEmail(email_address)
69diff --git a/lib/lp/services/database/doc/db-policy.txt b/lib/lp/services/database/doc/db-policy.txt
70index 48255e9..17dc147 100644
71--- a/lib/lp/services/database/doc/db-policy.txt
72+++ b/lib/lp/services/database/doc/db-policy.txt
73@@ -1,15 +1,15 @@
74 Storm Stores & Database Policies
75 ================================
76
77-Launchpad has multiple master and slave databases. Changes to data are
78-made on the master and replicated asynchronously to the slave
79-databases. Slave databases will usually lag a few seconds behind their
80-master. Under high load they may lag a few minutes behind, during
81+Launchpad has multiple primary and standby databases. Changes to data are
82+made on the primary and replicated asynchronously to the standby
83+databases. Standby databases will usually lag a few seconds behind their
84+primary. Under high load they may lag a few minutes behind, during
85 maintenance they may lag a few hours behind and if things explode
86 while admins are on holiday they may lag days behind.
87
88-If know your code needs to change data, or must have the latest posible
89-information, you retrieve objects from the master databases that stores
90+If you know your code needs to change data, or must have the latest possible
91+information, you retrieve objects from the primary database that stores
92 the data for your database class.
93
94 >>> from lp.services.database.interfaces import IMasterStore
95@@ -24,12 +24,12 @@ the data for your database class.
96
97 Sometimes though we know we will not make changes and don't care much
98 if the information is a little out of date. In these cases you should
99-explicitly retrieve objects from a slave.
100+explicitly retrieve objects from a standby.
101
102-The more agressively we retrieve objects from slave databases instead
103-of the master, the better the overall performance of Launchpad will be.
104-We can distribute this load over many slave databases but are limited to
105-a single master.
106+The more aggressively we retrieve objects from standby databases instead
107+of the primary, the better the overall performance of Launchpad will be.
108+We can distribute this load over many standby databases but are limited to
109+a single primary.
110
111 >>> from lp.services.database.interfaces import ISlaveStore
112 >>> ro_janitor = ISlaveStore(Person).find(
113@@ -57,28 +57,28 @@ depends on the currently installed database policy.
114 True
115
116 As you can see, the default database policy retrieves objects from
117-the master database. This allows our code written before database
118+the primary database. This allows our code written before database
119 replication was implemented to keep working.
120
121 To alter this behaviour, you can install a different database policy.
122
123- >>> from lp.services.database.policy import SlaveDatabasePolicy
124- >>> with SlaveDatabasePolicy():
125+ >>> from lp.services.database.policy import StandbyDatabasePolicy
126+ >>> with StandbyDatabasePolicy():
127 ... default_janitor = IStore(Person).find(
128 ... Person, Person.name == 'janitor').one()
129 >>> default_janitor is writable_janitor
130 False
131
132 The database policy can also affect what happens when objects are
133-explicitly retrieved from a slave or master database. For example,
134+explicitly retrieved from a standby or primary database. For example,
135 if we have code that needs to run during database maintenance or
136-code we want to prove only accesses slave database resources, we can
137-raise an exception if an attempt is made to access master database
138+code we want to prove only accesses standby database resources, we can
139+raise an exception if an attempt is made to access primary database
140 resources.
141
142 >>> from lp.services.database.policy import (
143- ... SlaveOnlyDatabasePolicy)
144- >>> with SlaveOnlyDatabasePolicy():
145+ ... StandbyOnlyDatabasePolicy)
146+ >>> with StandbyOnlyDatabasePolicy():
147 ... whoops = IMasterStore(Person).find(
148 ... Person, Person.name == 'janitor').one()
149 Traceback (most recent call last):
150@@ -103,7 +103,7 @@ IStoreSelector utility for cases where the 'with' syntax cannot
151 be used.
152
153 >>> from lp.services.database.interfaces import IStoreSelector
154- >>> getUtility(IStoreSelector).push(SlaveDatabasePolicy())
155+ >>> getUtility(IStoreSelector).push(StandbyDatabasePolicy())
156 >>> try:
157 ... default_janitor = IStore(Person).find(
158 ... Person, Person.name == 'janitor').one()
159diff --git a/lib/lp/services/database/policy.py b/lib/lp/services/database/policy.py
160index 803d4bc..a347060 100644
161--- a/lib/lp/services/database/policy.py
162+++ b/lib/lp/services/database/policy.py
163@@ -7,9 +7,9 @@ __all__ = [
164 'BaseDatabasePolicy',
165 'DatabaseBlockedPolicy',
166 'LaunchpadDatabasePolicy',
167- 'MasterDatabasePolicy',
168- 'SlaveDatabasePolicy',
169- 'SlaveOnlyDatabasePolicy',
170+ 'PrimaryDatabasePolicy',
171+ 'StandbyDatabasePolicy',
172+ 'StandbyOnlyDatabasePolicy',
173 ]
174
175 from datetime import (
176@@ -192,10 +192,10 @@ class DatabaseBlockedPolicy(BaseDatabasePolicy):
177 raise DisallowedStore(name, flavor)
178
179
180-class MasterDatabasePolicy(BaseDatabasePolicy):
181+class PrimaryDatabasePolicy(BaseDatabasePolicy):
182 """`IDatabasePolicy` that selects the MASTER_FLAVOR by default.
183
184- Slave databases can still be accessed if requested explicitly.
185+ Standby databases can still be accessed if requested explicitly.
186
187 This policy is used for XMLRPC and WebService requests which don't
188 support session cookies. It is also used when no policy has been
189@@ -204,15 +204,15 @@ class MasterDatabasePolicy(BaseDatabasePolicy):
190 default_flavor = MASTER_FLAVOR
191
192
193-class SlaveDatabasePolicy(BaseDatabasePolicy):
194+class StandbyDatabasePolicy(BaseDatabasePolicy):
195 """`IDatabasePolicy` that selects the SLAVE_FLAVOR by default.
196
197- Access to a master can still be made if requested explicitly.
198+ Access to the primary can still be made if requested explicitly.
199 """
200 default_flavor = SLAVE_FLAVOR
201
202
203-class SlaveOnlyDatabasePolicy(BaseDatabasePolicy):
204+class StandbyOnlyDatabasePolicy(BaseDatabasePolicy):
205 """`IDatabasePolicy` that only allows access to SLAVE_FLAVOR stores.
206
207 This policy is used for Feeds requests and other always-read only request.
208@@ -223,8 +223,7 @@ class SlaveOnlyDatabasePolicy(BaseDatabasePolicy):
209 """See `IDatabasePolicy`."""
210 if flavor == MASTER_FLAVOR:
211 raise DisallowedStore(flavor)
212- return super(SlaveOnlyDatabasePolicy, self).getStore(
213- name, SLAVE_FLAVOR)
214+ return super().getStore(name, SLAVE_FLAVOR)
215
216
217 def LaunchpadDatabasePolicyFactory(request):
218@@ -375,10 +374,10 @@ def WebServiceDatabasePolicyFactory(request):
219 """
220 # If a session cookie was sent with the request, use the
221 # standard Launchpad database policy for load balancing to
222- # the slave databases. The javascript web service libraries
223+ # the standby databases. The javascript web service libraries
224 # send the session cookie for authenticated users.
225 cookie_name = getUtility(IClientIdManager).namespace
226 if cookie_name in request.cookies:
227 return LaunchpadDatabasePolicy(request)
228- # Otherwise, use the master only web service database policy.
229- return MasterDatabasePolicy(request)
230+ # Otherwise, use the primary only web service database policy.
231+ return PrimaryDatabasePolicy(request)
232diff --git a/lib/lp/services/librarian/tests/test_client.py b/lib/lp/services/librarian/tests/test_client.py
233index a5528f9..99b8369 100644
234--- a/lib/lp/services/librarian/tests/test_client.py
235+++ b/lib/lp/services/librarian/tests/test_client.py
236@@ -26,7 +26,7 @@ import transaction
237 from lp.services.config import config
238 from lp.services.daemons.tachandler import TacTestSetup
239 from lp.services.database.interfaces import ISlaveStore
240-from lp.services.database.policy import SlaveDatabasePolicy
241+from lp.services.database.policy import StandbyDatabasePolicy
242 from lp.services.database.sqlbase import block_implicit_flushes
243 from lp.services.librarian import client as client_module
244 from lp.services.librarian.client import (
245@@ -293,14 +293,14 @@ class LibrarianClientTestCase(TestCase):
246 client.addFile,
247 'sample.txt', 7, io.BytesIO(b'sample'), 'text/plain')
248
249- def test_addFile_uses_master(self):
250+ def test_addFile_uses_primary(self):
251 # addFile is a write operation, so it should always use the
252- # master store, even if the slave is the default. Close the
253- # slave store and try to add a file, verifying that the master
254+ # primary store, even if the standby is the default. Close the
255+ # standby store and try to add a file, verifying that the primary
256 # is used.
257 client = LibrarianClient()
258 ISlaveStore(LibraryFileAlias).close()
259- with SlaveDatabasePolicy():
260+ with StandbyDatabasePolicy():
261 alias_id = client.addFile(
262 'sample.txt', 6, io.BytesIO(b'sample'), 'text/plain')
263 transaction.commit()
264diff --git a/lib/lp/services/webapp/adapter.py b/lib/lp/services/webapp/adapter.py
265index 0792cac..816f206 100644
266--- a/lib/lp/services/webapp/adapter.py
267+++ b/lib/lp/services/webapp/adapter.py
268@@ -60,7 +60,7 @@ from lp.services.database.interfaces import (
269 MASTER_FLAVOR,
270 SLAVE_FLAVOR,
271 )
272-from lp.services.database.policy import MasterDatabasePolicy
273+from lp.services.database.policy import PrimaryDatabasePolicy
274 from lp.services.database.postgresql import ConnectionString
275 from lp.services.log.loglevels import DEBUG2
276 from lp.services.stacktrace import (
277@@ -749,7 +749,7 @@ class StoreSelector:
278 """See `IStoreSelector`."""
279 db_policy = StoreSelector.get_current()
280 if db_policy is None:
281- db_policy = MasterDatabasePolicy(None)
282+ db_policy = PrimaryDatabasePolicy(None)
283 return db_policy.getStore(name, flavor)
284
285
286diff --git a/lib/lp/services/webapp/database.zcml b/lib/lp/services/webapp/database.zcml
287index 0655a5f..2d9fcd1 100644
288--- a/lib/lp/services/webapp/database.zcml
289+++ b/lib/lp/services/webapp/database.zcml
290@@ -13,7 +13,7 @@
291 <adapter
292 for="zope.publisher.interfaces.xmlrpc.IXMLRPCRequest"
293 provides="lp.services.database.interfaces.IDatabasePolicy"
294- factory="lp.services.database.policy.MasterDatabasePolicy"
295+ factory="lp.services.database.policy.PrimaryDatabasePolicy"
296 />
297 <adapter
298 for="lp.layers.WebServiceLayer"
299@@ -23,7 +23,7 @@
300 <adapter
301 for="lp.layers.FeedsLayer"
302 provides="lp.services.database.interfaces.IDatabasePolicy"
303- factory="lp.services.database.policy.SlaveOnlyDatabasePolicy"
304+ factory="lp.services.database.policy.StandbyOnlyDatabasePolicy"
305 />
306
307 <!-- Storm Store selector. -->
308diff --git a/lib/lp/services/webapp/doc/webapp-publication.txt b/lib/lp/services/webapp/doc/webapp-publication.txt
309index 98f1fd0..5bf86ce 100644
310--- a/lib/lp/services/webapp/doc/webapp-publication.txt
311+++ b/lib/lp/services/webapp/doc/webapp-publication.txt
312@@ -1134,11 +1134,11 @@ principal's access_level and scope will match what was specified in the
313 token.
314
315 >>> from lp.registry.interfaces.product import IProductSet
316- >>> from lp.services.database.policy import MasterDatabasePolicy
317+ >>> from lp.services.database.policy import PrimaryDatabasePolicy
318 >>> from lp.services.database.interfaces import IStoreSelector
319 >>> from lp.services.oauth.interfaces import IOAuthConsumerSet
320 >>> from lp.services.webapp.interfaces import OAuthPermission
321- >>> getUtility(IStoreSelector).push(MasterDatabasePolicy())
322+ >>> getUtility(IStoreSelector).push(PrimaryDatabasePolicy())
323 >>> salgado = getUtility(IPersonSet).getByName('salgado')
324 >>> consumer = getUtility(IOAuthConsumerSet).getByKey(u'foobar123451432')
325 >>> token, _ = consumer.newRequestToken()
326diff --git a/lib/lp/services/webapp/login.py b/lib/lp/services/webapp/login.py
327index 4ae264c..82f38e1 100644
328--- a/lib/lp/services/webapp/login.py
329+++ b/lib/lp/services/webapp/login.py
330@@ -47,7 +47,7 @@ from lp.registry.interfaces.person import (
331 TeamEmailAddressError,
332 )
333 from lp.services.config import config
334-from lp.services.database.policy import MasterDatabasePolicy
335+from lp.services.database.policy import PrimaryDatabasePolicy
336 from lp.services.identity.interfaces.account import (
337 AccountDeceasedError,
338 AccountSuspendedError,
339@@ -361,15 +361,15 @@ class OpenIDCallbackView(OpenIDLogin):
340 If the account is suspended, we stop and render an error page.
341
342 We also update the 'last_write' key in the session if we've done any
343- DB writes, to ensure subsequent requests use the master DB and see
344+ DB writes, to ensure subsequent requests use the primary DB and see
345 the changes we just did.
346 """
347 identifier = self.openid_response.identity_url.split('/')[-1]
348 identifier = six.ensure_text(identifier, encoding='ascii')
349 should_update_last_write = False
350- # Force the use of the master database to make sure a lagged slave
351- # doesn't fool us into creating a Person/Account when one already
352- # exists.
353+ # Force the use of the primary database to make sure a lagged
354+ # standby doesn't fool us into creating a Person/Account when one
355+ # already exists.
356 person_set = getUtility(IPersonSet)
357 email_address, full_name = self._getEmailAddressAndFullName()
358 try:
359@@ -393,7 +393,7 @@ class OpenIDCallbackView(OpenIDLogin):
360 self.discharge_macaroon_raw = (
361 self.macaroon_response.discharge_macaroon_raw)
362
363- with MasterDatabasePolicy():
364+ with PrimaryDatabasePolicy():
365 self.login(person)
366
367 if self.params.get('discharge_macaroon_field'):
368@@ -402,7 +402,7 @@ class OpenIDCallbackView(OpenIDLogin):
369 if should_update_last_write:
370 # This is a GET request but we changed the database, so update
371 # session_data['last_write'] to make sure further requests use
372- # the master DB and thus see the changes we've just made.
373+ # the primary DB and thus see the changes we've just made.
374 session_data = ISession(self.request)['lp.dbpolicy']
375 session_data['last_write'] = datetime.utcnow()
376 self._redirect()
377diff --git a/lib/lp/services/webapp/tests/test_dbpolicy.py b/lib/lp/services/webapp/tests/test_dbpolicy.py
378index c418683..a8eac12 100644
379--- a/lib/lp/services/webapp/tests/test_dbpolicy.py
380+++ b/lib/lp/services/webapp/tests/test_dbpolicy.py
381@@ -45,9 +45,9 @@ from lp.services.database.interfaces import (
382 from lp.services.database.policy import (
383 BaseDatabasePolicy,
384 LaunchpadDatabasePolicy,
385- MasterDatabasePolicy,
386- SlaveDatabasePolicy,
387- SlaveOnlyDatabasePolicy,
388+ PrimaryDatabasePolicy,
389+ StandbyDatabasePolicy,
390+ StandbyOnlyDatabasePolicy,
391 )
392 from lp.services.webapp.servers import LaunchpadTestRequest
393 from lp.testing import TestCase
394@@ -98,13 +98,13 @@ class BaseDatabasePolicyTestCase(ImplicitDatabasePolicyTestCase):
395 self.assertProvides(self.policy, IDatabasePolicy)
396
397
398-class SlaveDatabasePolicyTestCase(BaseDatabasePolicyTestCase):
399- """Tests for the `SlaveDatabasePolicy`."""
400+class StandbyDatabasePolicyTestCase(BaseDatabasePolicyTestCase):
401+ """Tests for the `StandbyDatabasePolicy`."""
402
403 def setUp(self):
404 if self.policy is None:
405- self.policy = SlaveDatabasePolicy()
406- super(SlaveDatabasePolicyTestCase, self).setUp()
407+ self.policy = StandbyDatabasePolicy()
408+ super().setUp()
409
410 def test_defaults(self):
411 for store in ALL_STORES:
412@@ -119,12 +119,12 @@ class SlaveDatabasePolicyTestCase(BaseDatabasePolicyTestCase):
413 IMasterStore)
414
415
416-class SlaveOnlyDatabasePolicyTestCase(SlaveDatabasePolicyTestCase):
417- """Tests for the `SlaveDatabasePolicy`."""
418+class StandbyOnlyDatabasePolicyTestCase(StandbyDatabasePolicyTestCase):
419+ """Tests for the `StandbyOnlyDatabasePolicy`."""
420
421 def setUp(self):
422- self.policy = SlaveOnlyDatabasePolicy()
423- super(SlaveOnlyDatabasePolicyTestCase, self).setUp()
424+ self.policy = StandbyOnlyDatabasePolicy()
425+ super().setUp()
426
427 def test_master_allowed(self):
428 for store in ALL_STORES:
429@@ -133,15 +133,15 @@ class SlaveOnlyDatabasePolicyTestCase(SlaveDatabasePolicyTestCase):
430 getUtility(IStoreSelector).get, store, MASTER_FLAVOR)
431
432
433-class MasterDatabasePolicyTestCase(BaseDatabasePolicyTestCase):
434- """Tests for the `MasterDatabasePolicy`."""
435+class PrimaryDatabasePolicyTestCase(BaseDatabasePolicyTestCase):
436+ """Tests for the `PrimaryDatabasePolicy`."""
437
438 def setUp(self):
439- self.policy = MasterDatabasePolicy()
440- super(MasterDatabasePolicyTestCase, self).setUp()
441+ self.policy = PrimaryDatabasePolicy()
442+ super().setUp()
443
444- def test_XMLRPCRequest_uses_MasterPolicy(self):
445- """XMLRPC should always use the master flavor, since they always
446+ def test_XMLRPCRequest_uses_PrimaryDatabasePolicy(self):
447+ """XMLRPC should always use the primary flavor, since they always
448 use POST and do not support session cookies.
449 """
450 request = LaunchpadTestRequest(
451@@ -149,22 +149,22 @@ class MasterDatabasePolicyTestCase(BaseDatabasePolicyTestCase):
452 setFirstLayer(request, IXMLRPCRequest)
453 policy = getAdapter(request, IDatabasePolicy)
454 self.assertTrue(
455- isinstance(policy, MasterDatabasePolicy),
456- "Expected MasterDatabasePolicy, not %s." % policy)
457+ isinstance(policy, PrimaryDatabasePolicy),
458+ "Expected PrimaryDatabasePolicy, not %s." % policy)
459
460- def test_slave_allowed(self):
461- # We get the master store even if the slave was requested.
462+ def test_standby_allowed(self):
463+ # We get the primary store even if the standby was requested.
464 for store in ALL_STORES:
465 self.assertProvides(
466 getUtility(IStoreSelector).get(store, SLAVE_FLAVOR),
467 ISlaveStore)
468
469
470-class LaunchpadDatabasePolicyTestCase(SlaveDatabasePolicyTestCase):
471+class LaunchpadDatabasePolicyTestCase(StandbyDatabasePolicyTestCase):
472 """Fuller LaunchpadDatabasePolicy tests are in the page tests.
473
474 This test just checks the defaults, which is the same as the
475- slave policy for unauthenticated requests.
476+ standby policy for unauthenticated requests.
477 """
478
479 def setUp(self):
480@@ -176,8 +176,8 @@ class LaunchpadDatabasePolicyTestCase(SlaveDatabasePolicyTestCase):
481 class LayerDatabasePolicyTestCase(TestCase):
482 layer = FunctionalLayer
483
484- def test_FeedsLayer_uses_SlaveDatabasePolicy(self):
485- """FeedsRequest should use the SlaveDatabasePolicy since they
486+ def test_FeedsLayer_uses_StandbyOnlyDatabasePolicy(self):
487+ """FeedsRequest should use the StandbyOnlyDatabasePolicy since they
488 are read-only in nature. Also we don't want to send session cookies
489 over them.
490 """
491@@ -185,10 +185,10 @@ class LayerDatabasePolicyTestCase(TestCase):
492 SERVER_URL='http://feeds.launchpad.test')
493 setFirstLayer(request, FeedsLayer)
494 policy = IDatabasePolicy(request)
495- self.assertIsInstance(policy, SlaveOnlyDatabasePolicy)
496+ self.assertIsInstance(policy, StandbyOnlyDatabasePolicy)
497
498- def test_WebServiceRequest_uses_MasterDatabasePolicy(self):
499- """WebService requests should always use the master flavor, since
500+ def test_WebServiceRequest_uses_PrimaryDatabasePolicy(self):
501+ """WebService requests should always use the primary flavor, since
502 it's likely that clients won't support cookies and thus mixing read
503 and write requests will result in incoherent views of the data.
504
505@@ -201,12 +201,12 @@ class LayerDatabasePolicyTestCase(TestCase):
506 request = LaunchpadTestRequest(SERVER_URL=server_url)
507 setFirstLayer(request, WebServiceLayer)
508 policy = IDatabasePolicy(request)
509- self.assertIsInstance(policy, MasterDatabasePolicy)
510+ self.assertIsInstance(policy, PrimaryDatabasePolicy)
511
512 def test_WebServiceRequest_uses_LaunchpadDatabasePolicy(self):
513 """WebService requests with a session cookie will use the
514 standard LaunchpadDatabasePolicy so their database queries
515- can be outsourced to a slave database when possible.
516+ can be outsourced to a standby database when possible.
517 """
518 api_prefix = getUtility(
519 IWebServiceConfiguration).active_versions[0]
520diff --git a/lib/lp/services/webapp/tests/test_login.py b/lib/lp/services/webapp/tests/test_login.py
521index 9abc359..c5a8956 100644
522--- a/lib/lp/services/webapp/tests/test_login.py
523+++ b/lib/lp/services/webapp/tests/test_login.py
524@@ -50,7 +50,7 @@ from lp.services.database.interfaces import (
525 IStore,
526 IStoreSelector,
527 )
528-from lp.services.database.policy import MasterDatabasePolicy
529+from lp.services.database.policy import PrimaryDatabasePolicy
530 from lp.services.identity.interfaces.account import (
531 AccountStatus,
532 IAccountSet,
533@@ -112,9 +112,9 @@ class StubbedOpenIDCallbackView(OpenIDCallbackView):
534 super(StubbedOpenIDCallbackView, self).login(account)
535 self.login_called = True
536 current_policy = getUtility(IStoreSelector).get_current()
537- if not isinstance(current_policy, MasterDatabasePolicy):
538+ if not isinstance(current_policy, PrimaryDatabasePolicy):
539 raise AssertionError(
540- "Not using the master store: %s" % current_policy)
541+ "Not using the primary store: %s" % current_policy)
542
543
544 class FakeConsumer:
545@@ -174,17 +174,17 @@ def MacaroonResponse_fromSuccessResponse_stubbed():
546 def IAccountSet_getByOpenIDIdentifier_monkey_patched():
547 # Monkey patch getUtility(IAccountSet).getByOpenIDIdentifier() with a
548 # method that will raise an AssertionError when it's called and the
549- # installed DB policy is not MasterDatabasePolicy. This is to ensure that
550- # the code we're testing forces the use of the master DB by installing the
551- # MasterDatabasePolicy.
552+ # installed DB policy is not PrimaryDatabasePolicy. This is to ensure
553+ # that the code we're testing forces the use of the primary DB by
554+ # installing the PrimaryDatabasePolicy.
555 account_set = removeSecurityProxy(getUtility(IAccountSet))
556 orig_getByOpenIDIdentifier = account_set.getByOpenIDIdentifier
557
558 def fake_getByOpenIDIdentifier(identifier):
559 current_policy = getUtility(IStoreSelector).get_current()
560- if not isinstance(current_policy, MasterDatabasePolicy):
561+ if not isinstance(current_policy, PrimaryDatabasePolicy):
562 raise AssertionError(
563- "Not using the master store: %s" % current_policy)
564+ "Not using the primary store: %s" % current_policy)
565 return orig_getByOpenIDIdentifier(identifier)
566
567 try:
568@@ -224,9 +224,9 @@ class TestOpenIDCallbackView(TestCaseWithFactory):
569 view.initialize()
570 view.openid_response = response
571 # Monkey-patch getByOpenIDIdentifier() to make sure the view uses the
572- # master DB. This mimics the problem we're trying to avoid, where
573+ # primary DB. This mimics the problem we're trying to avoid, where
574 # getByOpenIDIdentifier() doesn't find a newly created account because
575- # it looks in the slave database.
576+ # it looks in the standby database.
577 with IAccountSet_getByOpenIDIdentifier_monkey_patched():
578 html = view.render()
579 return view, html
580@@ -247,7 +247,7 @@ class TestOpenIDCallbackView(TestCaseWithFactory):
581 # The 'last_write' flag was not updated (unlike in the other test
582 # methods) because in this case we didn't have to create a
583 # Person/Account entry, so it's ok for further requests to hit the
584- # slave DBs.
585+ # standby DBs.
586 self.assertNotIn('last_write', ISession(view.request)['lp.dbpolicy'])
587
588 def test_gather_params(self):
589@@ -350,7 +350,7 @@ class TestOpenIDCallbackView(TestCaseWithFactory):
590 removeSecurityProxy(person.preferredemail).email)
591
592 # We also update the last_write flag in the session, to make sure
593- # further requests use the master DB and thus see the newly created
594+ # further requests use the primary DB and thus see the newly created
595 # stuff.
596 self.assertLastWriteIsSet(view.request)
597
598@@ -389,7 +389,7 @@ class TestOpenIDCallbackView(TestCaseWithFactory):
599 self.assertEqual('Test account', person.displayname)
600
601 # We also update the last_write flag in the session, to make sure
602- # further requests use the master DB and thus see the newly created
603+ # further requests use the primary DB and thus see the newly created
604 # stuff.
605 self.assertLastWriteIsSet(view.request)
606
607@@ -416,7 +416,7 @@ class TestOpenIDCallbackView(TestCaseWithFactory):
608 self.assertEqual(AccountStatus.ACTIVE, person.account.status)
609 self.assertEqual(email, person.preferredemail.email)
610 # We also update the last_write flag in the session, to make sure
611- # further requests use the master DB and thus see the newly created
612+ # further requests use the primary DB and thus see the newly created
613 # stuff.
614 self.assertLastWriteIsSet(view.request)
615
616@@ -442,7 +442,7 @@ class TestOpenIDCallbackView(TestCaseWithFactory):
617 self.assertEqual(AccountStatus.ACTIVE, person.account.status)
618 self.assertEqual(email, person.preferredemail.email)
619 # We also update the last_write flag in the session, to make sure
620- # further requests use the master DB and thus see the newly created
621+ # further requests use the primary DB and thus see the newly created
622 # stuff.
623 self.assertLastWriteIsSet(view.request)
624
625diff --git a/lib/lp/soyuz/stories/soyuz/xx-private-builds.txt b/lib/lp/soyuz/stories/soyuz/xx-private-builds.txt
626index c21f02a..362ad7b 100644
627--- a/lib/lp/soyuz/stories/soyuz/xx-private-builds.txt
628+++ b/lib/lp/soyuz/stories/soyuz/xx-private-builds.txt
629@@ -276,9 +276,9 @@ Let's make the iceweasel package available in breezy-autotest.
630 First log in as an admin to be able to manipulate the source publishing.
631
632 >>> login("foo.bar@canonical.com")
633- >>> from lp.services.database.policy import MasterDatabasePolicy
634+ >>> from lp.services.database.policy import PrimaryDatabasePolicy
635 >>> from lp.services.database.interfaces import IStoreSelector
636- >>> getUtility(IStoreSelector).push(MasterDatabasePolicy())
637+ >>> getUtility(IStoreSelector).push(PrimaryDatabasePolicy())
638 >>> ubuntutest = getUtility(IDistributionSet)['ubuntutest']
639 >>> breezy_autotest = ubuntutest['breezy-autotest']
640 >>> new_pub = private_source_pub.copyTo(
641diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
642index 2856fa0..684661f 100644
643--- a/lib/lp/testing/factory.py
644+++ b/lib/lp/testing/factory.py
645@@ -255,7 +255,7 @@ from lp.services.database.interfaces import (
646 IStore,
647 IStoreSelector,
648 )
649-from lp.services.database.policy import MasterDatabasePolicy
650+from lp.services.database.policy import PrimaryDatabasePolicy
651 from lp.services.database.sqlbase import flush_database_updates
652 from lp.services.gpg.interfaces import (
653 GPGKeyAlgorithm,
654@@ -408,7 +408,7 @@ def default_master_store(func):
655 except ComponentLookupError:
656 # Utilities not registered. No policies.
657 return func(*args, **kw)
658- store_selector.push(MasterDatabasePolicy())
659+ store_selector.push(PrimaryDatabasePolicy())
660 try:
661 return func(*args, **kw)
662 finally:
663diff --git a/lib/lp/translations/scripts/po_export_queue.py b/lib/lp/translations/scripts/po_export_queue.py
664index 4be8aef..2ee4434 100644
665--- a/lib/lp/translations/scripts/po_export_queue.py
666+++ b/lib/lp/translations/scripts/po_export_queue.py
667@@ -19,7 +19,7 @@ from zope.component import (
668 from lp.registry.interfaces.productseries import IProductSeries
669 from lp.registry.interfaces.sourcepackage import ISourcePackage
670 from lp.services.config import config
671-from lp.services.database.policy import SlaveOnlyDatabasePolicy
672+from lp.services.database.policy import StandbyOnlyDatabasePolicy
673 from lp.services.librarian.interfaces import ILibraryFileAliasSet
674 from lp.services.mail.helpers import (
675 get_contact_email_addresses,
676@@ -374,7 +374,7 @@ def process_request(person, objects, format, logger):
677 multiple files) and information about files that we failed to export (if
678 any).
679 """
680- # Keep as much work off the master store as possible, so we avoid
681+ # Keep as much work off the primary store as possible, so we avoid
682 # opening unnecessary transactions there. It could be a while
683 # before we get to the commit.
684 translation_exporter = getUtility(ITranslationExporter)
685@@ -412,13 +412,13 @@ def process_queue(transaction_manager, logger):
686 while request != no_request:
687
688 # This can take a long time. Make sure we don't open any
689- # transactions on the master store before we really need to.
690+ # transactions on the primary store before we really need to.
691 transaction_manager.commit()
692- with SlaveOnlyDatabasePolicy():
693+ with StandbyOnlyDatabasePolicy():
694 person, objects, format, request_ids = request
695 result = process_request(person, objects, format, logger)
696
697- # Almost done. Now we can go back to using the master database
698+ # Almost done. Now we can go back to using the primary database
699 # where needed.
700 result.upload(logger=logger)
701 result.notify()

Subscribers

People subscribed via source and target branches

to status/vote changes: