Merge lp:~tealeg/landscape-client/keystone-scoped-resynch into lp:~landscape/landscape-client/trunk

Proposed by Geoff Teale
Status: Merged
Approved by: Geoff Teale
Approved revision: 714
Merged at revision: 708
Proposed branch: lp:~tealeg/landscape-client/keystone-scoped-resynch
Merge into: lp:~landscape/landscape-client/trunk
Prerequisite: lp:~tealeg/landscape-client/centralise-resynch-handling
Diff against target: 125 lines (+60/-18)
3 files modified
landscape/manager/keystonetoken.py (+3/-3)
landscape/manager/tests/test_keystonetoken.py (+44/-15)
landscape/tests/helpers.py (+13/-0)
To merge this branch: bzr merge lp:~tealeg/landscape-client/keystone-scoped-resynch
Reviewer Review Type Date Requested Status
Jerry Seutter (community) Approve
Chris Glass (community) Approve
Review via email: mp+174289@code.launchpad.net

This proposal supersedes a proposal from 2013-07-05.

Commit message

This branch makes the keystone token plugin only respond
to resynchronize-clients events when they are either
"openstack" or global scope. Note, the server doesn't
currently send "openstack" scope, but I decided that all
plugins should have their scope defined so that we can
easily add scoped resynchs on the server when we need to.

Description of the change

This branch makes the keystone token plugin only respond to resynchronize-clients events when they are either "openstack" or global scope. Note, the server doesn't currently send "openstack" scope, but I decided that all plugins should have their scope defined so that we can easily add scoped resynchs on the server when we need to.

Note - this branch has now been re-based on the centralise-resynch-handling and will need re-review on that basis.

To post a comment you must log in.
Revision history for this message
Jerry Seutter (jseutter) wrote : Posted in a previous version of this proposal

+1, looks good.

review: Approve
Revision history for this message
Jerry Seutter (jseutter) wrote : Posted in a previous version of this proposal

Some lintian issues:

landscape/manager/tests/test_keystonetoken.py:9:1: E303 too many blank lines (3)
landscape/manager/tests/test_keystonetoken.py:125:80: E501 line too long (87 characters)
landscape/broker/tests/test_server.py:368:80: E501 line too long (80 characters)

Revision history for this message
Geoff Teale (tealeg) wrote : Posted in a previous version of this proposal

> Some lintian issues:
>
> landscape/manager/tests/test_keystonetoken.py:9:1: E303 too many blank lines
> (3)
> landscape/manager/tests/test_keystonetoken.py:125:80: E501 line too long (87
> characters)
> landscape/broker/tests/test_server.py:368:80: E501 line too long (80
> characters)

Cheers, all dealt with.

Revision history for this message
Chris Glass (tribaal) wrote : Posted in a previous version of this proposal

[1]
+class FakePersist(object):
+
+ def __init__(self):
+ self.called = False
+
+ def remove(self, key):
+ self.called = True

This should probably go to someplace else, like landscape/lib/persist or landscape/tests/helpers as I assume it can be reused by all other plugins using the persist mechanism?

