Merge lp:~xavi-garcia-mena/keeper/keeper-errors-in-state-property into lp:keeper/devel

Proposed by Xavi Garcia
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
Reviewer Review Type Date Requested Status
unity-api-1-bot continuous-integration Approve
Charles Kerr (community) Approve
Review via email: mp+313221@code.launchpad.net

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.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:131
https://jenkins.canonical.com/unity-api-1/job/lp-keeper-ci/150/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1268
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1275
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1056
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1056/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1056
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1056/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1056
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1056/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1056
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1056/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1056
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1056/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1056
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1056/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-keeper-ci/150/rebuild

review: Approve (continuous-integration)
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:132
https://jenkins.canonical.com/unity-api-1/job/lp-keeper-ci/151/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1269
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1276
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1057
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1057/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1057
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1057/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1057
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1057/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1057
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1057/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1057
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1057/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1057
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1057/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-keeper-ci/151/rebuild

review: Approve (continuous-integration)
Revision history for this message
Charles Kerr (charlesk) wrote :

Looks really good. As usual some minor suggestions, but less even of those than usual. Nice work.

review: Approve
Revision history for this message
Xavi Garcia (xavi-garcia-mena) wrote :

Thanks for the review, Charles.

I did all the suggested changes

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:133
https://jenkins.canonical.com/unity-api-1/job/lp-keeper-ci/157/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1288
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1295
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1076
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1076/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1076
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1076/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1076
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1076/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1076
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1076/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1076
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1076/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1076
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1076/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-keeper-ci/157/rebuild

review: Approve (continuous-integration)
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://jenkins.canonical.com/unity-api-1/job/lp-keeper-autoland/21/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/1289/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1296
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1077
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1077/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1077
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1077/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1077/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1077
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1077/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1077
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1077/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1077
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1077/artifact/output/*zip*/output.zip

review: Needs Fixing (continuous-integration)
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

FAILED: Autolanding.
More details in the following jenkins job:
https://jenkins.canonical.com/unity-api-1/job/lp-keeper-autoland/22/
Executed test runs:
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build/1290/console
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1297
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1078
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1078/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1078
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1078/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1078
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1078/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1078
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1078/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1078
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1078/artifact/output/*zip*/output.zip
    FAILURE: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1078/console

