Merge lp:~facundo/ubuntuone-client/dbus-inform-all-queue into lp:ubuntuone-client

Proposed by Facundo Batista
Status: Merged
Approved by: Rodrigo Moya
Approved revision: 477
Merged at revision: not available
Proposed branch: lp:~facundo/ubuntuone-client/dbus-inform-all-queue
Merge into: lp:ubuntuone-client
Diff against target: 116 lines (+28/-21)
2 files modified
tests/syncdaemon/test_dbus.py (+22/-18)
ubuntuone/syncdaemon/dbus_interface.py (+6/-3)
To merge this branch: bzr merge lp:~facundo/ubuntuone-client/dbus-inform-all-queue
Reviewer Review Type Date Requested Status
Rodrigo Moya (community) Approve
Natalia Bidart (community) Approve
Review via email: mp+22987@code.launchpad.net

Commit message

Include what the Queue is doing in the information published through DBus.

Description of the change

Include what the Queue is doing in the information published through DBus.

The interfaces to know what content and meta queues are doing lacked what they were currently doing, and this information was missing elsewhere.

The best solution was to change them to include that information: not only the queued for the future commands, but the full queue (queued for the future and what it's currently doing).

Tests attached.

To post a comment you must log in.
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

Good work!

review: Approve
Revision history for this message
Rodrigo Moya (rodrigo-moya) wrote :

Looks good and tests pass

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/syncdaemon/test_dbus.py'
2--- tests/syncdaemon/test_dbus.py 2010-03-26 18:29:38 +0000
3+++ tests/syncdaemon/test_dbus.py 2010-04-08 00:12:27 +0000
4@@ -211,26 +211,31 @@
5 self.main.vm.add_share(Share(path=share_path, volume_id='share_id'))
6 a_path = os.path.join(share_path, "path_a")
7 b_path = os.path.join(share_path, "path_b")
8+ c_path = os.path.join(share_path, "path_c")
9 self.fs_manager.create(a_path, "share_id")
10 self.fs_manager.create(b_path, "share_id")
11+ self.fs_manager.create(c_path, "share_id")
12 self.fs_manager.set_node_id(a_path, "node_id_a")
13 self.fs_manager.set_node_id(b_path, "node_id_b")
14+ self.fs_manager.set_node_id(c_path, "node_id_c")
15 # inject the fake data
16+ self.action_q.content_queue._head = FakeCommand("share_id",
17+ "node_id_a")
18 self.action_q.content_queue.waiting.extend([
19- FakeCommand("share_id", "node_id_a"),
20- FakeCommand("share_id", "node_id_b")])
21+ FakeCommand("share_id", "node_id_b"),
22+ FakeCommand("share_id", "node_id_c")])
23 # OK, testing time
24 client = DBusClient(self.bus, '/status', DBUS_IFACE_STATUS_NAME)
25 d = defer.Deferred()
26 self.second = False
27 def waiting_handler(result):
28 """ waiting_content reply handler """
29- self.assertEquals(2, len(result))
30+ self.assertEquals(3, len(result))
31 # the second time we're called, the result should be reversed
32 if self.second:
33- node_b, node_a = result
34+ node_a, node_c, node_b = result
35 else:
36- node_a, node_b = result
37+ node_a, node_b, node_c = result
38
39 self.assertEquals(a_path, str(node_a['path']))
40 self.assertEquals(b_path, str(node_b['path']))
41@@ -244,7 +249,7 @@
42 d.callback(True)
43 else:
44 # the last shall be the first, et cetera.
45- client.call_method('schedule_next', 'share_id', 'node_id_b',
46+ client.call_method('schedule_next', 'share_id', 'node_id_c',
47 reply_handler=reschedule_handler,
48 error_handler=self.error_handler)
49 def reschedule_handler(result):
50@@ -262,28 +267,27 @@
51 def test_waiting_metadata(self):
52 """Test Status.waiting_metadata with fake data in the AQ."""
53 # inject the fake data
54+ self.action_q.meta_queue._head = FakeCommand("n_a_foo", "n_a_bar")
55 self.action_q.meta_queue.waiting.extend([
56- FakeCommand("node_a_foo", "node_a_bar"),
57- FakeCommand("node_b_foo", "node_b_bar")])
58- # OK, testing time
59+ FakeCommand("n_b_foo", "n_b_bar"),
60+ FakeCommand("n_c_foo", "n_c_bar")])
61+
62+ # testing time
63 client = DBusClient(self.bus, '/status', DBUS_IFACE_STATUS_NAME)
64 d = defer.Deferred()
65 def waiting_handler(result):
66- """waiting_metadata reply handler."""
67- self.assertEquals(2, len(result))
68- # the second time we're called, the result should be reversed
69- node_a, node_b = result
70- self.assertEquals(str(FakeCommand("node_a_foo", "node_a_bar")),
71- node_a)
72- self.assertEquals(str(FakeCommand("node_b_foo", "node_b_bar")),
73- node_b)
74+ """Reply handler."""
75+ self.assertEquals(3, len(result))
76+ node_a, node_b, node_c = result
77+ self.assertEquals(str(FakeCommand("n_a_foo", "n_a_bar")), node_a)
78+ self.assertEquals(str(FakeCommand("n_b_foo", "n_b_bar")), node_b)
79+ self.assertEquals(str(FakeCommand("n_c_foo", "n_c_bar")), node_c)
80 d.callback(True)
81 client.call_method('waiting_metadata',
82 reply_handler=waiting_handler,
83 error_handler=self.error_handler)
84 return d
85
86-
87 def test_contq_changed(self):
88 """Test the Status.ContentQueueChanged signal."""
89 # prepare the VM so it lies for us
90
91=== modified file 'ubuntuone/syncdaemon/dbus_interface.py'
92--- ubuntuone/syncdaemon/dbus_interface.py 2010-03-26 20:16:23 +0000
93+++ ubuntuone/syncdaemon/dbus_interface.py 2010-04-08 00:12:27 +0000
94@@ -199,8 +199,9 @@
95 """Return a list of the operations in the meta-queue."""
96 logger.debug('called waiting_metadata')
97 waiting_metadata = []
98- for cmd in self.action_queue.meta_queue.waiting:
99- waiting_metadata.append(str(cmd))
100+ for cmd in self.action_queue.meta_queue.full_queue():
101+ if cmd is not None:
102+ waiting_metadata.append(str(cmd))
103 return waiting_metadata
104
105 @dbus.service.method(DBUS_IFACE_STATUS_NAME, out_signature='aa{ss}')
106@@ -210,7 +211,9 @@
107 """
108 logger.debug('called waiting_content')
109 waiting_content = []
110- for cmd in self.action_queue.content_queue.waiting:
111+ for cmd in self.action_queue.content_queue.full_queue():
112+ if cmd is None:
113+ continue
114 try:
115 if IMarker.providedBy(cmd.node_id):
116 # it's a marker! so it's the mdid :)

Subscribers

People subscribed via source and target branches