Merge lp:~xavi-garcia-mena/keeper/keeper-errors-in-state-property into lp:keeper/devel
- keeper-errors-in-state-property
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Xavi Garcia |
Approved revision: | 133 |
Merged at revision: | 125 |
Proposed branch: | lp:~xavi-garcia-mena/keeper/keeper-errors-in-state-property |
Merge into: | lp:keeper/devel |
Prerequisite: | lp:~xavi-garcia-mena/keeper/command-line-client-plus-bugs |
Diff against target: |
816 lines (+324/-27) 23 files modified
include/client/client.h (+3/-1) include/client/keeper-errors.h (+49/-0) include/helper/helper.h (+2/-0) src/cli/command-line-client-view.cpp (+54/-9) src/cli/command-line-client-view.h (+5/-2) src/client/CMakeLists.txt (+14/-0) src/client/client.cpp (+9/-1) src/client/keeper-errors.cpp (+74/-0) src/helper/backup-helper.cpp (+12/-2) src/helper/helper.cpp (+2/-1) src/helper/restore-helper.cpp (+9/-2) src/qdbus-stubs/dbus-types.h (+3/-1) src/service/CMakeLists.txt (+1/-0) src/service/keeper-task-backup.cpp (+1/-0) src/service/keeper-task.cpp (+28/-3) src/service/keeper-task.h (+4/-1) src/service/private/keeper-task_p.h (+4/-0) src/service/task-manager.cpp (+2/-1) tests/integration/helpers/helpers-test-failure.cpp (+7/-0) tests/integration/helpers/helpers-test.cc (+16/-3) tests/integration/helpers/test-helpers-base.cpp (+22/-0) tests/integration/helpers/test-helpers-base.h (+2/-0) tests/utils/CMakeLists.txt (+1/-0) |
To merge this branch: | bzr merge lp:~xavi-garcia-mena/keeper/keeper-errors-in-state-property |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
unity-api-1-bot | continuous-integration | Approve | |
Charles Kerr (community) | Approve | ||
Review via email:
|
Commit message
This branch adds error notification in each keeper task.
Description of the change
This branch adds error notification in each keeper task.
The error is an enum located at the client headers.
I've also created a helper method in the client library that converts the enum from QDBusArgument to KeeperError (the final type).
As we return a QVariantMap in the state call it looks like Qt is not converting the type itself.
We should maybe return a own defined type and offer the user an interface to obtain the different values of the state.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:132
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Charles Kerr (charlesk) wrote : | # |
Looks really good. As usual some minor suggestions, but less even of those than usual. Nice work.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Xavi Garcia (xavi-garcia-mena) wrote : | # |
Thanks for the review, Charles.
I did all the suggested changes
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:133
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
unity-api-1-bot (unity-api-1-bot) : | # |
Preview Diff
1 | === modified file 'include/client/client.h' | |||
2 | --- include/client/client.h 2016-12-05 11:36:32 +0000 | |||
3 | +++ include/client/client.h 2016-12-21 08:37:30 +0000 | |||
4 | @@ -19,6 +19,8 @@ | |||
5 | 19 | 19 | ||
6 | 20 | #pragma once | 20 | #pragma once |
7 | 21 | 21 | ||
8 | 22 | #include "keeper-errors.h" | ||
9 | 23 | |||
10 | 22 | #include <QObject> | 24 | #include <QObject> |
11 | 23 | #include <QScopedPointer> | 25 | #include <QScopedPointer> |
12 | 24 | #include <QStringList> | 26 | #include <QStringList> |
13 | @@ -73,7 +75,7 @@ | |||
14 | 73 | void readyToBackupChanged(); | 75 | void readyToBackupChanged(); |
15 | 74 | void backupBusyChanged(); | 76 | void backupBusyChanged(); |
16 | 75 | 77 | ||
18 | 76 | void taskStatusChanged(QString const & displayName, QString const & status, double percentage); | 78 | void taskStatusChanged(QString const & displayName, QString const & status, double percentage, keeper::KeeperError error); |
19 | 77 | void finished(); | 79 | void finished(); |
20 | 78 | 80 | ||
21 | 79 | private Q_SLOTS: | 81 | private Q_SLOTS: |
22 | 80 | 82 | ||
23 | === added file 'include/client/keeper-errors.h' | |||
24 | --- include/client/keeper-errors.h 1970-01-01 00:00:00 +0000 | |||
25 | +++ include/client/keeper-errors.h 2016-12-21 08:37:30 +0000 | |||
26 | @@ -0,0 +1,49 @@ | |||
27 | 1 | /* | ||
28 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
29 | 3 | * | ||
30 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
31 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
32 | 6 | * by the Free Software Foundation. | ||
33 | 7 | * | ||
34 | 8 | * This program is distributed in the hope that it will be useful, but | ||
35 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
36 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
37 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
38 | 12 | * | ||
39 | 13 | * You should have received a copy of the GNU General Public License along | ||
40 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
41 | 15 | * | ||
42 | 16 | * Authors: | ||
43 | 17 | * Xavi Garcia Mena <xavi.garcia.mena@canonical.com> | ||
44 | 18 | */ | ||
45 | 19 | |||
46 | 20 | #pragma once | ||
47 | 21 | |||
48 | 22 | #include <QDBusArgument> | ||
49 | 23 | #include <QMetaType> | ||
50 | 24 | |||
51 | 25 | namespace keeper | ||
52 | 26 | { | ||
53 | 27 | |||
54 | 28 | enum class KeeperError | ||
55 | 29 | { | ||
56 | 30 | OK, | ||
57 | 31 | ERROR_UNKNOWN, | ||
58 | 32 | HELPER_READ_ERROR, | ||
59 | 33 | HELPER_WRITE_ERROR, | ||
60 | 34 | HELPER_INACTIVITY_DETECTED, | ||
61 | 35 | HELPER_SOCKET_ERROR, | ||
62 | 36 | HELPER_START_TIMEOUT, | ||
63 | 37 | NO_HELPER_INFORMATION_IN_REGISTRY, | ||
64 | 38 | HELPER_BAD_URL, | ||
65 | 39 | MANIFEST_STORAGE_ERROR, | ||
66 | 40 | COMMITTING_DATA_ERROR | ||
67 | 41 | }; | ||
68 | 42 | |||
69 | 43 | KeeperError convertFromDBusVariant(const QVariant & value, bool *conversion_ok = nullptr); | ||
70 | 44 | } // namespace keeper | ||
71 | 45 | |||
72 | 46 | QDBusArgument &operator<<(QDBusArgument &argument, keeper::KeeperError value); | ||
73 | 47 | const QDBusArgument &operator>>(const QDBusArgument &argument, keeper::KeeperError &val); | ||
74 | 48 | |||
75 | 49 | Q_DECLARE_METATYPE(keeper::KeeperError) | ||
76 | 0 | 50 | ||
77 | === modified file 'include/helper/helper.h' | |||
78 | --- include/helper/helper.h 2016-09-15 16:02:54 +0000 | |||
79 | +++ include/helper/helper.h 2016-12-21 08:37:30 +0000 | |||
80 | @@ -19,6 +19,7 @@ | |||
81 | 19 | 19 | ||
82 | 20 | #pragma once | 20 | #pragma once |
83 | 21 | 21 | ||
84 | 22 | #include <client/keeper-errors.h> | ||
85 | 22 | #include <util/attributes.h> | 23 | #include <util/attributes.h> |
86 | 23 | 24 | ||
87 | 24 | #include <QObject> | 25 | #include <QObject> |
88 | @@ -69,6 +70,7 @@ | |||
89 | 69 | Q_SIGNALS: | 70 | Q_SIGNALS: |
90 | 70 | void state_changed(Helper::State); | 71 | void state_changed(Helper::State); |
91 | 71 | void percent_done_changed(float); | 72 | void percent_done_changed(float); |
92 | 73 | void error(keeper::KeeperError error); | ||
93 | 72 | 74 | ||
94 | 73 | protected: | 75 | protected: |
95 | 74 | Helper(QString const & appid, const clock_func& clock=default_clock, QObject *parent=nullptr); | 76 | Helper(QString const & appid, const clock_func& clock=default_clock, QObject *parent=nullptr); |
96 | 75 | 77 | ||
97 | === modified file 'src/cli/command-line-client-view.cpp' | |||
98 | --- src/cli/command-line-client-view.cpp 2016-12-01 14:18:57 +0000 | |||
99 | +++ src/cli/command-line-client-view.cpp 2016-12-21 08:37:30 +0000 | |||
100 | @@ -48,7 +48,7 @@ | |||
101 | 48 | 48 | ||
102 | 49 | void CommandLineClientView::add_task(QString const & display_name, QString const & initial_status, double initial_percentage) | 49 | void CommandLineClientView::add_task(QString const & display_name, QString const & initial_status, double initial_percentage) |
103 | 50 | { | 50 | { |
105 | 51 | tasks_strings_[display_name] = get_task_string(display_name, initial_status, initial_percentage); | 51 | tasks_strings_[display_name] = get_task_string(display_name, initial_status, initial_percentage, keeper::KeeperError::OK); |
106 | 52 | // TODO see if we can do this in a better way | 52 | // TODO see if we can do this in a better way |
107 | 53 | // We add a line per each backup task | 53 | // We add a line per each backup task |
108 | 54 | std::cout << std::endl; | 54 | std::cout << std::endl; |
109 | @@ -112,17 +112,62 @@ | |||
110 | 112 | return ret; | 112 | return ret; |
111 | 113 | } | 113 | } |
112 | 114 | 114 | ||
120 | 115 | QString CommandLineClientView::get_task_string(QString const & displayName, QString const & status, double percentage) | 115 | QString CommandLineClientView::get_task_string(QString const & displayName, QString const & status, double percentage, keeper::KeeperError error) |
121 | 116 | { | 116 | { |
122 | 117 | 117 | ||
123 | 118 | return QStringLiteral("%1 %2 % %3").arg(displayName, 15).arg((percentage * 100), 10, 'f', 2, ' ').arg(status, -15); | 118 | if (error == keeper::KeeperError::OK) |
124 | 119 | } | 119 | return QStringLiteral("%1 %2 % %3").arg(displayName, 15).arg((percentage * 100), 10, 'f', 2, ' ').arg(status, -15); |
125 | 120 | 120 | else | |
126 | 121 | void CommandLineClientView::on_task_state_changed(QString const & displayName, QString const & status, double percentage) | 121 | return QStringLiteral("%1 %2 % %3 %4").arg(displayName, 15).arg((percentage * 100), 10, 'f', 2, ' ').arg(status, -15).arg(get_error_string(error)); |
127 | 122 | } | ||
128 | 123 | |||
129 | 124 | QString CommandLineClientView::get_error_string(keeper::KeeperError error) | ||
130 | 125 | { | ||
131 | 126 | QString ret; | ||
132 | 127 | switch(error) | ||
133 | 128 | { | ||
134 | 129 | case keeper::KeeperError::ERROR_UNKNOWN: | ||
135 | 130 | ret = QStringLiteral("Unknown error"); | ||
136 | 131 | break; | ||
137 | 132 | case keeper::KeeperError::HELPER_BAD_URL: | ||
138 | 133 | ret = QStringLiteral("Bad URL for keeper helper"); | ||
139 | 134 | break; | ||
140 | 135 | case keeper::KeeperError::HELPER_INACTIVITY_DETECTED: | ||
141 | 136 | ret = QStringLiteral("Inactivity detected in task"); | ||
142 | 137 | break; | ||
143 | 138 | case keeper::KeeperError::HELPER_START_TIMEOUT: | ||
144 | 139 | ret = QStringLiteral("Task failed to start"); | ||
145 | 140 | break; | ||
146 | 141 | case keeper::KeeperError::HELPER_READ_ERROR: | ||
147 | 142 | ret = QStringLiteral("Read error"); | ||
148 | 143 | break; | ||
149 | 144 | case keeper::KeeperError::HELPER_SOCKET_ERROR: | ||
150 | 145 | ret = QStringLiteral("Error creating internal socket"); | ||
151 | 146 | break; | ||
152 | 147 | case keeper::KeeperError::HELPER_WRITE_ERROR: | ||
153 | 148 | ret = QStringLiteral("Write error"); | ||
154 | 149 | break; | ||
155 | 150 | case keeper::KeeperError::MANIFEST_STORAGE_ERROR: | ||
156 | 151 | ret = QStringLiteral("Error storing manifest file"); | ||
157 | 152 | break; | ||
158 | 153 | case keeper::KeeperError::NO_HELPER_INFORMATION_IN_REGISTRY: | ||
159 | 154 | ret = QStringLiteral("No helper information in registry"); | ||
160 | 155 | break; | ||
161 | 156 | case keeper::KeeperError::OK: | ||
162 | 157 | ret = QStringLiteral("Success"); | ||
163 | 158 | break; | ||
164 | 159 | case keeper::KeeperError::COMMITTING_DATA_ERROR: | ||
165 | 160 | ret = QStringLiteral("Error uploading data"); | ||
166 | 161 | break; | ||
167 | 162 | } | ||
168 | 163 | return ret; | ||
169 | 164 | } | ||
170 | 165 | |||
171 | 166 | void CommandLineClientView::on_task_state_changed(QString const & displayName, QString const & status, double percentage, keeper::KeeperError error) | ||
172 | 122 | { | 167 | { |
173 | 123 | auto iter = tasks_strings_.find(displayName); | 168 | auto iter = tasks_strings_.find(displayName); |
174 | 124 | if (iter != tasks_strings_.end()) | 169 | if (iter != tasks_strings_.end()) |
175 | 125 | { | 170 | { |
177 | 126 | tasks_strings_[displayName] = get_task_string(displayName, status, percentage); | 171 | tasks_strings_[displayName] = get_task_string(displayName, status, percentage, error); |
178 | 127 | } | 172 | } |
179 | 128 | } | 173 | } |
180 | 129 | 174 | ||
181 | === modified file 'src/cli/command-line-client-view.h' | |||
182 | --- src/cli/command-line-client-view.h 2016-11-30 14:46:29 +0000 | |||
183 | +++ src/cli/command-line-client-view.h 2016-12-21 08:37:30 +0000 | |||
184 | @@ -18,6 +18,8 @@ | |||
185 | 18 | */ | 18 | */ |
186 | 19 | #pragma once | 19 | #pragma once |
187 | 20 | 20 | ||
188 | 21 | #include <client/keeper-errors.h> | ||
189 | 22 | |||
190 | 21 | #include <QMap> | 23 | #include <QMap> |
191 | 22 | #include <QObject> | 24 | #include <QObject> |
192 | 23 | #include <QTimer> | 25 | #include <QTimer> |
193 | @@ -43,11 +45,12 @@ | |||
194 | 43 | 45 | ||
195 | 44 | public Q_SLOTS: | 46 | public Q_SLOTS: |
196 | 45 | void show_info(); | 47 | void show_info(); |
198 | 46 | void on_task_state_changed(QString const & displayName, QString const & status, double percentage); | 48 | void on_task_state_changed(QString const & displayName, QString const & status, double percentage, keeper::KeeperError error); |
199 | 47 | 49 | ||
200 | 48 | private: | 50 | private: |
201 | 49 | char get_next_spin_char(); | 51 | char get_next_spin_char(); |
203 | 50 | QString get_task_string(QString const & displayName, QString const & status, double percentage); | 52 | QString get_task_string(QString const & displayName, QString const & status, double percentage, keeper::KeeperError error); |
204 | 53 | QString get_error_string(keeper::KeeperError error); | ||
205 | 51 | 54 | ||
206 | 52 | QString status_; | 55 | QString status_; |
207 | 53 | QTimer timer_status_; | 56 | QTimer timer_status_; |
208 | 54 | 57 | ||
209 | === modified file 'src/client/CMakeLists.txt' | |||
210 | --- src/client/CMakeLists.txt 2016-11-30 14:46:29 +0000 | |||
211 | +++ src/client/CMakeLists.txt 2016-12-21 08:37:30 +0000 | |||
212 | @@ -1,8 +1,21 @@ | |||
213 | 1 | add_subdirectory(qml-plugin) | 1 | add_subdirectory(qml-plugin) |
214 | 2 | 2 | ||
215 | 3 | set( | 3 | set( |
216 | 4 | KEEPER_ERRORS_LIB | ||
217 | 5 | keeper-errors-lib | ||
218 | 6 | ) | ||
219 | 7 | |||
220 | 8 | add_library( | ||
221 | 9 | ${KEEPER_ERRORS_LIB} | ||
222 | 10 | STATIC | ||
223 | 11 | keeper-errors.cpp | ||
224 | 12 | ${CMAKE_SOURCE_DIR}/include/client/keeper-errors.h | ||
225 | 13 | ) | ||
226 | 14 | |||
227 | 15 | set( | ||
228 | 4 | CLIENT_HEADERS | 16 | CLIENT_HEADERS |
229 | 5 | ${CMAKE_SOURCE_DIR}/include/client/client.h | 17 | ${CMAKE_SOURCE_DIR}/include/client/client.h |
230 | 18 | ${CMAKE_SOURCE_DIR}/include/client/keeper-errors.h | ||
231 | 6 | ) | 19 | ) |
232 | 7 | 20 | ||
233 | 8 | add_library( | 21 | add_library( |
234 | @@ -18,6 +31,7 @@ | |||
235 | 18 | 31 | ||
236 | 19 | target_link_libraries( | 32 | target_link_libraries( |
237 | 20 | ${KEEPER_CLIENT_LIB} | 33 | ${KEEPER_CLIENT_LIB} |
238 | 34 | ${KEEPER_ERRORS_LIB} | ||
239 | 21 | qdbus-stubs | 35 | qdbus-stubs |
240 | 22 | Qt5::Core | 36 | Qt5::Core |
241 | 23 | Qt5::DBus | 37 | Qt5::DBus |
242 | 24 | 38 | ||
243 | === modified file 'src/client/client.cpp' | |||
244 | --- src/client/client.cpp 2016-12-16 09:34:05 +0000 | |||
245 | +++ src/client/client.cpp 2016-12-21 08:37:30 +0000 | |||
246 | @@ -281,12 +281,20 @@ | |||
247 | 281 | double progress = state.value("percent-done").toDouble(); | 281 | double progress = state.value("percent-done").toDouble(); |
248 | 282 | auto status = state.value("action").toString(); | 282 | auto status = state.value("action").toString(); |
249 | 283 | 283 | ||
250 | 284 | keeper::KeeperError keeper_error = keeper::KeeperError::OK; | ||
251 | 285 | auto iter_error = state.find("error"); | ||
252 | 286 | if (iter_error != state.end()) | ||
253 | 287 | { | ||
254 | 288 | bool conversion_ok; | ||
255 | 289 | keeper_error = keeper::convertFromDBusVariant(state.value("error"), &conversion_ok); | ||
256 | 290 | } | ||
257 | 291 | |||
258 | 284 | auto current_state = d->task_status[uuid]; | 292 | auto current_state = d->task_status[uuid]; |
259 | 285 | if (current_state.status != status || current_state.percentage < progress) | 293 | if (current_state.status != status || current_state.percentage < progress) |
260 | 286 | { | 294 | { |
261 | 287 | d->task_status[uuid].status = status; | 295 | d->task_status[uuid].status = status; |
262 | 288 | d->task_status[uuid].percentage = progress; | 296 | d->task_status[uuid].percentage = progress; |
264 | 289 | Q_EMIT(taskStatusChanged(state.value("display-name").toString(), status, progress)); | 297 | Q_EMIT(taskStatusChanged(state.value("display-name").toString(), status, progress, keeper_error)); |
265 | 290 | } | 298 | } |
266 | 291 | } | 299 | } |
267 | 292 | 300 | ||
268 | 293 | 301 | ||
269 | === added file 'src/client/keeper-errors.cpp' | |||
270 | --- src/client/keeper-errors.cpp 1970-01-01 00:00:00 +0000 | |||
271 | +++ src/client/keeper-errors.cpp 2016-12-21 08:37:30 +0000 | |||
272 | @@ -0,0 +1,74 @@ | |||
273 | 1 | /* | ||
274 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
275 | 3 | * | ||
276 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
277 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
278 | 6 | * by the Free Software Foundation. | ||
279 | 7 | * | ||
280 | 8 | * This program is distributed in the hope that it will be useful, but | ||
281 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
282 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
283 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
284 | 12 | * | ||
285 | 13 | * You should have received a copy of the GNU General Public License along | ||
286 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
287 | 15 | * | ||
288 | 16 | * Authors: | ||
289 | 17 | * Xavi Garcia <xavi.garcia.mena@canonical.com> | ||
290 | 18 | */ | ||
291 | 19 | |||
292 | 20 | #include <client/keeper-errors.h> | ||
293 | 21 | |||
294 | 22 | #include <QDebug> | ||
295 | 23 | |||
296 | 24 | QDBusArgument &operator<<(QDBusArgument &argument, keeper::KeeperError value) | ||
297 | 25 | { | ||
298 | 26 | argument.beginStructure(); | ||
299 | 27 | argument << static_cast<int>(value); | ||
300 | 28 | argument.endStructure(); | ||
301 | 29 | return argument; | ||
302 | 30 | } | ||
303 | 31 | |||
304 | 32 | const QDBusArgument &operator>>(const QDBusArgument &argument, keeper::KeeperError &val) | ||
305 | 33 | { | ||
306 | 34 | int int_val; | ||
307 | 35 | argument.beginStructure(); | ||
308 | 36 | argument >> int_val; | ||
309 | 37 | val = static_cast<keeper::KeeperError>(int_val); | ||
310 | 38 | argument.endStructure(); | ||
311 | 39 | return argument; | ||
312 | 40 | } | ||
313 | 41 | |||
314 | 42 | namespace keeper | ||
315 | 43 | { | ||
316 | 44 | KeeperError convertFromDBusVariant(const QVariant & value, bool *conversion_ok) | ||
317 | 45 | { | ||
318 | 46 | if (value.typeName() != QStringLiteral("QDBusArgument")) | ||
319 | 47 | { | ||
320 | 48 | qWarning() << Q_FUNC_INFO | ||
321 | 49 | << " Error converting dbus QVariant to KeeperError, expected type is [ QDBusArgument ] and current type is: [" | ||
322 | 50 | << value.typeName() << "]"; | ||
323 | 51 | if (conversion_ok) | ||
324 | 52 | *conversion_ok = false; | ||
325 | 53 | return KeeperError(keeper::KeeperError::ERROR_UNKNOWN); | ||
326 | 54 | } | ||
327 | 55 | auto dbus_arg = value.value<QDBusArgument>(); | ||
328 | 56 | |||
329 | 57 | if (dbus_arg.currentSignature() != "(i)") | ||
330 | 58 | { | ||
331 | 59 | qWarning() << Q_FUNC_INFO | ||
332 | 60 | << " Error converting dbus QVariant to KeeperError, expected signature is \"(i)\" and current signature is: \"" | ||
333 | 61 | << dbus_arg.currentSignature() << "\""; | ||
334 | 62 | if (conversion_ok) | ||
335 | 63 | *conversion_ok = false; | ||
336 | 64 | return KeeperError(keeper::KeeperError::ERROR_UNKNOWN); | ||
337 | 65 | } | ||
338 | 66 | KeeperError ret; | ||
339 | 67 | dbus_arg >> ret; | ||
340 | 68 | |||
341 | 69 | if (conversion_ok) | ||
342 | 70 | *conversion_ok = true; | ||
343 | 71 | |||
344 | 72 | return ret; | ||
345 | 73 | } | ||
346 | 74 | } | ||
347 | 0 | 75 | ||
348 | === modified file 'src/helper/backup-helper.cpp' | |||
349 | --- src/helper/backup-helper.cpp 2016-10-06 14:53:44 +0000 | |||
350 | +++ src/helper/backup-helper.cpp 2016-12-21 08:37:30 +0000 | |||
351 | @@ -62,8 +62,8 @@ | |||
352 | 62 | int rc = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, fds); | 62 | int rc = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, fds); |
353 | 63 | if (rc == -1) | 63 | if (rc == -1) |
354 | 64 | { | 64 | { |
357 | 65 | // TODO throw exception. | 65 | qWarning() << QStringLiteral("Error creating socket to communicate with helper");; |
358 | 66 | qWarning() << "BackupHelperPrivate: error creating socket pair to communicate with helper "; | 66 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_SOCKET_ERROR)); |
359 | 67 | return; | 67 | return; |
360 | 68 | } | 68 | } |
361 | 69 | 69 | ||
362 | @@ -140,7 +140,10 @@ | |||
363 | 140 | std::function<void(bool)>{[this](bool success){ | 140 | std::function<void(bool)>{[this](bool success){ |
364 | 141 | qDebug() << "Commit finished"; | 141 | qDebug() << "Commit finished"; |
365 | 142 | if (!success) | 142 | if (!success) |
366 | 143 | { | ||
367 | 143 | write_error_ = true; | 144 | write_error_ = true; |
368 | 145 | Q_EMIT(q_ptr->error(keeper::KeeperError::COMMITTING_DATA_ERROR)); | ||
369 | 146 | } | ||
370 | 144 | else | 147 | else |
371 | 145 | uploader_committed_file_name_ = uploader_->file_name(); | 148 | uploader_committed_file_name_ = uploader_->file_name(); |
372 | 146 | uploader_.reset(); | 149 | uploader_.reset(); |
373 | @@ -175,6 +178,7 @@ | |||
374 | 175 | { | 178 | { |
375 | 176 | stop_inactivity_timer(); | 179 | stop_inactivity_timer(); |
376 | 177 | qWarning() << "Inactivity detected in the helper...stopping it"; | 180 | qWarning() << "Inactivity detected in the helper...stopping it"; |
377 | 181 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_INACTIVITY_DETECTED)); | ||
378 | 178 | stop(); | 182 | stop(); |
379 | 179 | } | 183 | } |
380 | 180 | 184 | ||
381 | @@ -212,6 +216,7 @@ | |||
382 | 212 | } | 216 | } |
383 | 213 | else if (n < 0) { | 217 | else if (n < 0) { |
384 | 214 | read_error_ = true; | 218 | read_error_ = true; |
385 | 219 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_READ_ERROR)); | ||
386 | 215 | stop(); | 220 | stop(); |
387 | 216 | return; | 221 | return; |
388 | 217 | } | 222 | } |
389 | @@ -228,6 +233,7 @@ | |||
390 | 228 | if (n < 0) { | 233 | if (n < 0) { |
391 | 229 | write_error_ = true; | 234 | write_error_ = true; |
392 | 230 | qWarning() << "Write error:" << socket->errorString(); | 235 | qWarning() << "Write error:" << socket->errorString(); |
393 | 236 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_WRITE_ERROR)); | ||
394 | 231 | stop(); | 237 | stop(); |
395 | 232 | } | 238 | } |
396 | 233 | break; | 239 | break; |
397 | @@ -258,6 +264,10 @@ | |||
398 | 258 | { | 264 | { |
399 | 259 | if (!q_ptr->is_helper_running()) | 265 | if (!q_ptr->is_helper_running()) |
400 | 260 | { | 266 | { |
401 | 267 | if (n_uploaded_ > q_ptr->expected_size()) | ||
402 | 268 | { | ||
403 | 269 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_WRITE_ERROR)); | ||
404 | 270 | } | ||
405 | 261 | q_ptr->set_state(Helper::State::FAILED); | 271 | q_ptr->set_state(Helper::State::FAILED); |
406 | 262 | } | 272 | } |
407 | 263 | } | 273 | } |
408 | 264 | 274 | ||
409 | === modified file 'src/helper/helper.cpp' | |||
410 | --- src/helper/helper.cpp 2016-11-21 12:03:56 +0000 | |||
411 | +++ src/helper/helper.cpp 2016-12-21 08:37:30 +0000 | |||
412 | @@ -359,7 +359,8 @@ | |||
413 | 359 | 359 | ||
414 | 360 | void on_max_time_waiting_for_ual_started() | 360 | void on_max_time_waiting_for_ual_started() |
415 | 361 | { | 361 | { |
417 | 362 | qDebug() << "Max time reached waiting for UAL to start"; | 362 | qWarning() << "Maximum time reached waiting for the helper to start."; |
418 | 363 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_START_TIMEOUT)); | ||
419 | 363 | q_ptr->set_state(Helper::State::FAILED); | 364 | q_ptr->set_state(Helper::State::FAILED); |
420 | 364 | stop_wait_for_ual_timer(); | 365 | stop_wait_for_ual_timer(); |
421 | 365 | } | 366 | } |
422 | 366 | 367 | ||
423 | === modified file 'src/helper/restore-helper.cpp' | |||
424 | --- src/helper/restore-helper.cpp 2016-12-05 11:36:32 +0000 | |||
425 | +++ src/helper/restore-helper.cpp 2016-12-21 08:37:30 +0000 | |||
426 | @@ -57,8 +57,8 @@ | |||
427 | 57 | int rc = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, fds); | 57 | int rc = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, fds); |
428 | 58 | if (rc == -1) | 58 | if (rc == -1) |
429 | 59 | { | 59 | { |
432 | 60 | // TODO throw exception. | 60 | qWarning() << QStringLiteral("Error creating socket to communicate with helper");; |
433 | 61 | qWarning() << "RestoreHelperPrivate: error creating socket pair to communicate with helper "; | 61 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_SOCKET_ERROR)); |
434 | 62 | return; | 62 | return; |
435 | 63 | } | 63 | } |
436 | 64 | 64 | ||
437 | @@ -167,6 +167,7 @@ | |||
438 | 167 | { | 167 | { |
439 | 168 | stop_inactivity_timer(); | 168 | stop_inactivity_timer(); |
440 | 169 | qWarning() << "Inactivity detected in the helper...stopping it"; | 169 | qWarning() << "Inactivity detected in the helper...stopping it"; |
441 | 170 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_INACTIVITY_DETECTED)); | ||
442 | 170 | stop(); | 171 | stop(); |
443 | 171 | } | 172 | } |
444 | 172 | 173 | ||
445 | @@ -207,6 +208,7 @@ | |||
446 | 207 | else if (n < 0) { | 208 | else if (n < 0) { |
447 | 208 | read_error_ = true; | 209 | read_error_ = true; |
448 | 209 | qDebug() << "Read error in restore helper: " << socket->errorString(); | 210 | qDebug() << "Read error in restore helper: " << socket->errorString(); |
449 | 211 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_READ_ERROR)); | ||
450 | 210 | stop(); | 212 | stop(); |
451 | 211 | return; | 213 | return; |
452 | 212 | } | 214 | } |
453 | @@ -226,6 +228,7 @@ | |||
454 | 226 | if (n < 0) { | 228 | if (n < 0) { |
455 | 227 | write_error_ = true; | 229 | write_error_ = true; |
456 | 228 | qWarning() << "Write error:" << write_socket_.errorString(); | 230 | qWarning() << "Write error:" << write_socket_.errorString(); |
457 | 231 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_WRITE_ERROR)); | ||
458 | 229 | stop(); | 232 | stop(); |
459 | 230 | } | 233 | } |
460 | 231 | break; | 234 | break; |
461 | @@ -257,6 +260,10 @@ | |||
462 | 257 | { | 260 | { |
463 | 258 | if (!q_ptr->is_helper_running()) | 261 | if (!q_ptr->is_helper_running()) |
464 | 259 | { | 262 | { |
465 | 263 | if (n_uploaded_ > q_ptr->expected_size()) | ||
466 | 264 | { | ||
467 | 265 | Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_WRITE_ERROR)); | ||
468 | 266 | } | ||
469 | 260 | q_ptr->set_state(Helper::State::FAILED); | 267 | q_ptr->set_state(Helper::State::FAILED); |
470 | 261 | } | 268 | } |
471 | 262 | } | 269 | } |
472 | 263 | 270 | ||
473 | === modified file 'src/qdbus-stubs/dbus-types.h' | |||
474 | --- src/qdbus-stubs/dbus-types.h 2016-11-30 14:46:29 +0000 | |||
475 | +++ src/qdbus-stubs/dbus-types.h 2016-12-21 08:37:30 +0000 | |||
476 | @@ -22,6 +22,7 @@ | |||
477 | 22 | #include <QtCore> | 22 | #include <QtCore> |
478 | 23 | #include <QString> | 23 | #include <QString> |
479 | 24 | #include <QVariantMap> | 24 | #include <QVariantMap> |
480 | 25 | #include <client/keeper-errors.h> | ||
481 | 25 | 26 | ||
482 | 26 | typedef QMap<QString, QVariantMap> QVariantDictMap; | 27 | typedef QMap<QString, QVariantMap> QVariantDictMap; |
483 | 27 | Q_DECLARE_METATYPE(QVariantDictMap) | 28 | Q_DECLARE_METATYPE(QVariantDictMap) |
484 | @@ -35,10 +36,11 @@ | |||
485 | 35 | { | 36 | { |
486 | 36 | qRegisterMetaType<QVariantDictMap>("QVariantDictMap"); | 37 | qRegisterMetaType<QVariantDictMap>("QVariantDictMap"); |
487 | 37 | qRegisterMetaType<QStringMap>("QStringMap"); | 38 | qRegisterMetaType<QStringMap>("QStringMap"); |
488 | 39 | qRegisterMetaType<keeper::KeeperError>("keeper::KeeperError"); | ||
489 | 38 | 40 | ||
490 | 39 | qDBusRegisterMetaType<QVariantDictMap>(); | 41 | qDBusRegisterMetaType<QVariantDictMap>(); |
491 | 40 | qDBusRegisterMetaType<QStringMap>(); | 42 | qDBusRegisterMetaType<QStringMap>(); |
493 | 41 | // Helper::registerMetaTypes(); | 43 | qDBusRegisterMetaType<keeper::KeeperError>(); |
494 | 42 | } | 44 | } |
495 | 43 | 45 | ||
496 | 44 | constexpr const char KEEPER_SERVICE[] = "com.canonical.keeper"; | 46 | constexpr const char KEEPER_SERVICE[] = "com.canonical.keeper"; |
497 | 45 | 47 | ||
498 | === modified file 'src/service/CMakeLists.txt' | |||
499 | --- src/service/CMakeLists.txt 2016-11-11 14:50:06 +0000 | |||
500 | +++ src/service/CMakeLists.txt 2016-12-21 08:37:30 +0000 | |||
501 | @@ -49,6 +49,7 @@ | |||
502 | 49 | storage-framework | 49 | storage-framework |
503 | 50 | util | 50 | util |
504 | 51 | qdbus-stubs | 51 | qdbus-stubs |
505 | 52 | keeper-errors-lib | ||
506 | 52 | ) | 53 | ) |
507 | 53 | 54 | ||
508 | 54 | target_link_libraries( | 55 | target_link_libraries( |
509 | 55 | 56 | ||
510 | === modified file 'src/service/keeper-task-backup.cpp' | |||
511 | --- src/service/keeper-task-backup.cpp 2016-11-08 09:03:09 +0000 | |||
512 | +++ src/service/keeper-task-backup.cpp 2016-12-21 08:37:30 +0000 | |||
513 | @@ -50,6 +50,7 @@ | |||
514 | 50 | qDebug() << "Initializing a backup helper"; | 50 | qDebug() << "Initializing a backup helper"; |
515 | 51 | helper_.reset(new BackupHelper(DEKKO_APP_ID), [](Helper *h){h->deleteLater();}); | 51 | helper_.reset(new BackupHelper(DEKKO_APP_ID), [](Helper *h){h->deleteLater();}); |
516 | 52 | qDebug() << "Helper " << static_cast<void*>(helper_.data()) << " was created"; | 52 | qDebug() << "Helper " << static_cast<void*>(helper_.data()) << " was created"; |
517 | 53 | QObject::connect(helper_.data(), &Helper::error, [this](keeper::KeeperError error){ error_ = error;}); | ||
518 | 53 | } | 54 | } |
519 | 54 | 55 | ||
520 | 55 | void ask_for_uploader(quint64 n_bytes, QString const & dir_name) | 56 | void ask_for_uploader(quint64 n_bytes, QString const & dir_name) |
521 | 56 | 57 | ||
522 | === modified file 'src/service/keeper-task.cpp' | |||
523 | --- src/service/keeper-task.cpp 2016-11-08 09:03:09 +0000 | |||
524 | +++ src/service/keeper-task.cpp 2016-12-21 08:37:30 +0000 | |||
525 | @@ -35,6 +35,7 @@ | |||
526 | 35 | , task_data_(task_data) | 35 | , task_data_(task_data) |
527 | 36 | , helper_registry_(helper_registry) | 36 | , helper_registry_(helper_registry) |
528 | 37 | , storage_(storage) | 37 | , storage_(storage) |
529 | 38 | , error_(keeper::KeeperError::OK) | ||
530 | 38 | { | 39 | { |
531 | 39 | } | 40 | } |
532 | 40 | 41 | ||
533 | @@ -49,8 +50,8 @@ | |||
534 | 49 | if (urls.isEmpty()) | 50 | if (urls.isEmpty()) |
535 | 50 | { | 51 | { |
536 | 51 | task_data_.action = helper_->to_string(Helper::State::FAILED); | 52 | task_data_.action = helper_->to_string(Helper::State::FAILED); |
539 | 52 | task_data_.error = "no helper information in registry"; | 53 | error_ = keeper::KeeperError::HELPER_BAD_URL; |
540 | 53 | qWarning() << "ERROR: uuid: " << task_data_.metadata.uuid() << " has no url"; | 54 | qWarning() << QStringLiteral("Error: uuid %1 has no url").arg(task_data_.metadata.uuid()); |
541 | 54 | calculate_and_notify_state(Helper::State::FAILED); | 55 | calculate_and_notify_state(Helper::State::FAILED); |
542 | 55 | return false; | 56 | return false; |
543 | 56 | } | 57 | } |
544 | @@ -65,6 +66,10 @@ | |||
545 | 65 | std::bind(&KeeperTaskPrivate::on_helper_percent_done_changed, this, std::placeholders::_1) | 66 | std::bind(&KeeperTaskPrivate::on_helper_percent_done_changed, this, std::placeholders::_1) |
546 | 66 | ); | 67 | ); |
547 | 67 | 68 | ||
548 | 69 | QObject::connect(helper_.data(), &Helper::error, [this](keeper::KeeperError error){ | ||
549 | 70 | error_ = error; | ||
550 | 71 | }); | ||
551 | 72 | |||
552 | 68 | helper_->start(urls); | 73 | helper_->start(urls); |
553 | 69 | return true; | 74 | return true; |
554 | 70 | } | 75 | } |
555 | @@ -132,8 +137,16 @@ | |||
556 | 132 | auto const percent_done = helper_->percent_done(); | 137 | auto const percent_done = helper_->percent_done(); |
557 | 133 | ret.insert(QStringLiteral("percent-done"), double(percent_done)); | 138 | ret.insert(QStringLiteral("percent-done"), double(percent_done)); |
558 | 134 | 139 | ||
559 | 140 | qDebug() << "task_data_.action = " << task_data_.action; | ||
560 | 135 | if (task_data_.action == "failed" || task_data_.action == "cancelled") | 141 | if (task_data_.action == "failed" || task_data_.action == "cancelled") |
562 | 136 | ret.insert(QStringLiteral("error"), task_data_.error); | 142 | { |
563 | 143 | auto error = error_; | ||
564 | 144 | if (task_data_.error != keeper::KeeperError::OK) | ||
565 | 145 | { | ||
566 | 146 | error = task_data_.error; | ||
567 | 147 | } | ||
568 | 148 | ret.insert(QStringLiteral("error"), qVariantFromValue(error)); | ||
569 | 149 | } | ||
570 | 137 | 150 | ||
571 | 138 | ret.insert(QStringLiteral("uuid"), uuid); | 151 | ret.insert(QStringLiteral("uuid"), uuid); |
572 | 139 | 152 | ||
573 | @@ -193,6 +206,11 @@ | |||
574 | 193 | } | 206 | } |
575 | 194 | } | 207 | } |
576 | 195 | 208 | ||
577 | 209 | keeper::KeeperError KeeperTaskPrivate::error() const | ||
578 | 210 | { | ||
579 | 211 | return error_; | ||
580 | 212 | } | ||
581 | 213 | |||
582 | 196 | KeeperTask::KeeperTask(TaskData & task_data, | 214 | KeeperTask::KeeperTask(TaskData & task_data, |
583 | 197 | QSharedPointer<HelperRegistry> const & helper_registry, | 215 | QSharedPointer<HelperRegistry> const & helper_registry, |
584 | 198 | QSharedPointer<StorageFrameworkClient> const & storage, | 216 | QSharedPointer<StorageFrameworkClient> const & storage, |
585 | @@ -251,3 +269,10 @@ | |||
586 | 251 | 269 | ||
587 | 252 | return d->to_string(state); | 270 | return d->to_string(state); |
588 | 253 | } | 271 | } |
589 | 272 | |||
590 | 273 | keeper::KeeperError KeeperTask::error() const | ||
591 | 274 | { | ||
592 | 275 | Q_D(const KeeperTask); | ||
593 | 276 | |||
594 | 277 | return d->error(); | ||
595 | 278 | } | ||
596 | 254 | 279 | ||
597 | === modified file 'src/service/keeper-task.h' | |||
598 | --- src/service/keeper-task.h 2016-11-08 09:03:09 +0000 | |||
599 | +++ src/service/keeper-task.h 2016-12-21 08:37:30 +0000 | |||
600 | @@ -20,6 +20,7 @@ | |||
601 | 20 | 20 | ||
602 | 21 | #pragma once | 21 | #pragma once |
603 | 22 | 22 | ||
604 | 23 | #include "client/keeper-errors.h" | ||
605 | 23 | #include "helper/metadata.h" | 24 | #include "helper/metadata.h" |
606 | 24 | #include "helper/backup-helper.h" | 25 | #include "helper/backup-helper.h" |
607 | 25 | #include "helper/helper.h" | 26 | #include "helper/helper.h" |
608 | @@ -40,7 +41,7 @@ | |||
609 | 40 | struct TaskData | 41 | struct TaskData |
610 | 41 | { | 42 | { |
611 | 42 | QString action; | 43 | QString action; |
613 | 43 | QString error; | 44 | keeper::KeeperError error; |
614 | 44 | Metadata metadata; | 45 | Metadata metadata; |
615 | 45 | }; | 46 | }; |
616 | 46 | 47 | ||
617 | @@ -61,6 +62,8 @@ | |||
618 | 61 | void cancel(); | 62 | void cancel(); |
619 | 62 | 63 | ||
620 | 63 | QString to_string(Helper::State state); | 64 | QString to_string(Helper::State state); |
621 | 65 | |||
622 | 66 | keeper::KeeperError error() const; | ||
623 | 64 | Q_SIGNALS: | 67 | Q_SIGNALS: |
624 | 65 | void task_state_changed(Helper::State state); | 68 | void task_state_changed(Helper::State state); |
625 | 66 | void task_socket_ready(int socket_descriptor); | 69 | void task_socket_ready(int socket_descriptor); |
626 | 67 | 70 | ||
627 | === modified file 'src/service/private/keeper-task_p.h' | |||
628 | --- src/service/private/keeper-task_p.h 2016-11-08 09:03:09 +0000 | |||
629 | +++ src/service/private/keeper-task_p.h 2016-12-21 08:37:30 +0000 | |||
630 | @@ -41,6 +41,9 @@ | |||
631 | 41 | static QVariantMap get_initial_state(KeeperTask::TaskData const &td); | 41 | static QVariantMap get_initial_state(KeeperTask::TaskData const &td); |
632 | 42 | 42 | ||
633 | 43 | QString to_string(Helper::State state); | 43 | QString to_string(Helper::State state); |
634 | 44 | |||
635 | 45 | keeper::KeeperError error() const; | ||
636 | 46 | |||
637 | 44 | protected: | 47 | protected: |
638 | 45 | void set_current_task_action(QString const& action); | 48 | void set_current_task_action(QString const& action); |
639 | 46 | void on_helper_percent_done_changed(float percent_done); | 49 | void on_helper_percent_done_changed(float percent_done); |
640 | @@ -57,4 +60,5 @@ | |||
641 | 57 | QSharedPointer<StorageFrameworkClient> storage_; | 60 | QSharedPointer<StorageFrameworkClient> storage_; |
642 | 58 | QSharedPointer<Helper> helper_; | 61 | QSharedPointer<Helper> helper_; |
643 | 59 | QVariantMap state_; | 62 | QVariantMap state_; |
644 | 63 | keeper::KeeperError error_; | ||
645 | 60 | }; | 64 | }; |
646 | 61 | 65 | ||
647 | === modified file 'src/service/task-manager.cpp' | |||
648 | --- src/service/task-manager.cpp 2016-12-01 14:18:57 +0000 | |||
649 | +++ src/service/task-manager.cpp 2016-12-21 08:37:30 +0000 | |||
650 | @@ -147,6 +147,7 @@ | |||
651 | 147 | auto& td = task_data_[uuid]; | 147 | auto& td = task_data_[uuid]; |
652 | 148 | td.metadata = metadata; | 148 | td.metadata = metadata; |
653 | 149 | td.action = QStringLiteral("queued"); // TODO i18n | 149 | td.action = QStringLiteral("queued"); // TODO i18n |
654 | 150 | td.error = keeper::KeeperError::OK; | ||
655 | 150 | set_initial_task_state(td); | 151 | set_initial_task_state(td); |
656 | 151 | } | 152 | } |
657 | 152 | 153 | ||
658 | @@ -169,7 +170,7 @@ | |||
659 | 169 | } | 170 | } |
660 | 170 | else | 171 | else |
661 | 171 | { | 172 | { |
663 | 172 | td.error = "Error storing manifest file"; | 173 | td.error = keeper::KeeperError::MANIFEST_STORAGE_ERROR; |
664 | 173 | set_current_task_action(task_->to_string(Helper::State::FAILED)); | 174 | set_current_task_action(task_->to_string(Helper::State::FAILED)); |
665 | 174 | } | 175 | } |
666 | 175 | active_manifest_.reset(); | 176 | active_manifest_.reset(); |
667 | 176 | 177 | ||
668 | === modified file 'tests/integration/helpers/helpers-test-failure.cpp' | |||
669 | --- tests/integration/helpers/helpers-test-failure.cpp 2016-09-29 13:49:14 +0000 | |||
670 | +++ tests/integration/helpers/helpers-test-failure.cpp 2016-12-21 08:37:30 +0000 | |||
671 | @@ -90,6 +90,13 @@ | |||
672 | 90 | // this one uses pooling so it should just call Get once | 90 | // this one uses pooling so it should just call Get once |
673 | 91 | EXPECT_TRUE(wait_for_all_tasks_have_action_state({user_folder_uuid}, "failed", user_iface)); | 91 | EXPECT_TRUE(wait_for_all_tasks_have_action_state({user_folder_uuid}, "failed", user_iface)); |
674 | 92 | 92 | ||
675 | 93 | QVariant error_value; | ||
676 | 94 | EXPECT_TRUE(get_task_property_now(user_folder_uuid, user_iface, "error", error_value)); | ||
677 | 95 | bool conversion_ok; | ||
678 | 96 | auto keeper_error = keeper::convertFromDBusVariant(error_value, &conversion_ok); | ||
679 | 97 | EXPECT_TRUE(conversion_ok); | ||
680 | 98 | EXPECT_EQ(keeper_error, keeper::KeeperError::HELPER_WRITE_ERROR); | ||
681 | 99 | |||
682 | 93 | // check that the content of the file is the expected | 100 | // check that the content of the file is the expected |
683 | 94 | EXPECT_EQ(0, StorageFrameworkLocalUtils::check_storage_framework_nb_files()); | 101 | EXPECT_EQ(0, StorageFrameworkLocalUtils::check_storage_framework_nb_files()); |
684 | 95 | 102 | ||
685 | 96 | 103 | ||
686 | === modified file 'tests/integration/helpers/helpers-test.cc' | |||
687 | --- tests/integration/helpers/helpers-test.cc 2016-11-22 09:37:40 +0000 | |||
688 | +++ tests/integration/helpers/helpers-test.cc 2016-12-21 08:37:30 +0000 | |||
689 | @@ -41,6 +41,7 @@ | |||
690 | 41 | BackupHelper helper("com.test.multiple_first_1.2.3"); | 41 | BackupHelper helper("com.test.multiple_first_1.2.3"); |
691 | 42 | 42 | ||
692 | 43 | QSignalSpy spy(&helper, &BackupHelper::state_changed); | 43 | QSignalSpy spy(&helper, &BackupHelper::state_changed); |
693 | 44 | QSignalSpy spy_error(&helper, &Helper::error); | ||
694 | 44 | 45 | ||
695 | 45 | helper.start({"/bin/ls","/tmp"}); | 46 | helper.start({"/bin/ls","/tmp"}); |
696 | 46 | 47 | ||
697 | @@ -53,6 +54,8 @@ | |||
698 | 53 | EXPECT_EQ(qvariant_cast<Helper::State>(arguments.at(0)), Helper::State::STARTED); | 54 | EXPECT_EQ(qvariant_cast<Helper::State>(arguments.at(0)), Helper::State::STARTED); |
699 | 54 | arguments = spy.takeFirst(); | 55 | arguments = spy.takeFirst(); |
700 | 55 | EXPECT_EQ(qvariant_cast<Helper::State>(arguments.at(0)), Helper::State::COMPLETE); | 56 | EXPECT_EQ(qvariant_cast<Helper::State>(arguments.at(0)), Helper::State::COMPLETE); |
701 | 57 | |||
702 | 58 | EXPECT_EQ(spy_error.count(), 0); | ||
703 | 56 | } | 59 | } |
704 | 57 | 60 | ||
705 | 58 | TEST_F(TestHelpers, StartFullTest) | 61 | TEST_F(TestHelpers, StartFullTest) |
706 | @@ -300,15 +303,20 @@ | |||
707 | 300 | BackupHelper helper("com.bar_foo_8432.13.1"); | 303 | BackupHelper helper("com.bar_foo_8432.13.1"); |
708 | 301 | 304 | ||
709 | 302 | QSignalSpy spy(&helper, &BackupHelper::state_changed); | 305 | QSignalSpy spy(&helper, &BackupHelper::state_changed); |
710 | 306 | QSignalSpy spy_error(&helper, &Helper::error); | ||
711 | 303 | QStringList urls; | 307 | QStringList urls; |
712 | 304 | urls << "blah" << "/tmp"; | 308 | urls << "blah" << "/tmp"; |
713 | 305 | helper.start(urls); | 309 | helper.start(urls); |
714 | 306 | 310 | ||
715 | 307 | WAIT_FOR_SIGNALS(spy, 1, Helper::MAX_UAL_WAIT_TIME + 1000); | 311 | WAIT_FOR_SIGNALS(spy, 1, Helper::MAX_UAL_WAIT_TIME + 1000); |
716 | 308 | 312 | ||
718 | 309 | ASSERT_EQ(spy.count(), 1); | 313 | ASSERT_EQ(1, spy.count()); |
719 | 310 | QList<QVariant> arguments = spy.takeFirst(); | 314 | QList<QVariant> arguments = spy.takeFirst(); |
721 | 311 | EXPECT_EQ(qvariant_cast<Helper::State>(arguments.at(0)), Helper::State::FAILED); | 315 | EXPECT_EQ(Helper::State::FAILED, qvariant_cast<Helper::State>(arguments.at(0))); |
722 | 316 | |||
723 | 317 | ASSERT_EQ(1, spy_error.count()); | ||
724 | 318 | arguments = spy_error.takeFirst(); | ||
725 | 319 | EXPECT_EQ(keeper::KeeperError::HELPER_START_TIMEOUT, qvariant_cast<keeper::KeeperError>(arguments.at(0))); | ||
726 | 312 | } | 320 | } |
727 | 313 | 321 | ||
728 | 314 | TEST_F(TestHelpers, Inactivity) | 322 | TEST_F(TestHelpers, Inactivity) |
729 | @@ -319,6 +327,7 @@ | |||
730 | 319 | BackupHelper helper("com.bar_foo_8432.13.1"); | 327 | BackupHelper helper("com.bar_foo_8432.13.1"); |
731 | 320 | 328 | ||
732 | 321 | QSignalSpy spy(&helper, &BackupHelper::state_changed); | 329 | QSignalSpy spy(&helper, &BackupHelper::state_changed); |
733 | 330 | QSignalSpy spy_error(&helper, &Helper::error); | ||
734 | 322 | QStringList urls; | 331 | QStringList urls; |
735 | 323 | urls << TEST_INACTIVE_HELPER << "/tmp"; | 332 | urls << TEST_INACTIVE_HELPER << "/tmp"; |
736 | 324 | helper.start(urls); | 333 | helper.start(urls); |
737 | @@ -329,9 +338,13 @@ | |||
738 | 329 | // We can also check at the end for the state, which should be CANCELLED | 338 | // We can also check at the end for the state, which should be CANCELLED |
739 | 330 | WAIT_FOR_SIGNALS(spy, 2, BackupHelper::MAX_INACTIVITY_TIME + 2000); | 339 | WAIT_FOR_SIGNALS(spy, 2, BackupHelper::MAX_INACTIVITY_TIME + 2000); |
740 | 331 | 340 | ||
742 | 332 | ASSERT_EQ(spy.count(), 2); | 341 | ASSERT_EQ(2, spy.count()); |
743 | 333 | QList<QVariant> arguments = spy.takeFirst(); | 342 | QList<QVariant> arguments = spy.takeFirst(); |
744 | 334 | EXPECT_EQ(qvariant_cast<Helper::State>(arguments.at(0)), Helper::State::STARTED); | 343 | EXPECT_EQ(qvariant_cast<Helper::State>(arguments.at(0)), Helper::State::STARTED); |
745 | 335 | arguments = spy.takeFirst(); | 344 | arguments = spy.takeFirst(); |
746 | 336 | EXPECT_EQ(qvariant_cast<Helper::State>(arguments.at(0)), Helper::State::CANCELLED); | 345 | EXPECT_EQ(qvariant_cast<Helper::State>(arguments.at(0)), Helper::State::CANCELLED); |
747 | 346 | |||
748 | 347 | ASSERT_EQ(1, spy_error.count()); | ||
749 | 348 | arguments = spy_error.takeFirst(); | ||
750 | 349 | EXPECT_EQ(keeper::KeeperError::HELPER_INACTIVITY_DETECTED, qvariant_cast<keeper::KeeperError>(arguments.at(0))); | ||
751 | 337 | } | 350 | } |
752 | 338 | 351 | ||
753 | === modified file 'tests/integration/helpers/test-helpers-base.cpp' | |||
754 | --- tests/integration/helpers/test-helpers-base.cpp 2016-11-11 14:50:06 +0000 | |||
755 | +++ tests/integration/helpers/test-helpers-base.cpp 2016-12-21 08:37:30 +0000 | |||
756 | @@ -368,6 +368,7 @@ | |||
757 | 368 | void TestHelpersBase::SetUp() | 368 | void TestHelpersBase::SetUp() |
758 | 369 | { | 369 | { |
759 | 370 | Helper::registerMetaTypes(); | 370 | Helper::registerMetaTypes(); |
760 | 371 | DBusTypes::registerMetaTypes(); | ||
761 | 371 | 372 | ||
762 | 372 | g_setenv("XDG_DATA_DIRS", CMAKE_SOURCE_DIR, true); | 373 | g_setenv("XDG_DATA_DIRS", CMAKE_SOURCE_DIR, true); |
763 | 373 | g_setenv("XDG_CACHE_HOME", CMAKE_SOURCE_DIR "/libertine-data", true); | 374 | g_setenv("XDG_CACHE_HOME", CMAKE_SOURCE_DIR "/libertine-data", true); |
764 | @@ -440,6 +441,27 @@ | |||
765 | 440 | return finished; | 441 | return finished; |
766 | 441 | } | 442 | } |
767 | 442 | 443 | ||
768 | 444 | bool TestHelpersBase::get_task_property_now(QString const & uuid, QSharedPointer<DBusInterfaceKeeperUser> const & keeper_user_iface, QString const & property, QVariant & value) const | ||
769 | 445 | { | ||
770 | 446 | auto state = keeper_user_iface->state(); | ||
771 | 447 | auto iter = state.find(uuid); | ||
772 | 448 | if (iter == state.end()) | ||
773 | 449 | { | ||
774 | 450 | qWarning() << "Task " << uuid << " was not found in State"; | ||
775 | 451 | return false; | ||
776 | 452 | } | ||
777 | 453 | |||
778 | 454 | auto iter_props = (*iter).find(property); | ||
779 | 455 | if (iter_props == (*iter).end()) | ||
780 | 456 | { | ||
781 | 457 | qWarning() << "Property " << property << " was not found for task " << uuid; | ||
782 | 458 | return false; | ||
783 | 459 | } | ||
784 | 460 | |||
785 | 461 | value = (*iter_props); | ||
786 | 462 | return true; | ||
787 | 463 | } | ||
788 | 464 | |||
789 | 443 | bool TestHelpersBase::check_task_has_action_state(QVariantDictMap const & state, QString const & uuid, QString const & action_state) | 465 | bool TestHelpersBase::check_task_has_action_state(QVariantDictMap const & state, QString const & uuid, QString const & action_state) |
790 | 444 | { | 466 | { |
791 | 445 | auto iter = state.find(uuid); | 467 | auto iter = state.find(uuid); |
792 | 446 | 468 | ||
793 | === modified file 'tests/integration/helpers/test-helpers-base.h' | |||
794 | --- tests/integration/helpers/test-helpers-base.h 2016-10-14 09:23:11 +0000 | |||
795 | +++ tests/integration/helpers/test-helpers-base.h 2016-12-21 08:37:30 +0000 | |||
796 | @@ -97,6 +97,8 @@ | |||
797 | 97 | 97 | ||
798 | 98 | bool check_task_has_action_state(QVariantDictMap const & state, QString const & uuid, QString const & action_state); | 98 | bool check_task_has_action_state(QVariantDictMap const & state, QString const & uuid, QString const & action_state); |
799 | 99 | 99 | ||
800 | 100 | bool get_task_property_now(QString const & uuid, QSharedPointer<DBusInterfaceKeeperUser> const & keeper_user_iface, QString const & property, QVariant & value) const; | ||
801 | 101 | |||
802 | 100 | bool capture_and_check_state_until_all_tasks_complete(QSignalSpy & spy, QStringList const & uuids, QString const & action_state, int max_timeout_msec = 15000); | 102 | bool capture_and_check_state_until_all_tasks_complete(QSignalSpy & spy, QStringList const & uuids, QString const & action_state, int max_timeout_msec = 15000); |
803 | 101 | 103 | ||
804 | 102 | bool cancel_first_task_at_percentage(QSignalSpy & spy, double expected_percentage, QSharedPointer<DBusInterfaceKeeperUser> const & user_iface, int max_timeout_msec = 15000); | 104 | bool cancel_first_task_at_percentage(QSignalSpy & spy, double expected_percentage, QSharedPointer<DBusInterfaceKeeperUser> const & user_iface, int max_timeout_msec = 15000); |
805 | 103 | 105 | ||
806 | === modified file 'tests/utils/CMakeLists.txt' | |||
807 | --- tests/utils/CMakeLists.txt 2016-09-29 13:49:14 +0000 | |||
808 | +++ tests/utils/CMakeLists.txt 2016-12-21 08:37:30 +0000 | |||
809 | @@ -19,6 +19,7 @@ | |||
810 | 19 | target_link_libraries( | 19 | target_link_libraries( |
811 | 20 | ${LIB_NAME} | 20 | ${LIB_NAME} |
812 | 21 | backup-helper | 21 | backup-helper |
813 | 22 | keeper-errors-lib | ||
814 | 22 | util | 23 | util |
815 | 23 | Qt5::Core | 24 | Qt5::Core |
816 | 24 | ) | 25 | ) |
PASSED: Continuous integration, rev:131 /jenkins. canonical. com/unity- api-1/job/ lp-keeper- ci/150/ /jenkins. canonical. com/unity- api-1/job/ build/1268 /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/1275 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1056 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1056/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= zesty/1056 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= zesty/1056/ artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1056 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1056/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= zesty/1056 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= zesty/1056/ artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1056 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1056/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= zesty/1056 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= zesty/1056/ artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-keeper- ci/150/ rebuild
https:/