review: Needs Fixing (continuous-integration)
Revision history for this message
unity-api-1-bot (unity-api-1-bot) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/client/client.h'
--- include/client/client.h 2016-12-05 11:36:32 +0000
+++ include/client/client.h 2016-12-21 08:37:30 +0000
@@ -19,6 +19,8 @@
1919
20#pragma once20#pragma once
2121
22#include "keeper-errors.h"
23
22#include <QObject>24#include <QObject>
23#include <QScopedPointer>25#include <QScopedPointer>
24#include <QStringList>26#include <QStringList>
@@ -73,7 +75,7 @@
73 void readyToBackupChanged();75 void readyToBackupChanged();
74 void backupBusyChanged();76 void backupBusyChanged();
7577
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);
77 void finished();79 void finished();
7880
79private Q_SLOTS:81private Q_SLOTS:
8082
=== added file 'include/client/keeper-errors.h'
--- include/client/keeper-errors.h 1970-01-01 00:00:00 +0000
+++ include/client/keeper-errors.h 2016-12-21 08:37:30 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Xavi Garcia Mena <xavi.garcia.mena@canonical.com>
18 */
19
20#pragma once
21
22#include <QDBusArgument>
23#include <QMetaType>
24
25namespace keeper
26{
27
28enum class KeeperError
29{
30 OK,
31 ERROR_UNKNOWN,
32 HELPER_READ_ERROR,
33 HELPER_WRITE_ERROR,
34 HELPER_INACTIVITY_DETECTED,
35 HELPER_SOCKET_ERROR,
36 HELPER_START_TIMEOUT,
37 NO_HELPER_INFORMATION_IN_REGISTRY,
38 HELPER_BAD_URL,
39 MANIFEST_STORAGE_ERROR,
40 COMMITTING_DATA_ERROR
41};
42
43KeeperError convertFromDBusVariant(const QVariant & value, bool *conversion_ok = nullptr);
44} // namespace keeper
45
46QDBusArgument &operator<<(QDBusArgument &argument, keeper::KeeperError value);
47const QDBusArgument &operator>>(const QDBusArgument &argument, keeper::KeeperError &val);
48
49Q_DECLARE_METATYPE(keeper::KeeperError)
050
=== modified file 'include/helper/helper.h'
--- include/helper/helper.h 2016-09-15 16:02:54 +0000
+++ include/helper/helper.h 2016-12-21 08:37:30 +0000
@@ -19,6 +19,7 @@
1919
20#pragma once20#pragma once
2121
22#include <client/keeper-errors.h>
22#include <util/attributes.h>23#include <util/attributes.h>
2324
24#include <QObject>25#include <QObject>
@@ -69,6 +70,7 @@
69Q_SIGNALS:70Q_SIGNALS:
70 void state_changed(Helper::State);71 void state_changed(Helper::State);
71 void percent_done_changed(float);72 void percent_done_changed(float);
73 void error(keeper::KeeperError error);
7274
73protected:75protected:
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);
7577
=== modified file 'src/cli/command-line-client-view.cpp'
--- src/cli/command-line-client-view.cpp 2016-12-01 14:18:57 +0000
+++ src/cli/command-line-client-view.cpp 2016-12-21 08:37:30 +0000
@@ -48,7 +48,7 @@
4848
49void CommandLineClientView::add_task(QString const & display_name, QString const & initial_status, double initial_percentage)49void CommandLineClientView::add_task(QString const & display_name, QString const & initial_status, double initial_percentage)
50{50{
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);
52 // TODO see if we can do this in a better way52 // TODO see if we can do this in a better way
53 // We add a line per each backup task53 // We add a line per each backup task
54 std::cout << std::endl;54 std::cout << std::endl;
@@ -112,17 +112,62 @@
112 return ret;112 return ret;
113}113}
114114
115QString CommandLineClientView::get_task_string(QString const & displayName, QString const & status, double percentage)115QString CommandLineClientView::get_task_string(QString const & displayName, QString const & status, double percentage, keeper::KeeperError error)
116{116{
117117
118 return QStringLiteral("%1 %2 % %3").arg(displayName, 15).arg((percentage * 100), 10, 'f', 2, ' ').arg(status, -15);118 if (error == keeper::KeeperError::OK)
119}119 return QStringLiteral("%1 %2 % %3").arg(displayName, 15).arg((percentage * 100), 10, 'f', 2, ' ').arg(status, -15);
120120 else
121void 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));
122}
123
124QString CommandLineClientView::get_error_string(keeper::KeeperError error)
125{
126 QString ret;
127 switch(error)
128 {
129 case keeper::KeeperError::ERROR_UNKNOWN:
130 ret = QStringLiteral("Unknown error");
131 break;
132 case keeper::KeeperError::HELPER_BAD_URL:
133 ret = QStringLiteral("Bad URL for keeper helper");
134 break;
135 case keeper::KeeperError::HELPER_INACTIVITY_DETECTED:
136 ret = QStringLiteral("Inactivity detected in task");
137 break;
138 case keeper::KeeperError::HELPER_START_TIMEOUT:
139 ret = QStringLiteral("Task failed to start");
140 break;
141 case keeper::KeeperError::HELPER_READ_ERROR:
142 ret = QStringLiteral("Read error");
143 break;
144 case keeper::KeeperError::HELPER_SOCKET_ERROR:
145 ret = QStringLiteral("Error creating internal socket");
146 break;
147 case keeper::KeeperError::HELPER_WRITE_ERROR:
148 ret = QStringLiteral("Write error");
149 break;
150 case keeper::KeeperError::MANIFEST_STORAGE_ERROR:
151 ret = QStringLiteral("Error storing manifest file");
152 break;
153 case keeper::KeeperError::NO_HELPER_INFORMATION_IN_REGISTRY:
154 ret = QStringLiteral("No helper information in registry");
155 break;
156 case keeper::KeeperError::OK:
157 ret = QStringLiteral("Success");
158 break;
159 case keeper::KeeperError::COMMITTING_DATA_ERROR:
160 ret = QStringLiteral("Error uploading data");
161 break;
162 }
163 return ret;
164}
165
166void CommandLineClientView::on_task_state_changed(QString const & displayName, QString const & status, double percentage, keeper::KeeperError error)
122{167{
123 auto iter = tasks_strings_.find(displayName);168 auto iter = tasks_strings_.find(displayName);
124 if (iter != tasks_strings_.end())169 if (iter != tasks_strings_.end())
125 {170 {
126 tasks_strings_[displayName] = get_task_string(displayName, status, percentage);171 tasks_strings_[displayName] = get_task_string(displayName, status, percentage, error);
127 }172 }
128}173}
129174
=== modified file 'src/cli/command-line-client-view.h'
--- src/cli/command-line-client-view.h 2016-11-30 14:46:29 +0000
+++ src/cli/command-line-client-view.h 2016-12-21 08:37:30 +0000
@@ -18,6 +18,8 @@
18 */18 */
19#pragma once19#pragma once
2020
21#include <client/keeper-errors.h>
22
21#include <QMap>23#include <QMap>
22#include <QObject>24#include <QObject>
23#include <QTimer>25#include <QTimer>
@@ -43,11 +45,12 @@
4345
44public Q_SLOTS:46public Q_SLOTS:
45 void show_info();47 void show_info();
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);
4749
48private:50private:
49 char get_next_spin_char();51 char get_next_spin_char();
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);
53 QString get_error_string(keeper::KeeperError error);
5154
52 QString status_;55 QString status_;
53 QTimer timer_status_;56 QTimer timer_status_;
5457
=== modified file 'src/client/CMakeLists.txt'
--- src/client/CMakeLists.txt 2016-11-30 14:46:29 +0000
+++ src/client/CMakeLists.txt 2016-12-21 08:37:30 +0000
@@ -1,8 +1,21 @@
1add_subdirectory(qml-plugin)1add_subdirectory(qml-plugin)
22
3set(3set(
4 KEEPER_ERRORS_LIB
5 keeper-errors-lib
6)
7
8add_library(
9 ${KEEPER_ERRORS_LIB}
10 STATIC
11 keeper-errors.cpp
12 ${CMAKE_SOURCE_DIR}/include/client/keeper-errors.h
13)
14
15set(
4 CLIENT_HEADERS16 CLIENT_HEADERS
5 ${CMAKE_SOURCE_DIR}/include/client/client.h17 ${CMAKE_SOURCE_DIR}/include/client/client.h
18 ${CMAKE_SOURCE_DIR}/include/client/keeper-errors.h
6)19)
720
8add_library(21add_library(
@@ -18,6 +31,7 @@
1831
19target_link_libraries(32target_link_libraries(
20 ${KEEPER_CLIENT_LIB}33 ${KEEPER_CLIENT_LIB}
34 ${KEEPER_ERRORS_LIB}
21 qdbus-stubs35 qdbus-stubs
22 Qt5::Core36 Qt5::Core
23 Qt5::DBus37 Qt5::DBus
2438
=== modified file 'src/client/client.cpp'
--- src/client/client.cpp 2016-12-16 09:34:05 +0000
+++ src/client/client.cpp 2016-12-21 08:37:30 +0000
@@ -281,12 +281,20 @@
281 double progress = state.value("percent-done").toDouble();281 double progress = state.value("percent-done").toDouble();
282 auto status = state.value("action").toString();282 auto status = state.value("action").toString();
283283
284 keeper::KeeperError keeper_error = keeper::KeeperError::OK;
285 auto iter_error = state.find("error");
286 if (iter_error != state.end())
287 {
288 bool conversion_ok;
289 keeper_error = keeper::convertFromDBusVariant(state.value("error"), &conversion_ok);
290 }
291
284 auto current_state = d->task_status[uuid];292 auto current_state = d->task_status[uuid];
285 if (current_state.status != status || current_state.percentage < progress)293 if (current_state.status != status || current_state.percentage < progress)
286 {294 {
287 d->task_status[uuid].status = status;295 d->task_status[uuid].status = status;
288 d->task_status[uuid].percentage = progress;296 d->task_status[uuid].percentage = progress;
289 Q_EMIT(taskStatusChanged(state.value("display-name").toString(), status, progress));297 Q_EMIT(taskStatusChanged(state.value("display-name").toString(), status, progress, keeper_error));
290 }298 }
291 }299 }
292300
293301
=== added file 'src/client/keeper-errors.cpp'
--- src/client/keeper-errors.cpp 1970-01-01 00:00:00 +0000
+++ src/client/keeper-errors.cpp 2016-12-21 08:37:30 +0000
@@ -0,0 +1,74 @@
1/*
2 * Copyright (C) 2016 Canonical, Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Xavi Garcia <xavi.garcia.mena@canonical.com>
18 */
19
20#include <client/keeper-errors.h>
21
22#include <QDebug>
23
24QDBusArgument &operator<<(QDBusArgument &argument, keeper::KeeperError value)
25{
26 argument.beginStructure();
27 argument << static_cast<int>(value);
28 argument.endStructure();
29 return argument;
30}
31
32const QDBusArgument &operator>>(const QDBusArgument &argument, keeper::KeeperError &val)
33{
34 int int_val;
35 argument.beginStructure();
36 argument >> int_val;
37 val = static_cast<keeper::KeeperError>(int_val);
38 argument.endStructure();
39 return argument;
40}
41
42namespace keeper
43{
44KeeperError convertFromDBusVariant(const QVariant & value, bool *conversion_ok)
45{
46 if (value.typeName() != QStringLiteral("QDBusArgument"))
47 {
48 qWarning() << Q_FUNC_INFO
49 << " Error converting dbus QVariant to KeeperError, expected type is [ QDBusArgument ] and current type is: ["
50 << value.typeName() << "]";
51 if (conversion_ok)
52 *conversion_ok = false;
53 return KeeperError(keeper::KeeperError::ERROR_UNKNOWN);
54 }
55 auto dbus_arg = value.value<QDBusArgument>();
56
57 if (dbus_arg.currentSignature() != "(i)")
58 {
59 qWarning() << Q_FUNC_INFO
60 << " Error converting dbus QVariant to KeeperError, expected signature is \"(i)\" and current signature is: \""
61 << dbus_arg.currentSignature() << "\"";
62 if (conversion_ok)
63 *conversion_ok = false;
64 return KeeperError(keeper::KeeperError::ERROR_UNKNOWN);
65 }
66 KeeperError ret;
67 dbus_arg >> ret;
68
69 if (conversion_ok)
70 *conversion_ok = true;
71
72 return ret;
73}
74}
075
=== modified file 'src/helper/backup-helper.cpp'
--- src/helper/backup-helper.cpp 2016-10-06 14:53:44 +0000
+++ src/helper/backup-helper.cpp 2016-12-21 08:37:30 +0000
@@ -62,8 +62,8 @@
62 int rc = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, fds);62 int rc = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, fds);
63 if (rc == -1)63 if (rc == -1)
64 {64 {
65 // TODO throw exception.65 qWarning() << QStringLiteral("Error creating socket to communicate with helper");;
66 qWarning() << "BackupHelperPrivate: error creating socket pair to communicate with helper ";66 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_SOCKET_ERROR));
67 return;67 return;
68 }68 }
6969
@@ -140,7 +140,10 @@
140 std::function<void(bool)>{[this](bool success){140 std::function<void(bool)>{[this](bool success){
141 qDebug() << "Commit finished";141 qDebug() << "Commit finished";
142 if (!success)142 if (!success)
143 {
143 write_error_ = true;144 write_error_ = true;
145 Q_EMIT(q_ptr->error(keeper::KeeperError::COMMITTING_DATA_ERROR));
146 }
144 else147 else
145 uploader_committed_file_name_ = uploader_->file_name();148 uploader_committed_file_name_ = uploader_->file_name();
146 uploader_.reset();149 uploader_.reset();
@@ -175,6 +178,7 @@
175 {178 {
176 stop_inactivity_timer();179 stop_inactivity_timer();
177 qWarning() << "Inactivity detected in the helper...stopping it";180 qWarning() << "Inactivity detected in the helper...stopping it";
181 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_INACTIVITY_DETECTED));
178 stop();182 stop();
179 }183 }
180184
@@ -212,6 +216,7 @@
212 }216 }
213 else if (n < 0) {217 else if (n < 0) {
214 read_error_ = true;218 read_error_ = true;
219 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_READ_ERROR));
215 stop();220 stop();
216 return;221 return;
217 }222 }
@@ -228,6 +233,7 @@
228 if (n < 0) {233 if (n < 0) {
229 write_error_ = true;234 write_error_ = true;
230 qWarning() << "Write error:" << socket->errorString();235 qWarning() << "Write error:" << socket->errorString();
236 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_WRITE_ERROR));
231 stop();237 stop();
232 }238 }
233 break;239 break;
@@ -258,6 +264,10 @@
258 {264 {
259 if (!q_ptr->is_helper_running())265 if (!q_ptr->is_helper_running())
260 {266 {
267 if (n_uploaded_ > q_ptr->expected_size())
268 {
269 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_WRITE_ERROR));
270 }
261 q_ptr->set_state(Helper::State::FAILED);271 q_ptr->set_state(Helper::State::FAILED);
262 }272 }
263 }273 }
264274
=== modified file 'src/helper/helper.cpp'
--- src/helper/helper.cpp 2016-11-21 12:03:56 +0000
+++ src/helper/helper.cpp 2016-12-21 08:37:30 +0000
@@ -359,7 +359,8 @@
359359
360 void on_max_time_waiting_for_ual_started()360 void on_max_time_waiting_for_ual_started()
361 {361 {
362 qDebug() << "Max time reached waiting for UAL to start";362 qWarning() << "Maximum time reached waiting for the helper to start.";
363 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_START_TIMEOUT));
363 q_ptr->set_state(Helper::State::FAILED);364 q_ptr->set_state(Helper::State::FAILED);
364 stop_wait_for_ual_timer();365 stop_wait_for_ual_timer();
365 }366 }
366367
=== modified file 'src/helper/restore-helper.cpp'
--- src/helper/restore-helper.cpp 2016-12-05 11:36:32 +0000
+++ src/helper/restore-helper.cpp 2016-12-21 08:37:30 +0000
@@ -57,8 +57,8 @@
57 int rc = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, fds);57 int rc = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, fds);
58 if (rc == -1)58 if (rc == -1)
59 {59 {
60 // TODO throw exception.60 qWarning() << QStringLiteral("Error creating socket to communicate with helper");;
61 qWarning() << "RestoreHelperPrivate: error creating socket pair to communicate with helper ";61 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_SOCKET_ERROR));
62 return;62 return;
63 }63 }
6464
@@ -167,6 +167,7 @@
167 {167 {
168 stop_inactivity_timer();168 stop_inactivity_timer();
169 qWarning() << "Inactivity detected in the helper...stopping it";169 qWarning() << "Inactivity detected in the helper...stopping it";
170 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_INACTIVITY_DETECTED));
170 stop();171 stop();
171 }172 }
172173
@@ -207,6 +208,7 @@
207 else if (n < 0) {208 else if (n < 0) {
208 read_error_ = true;209 read_error_ = true;
209 qDebug() << "Read error in restore helper: " << socket->errorString();210 qDebug() << "Read error in restore helper: " << socket->errorString();
211 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_READ_ERROR));
210 stop();212 stop();
211 return;213 return;
212 }214 }
@@ -226,6 +228,7 @@
226 if (n < 0) {228 if (n < 0) {
227 write_error_ = true;229 write_error_ = true;
228 qWarning() << "Write error:" << write_socket_.errorString();230 qWarning() << "Write error:" << write_socket_.errorString();
231 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_WRITE_ERROR));
229 stop();232 stop();
230 }233 }
231 break;234 break;
@@ -257,6 +260,10 @@
257 {260 {
258 if (!q_ptr->is_helper_running())261 if (!q_ptr->is_helper_running())
259 {262 {
263 if (n_uploaded_ > q_ptr->expected_size())
264 {
265 Q_EMIT(q_ptr->error(keeper::KeeperError::HELPER_WRITE_ERROR));
266 }
260 q_ptr->set_state(Helper::State::FAILED);267 q_ptr->set_state(Helper::State::FAILED);
261 }268 }
262 }269 }
263270
=== modified file 'src/qdbus-stubs/dbus-types.h'
--- src/qdbus-stubs/dbus-types.h 2016-11-30 14:46:29 +0000
+++ src/qdbus-stubs/dbus-types.h 2016-12-21 08:37:30 +0000
@@ -22,6 +22,7 @@
22#include <QtCore>22#include <QtCore>
23#include <QString>23#include <QString>
24#include <QVariantMap>24#include <QVariantMap>
25#include <client/keeper-errors.h>
2526
26typedef QMap<QString, QVariantMap> QVariantDictMap;27typedef QMap<QString, QVariantMap> QVariantDictMap;
27Q_DECLARE_METATYPE(QVariantDictMap)28Q_DECLARE_METATYPE(QVariantDictMap)
@@ -35,10 +36,11 @@
35 {36 {
36 qRegisterMetaType<QVariantDictMap>("QVariantDictMap");37 qRegisterMetaType<QVariantDictMap>("QVariantDictMap");
37 qRegisterMetaType<QStringMap>("QStringMap");38 qRegisterMetaType<QStringMap>("QStringMap");
39 qRegisterMetaType<keeper::KeeperError>("keeper::KeeperError");
3840
39 qDBusRegisterMetaType<QVariantDictMap>();41 qDBusRegisterMetaType<QVariantDictMap>();
40 qDBusRegisterMetaType<QStringMap>();42 qDBusRegisterMetaType<QStringMap>();
41// Helper::registerMetaTypes();43 qDBusRegisterMetaType<keeper::KeeperError>();
42 }44 }
4345
44 constexpr const char KEEPER_SERVICE[] = "com.canonical.keeper";46 constexpr const char KEEPER_SERVICE[] = "com.canonical.keeper";
4547
=== modified file 'src/service/CMakeLists.txt'
--- src/service/CMakeLists.txt 2016-11-11 14:50:06 +0000
+++ src/service/CMakeLists.txt 2016-12-21 08:37:30 +0000
@@ -49,6 +49,7 @@
49 storage-framework49 storage-framework
50 util50 util
51 qdbus-stubs51 qdbus-stubs
52 keeper-errors-lib
52)53)
5354
54target_link_libraries(55target_link_libraries(
5556
=== modified file 'src/service/keeper-task-backup.cpp'
--- src/service/keeper-task-backup.cpp 2016-11-08 09:03:09 +0000
+++ src/service/keeper-task-backup.cpp 2016-12-21 08:37:30 +0000
@@ -50,6 +50,7 @@
50 qDebug() << "Initializing a backup helper";50 qDebug() << "Initializing a backup helper";
51 helper_.reset(new BackupHelper(DEKKO_APP_ID), [](Helper *h){h->deleteLater();});51 helper_.reset(new BackupHelper(DEKKO_APP_ID), [](Helper *h){h->deleteLater();});
52 qDebug() << "Helper " << static_cast<void*>(helper_.data()) << " was created";52 qDebug() << "Helper " << static_cast<void*>(helper_.data()) << " was created";
53 QObject::connect(helper_.data(), &Helper::error, [this](keeper::KeeperError error){ error_ = error;});
53 }54 }
5455
55 void ask_for_uploader(quint64 n_bytes, QString const & dir_name)56 void ask_for_uploader(quint64 n_bytes, QString const & dir_name)
5657
=== modified file 'src/service/keeper-task.cpp'
--- src/service/keeper-task.cpp 2016-11-08 09:03:09 +0000
+++ src/service/keeper-task.cpp 2016-12-21 08:37:30 +0000
@@ -35,6 +35,7 @@
35 , task_data_(task_data)35 , task_data_(task_data)
36 , helper_registry_(helper_registry)36 , helper_registry_(helper_registry)
37 , storage_(storage)37 , storage_(storage)
38 , error_(keeper::KeeperError::OK)
38{39{
39}40}
4041
@@ -49,8 +50,8 @@
49 if (urls.isEmpty())50 if (urls.isEmpty())
50 {51 {
51 task_data_.action = helper_->to_string(Helper::State::FAILED);52 task_data_.action = helper_->to_string(Helper::State::FAILED);
52 task_data_.error = "no helper information in registry";53 error_ = keeper::KeeperError::HELPER_BAD_URL;
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());
54 calculate_and_notify_state(Helper::State::FAILED);55 calculate_and_notify_state(Helper::State::FAILED);
55 return false;56 return false;
56 }57 }
@@ -65,6 +66,10 @@
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)
66 );67 );
6768
69 QObject::connect(helper_.data(), &Helper::error, [this](keeper::KeeperError error){
70 error_ = error;
71 });
72
68 helper_->start(urls);73 helper_->start(urls);
69 return true;74 return true;
70}75}
@@ -132,8 +137,16 @@
132 auto const percent_done = helper_->percent_done();137 auto const percent_done = helper_->percent_done();
133 ret.insert(QStringLiteral("percent-done"), double(percent_done));138 ret.insert(QStringLiteral("percent-done"), double(percent_done));
134139
140 qDebug() << "task_data_.action = " << task_data_.action;
135 if (task_data_.action == "failed" || task_data_.action == "cancelled")141 if (task_data_.action == "failed" || task_data_.action == "cancelled")
136 ret.insert(QStringLiteral("error"), task_data_.error);142 {
143 auto error = error_;
144 if (task_data_.error != keeper::KeeperError::OK)
145 {
146 error = task_data_.error;
147 }
148 ret.insert(QStringLiteral("error"), qVariantFromValue(error));
149 }
137150
138 ret.insert(QStringLiteral("uuid"), uuid);151 ret.insert(QStringLiteral("uuid"), uuid);
139152
@@ -193,6 +206,11 @@
193 }206 }
194}207}
195208
209keeper::KeeperError KeeperTaskPrivate::error() const
210{
211 return error_;
212}
213
196KeeperTask::KeeperTask(TaskData & task_data,214KeeperTask::KeeperTask(TaskData & task_data,
197 QSharedPointer<HelperRegistry> const & helper_registry,215 QSharedPointer<HelperRegistry> const & helper_registry,
198 QSharedPointer<StorageFrameworkClient> const & storage,216 QSharedPointer<StorageFrameworkClient> const & storage,
@@ -251,3 +269,10 @@
251269
252 return d->to_string(state);270 return d->to_string(state);
253}271}
272
273keeper::KeeperError KeeperTask::error() const
274{
275 Q_D(const KeeperTask);
276
277 return d->error();
278}
254279
=== modified file 'src/service/keeper-task.h'
--- src/service/keeper-task.h 2016-11-08 09:03:09 +0000
+++ src/service/keeper-task.h 2016-12-21 08:37:30 +0000
@@ -20,6 +20,7 @@
2020
21#pragma once21#pragma once
2222
23#include "client/keeper-errors.h"
23#include "helper/metadata.h"24#include "helper/metadata.h"
24#include "helper/backup-helper.h"25#include "helper/backup-helper.h"
25#include "helper/helper.h"26#include "helper/helper.h"
@@ -40,7 +41,7 @@
40 struct TaskData41 struct TaskData
41 {42 {
42 QString action;43 QString action;
43 QString error;44 keeper::KeeperError error;
44 Metadata metadata;45 Metadata metadata;
45 };46 };
4647
@@ -61,6 +62,8 @@
61 void cancel();62 void cancel();
6263
63 QString to_string(Helper::State state);64 QString to_string(Helper::State state);
65
66 keeper::KeeperError error() const;
64Q_SIGNALS:67Q_SIGNALS:
65 void task_state_changed(Helper::State state);68 void task_state_changed(Helper::State state);
66 void task_socket_ready(int socket_descriptor);69 void task_socket_ready(int socket_descriptor);
6770
=== modified file 'src/service/private/keeper-task_p.h'
--- src/service/private/keeper-task_p.h 2016-11-08 09:03:09 +0000
+++ src/service/private/keeper-task_p.h 2016-12-21 08:37:30 +0000
@@ -41,6 +41,9 @@
41 static QVariantMap get_initial_state(KeeperTask::TaskData const &td);41 static QVariantMap get_initial_state(KeeperTask::TaskData const &td);
4242
43 QString to_string(Helper::State state);43 QString to_string(Helper::State state);
44
45 keeper::KeeperError error() const;
46
44protected:47protected:
45 void set_current_task_action(QString const& action);48 void set_current_task_action(QString const& action);
46 void on_helper_percent_done_changed(float percent_done);49 void on_helper_percent_done_changed(float percent_done);
@@ -57,4 +60,5 @@
57 QSharedPointer<StorageFrameworkClient> storage_;60 QSharedPointer<StorageFrameworkClient> storage_;
58 QSharedPointer<Helper> helper_;61 QSharedPointer<Helper> helper_;
59 QVariantMap state_;62 QVariantMap state_;
63 keeper::KeeperError error_;
60};64};
6165
=== modified file 'src/service/task-manager.cpp'
--- src/service/task-manager.cpp 2016-12-01 14:18:57 +0000
+++ src/service/task-manager.cpp 2016-12-21 08:37:30 +0000
@@ -147,6 +147,7 @@
147 auto& td = task_data_[uuid];147 auto& td = task_data_[uuid];
148 td.metadata = metadata;148 td.metadata = metadata;
149 td.action = QStringLiteral("queued"); // TODO i18n149 td.action = QStringLiteral("queued"); // TODO i18n
150 td.error = keeper::KeeperError::OK;
150 set_initial_task_state(td);151 set_initial_task_state(td);
151 }152 }
152153
@@ -169,7 +170,7 @@
169 }170 }
170 else171 else
171 {172 {
172 td.error = "Error storing manifest file";173 td.error = keeper::KeeperError::MANIFEST_STORAGE_ERROR;
173 set_current_task_action(task_->to_string(Helper::State::FAILED));174 set_current_task_action(task_->to_string(Helper::State::FAILED));
174 }175 }
175 active_manifest_.reset();176 active_manifest_.reset();
176177
=== modified file 'tests/integration/helpers/helpers-test-failure.cpp'
--- tests/integration/helpers/helpers-test-failure.cpp 2016-09-29 13:49:14 +0000
+++ tests/integration/helpers/helpers-test-failure.cpp 2016-12-21 08:37:30 +0000
@@ -90,6 +90,13 @@
90 // this one uses pooling so it should just call Get once90 // this one uses pooling so it should just call Get once
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));
9292
93 QVariant error_value;
94 EXPECT_TRUE(get_task_property_now(user_folder_uuid, user_iface, "error", error_value));
95 bool conversion_ok;
96 auto keeper_error = keeper::convertFromDBusVariant(error_value, &conversion_ok);
97 EXPECT_TRUE(conversion_ok);
98 EXPECT_EQ(keeper_error, keeper::KeeperError::HELPER_WRITE_ERROR);
99
93 // check that the content of the file is the expected100 // check that the content of the file is the expected
94 EXPECT_EQ(0, StorageFrameworkLocalUtils::check_storage_framework_nb_files());101 EXPECT_EQ(0, StorageFrameworkLocalUtils::check_storage_framework_nb_files());
95102
96103
=== modified file 'tests/integration/helpers/helpers-test.cc'
--- tests/integration/helpers/helpers-test.cc 2016-11-22 09:37:40 +0000
+++ tests/integration/helpers/helpers-test.cc 2016-12-21 08:37:30 +0000
@@ -41,6 +41,7 @@
41 BackupHelper helper("com.test.multiple_first_1.2.3");41 BackupHelper helper("com.test.multiple_first_1.2.3");
4242
43 QSignalSpy spy(&helper, &BackupHelper::state_changed);43 QSignalSpy spy(&helper, &BackupHelper::state_changed);
44 QSignalSpy spy_error(&helper, &Helper::error);
4445
45 helper.start({"/bin/ls","/tmp"});46 helper.start({"/bin/ls","/tmp"});
4647
@@ -53,6 +54,8 @@
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);
54 arguments = spy.takeFirst();55 arguments = spy.takeFirst();
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);
57
58 EXPECT_EQ(spy_error.count(), 0);
56}59}
5760
58TEST_F(TestHelpers, StartFullTest)61TEST_F(TestHelpers, StartFullTest)
@@ -300,15 +303,20 @@
300 BackupHelper helper("com.bar_foo_8432.13.1");303 BackupHelper helper("com.bar_foo_8432.13.1");
301304
302 QSignalSpy spy(&helper, &BackupHelper::state_changed);305 QSignalSpy spy(&helper, &BackupHelper::state_changed);
306 QSignalSpy spy_error(&helper, &Helper::error);
303 QStringList urls;307 QStringList urls;
304 urls << "blah" << "/tmp";308 urls << "blah" << "/tmp";
305 helper.start(urls);309 helper.start(urls);
306310
307 WAIT_FOR_SIGNALS(spy, 1, Helper::MAX_UAL_WAIT_TIME + 1000);311 WAIT_FOR_SIGNALS(spy, 1, Helper::MAX_UAL_WAIT_TIME + 1000);
308312
309 ASSERT_EQ(spy.count(), 1);313 ASSERT_EQ(1, spy.count());
310 QList<QVariant> arguments = spy.takeFirst();314 QList<QVariant> arguments = spy.takeFirst();
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)));
316
317 ASSERT_EQ(1, spy_error.count());
318 arguments = spy_error.takeFirst();
319 EXPECT_EQ(keeper::KeeperError::HELPER_START_TIMEOUT, qvariant_cast<keeper::KeeperError>(arguments.at(0)));
312}320}
313321
314TEST_F(TestHelpers, Inactivity)322TEST_F(TestHelpers, Inactivity)
@@ -319,6 +327,7 @@
319 BackupHelper helper("com.bar_foo_8432.13.1");327 BackupHelper helper("com.bar_foo_8432.13.1");
320328
321 QSignalSpy spy(&helper, &BackupHelper::state_changed);329 QSignalSpy spy(&helper, &BackupHelper::state_changed);
330 QSignalSpy spy_error(&helper, &Helper::error);
322 QStringList urls;331 QStringList urls;
323 urls << TEST_INACTIVE_HELPER << "/tmp";332 urls << TEST_INACTIVE_HELPER << "/tmp";
324 helper.start(urls);333 helper.start(urls);
@@ -329,9 +338,13 @@
329 // We can also check at the end for the state, which should be CANCELLED338 // We can also check at the end for the state, which should be CANCELLED
330 WAIT_FOR_SIGNALS(spy, 2, BackupHelper::MAX_INACTIVITY_TIME + 2000);339 WAIT_FOR_SIGNALS(spy, 2, BackupHelper::MAX_INACTIVITY_TIME + 2000);
331340
332 ASSERT_EQ(spy.count(), 2);341 ASSERT_EQ(2, spy.count());
333 QList<QVariant> arguments = spy.takeFirst();342 QList<QVariant> arguments = spy.takeFirst();
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);
335 arguments = spy.takeFirst();344 arguments = spy.takeFirst();
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);
346
347 ASSERT_EQ(1, spy_error.count());
348 arguments = spy_error.takeFirst();
349 EXPECT_EQ(keeper::KeeperError::HELPER_INACTIVITY_DETECTED, qvariant_cast<keeper::KeeperError>(arguments.at(0)));
337}350}
338351
=== modified file 'tests/integration/helpers/test-helpers-base.cpp'
--- tests/integration/helpers/test-helpers-base.cpp 2016-11-11 14:50:06 +0000
+++ tests/integration/helpers/test-helpers-base.cpp 2016-12-21 08:37:30 +0000
@@ -368,6 +368,7 @@
368void TestHelpersBase::SetUp()368void TestHelpersBase::SetUp()
369{369{
370 Helper::registerMetaTypes();370 Helper::registerMetaTypes();
371 DBusTypes::registerMetaTypes();
371372
372 g_setenv("XDG_DATA_DIRS", CMAKE_SOURCE_DIR, true);373 g_setenv("XDG_DATA_DIRS", CMAKE_SOURCE_DIR, true);
373 g_setenv("XDG_CACHE_HOME", CMAKE_SOURCE_DIR "/libertine-data", true);374 g_setenv("XDG_CACHE_HOME", CMAKE_SOURCE_DIR "/libertine-data", true);
@@ -440,6 +441,27 @@
440 return finished;441 return finished;
441}442}
442443
444bool TestHelpersBase::get_task_property_now(QString const & uuid, QSharedPointer<DBusInterfaceKeeperUser> const & keeper_user_iface, QString const & property, QVariant & value) const
445{
446 auto state = keeper_user_iface->state();
447 auto iter = state.find(uuid);
448 if (iter == state.end())
449 {
450 qWarning() << "Task " << uuid << " was not found in State";
451 return false;
452 }
453
454 auto iter_props = (*iter).find(property);
455 if (iter_props == (*iter).end())
456 {
457 qWarning() << "Property " << property << " was not found for task " << uuid;
458 return false;
459 }
460
461 value = (*iter_props);
462 return true;
463}
464
443bool TestHelpersBase::check_task_has_action_state(QVariantDictMap const & state, QString const & uuid, QString const & action_state)465bool TestHelpersBase::check_task_has_action_state(QVariantDictMap const & state, QString const & uuid, QString const & action_state)
444{466{
445 auto iter = state.find(uuid);467 auto iter = state.find(uuid);
446468
=== modified file 'tests/integration/helpers/test-helpers-base.h'
--- tests/integration/helpers/test-helpers-base.h 2016-10-14 09:23:11 +0000
+++ tests/integration/helpers/test-helpers-base.h 2016-12-21 08:37:30 +0000
@@ -97,6 +97,8 @@
9797
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);
9999
100 bool get_task_property_now(QString const & uuid, QSharedPointer<DBusInterfaceKeeperUser> const & keeper_user_iface, QString const & property, QVariant & value) const;
101
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);
101103
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);
103105
=== modified file 'tests/utils/CMakeLists.txt'
--- tests/utils/CMakeLists.txt 2016-09-29 13:49:14 +0000
+++ tests/utils/CMakeLists.txt 2016-12-21 08:37:30 +0000
@@ -19,6 +19,7 @@
19target_link_libraries(19target_link_libraries(
20 ${LIB_NAME}20 ${LIB_NAME}
21 backup-helper21 backup-helper
22 keeper-errors-lib
22 util23 util
23 Qt5::Core24 Qt5::Core
24)25)

Subscribers

People subscribed via source and target branches

to all changes: