Merge lp:~nataliabidart/ubuntuone-client/send-status-changed-when-quitting into lp:ubuntuone-client

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 811
Merged at revision: 811
Proposed branch: lp:~nataliabidart/ubuntuone-client/send-status-changed-when-quitting
Merge into: lp:ubuntuone-client
Diff against target: 287 lines (+117/-14)
6 files modified
docs/states_manager.svg (+82/-11)
tests/syncdaemon/test_main.py (+11/-0)
tests/syncdaemon/test_states.py (+14/-3)
ubuntuone/syncdaemon/event_queue.py (+1/-0)
ubuntuone/syncdaemon/main.py (+1/-0)
ubuntuone/syncdaemon/states.py (+8/-0)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-client/send-status-changed-when-quitting
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
Guillermo Gonzalez Approve
Review via email: mp+46666@code.launchpad.net

Commit message

Syncdaemon now sends a StatusChanged with a QUIT state when quitting (LP: #704599).

Description of the change

To test IRL, in this branch, run:

u1sdtool -q; PYTHONPATH=. ./bin/ubuntuone-syncdaemon

and then, from another terminal, run:

u1sdtool -q

You should get this in the log file:

2011-01-18 16:36:23,073 - ubuntuone.SyncDaemon.StateManager - DEBUG - ConnectionManager returned None
2011-01-18 16:36:23,073 - ubuntuone.SyncDaemon.EQ - DEBUG - push_event: SYS_QUIT, args:(), kw:{}
2011-01-18 16:36:23,074 - ubuntuone.SyncDaemon.StateManager - DEBUG - received event 'SYS_QUIT'
2011-01-18 16:36:23,074 - ubuntuone.SyncDaemon.StateManager - DEBUG - Transition LOCAL_RESCAN --[SYS_QUIT]--> QUIT (queues: WORKING; connection: Not User With Network)
2011-01-18 16:36:23,074 - ubuntuone.SyncDaemon.EQ - DEBUG - push_event: SYS_STATE_CHANGED, args:(), kw:{'state': QUIT (error=False connected=False online=False) Queue: WORKING Connection: Not User With Network}

To post a comment you must log in.
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

+1

As discussed on IRC, the name should be different. something a bit more state-like.

review: Approve
810. By Natalia Bidart

Renaming QUIT state to SHUTDOWN.

811. By Natalia Bidart

Typo!

Revision history for this message
Alejandro J. Cura (alecu) wrote :

All tests pass and works as advertised.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'docs/states_manager.svg'
2--- docs/states_manager.svg 2010-04-12 15:15:47 +0000
3+++ docs/states_manager.svg 2011-01-18 20:44:49 +0000
4@@ -13,7 +13,7 @@
5 height="744.09448"
6 id="svg2"
7 sodipodi:version="0.32"
8- inkscape:version="0.47 r22583"
9+ inkscape:version="0.48.0 r9654"
10 version="1.0"
11 sodipodi:docname="states_manager.svg"
12 inkscape:output_extension="org.inkscape.output.svg.inkscape">
13@@ -27,15 +27,15 @@
14 objecttolerance="10"
15 inkscape:pageopacity="0.0"
16 inkscape:pageshadow="2"
17- inkscape:zoom="1.0427072"
18- inkscape:cx="495.3424"
19- inkscape:cy="229.5042"
20+ inkscape:zoom="4.1708288"
21+ inkscape:cx="161.41473"
22+ inkscape:cy="87.320796"
23 inkscape:document-units="px"
24 inkscape:current-layer="layer1"
25 showgrid="false"
26- inkscape:window-width="1410"
27- inkscape:window-height="875"
28- inkscape:window-x="0"
29+ inkscape:window-width="1380"
30+ inkscape:window-height="876"
31+ inkscape:window-x="30"
32 inkscape:window-y="0"
33 inkscape:window-maximized="1"
34 showguides="true"
35@@ -5989,6 +5989,20 @@
36 inkscape:vp_y="0 : 1000 : 0"
37 inkscape:vp_x="0 : 0.5 : 1"
38 sodipodi:type="inkscape:persp3d" />
39+ <marker
40+ inkscape:stockid="Arrow1Mend1u64"
41+ orient="auto"
42+ refY="0"
43+ refX="0"
44+ id="Arrow1Mend1u64-802"
45+ style="overflow:visible">
46+ <path
47+ inkscape:connector-curvature="0"
48+ id="path7114-81"
49+ d="M 0,0 5,-5 -12.5,0 5,5 0,0 z"
50+ style="fill:#796a69;fill-rule:evenodd;stroke:#000000;stroke-width:1pt;marker-start:none"
51+ transform="matrix(-0.4,0,0,-0.4,-4,0)" />
52+ </marker>
53 </defs>
54 <metadata
55 id="metadata7">
56@@ -6007,6 +6021,24 @@
57 id="layer1"
58 style="display:inline">
59 <path
60+ style="opacity:0.80373798;color:#000000;fill:#ececec;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:0.25548708;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
61+ d="m 163.37882,673.45664 14.44899,14.449 -13.9982,13.99821 99.42455,0 -14.44899,-14.449 13.9982,-13.99821 -99.42455,0 z"
62+ id="rect8502-1-3-1-3-5-8"
63+ sodipodi:nodetypes="ccccccc"
64+ inkscape:connector-curvature="0" />
65+ <text
66+ id="text2429-9-7-7-2-2-4-3-9-2"
67+ y="690.83258"
68+ x="213.31433"
69+ style="font-size:8.65986252px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:150%;writing-mode:lr-tb;text-anchor:middle;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
70+ xml:space="preserve"
71+ sodipodi:linespacing="150%"><tspan
72+ style="font-size:8.65986252px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:center;line-height:150%;writing-mode:lr-tb;text-anchor:middle;font-family:DejaVu Sans;-inkscape-font-specification:DejaVu Sans"
73+ y="690.83258"
74+ x="213.31433"
75+ sodipodi:role="line"
76+ id="tspan8676-1-9-7-6">SHUTDOWN</tspan></text>
77+ <path
78 style="color:#000000;fill:none;stroke:#000000;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;marker-start:url(#DotM);visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
79 d="m 779.90701,324.28835 21.9219,4.98314"
80 id="path9275-28-4"
81@@ -7653,12 +7685,12 @@
82 sodipodi:linespacing="125%"
83 xml:space="preserve"
84 style="font-size:12.8904295px;font-style:italic;font-weight:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;color:#000000;fill:#967b71;fill-opacity:1;stroke:none;stroke-width:2;marker:none;marker-end:url(#Arrow1Mend1u64);visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans;-inkscape-font-specification:Sans"
85- x="748.91864"
86+ x="708.91864"
87 y="655.28705"
88 id="text2467-1-5-4-7-3-64-9-9-6"><tspan
89 sodipodi:role="line"
90 id="tspan2469-4-3-8-9-0-4-4-7-4"
91- x="748.91864"
92+ x="708.91864"
93 y="655.28705"
94 style="font-size:8.20300102px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;color:#000000;fill:#967b71;fill-opacity:1;stroke:none;stroke-width:2;marker:none;marker-end:url(#Arrow1Mend1u64);visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans Mono;-inkscape-font-specification:Bitstream Vera Sans Mono">SYS_UNKNOWN_ERROR</tspan></text>
95 <g
96@@ -7703,12 +7735,12 @@
97 sodipodi:linespacing="125%"
98 xml:space="preserve"
99 style="font-size:12.8904295px;font-style:italic;font-weight:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;color:#000000;fill:#967b71;fill-opacity:1;stroke:none;stroke-width:2;marker:none;marker-end:url(#Arrow1Mend1u64);visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans;-inkscape-font-specification:Sans"
100- x="916.75098"
101+ x="876.75098"
102 y="655.28705"
103 id="text2467-1-5-4-7-3-64-9-9-6-2"><tspan
104 sodipodi:role="line"
105 id="tspan2469-4-3-8-9-0-4-4-7-4-2"
106- x="916.75098"
107+ x="876.75098"
108 y="655.28705"
109 style="font-size:8.20300102px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;color:#000000;fill:#967b71;fill-opacity:1;stroke:none;stroke-width:2;marker:none;marker-end:url(#Arrow1Mend1u64);visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans Mono;-inkscape-font-specification:Bitstream Vera Sans Mono">SYS_ROOT_MISMATCH</tspan></text>
110 <path
111@@ -7821,5 +7853,44 @@
112 id="path4627-2-8-04-1-5"
113 style="opacity:0.65322583;color:#000000;fill:#00ff00;fill-opacity:1;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
114 sodipodi:type="arc" />
115+ <path
116+ inkscape:connector-curvature="0"
117+ style="color:#000000;fill:none;stroke:#967b71;stroke-width:1.51844954;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;marker-end:url(#Arrow1Mend1u64);visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
118+ d="m 106.62966,642.72783 c 113.49645,-0.51905 104.84581,-0.36756 107.441,27.48751"
119+ id="path8817-5-8-1-5-2-5-4"
120+ sodipodi:nodetypes="cc" />
121+ <text
122+ sodipodi:linespacing="125%"
123+ xml:space="preserve"
124+ style="font-size:9.54122162px;font-style:italic;font-weight:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;fill:#000000;fill-opacity:1;stroke:none;display:inline;font-family:Bitstream Vera Sans;-inkscape-font-specification:Sans Italic"
125+ x="106.23523"
126+ y="639.35211"
127+ id="text2461-6-0-31-6-2-3-8"><tspan
128+ sodipodi:role="line"
129+ x="106.23523"
130+ y="639.35211"
131+ id="tspan2463-3-4-2-8-1-8-7">From any node</tspan></text>
132+ <path
133+ transform="matrix(0.18533464,0,0,0.17050787,248.96653,596.37403)"
134+ d="m -147.4098,407.55515 a 42.646858,47.282387 0 1 1 -85.29371,0 42.646858,47.282387 0 1 1 85.29371,0 z"
135+ sodipodi:ry="47.282387"
136+ sodipodi:rx="42.646858"
137+ sodipodi:cy="407.55515"
138+ sodipodi:cx="-190.05666"
139+ id="path4627-2-8-0-8-1"
140+ style="opacity:0.65322583;color:#000000;fill:#00ff00;fill-opacity:1;stroke:none;stroke-width:3;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
141+ sodipodi:type="arc" />
142+ <text
143+ sodipodi:linespacing="125%"
144+ xml:space="preserve"
145+ style="font-size:12.72880554px;font-style:italic;font-weight:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;color:#000000;fill:#967b71;fill-opacity:1;stroke:none;stroke-width:2;marker:none;marker-end:url(#Arrow1Mend1u64);visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans;-inkscape-font-specification:Sans"
146+ x="146.72015"
147+ y="655.46698"
148+ id="text2467-1-5-4-7-3-64-9-9-6-9"><tspan
149+ sodipodi:role="line"
150+ id="tspan2469-4-3-8-9-0-4-4-7-4-4"
151+ x="146.72015"
152+ y="655.46698"
153+ style="font-size:8.10014915px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;writing-mode:lr-tb;text-anchor:start;color:#000000;fill:#967b71;fill-opacity:1;stroke:none;stroke-width:2;marker:none;marker-end:url(#Arrow1Mend1u64);visibility:visible;display:inline;overflow:visible;enable-background:accumulate;font-family:Bitstream Vera Sans Mono;-inkscape-font-specification:Bitstream Vera Sans Mono">SYS_QUIT</tspan></text>
154 </g>
155 </svg>
156
157=== modified file 'tests/syncdaemon/test_main.py'
158--- tests/syncdaemon/test_main.py 2011-01-14 20:43:15 +0000
159+++ tests/syncdaemon/test_main.py 2011-01-18 20:44:49 +0000
160@@ -91,6 +91,17 @@
161 self.assertTrue(self.restarted)
162 main.shutdown()
163
164+ def test_shutdown_pushes_sys_quit(self):
165+ """When shutting down, the SYS_QUIT event is pushed."""
166+ main = self.build_main()
167+ events = []
168+ self.patch(main.event_q, 'push',
169+ lambda *a, **kw: events.append((a, kw)))
170+
171+ main.shutdown()
172+ expected = [(('SYS_USER_DISCONNECT',), {}), (('SYS_QUIT',), {})]
173+ self.assertEqual(expected, events)
174+
175 def test_handshake_timeout(self):
176 """Check connecting times out."""
177 d0 = defer.Deferred()
178
179=== modified file 'tests/syncdaemon/test_states.py'
180--- tests/syncdaemon/test_states.py 2011-01-13 22:06:43 +0000
181+++ tests/syncdaemon/test_states.py 2011-01-18 20:44:49 +0000
182@@ -338,7 +338,6 @@
183 self.assertTrue(new_node is None) # if working, it should return a node
184
185
186-
187 class TestConnectionManagerTimings(Base):
188 """Times handled by ConnectionManager."""
189
190@@ -594,7 +593,6 @@
191 return defer.DeferredList(d)
192
193
194-
195 class TestStateManagerTimeoutTransitions(StateManagerTransitions):
196 """Test StateManager when HandshakeTimeouts."""
197
198@@ -628,6 +626,16 @@
199 'STANDOFF', True)
200
201
202+class TestStateManagerShutdown(StateManagerTransitions):
203+ """Test StateManager when shutting down."""
204+
205+ def test_shutdown(self):
206+ """All nodes go to SHUTDOWN."""
207+ d = []
208+ for node in self.sm_allnodes:
209+ d.append(self.check(node, 'SYS_QUIT', 'SHUTDOWN'))
210+ return defer.DeferredList(d)
211+
212
213 class TestStateManagerErrors(StateManagerTransitions):
214 """Test StateManager on error conditions."""
215@@ -657,7 +665,6 @@
216 return defer.DeferredList(d)
217
218
219-
220 class TestStateManagerEnterExit(Base):
221 """Test StateManager on enter and exit transitions."""
222
223@@ -1003,3 +1010,7 @@
224 self.sm.state = StateManager.STANDOFF
225 self.check_node("STANDOFF", error=False, conn=True, online=False)
226
227+ def test_SHUTDOWN(self):
228+ """SHUTDOWN internals."""
229+ self.sm.state = StateManager.SHUTDOWN
230+ self.check_node("SHUTDOWN", error=False, conn=False, online=False)
231
232=== modified file 'ubuntuone/syncdaemon/event_queue.py'
233--- ubuntuone/syncdaemon/event_queue.py 2011-01-13 21:32:21 +0000
234+++ ubuntuone/syncdaemon/event_queue.py 2011-01-18 20:44:49 +0000
235@@ -139,6 +139,7 @@
236 'SYS_SERVER_ERROR': ('error',),
237 'SYS_QUOTA_EXCEEDED': ('volume_id', 'free_bytes'),
238 'SYS_BROKEN_NODE': ('volume_id', 'node_id', 'path', 'mdid'),
239+ 'SYS_QUIT': (),
240
241 'FSM_FILE_CONFLICT': ('old_name', 'new_name'),
242 'FSM_DIR_CONFLICT': ('old_name', 'new_name'),
243
244=== modified file 'ubuntuone/syncdaemon/main.py'
245--- ubuntuone/syncdaemon/main.py 2011-01-14 22:32:48 +0000
246+++ ubuntuone/syncdaemon/main.py 2011-01-18 20:44:49 +0000
247@@ -200,6 +200,7 @@
248 def shutdown(self, with_restart=False):
249 """Shutdown the daemon; optionally restart it."""
250 self.event_q.push('SYS_USER_DISCONNECT')
251+ self.event_q.push('SYS_QUIT')
252 self.event_q.shutdown()
253 self.hash_q.shutdown()
254 self.db.shutdown()
255
256=== modified file 'ubuntuone/syncdaemon/states.py'
257--- ubuntuone/syncdaemon/states.py 2011-01-14 14:04:37 +0000
258+++ ubuntuone/syncdaemon/states.py 2011-01-18 20:44:49 +0000
259@@ -288,6 +288,7 @@
260 'SYS_NET_DISCONNECTED',
261 'SYS_PROTOCOL_VERSION_ERROR',
262 'SYS_PROTOCOL_VERSION_OK',
263+ 'SYS_QUIT',
264 'SYS_ROOT_MISMATCH',
265 'SYS_SERVER_RESCAN_DONE',
266 'SYS_SERVER_ERROR',
267@@ -329,6 +330,8 @@
268 "different", error=True)
269 UNKNOWN_ERROR = Node('UNKNOWN_ERROR', "something went wrong", error=True)
270
271+ SHUTDOWN = Node('SHUTDOWN', "shutting down the service")
272+
273 def __init__(self, main, handshake_timeout=None):
274 self.main = main
275 self.aq = main.action_q
276@@ -381,6 +384,11 @@
277 return
278 self.log.debug("received event %r", event)
279
280+ # quit
281+ if event == 'SYS_QUIT':
282+ self._transition(event, StateManager.SHUTDOWN)
283+ return
284+
285 # error management
286 if event == 'SYS_UNKNOWN_ERROR':
287 self._transition(event, StateManager.UNKNOWN_ERROR)

Subscribers

People subscribed via source and target branches