(ongoing review, saving just because I'm afraid chromium will die on me again)

Revision history for this message
Chris Glass (tribaal) wrote : Posted in a previous version of this proposal

Alright, +1!

review: Approve
Revision history for this message
Geoff Teale (tealeg) wrote :

Chris, I addressed your previous review point.

Revision history for this message
Chris Glass (tribaal) wrote :

Looks good! Thanks!

review: Approve
Revision history for this message
Jerry Seutter (jseutter) wrote :

+1

landscape/tests/helpers.py:655:1: W391 blank line at end of file

review: Approve
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'landscape/manager/keystonetoken.py'
--- landscape/manager/keystonetoken.py 2013-01-25 17:28:02 +0000
+++ landscape/manager/keystonetoken.py 2013-07-17 07:49:27 +0000
@@ -17,6 +17,7 @@
17 message_type = "keystone-token"17 message_type = "keystone-token"
18 message_key = "data"18 message_key = "data"
19 run_interval = 60 * 1519 run_interval = 60 * 15
20 scope = "openstack"
2021
21 def __init__(self, keystone_config_file=KEYSTONE_CONFIG_FILE):22 def __init__(self, keystone_config_file=KEYSTONE_CONFIG_FILE):
22 self._keystone_config_file = keystone_config_file23 self._keystone_config_file = keystone_config_file
@@ -26,13 +27,12 @@
26 self._persist_filename = os.path.join(self.registry.config.data_path,27 self._persist_filename = os.path.join(self.registry.config.data_path,
27 "keystone.bpickle")28 "keystone.bpickle")
28 self._persist = Persist(filename=self._persist_filename)29 self._persist = Persist(filename=self._persist_filename)
29 self.registry.reactor.call_on("resynchronize", self._resynchronize)
30 self.registry.reactor.call_every(self.registry.config.flush_interval,30 self.registry.reactor.call_every(self.registry.config.flush_interval,
31 self.flush)31 self.flush)
3232
33 def _resynchronize(self):33 def _reset(self):
34 """34 """
35 Recreate the persist upon C{_resynchronize}.35 Reset the persist.
36 """36 """
37 self._persist.remove("data")37 self._persist.remove("data")
3838
3939
=== modified file 'landscape/manager/tests/test_keystonetoken.py'
--- landscape/manager/tests/test_keystonetoken.py 2013-01-25 17:28:02 +0000
+++ landscape/manager/tests/test_keystonetoken.py 2013-07-17 07:49:27 +0000
@@ -2,7 +2,7 @@
2from landscape.tests.helpers import LandscapeTest2from landscape.tests.helpers import LandscapeTest
33
4from landscape.manager.keystonetoken import KeystoneToken4from landscape.manager.keystonetoken import KeystoneToken
5from landscape.tests.helpers import ManagerHelper5from landscape.tests.helpers import ManagerHelper, FakePersist
66
77
8class KeystoneTokenTest(LandscapeTest):8class KeystoneTokenTest(LandscapeTest):
@@ -88,20 +88,49 @@
88 self.reactor.advance(flush_interval)88 self.reactor.advance(flush_interval)
89 self.assertTrue(os.path.exists(persist_filename))89 self.assertTrue(os.path.exists(persist_filename))
9090
91 def test_resynchronize_message_calls_resynchronize_method(self):91 def test_resynchronize_message_calls_reset_method(self):
92 """92 """
93 If the reactor fires a "resynchronize" even the C{_resynchronize}93 If the reactor fires a "resynchronize", with 'openstack' scope, the
94 method on the keystone plugin object is called.94 C{_reset} method on the keystone plugin object is called.
95 """95 """
96 self.called = False96 self.manager.add(self.plugin)
9797 self.plugin._persist = FakePersist()
98 def stub_resynchronize():98 openstack_scope = ["openstack"]
99 self.called = True99 self.reactor.fire("resynchronize", openstack_scope)
100 self.plugin._resynchronize = stub_resynchronize100 self.assertTrue(self.plugin._persist.called)
101101
102 self.manager.add(self.plugin)102 def test_resynchronize_gets_new_session_id(self):
103 self.reactor.fire("resynchronize")103 """
104 self.assertTrue(self.called)104 If L{KeystoneToken} reacts to a "resynchronize" event it should get a
105 new session id as part of the process.
106 """
107 self.manager.add(self.plugin)
108 session_id = self.plugin._session_id
109 self.plugin._persist = FakePersist()
110 self.plugin.client.broker.message_store.drop_session_ids()
111 self.reactor.fire("resynchronize")
112 self.assertNotEqual(session_id, self.plugin._session_id)
113
114 def test_resynchronize_with_global_scope(self):
115 """
116 If the reactor fires a "resynchronize", with global scope, we act as if
117 it had 'openstack' scope.
118 """
119 self.manager.add(self.plugin)
120 self.plugin._persist = FakePersist()
121 self.reactor.fire("resynchronize")
122 self.assertTrue(self.plugin._persist.called)
123
124 def test_do_not_resynchronize_with_other_scope(self):
125 """
126 If the reactor fires a "resynchronize", with an irrelevant scope, we do
127 nothing.
128 """
129 self.manager.add(self.plugin)
130 self.plugin._persist = FakePersist()
131 disk_scope = ["disk"]
132 self.reactor.fire("resynchronize", disk_scope)
133 self.assertFalse(self.plugin._persist.called)
105134
106 def test_send_message_with_no_data(self):135 def test_send_message_with_no_data(self):
107 """136 """
108137
=== modified file 'landscape/tests/helpers.py'
--- landscape/tests/helpers.py 2013-04-30 14:02:42 +0000
+++ landscape/tests/helpers.py 2013-07-17 07:49:27 +0000
@@ -639,3 +639,16 @@
639 """Remove sample data for the process that matches C{process_id}."""639 """Remove sample data for the process that matches C{process_id}."""
640 process_dir = os.path.join(self._sample_dir, str(process_id))640 process_dir = os.path.join(self._sample_dir, str(process_id))
641 shutil.rmtree(process_dir)641 shutil.rmtree(process_dir)
642
643
644class FakePersist(object):
645 """
646 Incompletely fake a C{landscape.lib.Persist} to simplify higher level tests
647 that result in an attempt to clear down persisted data.
648 """
649
650 def __init__(self):
651 self.called = False
652
653 def remove(self, key):
654 self.called = True

Subscribers

People subscribed via source and target branches

to all changes: