Merge lp://staging/~tealeg/landscape-client/package-monitor-scoped-resynch into lp://staging/~landscape/landscape-client/trunk

Proposed by Geoff Teale
Status: Merged
Approved by: Geoff Teale
Approved revision: 723
Merged at revision: 713
Proposed branch: lp://staging/~tealeg/landscape-client/package-monitor-scoped-resynch
Merge into: lp://staging/~landscape/landscape-client/trunk
Diff against target: 178 lines (+76/-56)
3 files modified
landscape/monitor/packagemonitor.py (+1/-0)
landscape/monitor/tests/test_packagemonitor.py (+75/-15)
landscape/monitor/tests/test_usermonitor.py (+0/-41)
To merge this branch: bzr merge lp://staging/~tealeg/landscape-client/package-monitor-scoped-resynch
Reviewer Review Type Date Requested Status
Björn Tillenius (community) Approve
Jerry Seutter (community) Approve
Review via email: mp+175014@code.staging.launchpad.net

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

Commit message

This branch makes the PackageMonitor plugin only respond to resynchronize-clients events when they are either "package" or global scope.

Description of the change

This branch makes the PackageMonitor plugin only respond to resynchronize-clients events when they are either "package" or global scope.

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.

landscape/monitor/tests/test_packagemonitor.py:233:80: E501 line too long (80 characters)

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

In other branches the call signature for _resynchronize uses scopes:
def _resynchronize(self, scopes):

Can you update this changeset to use scopes instead of scope?

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

> +1, looks good.
>
> landscape/monitor/tests/test_packagemonitor.py:233:80: E501 line too long (80
> characters)

Done.

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

> In other branches the call signature for _resynchronize uses scopes:
> def _resynchronize(self, scopes):
>
> Can you update this changeset to use scopes instead of scope?

Done.

Revision history for this message
Björn Tillenius (bjornt) wrote : Posted in a previous version of this proposal

[1]

+ if len(scopes) == 0 or self.scope in scopes:

This makes me a bit sad. Having this in every _resynchronize() doesn't
doesn't look good.

I see that we register the resynchronize method with something like
this:

  self.registry.reactor.call_on("resynchronize", self._resynchronize)

I'd suggest doing something like this instead:

  self.registry.register_resynchronize(self.scope, self._resynchronize)

That way self._resynchronize would be called only for the relevant
scope, which makes the method easier to read.

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

> [1]
>
> + if len(scopes) == 0 or self.scope in scopes:
>
> This makes me a bit sad. Having this in every _resynchronize() doesn't
> doesn't look good.
>
> I see that we register the resynchronize method with something like
> this:
>
> self.registry.reactor.call_on("resynchronize", self._resynchronize)
>
> I'd suggest doing something like this instead:
>
> self.registry.register_resynchronize(self.scope, self._resynchronize)
>
> That way self._resynchronize would be called only for the relevant
> scope, which makes the method easier to read.

Hi Bjorn, would you be happy for me to make that change as a follow on branch? It effects multiple branches here and it would be cleaner to tidy it all up in one swoop.

Revision history for this message
Björn Tillenius (bjornt) wrote : Posted in a previous version of this proposal

On Wed, Jul 10, 2013 at 05:37:53PM -0000, Geoff Teale wrote:
> > [1]
> >
> > + if len(scopes) == 0 or self.scope in scopes:
> >
> > This makes me a bit sad. Having this in every _resynchronize() doesn't
> > doesn't look good.
> >
> > I see that we register the resynchronize method with something like
> > this:
> >
> > self.registry.reactor.call_on("resynchronize", self._resynchronize)
> >
> > I'd suggest doing something like this instead:
> >
> > self.registry.register_resynchronize(self.scope, self._resynchronize)
> >
> > That way self._resynchronize would be called only for the relevant
> > scope, which makes the method easier to read.
>
> Hi Bjorn, would you be happy for me to make that change as a follow on
> branch? It effects multiple branches here and it would be cleaner to
> tidy it all up in one swoop.

Sure, that would be fine, if it's easier.

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

> > Hi Bjorn, would you be happy for me to make that change as a follow on
> > branch? It effects multiple branches here and it would be cleaner to
> > tidy it all up in one swoop.
>
> Sure, that would be fine, if it's easier.

OK, I'll add a clean up branch at the end, I have some other calls to tidy up across all branches too.

722. By Geoff Teale

merge forwards and resolve conflicts.

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

+1

review: Approve
Revision history for this message
Björn Tillenius (bjornt) wrote :

Looks good, +1

[1]

+ def test_not_resynchronize_with_other_scope(self):
+ """
+ If a 'resynchronize' reactor event is fired with an irrelevant scope,
+ the package monitor should not respond to this.
+ """
+ self.monitor.add(self.package_monitor)
+ self.createReporterTask()
+
+ disk_scope = ["disk"]
+ self.monitor.reactor.fire("resynchronize", disk_scope)
+
+ # The next task should *not* be the resynchronize message.
+ self.assertSingleReporterTask(
+ {'ids': [None], 'request-id': 1, 'type': 'package-ids'}, 1)

Where does that dict on the last line come from? Ok, after reading the
diff I can see that it's from createReporterTask(), but if someone looks
at the test only, it's hard to see.

It would be better to either explicitly add that task you expect to be
there, or make createReportTask() return the task and id, so that it's
clear that you expect the existing task to still be there, and no a new
one.

review: Approve
723. By Geoff Teale

Make test more readable by returning the task from createReporterTask.

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

> Looks good, +1
>
> [1]
>

Agreed, I've tidied that up.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: