Merge lp:~xavi-garcia-mena/keeper/fakes-and-integration-tests into lp:keeper

Proposed by Xavi Garcia
Status: Merged
Approved by: Charles Kerr
Approved revision: 47
Merged at revision: 48
Proposed branch: lp:~xavi-garcia-mena/keeper/fakes-and-integration-tests
Merge into: lp:keeper
Diff against target: 532 lines (+138/-229)
16 files modified
debian/keeper.install (+0/-1)
src/CMakeLists.txt (+0/-1)
src/simple-helper/CMakeLists.txt (+0/-22)
src/simple-helper/main.cpp (+0/-94)
src/simple-helper/simple-helper-defs.h (+0/-26)
tests/CMakeLists.txt (+21/-0)
tests/dbusmock/CMakeLists.txt (+1/-18)
tests/dbusmock/keeper-template-test.cpp (+1/-1)
tests/fakes/CMakeLists.txt (+29/-0)
tests/fakes/fake-backup-helper.cpp (+5/-0)
tests/fakes/fake-backup-helper.h (+6/-0)
tests/integration/CMakeLists.txt (+15/-0)
tests/integration/helpers/CMakeLists.txt (+59/-0)
tests/integration/helpers/helpers-test.cc (+1/-1)
tests/unit/CMakeLists.txt (+0/-12)
tests/unit/helper/CMakeLists.txt (+0/-53)
To merge this branch: bzr merge lp:~xavi-garcia-mena/keeper/fakes-and-integration-tests
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+301256@code.launchpad.net

Commit message

Moved and merged fake helpers and created integration tests directory.

Description of the change

Moved and merged fake helpers and created integration tests directory.

Created the tests/fakes directory containing a merge of simple-helper and fake-backup-helper.
Moved test-helper.sh to tests/fakes

Removed src/simple-helper

Created tests/integration/tests, containing the upstart and full integration tests for helpers (helpers_test).

Removed simple-helper from the debian installation.

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

Great work!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/keeper.install'
2--- debian/keeper.install 2016-07-11 14:55:36 +0000
3+++ debian/keeper.install 2016-07-27 10:18:45 +0000
4@@ -1,4 +1,3 @@
5 usr/lib/*/keeper/keeper-service
6-usr/lib/*/keeper/simple-helper
7 usr/lib/*/ubuntu-app-launch/backup-helper/exec-tool
8 usr/lib/*/keeper/keeper-tar-create
9
10=== modified file 'src/CMakeLists.txt'
11--- src/CMakeLists.txt 2016-07-22 04:01:28 +0000
12+++ src/CMakeLists.txt 2016-07-27 10:18:45 +0000
13@@ -9,7 +9,6 @@
14 add_subdirectory(util)
15 add_subdirectory(helper)
16 add_subdirectory(storage-framework)
17-add_subdirectory(simple-helper)
18 add_subdirectory(tar)
19
20 set(
21
22=== removed directory 'src/simple-helper'
23=== removed file 'src/simple-helper/CMakeLists.txt'
24--- src/simple-helper/CMakeLists.txt 2016-06-21 13:06:11 +0000
25+++ src/simple-helper/CMakeLists.txt 1970-01-01 00:00:00 +0000
26@@ -1,22 +0,0 @@
27-include_directories("${CMAKE_SOURCE_DIR}/src")
28-include_directories("${CMAKE_BINARY_DIR}/src/qdbus-stubs")
29-include_directories("${CMAKE_SOURCE_DIR}/src/qdbus-stubs")
30-
31-add_executable(
32- simple-helper
33- main.cpp
34-)
35-
36-target_link_libraries(
37- simple-helper
38- qdbus-stubs
39- Qt5::Core
40- Qt5::DBus
41- Qt5::Network
42-)
43-
44-install(
45- TARGETS
46- simple-helper
47- RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}
48-)
49\ No newline at end of file
50
51=== removed file 'src/simple-helper/main.cpp'
52--- src/simple-helper/main.cpp 2016-07-13 00:25:01 +0000
53+++ src/simple-helper/main.cpp 1970-01-01 00:00:00 +0000
54@@ -1,94 +0,0 @@
55-/*
56- * Copyright (C) 2016 Canonical, Ltd.
57- *
58- * This program is free software: you can redistribute it and/or modify it
59- * under the terms of the GNU General Public License version 3, as published
60- * by the Free Software Foundation.
61- *
62- * This program is distributed in the hope that it will be useful, but
63- * WITHOUT ANY WARRANTY; without even the implied warranties of
64- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
65- * PURPOSE. See the GNU General Public License for more details.
66- *
67- * You should have received a copy of the GNU General Public License along
68- * with this program. If not, see <http://www.gnu.org/licenses/>.
69- *
70- * Authors: Charles Kerr <charles.kerr@canonical.com>
71- * Xavi Garcia <xavi.garcia.mena@canonical.com>
72- */
73-#include <dbus-types.h>
74-
75-#include "keeper_helper_interface.h"
76-#include "simple-helper-defs.h"
77-
78-#include <QCoreApplication>
79-#include <QDBusConnection>
80-#include <QDBusUnixFileDescriptor>
81-#include <QLocalSocket>
82-
83-#include <libintl.h>
84-#include <cstdlib>
85-#include <ctime>
86-
87-int
88-main(int argc, char **argv)
89-{
90- QCoreApplication app(argc, argv);
91- std::srand(unsigned(std::time(nullptr)));
92-
93- // boilerplate locale
94- bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
95- setlocale(LC_ALL, "");
96- bindtextdomain(GETTEXT_PACKAGE, LOCALE_DIR);
97- textdomain(GETTEXT_PACKAGE);
98-
99- QScopedPointer<DBusInterfaceKeeperHelper> helperInterface(
100- new DBusInterfaceKeeperHelper(
101- DBusTypes::KEEPER_SERVICE,
102- DBusTypes::KEEPER_HELPER_PATH,
103- QDBusConnection::sessionBus()
104- )
105- );
106-
107- const quint64 n_bytes = sizeof(SIMPLE_HELPER_TEXT_TO_WRITE);
108- qDebug("simple helper calling Helper.StartBackup(%zu)", size_t(n_bytes));
109- auto reply = helperInterface->StartBackup(n_bytes);
110- reply.waitForFinished();
111-
112- if (!reply.isValid())
113- {
114- qWarning() << "Error getting backup socket: " << reply.error().message();
115- }
116- else
117- {
118- auto backupSocket = reply.value().fileDescriptor();
119- qDebug() << "I've got the following socket descriptor: " << backupSocket;
120-
121- QLocalSocket localSocket;
122- localSocket.setSocketDescriptor(backupSocket);
123- QByteArray writeme (SIMPLE_HELPER_TEXT_TO_WRITE, sizeof(SIMPLE_HELPER_TEXT_TO_WRITE));
124- qDebug() << "Wrote" << localSocket.write(writeme) << "bytes to it.";
125- localSocket.flush();
126- localSocket.disconnectFromServer();
127-
128-
129- QFile markFile(SIMPLE_HELPER_MARK_FILE_PATH);
130- markFile.open(QFile::WriteOnly);
131- markFile.close();
132- // this is just used when we need to simulate that the helper has finished
133- // when not running the full setup with upstart
134-// qDebug() << "Finishing...";
135-// QDBusReply<void> finishResp = keeperInterface->call(QLatin1String("finish"));
136-//
137-// if (!finishResp.isValid())
138-// {
139-// qWarning() << "Error finishing: " << finishResp.error().message();
140-// }
141-// else
142-// {
143-// qDebug() << "Finished.";
144-// }
145- }
146-
147- return 0;
148-}
149
150=== removed file 'src/simple-helper/simple-helper-defs.h'
151--- src/simple-helper/simple-helper-defs.h 2016-06-30 13:01:31 +0000
152+++ src/simple-helper/simple-helper-defs.h 1970-01-01 00:00:00 +0000
153@@ -1,26 +0,0 @@
154-/*
155- * Copyright (C) 2016 Canonical, Ltd.
156- *
157- * This program is free software: you can redistribute it and/or modify it
158- * under the terms of the GNU General Public License version 3, as published
159- * by the Free Software Foundation.
160- *
161- * This program is distributed in the hope that it will be useful, but
162- * WITHOUT ANY WARRANTY; without even the implied warranties of
163- * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
164- * PURPOSE. See the GNU General Public License for more details.
165- *
166- * You should have received a copy of the GNU General Public License along
167- * with this program. If not, see <http://www.gnu.org/licenses/>.
168- *
169- * Authors: Charles Kerr <charles.kerr@canonical.com>
170- * Xavi Garcia <xavi.garcia.mena@canonical.com>
171- */
172-#pragma once
173-
174-namespace
175-{
176-constexpr char const SIMPLE_HELPER_MARK_FILE_PATH[] = "/tmp/simple-helper-finished";
177-constexpr char const SIMPLE_HELPER_TEXT_TO_WRITE[] = "This is a test";
178-
179-}
180
181=== modified file 'tests/CMakeLists.txt'
182--- tests/CMakeLists.txt 2016-07-22 13:47:58 +0000
183+++ tests/CMakeLists.txt 2016-07-27 10:18:45 +0000
184@@ -14,6 +14,25 @@
185 ### Service DBusMock
186 ###
187
188+set(
189+ BACKUP_HELPER
190+ fake-backup-helper
191+)
192+
193+set(KEEPER_TAR_CREATE_BIN ${CMAKE_BINARY_DIR}/src/tar/keeper-tar-create)
194+set(KEEPER_TAR_CREATE_INVOKE ${CMAKE_CURRENT_BINARY_DIR}/tar/keeper-tar-create-invoke.sh)
195+
196+add_definitions(
197+ -DCMAKE_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
198+ -DCMAKE_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}"
199+ -DTEST_SIMPLE_HELPER="${CMAKE_BINARY_DIR}/tests/fakes/${BACKUP_HELPER}"
200+ -DKEEPER_SERVICE_BIN="${CMAKE_BINARY_DIR}/src/service/keeper-service"
201+ -DKEEPER_CLIENT_BIN="${CMAKE_BINARY_DIR}/src/cli/keeper"
202+ -DTEST_SIMPLE_HELPER_SH="${CMAKE_SOURCE_DIR}/tests/fakes/helper-test.sh"
203+ -DKEEPER_TAR_CREATE_BIN="${KEEPER_TAR_CREATE_BIN}"
204+ -DKEEPER_TAR_CREATE_INVOKE="${KEEPER_TAR_CREATE_INVOKE}"
205+)
206+
207 set(SERVICE_TEMPLATE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/com_canonical_keeper.py")
208 add_definitions(-DSERVICE_TEMPLATE_FILE="${SERVICE_TEMPLATE_FILE}")
209
210@@ -54,6 +73,8 @@
211 add_subdirectory(dbusmock)
212 add_subdirectory(unit)
213 add_subdirectory(utils)
214+add_subdirectory(fakes)
215+add_subdirectory(integration)
216
217 set(
218 UNIT_TEST_TARGETS
219
220=== modified file 'tests/dbusmock/CMakeLists.txt'
221--- tests/dbusmock/CMakeLists.txt 2016-07-15 01:15:39 +0000
222+++ tests/dbusmock/CMakeLists.txt 2016-07-27 10:18:45 +0000
223@@ -20,23 +20,6 @@
224 ###
225
226 set(
227- BACKUP_HELPER
228- fake-backup-helper
229-)
230-
231-add_executable(
232- ${BACKUP_HELPER}
233- fake-backup-helper.cpp
234-)
235-target_link_libraries(
236- ${BACKUP_HELPER}
237- ${LINK_LIBS}
238-)
239-
240-###
241-###
242-
243-set(
244 TEST_NAME
245 keeper-template-test
246 )
247@@ -48,7 +31,7 @@
248
249 set_property(
250 SOURCE keeper-template-test.cpp
251- PROPERTIES APPEND_STRING PROPERTY COMPILE_DEFINITIONS FAKE_BACKUP_HELPER_EXEC=\"${CMAKE_CURRENT_BINARY_DIR}/${BACKUP_HELPER}\"
252+ PROPERTIES APPEND_STRING PROPERTY COMPILE_DEFINITIONS FAKE_BACKUP_HELPER_EXEC=\"${CMAKE_BINARY_DIR}/tests/fakes/${BACKUP_HELPER}\"
253 )
254
255 target_link_libraries(
256
257=== modified file 'tests/dbusmock/keeper-template-test.cpp'
258--- tests/dbusmock/keeper-template-test.cpp 2016-07-22 14:13:45 +0000
259+++ tests/dbusmock/keeper-template-test.cpp 2016-07-27 10:18:45 +0000
260@@ -17,7 +17,7 @@
261 * Charles Kerr <charles.kerr@canonical.com>
262 */
263
264-#include "fake-backup-helper.h"
265+#include "tests/fakes/fake-backup-helper.h"
266
267 #include "tests/utils/keeper-dbusmock-fixture.h"
268
269
270=== added directory 'tests/fakes'
271=== added file 'tests/fakes/CMakeLists.txt'
272--- tests/fakes/CMakeLists.txt 1970-01-01 00:00:00 +0000
273+++ tests/fakes/CMakeLists.txt 2016-07-27 10:18:45 +0000
274@@ -0,0 +1,29 @@
275+
276+include_directories(
277+ ${CMAKE_SOURCE_DIR}/src
278+ ${CMAKE_BINARY_DIR}/src
279+)
280+
281+set(
282+ LINK_LIBS
283+ qdbus-stubs
284+ ${TEST_DEPENDENCIES_LDFLAGS}
285+ test-utils
286+ Qt5::Core
287+ Qt5::DBus
288+ Qt5::Network
289+ ${GTEST_LIBRARIES}
290+ ${GMOCK_LIBRARIES}
291+)
292+
293+###
294+###
295+
296+add_executable(
297+ ${BACKUP_HELPER}
298+ fake-backup-helper.cpp
299+)
300+target_link_libraries(
301+ ${BACKUP_HELPER}
302+ ${LINK_LIBS}
303+)
304
305=== renamed file 'tests/dbusmock/fake-backup-helper.cpp' => 'tests/fakes/fake-backup-helper.cpp'
306--- tests/dbusmock/fake-backup-helper.cpp 2016-07-15 01:15:39 +0000
307+++ tests/fakes/fake-backup-helper.cpp 2016-07-27 10:18:45 +0000
308@@ -59,5 +59,10 @@
309 qDebug() << "wrote" << sock.write(blob) << "bytes";
310 sock.flush();
311
312+ // create the mark file so we can check when it finished without upstart
313+ QFile markFile(SIMPLE_HELPER_MARK_FILE_PATH);
314+ markFile.open(QFile::WriteOnly);
315+ markFile.close();
316+
317 return EXIT_SUCCESS;
318 }
319
320=== renamed file 'tests/dbusmock/fake-backup-helper.h' => 'tests/fakes/fake-backup-helper.h'
321--- tests/dbusmock/fake-backup-helper.h 2016-07-15 01:15:39 +0000
322+++ tests/fakes/fake-backup-helper.h 2016-07-27 10:18:45 +0000
323@@ -19,6 +19,8 @@
324
325 #pragma once
326
327+namespace
328+{
329 static const char* FAKE_BACKUP_HELPER_PAYLOAD = R"(
330 Oh mmm I know a place
331 Ain't nobody cryin'
332@@ -36,3 +38,7 @@
333 Oh-oh! Let me take you there! (I'll take you there)
334 Play your, play your piano now
335 )";
336+
337+static char const SIMPLE_HELPER_MARK_FILE_PATH[] = "/tmp/simple-helper-finished";
338+
339+}
340
341=== renamed file 'src/simple-helper/helper-test.sh' => 'tests/fakes/helper-test.sh'
342=== added directory 'tests/integration'
343=== added file 'tests/integration/CMakeLists.txt'
344--- tests/integration/CMakeLists.txt 1970-01-01 00:00:00 +0000
345+++ tests/integration/CMakeLists.txt 2016-07-27 10:18:45 +0000
346@@ -0,0 +1,15 @@
347+set(
348+ INTEGRATION_TEST_LIBRARIES
349+ backup-helper
350+ test-utils
351+ keeperservice
352+ keepertar
353+ qdbus-stubs
354+ ${SERVICE_DEPS_LDFLAGS}
355+ ${HELPERS_TEST_DEPS_LDFLAGS}
356+ ${TEST_DEPENDENCIES_LDFLAGS}
357+ ${GTEST_LIBRARIES}
358+ ${GMOCK_LIBRARIES}
359+)
360+
361+add_subdirectory(helpers)
362
363=== added directory 'tests/integration/helpers'
364=== added file 'tests/integration/helpers/CMakeLists.txt'
365--- tests/integration/helpers/CMakeLists.txt 1970-01-01 00:00:00 +0000
366+++ tests/integration/helpers/CMakeLists.txt 2016-07-27 10:18:45 +0000
367@@ -0,0 +1,59 @@
368+
369+#
370+# helpers-test
371+#
372+
373+pkg_check_modules(HELPERS_TEST_DEPS REQUIRED
374+ ubuntu-app-launch-2
375+ properties-cpp
376+ dbustest-1>=14.04.0
377+ glib-2.0>=2.26
378+ gio-2.0>=2.26
379+ gio-unix-2.0
380+)
381+
382+include_directories(
383+ SYSTEM
384+ ${UAL_INCLUDE_DIRS}
385+ ${PROP-CPP_INCLUDE_DIRS}
386+ ${HELPERS_TEST_DEPS_INCLUDE_DIRS}
387+)
388+
389+set(
390+ HELPERS_TEST
391+ helpers-test
392+)
393+
394+add_executable(
395+ ${HELPERS_TEST}
396+ helpers-test.cc
397+ mir-mock.cpp
398+)
399+
400+set_target_properties(
401+ ${HELPERS_TEST}
402+ PROPERTIES
403+ COMPILE_FLAGS -fPIC
404+ AUTOMOC TRUE
405+)
406+
407+target_link_libraries(
408+ ${HELPERS_TEST}
409+ ${HELPERS_TEST_DEPS_LDFLAGS}
410+ ${INTEGRATION_TEST_LIBRARIES}
411+ Qt5::Core
412+ Qt5::DBus
413+ Qt5::Test
414+)
415+
416+add_test(
417+ NAME ${HELPERS_TEST}
418+ COMMAND ${HELPERS_TEST}
419+)
420+
421+set(
422+ UNIT_TEST_TARGETS
423+ ${UNIT_TEST_TARGETS}
424+ ${HELPERS_TEST}
425+ PARENT_SCOPE
426+)
427
428=== renamed file 'tests/unit/helper/helpers-test.cc' => 'tests/integration/helpers/helpers-test.cc'
429--- tests/unit/helper/helpers-test.cc 2016-07-22 13:25:07 +0000
430+++ tests/integration/helpers/helpers-test.cc 2016-07-27 10:18:45 +0000
431@@ -37,7 +37,7 @@
432 #include "mir-mock.h"
433 #include <helper/backup-helper.h>
434 #include <qdbus-stubs/dbus-types.h>
435-#include <simple-helper/simple-helper-defs.h>
436+#include "tests/fakes/fake-backup-helper.h"
437 #include "tests/utils/file-utils.h"
438 #include "../../../src/service/app-const.h"
439
440
441=== renamed file 'tests/unit/helper/mir-mock.cpp' => 'tests/integration/helpers/mir-mock.cpp'
442=== renamed file 'tests/unit/helper/mir-mock.h' => 'tests/integration/helpers/mir-mock.h'
443=== modified file 'tests/unit/CMakeLists.txt'
444--- tests/unit/CMakeLists.txt 2016-07-22 13:49:34 +0000
445+++ tests/unit/CMakeLists.txt 2016-07-27 10:18:45 +0000
446@@ -1,15 +1,3 @@
447-set(KEEPER_TAR_CREATE_BIN ${CMAKE_BINARY_DIR}/src/tar/keeper-tar-create)
448-set(KEEPER_TAR_CREATE_INVOKE ${CMAKE_CURRENT_BINARY_DIR}/tar/keeper-tar-create-invoke.sh)
449-
450-add_definitions(
451- -DCMAKE_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
452- -DTEST_SIMPLE_HELPER="${CMAKE_BINARY_DIR}/src/simple-helper/simple-helper"
453- -DKEEPER_SERVICE_BIN="${CMAKE_BINARY_DIR}/src/service/keeper-service"
454- -DKEEPER_CLIENT_BIN="${CMAKE_BINARY_DIR}/src/cli/keeper"
455- -DTEST_SIMPLE_HELPER_SH="${CMAKE_SOURCE_DIR}/src/simple-helper/helper-test.sh"
456- -DKEEPER_TAR_CREATE_BIN="${KEEPER_TAR_CREATE_BIN}"
457- -DKEEPER_TAR_CREATE_INVOKE="${KEEPER_TAR_CREATE_INVOKE}"
458-)
459
460 include_directories(
461 "${CMAKE_SOURCE_DIR}/src"
462
463=== modified file 'tests/unit/helper/CMakeLists.txt'
464--- tests/unit/helper/CMakeLists.txt 2016-07-22 12:59:11 +0000
465+++ tests/unit/helper/CMakeLists.txt 2016-07-27 10:18:45 +0000
466@@ -4,58 +4,6 @@
467 )
468
469 #
470-# helpers-test
471-#
472-
473-pkg_check_modules(HELPERS_TEST_DEPS REQUIRED
474- ubuntu-app-launch-2
475- properties-cpp
476- dbustest-1>=14.04.0
477- glib-2.0>=2.26
478- gio-2.0>=2.26
479- gio-unix-2.0
480-)
481-
482-include_directories(
483- SYSTEM
484- ${UAL_INCLUDE_DIRS}
485- ${PROP-CPP_INCLUDE_DIRS}
486- ${HELPERS_TEST_DEPS_INCLUDE_DIRS}
487-)
488-
489-set(
490- HELPERS_TEST
491- helpers-test
492-)
493-
494-add_executable(
495- ${HELPERS_TEST}
496- helpers-test.cc
497- mir-mock.cpp
498-)
499-
500-set_target_properties(
501- ${HELPERS_TEST}
502- PROPERTIES
503- COMPILE_FLAGS -fPIC
504- AUTOMOC TRUE
505-)
506-
507-target_link_libraries(
508- ${HELPERS_TEST}
509- ${HELPERS_TEST_DEPS_LDFLAGS}
510- ${UNIT_TEST_LIBRARIES}
511- Qt5::Core
512- Qt5::DBus
513- Qt5::Test
514-)
515-
516-add_test(
517- NAME ${HELPERS_TEST}
518- COMMAND ${HELPERS_TEST}
519-)
520-
521-#
522 # speed-test
523 #
524
525@@ -97,7 +45,6 @@
526 set(
527 UNIT_TEST_TARGETS
528 ${UNIT_TEST_TARGETS}
529- ${HELPERS_TEST}
530 ${SPEED_TEST}
531 PARENT_SCOPE
532 )

Subscribers

People subscribed via source and target branches

to all changes: