2006-12-01 23:50:17 +01:00
|
|
|
/*
|
2009-03-25 15:21:04 +01:00
|
|
|
* Copyright (C) 2005-2009 Patrick Ohly <patrick.ohly@gmx.de>
|
|
|
|
* Copyright (C) 2009 Intel Corporation
|
2009-04-30 18:14:03 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) version 3.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301 USA
|
2006-12-01 23:50:17 +01:00
|
|
|
*/
|
|
|
|
|
2009-10-05 14:49:32 +02:00
|
|
|
#include "config.h"
|
2006-12-01 23:50:17 +01:00
|
|
|
|
2008-08-16 12:02:41 +02:00
|
|
|
#include <ClientTest.h>
|
2006-12-01 23:50:17 +01:00
|
|
|
|
|
|
|
#include <exception>
|
2007-04-15 21:30:15 +02:00
|
|
|
#include <fstream>
|
2007-08-25 15:23:25 +02:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
2007-09-24 23:17:40 +02:00
|
|
|
#include <errno.h>
|
2006-12-01 23:50:17 +01:00
|
|
|
|
2010-04-19 14:38:27 +02:00
|
|
|
#include "CmdlineSyncClient.h"
|
2011-05-13 14:16:43 +02:00
|
|
|
#include <syncevo/SyncSource.h>
|
2009-10-05 14:49:32 +02:00
|
|
|
#include <syncevo/util.h>
|
|
|
|
#include <syncevo/VolatileConfigNode.h>
|
2008-04-19 10:02:42 +02:00
|
|
|
|
2011-03-02 11:50:40 +01:00
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
2009-10-05 14:49:32 +02:00
|
|
|
#include <syncevo/declarations.h>
|
buteo testing: enable buteo testing in client-test
To enable it in configuration, use '--enable-buteo-tests'.
To test client-test with buteo to do sync, make sure the
environment variable 'CLIENT_TEST_BUTEO=1' is set.
Three main steps to support buteo testing in client-test,
1) pre-run: storage preparation, clean up buteo logging
files and set corresponding keys in meego-sync-conf.xml.
For qtcontacts, switch backend database files for each
client; For calendar/todo/note, specify different notebook
names for each client.
2) run: re-implement ClientTest.doSync function, which
dbus-calls 'msyncd', the dbus daemon of buteo to do sync.
Listen to needed signals to track its status.
3) post-run: collect its status and summarize its statistics
and convert to internal sync report.
Buteo doesn't support explicit slow-sync mode and refresh-
from-server mode. Add two workarounds for them:
For slow-sync mode, wipe out anchors;
For refresh-from-server, wipe out anchors and clean all local
data and do two-way sync.
To enable buteo testing in your environment, you have to:
1) Add read/write privilege for the directory /etc/sync for
current testing user
2) To test one remote server, make sure the profile xml is put
in $HOME/.sync/profiles/sync. The name of the profile xml should
be set as the server name.
2010-12-07 14:03:01 +01:00
|
|
|
|
2009-10-02 17:23:53 +02:00
|
|
|
SE_BEGIN_CXX
|
|
|
|
|
2008-04-19 10:02:42 +02:00
|
|
|
/*
|
|
|
|
* always provide this test class, even if not used:
|
|
|
|
* that way the test scripts can unconditionally
|
|
|
|
* invoke "client-test SyncEvolution"
|
|
|
|
*/
|
|
|
|
CPPUNIT_REGISTRY_ADD_TO_DEFAULT("SyncEvolution");
|
2007-08-25 15:23:25 +02:00
|
|
|
|
2007-06-27 22:24:45 +02:00
|
|
|
class EvolutionLocalTests : public LocalTests {
|
|
|
|
public:
|
|
|
|
EvolutionLocalTests(const std::string &name, ClientTest &cl, int sourceParam, ClientTest::Config &co) :
|
|
|
|
LocalTests(name, cl, sourceParam, co)
|
|
|
|
{}
|
|
|
|
|
|
|
|
virtual void addTests() {
|
|
|
|
LocalTests::addTests();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-08-27 12:47:16 +02:00
|
|
|
/**
|
|
|
|
* This is a workaround for libecal/libebook in Evolution >= 2.30.
|
|
|
|
* The storage daemons shut down after only 10 seconds of no client
|
|
|
|
* being attached. Due to limitations in libecal/libebook this is not
|
|
|
|
* detected when only using the synchronous API ("destroyed" signal
|
|
|
|
* not delivered, see e-cal.c), which then leads to D-Bus errors.
|
|
|
|
*
|
|
|
|
* The workaround consists of keeping one open SyncEvolution backend
|
2011-05-05 14:15:55 +02:00
|
|
|
* around for each of eds_event and eds_contact/30, if they ever were used
|
2010-08-27 12:47:16 +02:00
|
|
|
* during testing.
|
|
|
|
*/
|
|
|
|
static map<string, boost::shared_ptr<TestingSyncSource> > lockEvolution;
|
2010-09-01 18:01:19 +02:00
|
|
|
static void CleanupSources()
|
|
|
|
{
|
|
|
|
lockEvolution.clear();
|
|
|
|
}
|
2010-08-27 12:47:16 +02:00
|
|
|
|
2008-08-03 22:26:06 +02:00
|
|
|
/**
|
|
|
|
* This code uses the ClientTest and and information provided by
|
|
|
|
* the backends in their RegisterSyncSourceTest instances to test
|
|
|
|
* real synchronization with a server.
|
|
|
|
*
|
|
|
|
* Configuration is done by environment variables which indicate which
|
|
|
|
* part below the root node "client-test" of the the configuration tree to use;
|
|
|
|
* beyond that everything needed for synchronization is read from the
|
|
|
|
* configuration tree.
|
|
|
|
*
|
|
|
|
* - CLIENT_TEST_SERVER = maps to name of root node in configuration tree
|
|
|
|
* - CLIENT_TEST_EVOLUTION_PREFIX = a common "evolutionsource" prefix for *all*
|
|
|
|
* sources; the source name followed by "_[12]"
|
|
|
|
* is appended to get unique names
|
2008-08-09 10:57:30 +02:00
|
|
|
* - CLIENT_TEST_EVOLUTION_USER = sets the "evolutionuser" property of all sources
|
|
|
|
* - CLIENT_TEST_EVOLUTION_PASSWORD = sets the "evolutionpassword" property of all sources
|
2008-08-03 22:26:06 +02:00
|
|
|
* - CLIENT_TEST_SOURCES = comma separated list of active sources,
|
|
|
|
* names as selected in their RegisterSyncSourceTest
|
|
|
|
* instances
|
|
|
|
* - CLIENT_TEST_DELAY = number of seconds to sleep between syncs, required
|
|
|
|
* by some servers
|
|
|
|
* - CLIENT_TEST_LOG = logfile name of a server, can be empty:
|
|
|
|
* if given, then the content of that file will be
|
|
|
|
* copied and stored together with the client log
|
|
|
|
* (only works on Unix)
|
|
|
|
* - CLIENT_TEST_NUM_ITEMS = numbers of contacts/events/... to use during
|
|
|
|
* local and sync tests which create artificial
|
|
|
|
* items
|
|
|
|
*
|
|
|
|
* The CLIENT_TEST_SERVER also has another meaning: it is used as hint
|
|
|
|
* by the synccompare.pl script and causes it to automatically ignore
|
|
|
|
* known, acceptable data modifications caused by sending an item to
|
|
|
|
* a server and back again. Currently the script recognizes "funambol",
|
|
|
|
* "scheduleworld", "synthesis" and "egroupware" as special server
|
|
|
|
* names.
|
|
|
|
*/
|
2006-12-01 23:50:17 +01:00
|
|
|
class TestEvolution : public ClientTest {
|
|
|
|
public:
|
2006-12-07 23:27:18 +01:00
|
|
|
/**
|
|
|
|
* can be instantiated as client A with id == "1" and client B with id == "2"
|
|
|
|
*/
|
|
|
|
TestEvolution(const string &id) :
|
2013-03-22 10:05:42 +01:00
|
|
|
ClientTest(atoi(getEnv("CLIENT_TEST_DELAY", "0")),
|
|
|
|
getEnv("CLIENT_TEST_LOG", "")),
|
2011-08-12 21:03:34 +02:00
|
|
|
m_initialized(false),
|
2008-08-02 17:46:23 +02:00
|
|
|
m_clientID(id),
|
2011-05-13 14:16:43 +02:00
|
|
|
m_configs(SyncSource::getTestRegistry())
|
2008-08-02 17:46:23 +02:00
|
|
|
{
|
2011-08-12 21:03:34 +02:00
|
|
|
}
|
|
|
|
|
2012-04-23 13:03:32 +02:00
|
|
|
virtual std::string getClientID() const { return m_clientID; }
|
|
|
|
|
2011-08-12 21:03:34 +02:00
|
|
|
/**
|
|
|
|
* code depends on other global constructors to run first, execute it after constructor but before
|
|
|
|
* any other methods
|
|
|
|
*/
|
|
|
|
void init()
|
|
|
|
{
|
|
|
|
if (m_initialized) {
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
m_initialized = true;
|
|
|
|
}
|
|
|
|
|
2012-06-12 17:26:09 +02:00
|
|
|
// allow each backend test to create more backend tests
|
|
|
|
size_t count = 0;
|
|
|
|
while (count != m_configs.size()) {
|
|
|
|
count = m_configs.size();
|
|
|
|
BOOST_FOREACH (const RegisterSyncSourceTest *test,
|
|
|
|
TestRegistry(m_configs)) {
|
|
|
|
test->init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-31 18:22:40 +02:00
|
|
|
const char *server = getenv("CLIENT_TEST_SERVER");
|
|
|
|
|
2011-08-12 21:03:34 +02:00
|
|
|
if (m_clientID == "1") {
|
2008-08-02 17:46:23 +02:00
|
|
|
m_clientB.reset(new TestEvolution("2"));
|
2006-12-07 23:27:18 +01:00
|
|
|
}
|
|
|
|
|
2007-03-31 18:22:40 +02:00
|
|
|
/* check server */
|
|
|
|
if (!server) {
|
|
|
|
server = "funambol";
|
|
|
|
setenv("CLIENT_TEST_SERVER", "funambol", 1);
|
|
|
|
}
|
|
|
|
|
2007-04-01 20:26:28 +02:00
|
|
|
/* override Evolution database names? */
|
|
|
|
const char *evoprefix = getenv("CLIENT_TEST_EVOLUTION_PREFIX");
|
2008-08-02 17:46:23 +02:00
|
|
|
m_evoPrefix = evoprefix ? evoprefix : "SyncEvolution_Test_";
|
2008-08-09 10:57:30 +02:00
|
|
|
const char *evouser = getenv("CLIENT_TEST_EVOLUTION_USER");
|
|
|
|
if (evouser) {
|
|
|
|
m_evoUser = evouser;
|
|
|
|
}
|
|
|
|
const char *evopasswd = getenv("CLIENT_TEST_EVOLUTION_PASSWORD");
|
|
|
|
if (evopasswd) {
|
|
|
|
m_evoPassword = evopasswd;
|
|
|
|
}
|
2007-04-01 20:26:28 +02:00
|
|
|
|
2007-03-31 18:22:40 +02:00
|
|
|
/* check sources */
|
|
|
|
const char *sourcelist = getenv("CLIENT_TEST_SOURCES");
|
2008-08-02 17:46:23 +02:00
|
|
|
set<string> sources;
|
|
|
|
if (sourcelist) {
|
|
|
|
boost::split(sources, sourcelist, boost::is_any_of(","));
|
|
|
|
} else {
|
|
|
|
BOOST_FOREACH(const RegisterSyncSourceTest *test, m_configs) {
|
2012-06-12 17:26:09 +02:00
|
|
|
if (!test->m_configName.empty()) {
|
|
|
|
sources.insert(test->m_configName);
|
|
|
|
}
|
2008-08-02 17:46:23 +02:00
|
|
|
}
|
2007-03-31 18:22:40 +02:00
|
|
|
}
|
|
|
|
|
2008-08-02 17:46:23 +02:00
|
|
|
BOOST_FOREACH(const RegisterSyncSourceTest *test, m_configs) {
|
2012-06-12 17:26:09 +02:00
|
|
|
if (sources.find(test->m_configName) != sources.end() &&
|
|
|
|
!test->m_configName.empty()) {
|
2009-12-16 07:43:08 +01:00
|
|
|
m_syncSource2Config.push_back(test->m_configName);
|
2007-03-31 18:22:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-16 07:43:08 +01:00
|
|
|
/* Local Test SyncSource : remove all virtual datastores, inserting the
|
|
|
|
* sub datastores*/
|
|
|
|
ClientTest::Config conf;
|
|
|
|
BOOST_FOREACH (string source, sources) {
|
|
|
|
getSourceConfig (source, conf);
|
2011-09-02 09:42:19 +02:00
|
|
|
if (!conf.m_subConfigs.empty()) {
|
2009-12-16 07:43:08 +01:00
|
|
|
vector<string> subs;
|
2011-09-02 09:42:19 +02:00
|
|
|
boost::split (subs, conf.m_subConfigs, boost::is_any_of(","));
|
2009-12-16 07:43:08 +01:00
|
|
|
BOOST_FOREACH (string sub, subs) {
|
2010-08-25 08:12:58 +02:00
|
|
|
pushLocalSource2Config(sub);
|
2009-12-16 07:43:08 +01:00
|
|
|
}
|
|
|
|
} else {
|
2010-08-25 08:12:58 +02:00
|
|
|
pushLocalSource2Config(source);
|
2009-12-16 07:43:08 +01:00
|
|
|
}
|
|
|
|
}
|
2007-03-31 18:22:40 +02:00
|
|
|
// get configuration and set obligatory fields
|
2009-02-18 12:39:51 +01:00
|
|
|
LoggerBase::instance().setLevel(Logger::DEBUG);
|
2011-08-12 21:03:34 +02:00
|
|
|
std::string root = std::string("evolution/") + server + "_" + m_clientID;
|
|
|
|
boost::shared_ptr<SyncConfig> config(new SyncConfig(string(server) + "_" + m_clientID));
|
2009-10-06 17:22:47 +02:00
|
|
|
boost::shared_ptr<SyncConfig> from = boost::shared_ptr<SyncConfig> ();
|
2009-08-04 10:40:26 +02:00
|
|
|
|
2009-11-25 17:18:37 +01:00
|
|
|
if (!config->exists()) {
|
|
|
|
// no configuration yet, create in different contexts because
|
|
|
|
// device ID is different
|
2011-08-12 21:03:34 +02:00
|
|
|
config.reset(new SyncConfig(string(server) + "_" + m_clientID + "@client-test-" + m_clientID));
|
2009-11-25 17:18:37 +01:00
|
|
|
config->setDefaults();
|
Configuration templates matching: match templates based on metadata
Introduced TemplateConfig to abstracting the template configuration structure,
the template metadata used for matching is also parsed here.
The fields introduced in the metadata are:
PeerIsClient: identify whether this is a server side configuration or a client
side configuration.
Fingerprint: the matching string for this template, it is a comma separated string
with each string modeled as: "Manufacture_Model". The first substring is also
used as the name to identify this template so that user can select the template
by this name.
eg:
Nokia 7210c: Nokia_7210c
SyncEvolution server: SyncEvolutionServer, SyncEvolution
ScheduleWorld: ScheduleWorld,default
SyncEvolution client: SyncEvolutionClient, SyncEvolution
Description: this is a just a descriptive string not used for matching.
GetServerTemplates is changed to add another "devices" parameter to identify
it is asking for templates for a list of "devices". Each device is a tuple
<matchstring (devicename), matchMode (server/client/all)>.
TemplateList as the return type, which is a list of class TemplateDescription
so that we can also return enough information for corresponding templates. This
list is sorted by the 3-tuple <finger, rank, name>.
Add MatchServerTemplates method which will iterating all templates inside the
folder and match against the input parameter and finally return a sorted
list of matched templates.
The atcually fuzzy match algorithm is based on a LCS (added in the following
commit).
Cmdline interface is changed accordingly:
--template ? is changed to --template ?[string], so that user use the former
case to match all templates for a tradiontial SyncML client and the latter case
to match templates related to an input string.
SyncConfig API is also renamed (Server -> Peer) because both server/client
configuration/template are handled.
The original configuration template (Funambol and ScheduleWorld) has been moved
to the new template structure (under servers), they also have a .template.ini
file added so that they can be matched and picked up. All templates for
supported servers still have built-in template support in the code as before.
Templates for SyncEvolution based server is also added.
Server side templates are added (Nokia default, Nokia_7210c and SyncEvolutionServer).
Add unit test for the new template match use case.
2010-01-19 08:01:05 +01:00
|
|
|
from = SyncConfig::createPeerTemplate(server);
|
2009-08-04 10:40:26 +02:00
|
|
|
if(from) {
|
|
|
|
set<string> filter;
|
2009-11-25 17:18:37 +01:00
|
|
|
config->copy(*from, &filter);
|
2009-08-04 10:40:26 +02:00
|
|
|
}
|
2011-08-12 21:03:34 +02:00
|
|
|
config->setDevID(m_clientID == "1" ? "sc-api-nat" : "sc-pim-ppc");
|
2007-03-31 18:22:40 +02:00
|
|
|
}
|
2008-08-02 17:46:23 +02:00
|
|
|
BOOST_FOREACH(const RegisterSyncSourceTest *test, m_configs) {
|
2012-06-12 17:26:09 +02:00
|
|
|
if (test->m_configName.empty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-03-31 18:22:40 +02:00
|
|
|
ClientTest::Config testconfig;
|
2008-08-02 17:46:23 +02:00
|
|
|
getSourceConfig(test, testconfig);
|
2011-09-02 09:42:19 +02:00
|
|
|
CPPUNIT_ASSERT(!testconfig.m_type.empty());
|
2007-03-31 18:22:40 +02:00
|
|
|
|
2011-09-02 09:42:19 +02:00
|
|
|
boost::shared_ptr<SyncSourceConfig> sc = config->getSyncSourceConfig(testconfig.m_sourceName);
|
2008-03-09 20:08:34 +01:00
|
|
|
if (!sc || !sc->exists()) {
|
2007-03-31 18:22:40 +02:00
|
|
|
// no configuration yet
|
2011-09-02 09:42:19 +02:00
|
|
|
config->setSourceDefaults(testconfig.m_sourceName);
|
|
|
|
sc = config->getSyncSourceConfig(testconfig.m_sourceName);
|
2007-03-31 18:22:40 +02:00
|
|
|
CPPUNIT_ASSERT(sc);
|
2011-09-02 09:42:19 +02:00
|
|
|
sc->setURI(testconfig.m_uri);
|
|
|
|
if(from && !testconfig.m_sourceNameServerTemplate.empty()) {
|
|
|
|
boost::shared_ptr<SyncSourceConfig> scServerTemplate = from->getSyncSourceConfig(testconfig.m_sourceNameServerTemplate);
|
2009-08-04 10:40:26 +02:00
|
|
|
sc->setURI(scServerTemplate->getURI());
|
|
|
|
}
|
2007-03-31 18:22:40 +02:00
|
|
|
}
|
|
|
|
|
2012-04-23 13:03:32 +02:00
|
|
|
// Set these properties if not set yet: that means the env
|
|
|
|
// variables are used when creating the config initially,
|
|
|
|
// but then no longer can be used to change the config.
|
|
|
|
// This prevents accidentally running a test with default
|
|
|
|
// values, for example for the database.
|
2012-06-04 11:04:26 +02:00
|
|
|
if (!sc->getDatabaseID().wasSet()) {
|
2012-04-23 13:03:32 +02:00
|
|
|
string database = getDatabaseName(test->m_configName);
|
|
|
|
sc->setDatabaseID(database);
|
|
|
|
}
|
2012-06-04 11:04:26 +02:00
|
|
|
if (!sc->getUser().wasSet() && !m_evoUser.empty()) {
|
2012-04-23 13:03:32 +02:00
|
|
|
sc->setUser(m_evoUser);
|
|
|
|
}
|
2012-06-04 11:04:26 +02:00
|
|
|
if (!sc->getPassword().wasSet() && !m_evoPassword.empty()) {
|
2012-04-23 13:03:32 +02:00
|
|
|
sc->setPassword(m_evoPassword);
|
|
|
|
}
|
|
|
|
// Always set this one, to ensure the config matches the test.
|
2011-09-02 09:42:19 +02:00
|
|
|
sc->setBackend(SourceType(testconfig.m_type).m_backend);
|
2007-03-31 18:22:40 +02:00
|
|
|
}
|
2009-11-25 17:18:37 +01:00
|
|
|
config->flush();
|
2007-03-31 18:22:40 +02:00
|
|
|
}
|
|
|
|
|
2007-06-27 22:24:45 +02:00
|
|
|
virtual LocalTests *createLocalTests(const std::string &name, int sourceParam, ClientTest::Config &co) {
|
2011-08-12 21:03:34 +02:00
|
|
|
init();
|
2007-06-27 22:24:45 +02:00
|
|
|
return new EvolutionLocalTests(name, *this, sourceParam, co);
|
|
|
|
}
|
|
|
|
|
2009-12-16 07:43:08 +01:00
|
|
|
virtual int getNumLocalSources() {
|
2011-08-12 21:03:34 +02:00
|
|
|
init();
|
2009-12-16 07:43:08 +01:00
|
|
|
return m_localSource2Config.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int getNumSyncSources() {
|
2011-08-12 21:03:34 +02:00
|
|
|
init();
|
2009-12-16 07:43:08 +01:00
|
|
|
return m_syncSource2Config.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void getLocalSourceConfig(int source, Config &config) {
|
2011-08-12 21:03:34 +02:00
|
|
|
init();
|
2009-12-16 07:43:08 +01:00
|
|
|
getSourceConfig(m_configs[m_localSource2Config[source]], config);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void getSyncSourceConfig(int source, Config &config) {
|
2011-08-12 21:03:34 +02:00
|
|
|
init();
|
2009-12-16 07:43:08 +01:00
|
|
|
getSourceConfig(m_configs[m_syncSource2Config[source]], config);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int getLocalSourcePosition(const string &configName) {
|
|
|
|
for (size_t i=0; i< m_localSource2Config.size(); i++) {
|
|
|
|
if(m_localSource2Config[i] == configName) {
|
|
|
|
return i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
2008-08-02 17:46:23 +02:00
|
|
|
}
|
|
|
|
|
2009-12-16 07:43:08 +01:00
|
|
|
virtual void getSourceConfig (const string &configName, Config &config) {
|
2011-08-12 21:03:34 +02:00
|
|
|
init();
|
2009-12-16 07:43:08 +01:00
|
|
|
return getSourceConfig (m_configs[configName], config);
|
2006-12-01 23:50:17 +01:00
|
|
|
}
|
2007-03-31 18:22:40 +02:00
|
|
|
|
2008-08-02 17:46:23 +02:00
|
|
|
static void getSourceConfig(const RegisterSyncSourceTest *test, Config &config) {
|
|
|
|
ClientTest::getTestData(test->m_testCaseName.c_str(), config);
|
2011-09-02 09:42:19 +02:00
|
|
|
config.m_createSourceA = createSource;
|
|
|
|
config.m_createSourceB = createSource;
|
|
|
|
config.m_sourceName = test->m_configName.c_str();
|
2012-06-12 17:20:40 +02:00
|
|
|
config.m_linkedSources = test->m_linkedSources;
|
2007-03-31 18:22:40 +02:00
|
|
|
|
2008-08-02 17:46:23 +02:00
|
|
|
test->updateConfig(config);
|
2006-12-01 23:50:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual ClientTest *getClientB() {
|
2011-08-12 21:03:34 +02:00
|
|
|
init();
|
2008-08-02 17:46:23 +02:00
|
|
|
return m_clientB.get();
|
2006-12-01 23:50:17 +01:00
|
|
|
}
|
|
|
|
|
2006-12-09 18:50:38 +01:00
|
|
|
virtual bool isB64Enabled() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-03-11 11:22:23 +01:00
|
|
|
virtual SyncMLStatus doSync(const int *sources,
|
|
|
|
const std::string &logbase,
|
|
|
|
const SyncOptions &options)
|
|
|
|
{
|
2011-08-12 21:03:34 +02:00
|
|
|
init();
|
|
|
|
|
2012-05-22 11:50:27 +02:00
|
|
|
// Let "Client_Sync_Current" symlink point to a new, empty
|
|
|
|
// directory logbase + ".server". Can be used by SyncEvolution
|
|
|
|
// server as per-test logdir.
|
|
|
|
std::string current = logbase + ".server";
|
|
|
|
rm_r(current);
|
|
|
|
mkdir_p(current);
|
|
|
|
rm_r("Client_Sync_Current");
|
|
|
|
symlink(current.c_str(), "Client_Sync_Current");
|
|
|
|
|
2007-03-31 18:22:40 +02:00
|
|
|
string server = getenv("CLIENT_TEST_SERVER") ? getenv("CLIENT_TEST_SERVER") : "funambol";
|
2006-12-07 23:27:18 +01:00
|
|
|
server += "_";
|
2008-08-02 17:46:23 +02:00
|
|
|
server += m_clientID;
|
2006-12-01 23:50:17 +01:00
|
|
|
|
buteo testing: enable buteo testing in client-test
To enable it in configuration, use '--enable-buteo-tests'.
To test client-test with buteo to do sync, make sure the
environment variable 'CLIENT_TEST_BUTEO=1' is set.
Three main steps to support buteo testing in client-test,
1) pre-run: storage preparation, clean up buteo logging
files and set corresponding keys in meego-sync-conf.xml.
For qtcontacts, switch backend database files for each
client; For calendar/todo/note, specify different notebook
names for each client.
2) run: re-implement ClientTest.doSync function, which
dbus-calls 'msyncd', the dbus daemon of buteo to do sync.
Listen to needed signals to track its status.
3) post-run: collect its status and summarize its statistics
and convert to internal sync report.
Buteo doesn't support explicit slow-sync mode and refresh-
from-server mode. Add two workarounds for them:
For slow-sync mode, wipe out anchors;
For refresh-from-server, wipe out anchors and clean all local
data and do two-way sync.
To enable buteo testing in your environment, you have to:
1) Add read/write privilege for the directory /etc/sync for
current testing user
2) To test one remote server, make sure the profile xml is put
in $HOME/.sync/profiles/sync. The name of the profile xml should
be set as the server name.
2010-12-07 14:03:01 +01:00
|
|
|
|
2010-04-19 14:38:27 +02:00
|
|
|
class ClientTest : public CmdlineSyncClient {
|
2006-12-01 23:50:17 +01:00
|
|
|
public:
|
|
|
|
ClientTest(const string &server,
|
2009-02-19 10:52:35 +01:00
|
|
|
const string &logbase,
|
2009-03-11 11:22:23 +01:00
|
|
|
const SyncOptions &options) :
|
password handling: fixed KWallet support, global configuration option
KWallet support was broken: syncevo-dbus-server checked
KDE_FULL_SESSION to determine whether it should use KWallet instead of
GNOME Keyring. That did not work, because the env variable was not set
for D-Bus daemons.
Automatically detecting KDE users is not possible at the
moment. Instead KDE users have to manually set the new "keyring"
global config property to "KDE" (case insensitive) if the
SyncEvolution installation supports both, because GNOME Keyring is the
default to avoid surprises for traditional users. If only KWallet
support is enabled, then this is not necessary.
"GNOME" and "true/false/1/0/yes/no" can also be set. This has the
advantage that keyring usage can be enabled permanently for the
command line in --daemon=no mode; normally keyrings are not used in
that mode because accessing them can bring up UI dialogs.
It also becomes possible to disable keyring usage in syncevo-dbus-server,
something which couldn't be done before.
The --keyring command line option is still supported, as an alias for
"[--sync-property] keyring=<value>". The default value for --keyring
is true, to match the traditional behavior. In contrast to other sync
properties, setting "keyring" does not require an explicit --run
parameter. Again this is done to mirror traditional usage.
Reading a password also (unintentionally) checked all supported
storages while searching for the password. Now it uses exactly
one storage and falls back to asking for the password directly.
The commit itself also cleans up the code a bit (reformatted, fixed
comments). Choosing the right slot in the password signals is done via
a new InitStateTri parameter which contains the "keyring" setting.
Error checking (unsupported keyring string, --keyring=yes and no
keyring enabled) is done in additional slots which run after all the
regular ones.
Parameter parsing for --sync and --keyring were unified. However,
there is the difference that --keyring has an implicit default value
("yes") and never has an additional parameter, in contrast to --sync,
which always is followed by one.
The new CmdlineTest::testKeyring covers different ways of using
--keyring. It relies on actually invoking keyring backends, something
not done by the default SyncContext UI. Therefore
CmdlineSyncClient+KeyringSyncCmdline were moved into libsyncevolution,
to be used by CmdlineTest.
2012-05-29 18:14:13 +02:00
|
|
|
CmdlineSyncClient(server, false),
|
2009-02-19 10:52:35 +01:00
|
|
|
m_logbase(logbase),
|
2009-03-11 15:01:07 +01:00
|
|
|
m_options(options),
|
2009-06-26 08:01:02 +02:00
|
|
|
m_started(false)
|
2006-12-01 23:50:17 +01:00
|
|
|
{}
|
|
|
|
|
|
|
|
protected:
|
2009-02-19 10:52:35 +01:00
|
|
|
virtual void prepare() {
|
|
|
|
setLogDir(m_logbase, true);
|
|
|
|
setMaxLogDirs(0, true);
|
2009-03-11 11:22:23 +01:00
|
|
|
setMaxObjSize(m_options.m_maxObjSize, true);
|
|
|
|
setMaxMsgSize(m_options.m_maxMsgSize, true);
|
2009-03-17 14:16:49 +01:00
|
|
|
setWBXML(m_options.m_isWBXML, true);
|
2010-03-05 17:24:49 +01:00
|
|
|
setRetryDuration(m_options.m_retryDuration, true);
|
|
|
|
setRetryInterval(m_options.m_retryInterval, true);
|
2010-12-06 14:47:32 +01:00
|
|
|
if (m_options.m_syncMode == SYNC_TWO_WAY &&
|
|
|
|
m_options.m_checkReport.syncMode == SYNC_NONE) {
|
|
|
|
// For this test, any kind of final sync mode is
|
|
|
|
// acceptable. Disable slow sync prevention
|
|
|
|
// temporarily. The check for the requested sync
|
|
|
|
// mode is perhaps too conservative, but in
|
|
|
|
// practice the only test where slow sync
|
|
|
|
// prevention caused a test failure was
|
2011-05-05 14:15:55 +02:00
|
|
|
// Client::Sync::eds_contact::testTwoWaySync after
|
2010-12-06 14:47:32 +01:00
|
|
|
// some other failed test, so let's be conservative...
|
|
|
|
setPreventSlowSync(false);
|
|
|
|
}
|
2009-10-05 14:49:32 +02:00
|
|
|
SyncContext::prepare();
|
2011-02-09 15:37:57 +01:00
|
|
|
if (m_options.m_prepareCallback &&
|
|
|
|
m_options.m_prepareCallback(*this, m_options)) {
|
|
|
|
m_options.m_isAborted = true;
|
|
|
|
}
|
2009-02-19 10:52:35 +01:00
|
|
|
}
|
2006-12-01 23:50:17 +01:00
|
|
|
|
2009-03-11 15:01:07 +01:00
|
|
|
virtual void displaySyncProgress(sysync::TProgressEventEnum type,
|
|
|
|
int32_t extra1, int32_t extra2, int32_t extra3)
|
|
|
|
{
|
|
|
|
if (!m_started) {
|
|
|
|
m_started = true;
|
|
|
|
if (m_options.m_startCallback(*this, m_options)) {
|
2009-06-26 08:01:02 +02:00
|
|
|
m_options.m_isAborted = true;
|
2009-03-11 15:01:07 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-26 08:01:02 +02:00
|
|
|
virtual bool checkForAbort() { return m_options.m_isAborted; }
|
|
|
|
virtual bool checkForSuspend() {return m_options.m_isSuspended;}
|
|
|
|
|
|
|
|
virtual boost::shared_ptr<TransportAgent> createTransportAgent()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<TransportAgent>wrapper = m_options.m_transport;
|
2009-10-05 14:49:32 +02:00
|
|
|
boost::shared_ptr<TransportAgent>agent =SyncContext::createTransportAgent();
|
2009-06-26 08:01:02 +02:00
|
|
|
if (!wrapper.get())
|
|
|
|
return agent;
|
|
|
|
dynamic_cast<TransportWrapper*>(wrapper.get())->setAgent(agent);
|
|
|
|
dynamic_cast<TransportWrapper*>(wrapper.get())->setSyncOptions(&m_options);
|
|
|
|
return wrapper;
|
|
|
|
}
|
2009-03-11 15:01:07 +01:00
|
|
|
|
2006-12-01 23:50:17 +01:00
|
|
|
private:
|
2009-02-19 10:52:35 +01:00
|
|
|
const string m_logbase;
|
2009-03-11 11:22:23 +01:00
|
|
|
SyncOptions m_options;
|
2009-03-11 15:01:07 +01:00
|
|
|
bool m_started;
|
2009-09-14 21:54:43 +02:00
|
|
|
} client(server, logbase, options);
|
2006-12-01 23:50:17 +01:00
|
|
|
|
2009-10-29 16:08:57 +01:00
|
|
|
// configure active sources with the desired sync mode,
|
|
|
|
// disable the rest
|
|
|
|
FilterConfigNode::ConfigFilter filter;
|
2012-06-05 12:57:33 +02:00
|
|
|
filter["sync"] = InitStateString("none", true);
|
2009-10-29 16:08:57 +01:00
|
|
|
client.setConfigFilter(false, "", filter);
|
configuration: added possibility to define property name aliases
The goal is to allow multiple names for properties. This will be used
to replace legacy names like "evolutionsource", but it could also be
used to allow abbreviations on the command line.
First the patch replaces the single ConfigProperty::m_name with a list
of names, of which the first one is the current name of the
property.
The name that is to be used depends on the node which is to be
manipulated: if it already has a property under an alias, that alias
is read and also written, so existing configuration continue to use
the old config name (avoids the problem of having to remove the old
name and insert the new one at the same spot in a .ini file). Old
configs continue to parse okay. Writing into node which has none of
the names set, as in migrating into a fresh config, uses the new
names.
Most of the patch deals with the removal of a single, unique name,
either by picking the name so that it matches a node, using the
default name or simply hard-coding a property name ("sync").
The command line accepts all aliases, then uses the main name for
overriding configuration options.
2011-01-18 15:18:21 +01:00
|
|
|
filter["sync"] =
|
2012-06-05 12:57:33 +02:00
|
|
|
InitStateString(PrettyPrintSyncMode(options.m_syncMode), true);
|
2009-10-29 16:08:57 +01:00
|
|
|
for(int i = 0; sources[i] >= 0; i++) {
|
2010-09-01 18:05:27 +02:00
|
|
|
std::string &name = m_syncSource2Config[sources[i]];
|
|
|
|
client.setConfigFilter(false, name, filter);
|
|
|
|
checkEvolutionSource(name);
|
2009-10-29 16:08:57 +01:00
|
|
|
}
|
|
|
|
|
2009-02-19 14:53:55 +01:00
|
|
|
SyncReport report;
|
|
|
|
SyncMLStatus status = client.sync(&report);
|
2009-03-11 11:22:23 +01:00
|
|
|
options.m_checkReport.check(status, report);
|
2009-02-19 14:53:55 +01:00
|
|
|
return status;
|
2007-03-31 18:22:40 +02:00
|
|
|
}
|
2009-03-11 16:30:23 +01:00
|
|
|
|
2006-12-01 23:50:17 +01:00
|
|
|
private:
|
2011-08-12 21:03:34 +02:00
|
|
|
bool m_initialized;
|
2008-08-02 17:46:23 +02:00
|
|
|
string m_clientID;
|
|
|
|
std::auto_ptr<TestEvolution> m_clientB;
|
|
|
|
const TestRegistry &m_configs;
|
2007-03-31 18:22:40 +02:00
|
|
|
|
2008-08-09 10:57:30 +02:00
|
|
|
/** prefix, username, password to be used for local databases */
|
|
|
|
string m_evoPrefix, m_evoUser, m_evoPassword;
|
2008-08-02 17:46:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The ClientTest framework identifies active configs with an integer.
|
|
|
|
* This is the mapping to the corresponding config name, created when
|
|
|
|
* constructing this instance.
|
|
|
|
*/
|
2009-12-16 07:43:08 +01:00
|
|
|
vector<string> m_localSource2Config;
|
|
|
|
vector<string> m_syncSource2Config;
|
2007-03-31 18:22:40 +02:00
|
|
|
|
|
|
|
/** returns the name of the Evolution database */
|
2008-08-02 17:46:23 +02:00
|
|
|
string getDatabaseName(const string &configName) {
|
2010-03-26 06:03:26 +01:00
|
|
|
if (configName == "calendar+todo") {
|
2011-05-05 14:15:55 +02:00
|
|
|
return "eds_event,eds_task";
|
2010-03-26 06:03:26 +01:00
|
|
|
} else if (configName == "file_calendar+todo") {
|
2011-05-05 14:15:55 +02:00
|
|
|
return "file_event,file_task";
|
2010-03-26 06:03:26 +01:00
|
|
|
}
|
2008-08-02 17:46:23 +02:00
|
|
|
return m_evoPrefix + configName + "_" + m_clientID;
|
2007-03-31 18:22:40 +02:00
|
|
|
}
|
2010-08-27 12:47:16 +02:00
|
|
|
|
|
|
|
/** called by test frame work */
|
2012-04-23 13:03:32 +02:00
|
|
|
static TestingSyncSource *createSource(ClientTest &client, const std::string &clientID, int source, bool isSourceA) {
|
2008-08-02 17:46:23 +02:00
|
|
|
TestEvolution &evClient((TestEvolution &)client);
|
2009-12-16 07:43:08 +01:00
|
|
|
string name = evClient.m_localSource2Config[source];
|
2008-03-06 23:23:13 +01:00
|
|
|
|
2010-08-27 12:47:16 +02:00
|
|
|
// implement Evolution shutdown workaround (see lockEvolution above)
|
2010-09-01 18:05:27 +02:00
|
|
|
evClient.checkEvolutionSource(name);
|
2010-08-27 12:47:16 +02:00
|
|
|
|
2011-03-02 11:50:40 +01:00
|
|
|
return evClient.createNamedSource(name, isSourceA);
|
2010-08-27 12:47:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** called internally in this class */
|
2011-03-02 11:50:40 +01:00
|
|
|
TestingSyncSource *createNamedSource(const string &name, bool isSourceA) {
|
2010-08-27 12:47:16 +02:00
|
|
|
string database = getDatabaseName(name);
|
2011-08-15 17:32:01 +02:00
|
|
|
std::string config = "target-config@client-test";
|
|
|
|
const char *server = getenv("CLIENT_TEST_SERVER");
|
|
|
|
if (server) {
|
|
|
|
config += "-";
|
|
|
|
config += server;
|
|
|
|
}
|
2012-04-23 13:03:32 +02:00
|
|
|
std::string tracking =
|
|
|
|
string("_") + m_clientID +
|
|
|
|
"_" + (isSourceA ? "A" : "B");
|
2013-04-08 19:17:36 +02:00
|
|
|
SE_LOG_DEBUG(NULL, "instantiating testing source %s in config %s, with tracking name %s",
|
2012-04-23 13:03:32 +02:00
|
|
|
name.c_str(),
|
|
|
|
config.c_str(),
|
|
|
|
tracking.c_str());
|
2011-08-15 17:32:01 +02:00
|
|
|
boost::shared_ptr<SyncConfig> context(new SyncConfig(config));
|
2012-04-23 13:03:32 +02:00
|
|
|
SyncSourceNodes nodes = context->getSyncSourceNodes(name, tracking);
|
|
|
|
|
|
|
|
// The user of client-test must have configured the source
|
|
|
|
// @<CLIENT_TEST_SERVER>_<m_clientID>/<name> when doing
|
|
|
|
// Client::Sync testing. Our testing source must use the same
|
|
|
|
// properties, but different change tracking.
|
|
|
|
std::string peerName = server ? (std::string(server) + "_" + m_clientID) : "@default";
|
|
|
|
boost::shared_ptr<SyncConfig> peer(new SyncConfig(peerName));
|
|
|
|
SyncSourceNodes peerNodes = peer->getSyncSourceNodes(name);
|
2013-04-08 19:17:36 +02:00
|
|
|
SE_LOG_DEBUG(NULL, "overriding testing source %s properties with the ones from config %s = %s",
|
2012-04-23 13:03:32 +02:00
|
|
|
name.c_str(),
|
|
|
|
peerName.c_str(),
|
|
|
|
peer->getRootPath().c_str());
|
|
|
|
BOOST_FOREACH(const ConfigProperty *prop, SyncSourceConfig::getRegistry()) {
|
|
|
|
if (prop->isHidden()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
boost::shared_ptr<FilterConfigNode> node = peerNodes.getNode(*prop);
|
|
|
|
InitStateString value = prop->getProperty(*node);
|
2013-04-08 19:17:36 +02:00
|
|
|
SE_LOG_DEBUG(NULL, " %s = %s (%s)",
|
2012-04-23 13:03:32 +02:00
|
|
|
prop->getMainName().c_str(),
|
|
|
|
value.c_str(),
|
|
|
|
value.wasSet() ? "set" : "default");
|
|
|
|
node = nodes.getNode(*prop);
|
|
|
|
node->setProperty(prop->getMainName(), value);
|
|
|
|
}
|
|
|
|
context->flush();
|
|
|
|
|
|
|
|
// Same as in init() above: set values if still empty, but don't
|
|
|
|
// overwrite anything.
|
|
|
|
boost::shared_ptr<FilterConfigNode> props = nodes.getProperties();
|
|
|
|
std::string value;
|
|
|
|
if (!props->getProperty("database", value)) {
|
|
|
|
props->setProperty("database", database);
|
|
|
|
}
|
|
|
|
if (!props->getProperty("databaseUser", value) &&
|
|
|
|
!m_evoUser.empty()) {
|
|
|
|
props->setProperty("databaseUser", m_evoUser);
|
|
|
|
}
|
|
|
|
if (!props->getProperty("databasePassword", value) &&
|
|
|
|
!m_evoPassword.empty()) {
|
|
|
|
props->setProperty("databasePassword", m_evoPassword);
|
|
|
|
}
|
2008-03-06 23:23:13 +01:00
|
|
|
|
redesigned SyncSource base class + API
The main motivation for this change is that it allows the implementor
of a backend to choose the implementations for the different aspects
of a datasource (change tracking, item import/export, logging, ...)
independently of each other. For example, change tracking via revision
strings can now be combined with exchanging data with the Synthesis
engine via a single string (the traditional method in SyncEvolution)
and with direct access to the Synthesis field list (now possible for
the first time).
The new backend API is based on the concept of providing
implementations for certain functionality via function objects instead
of implementing certain virtual methods. The advantage is that
implementors can define their own, custom interfaces and mix and match
implementations of the different groups of functionality.
Logging (see SyncSourceLogging in a later commit) can be done by
wrapping some arbitrary other item import/export function objects
(decorator design pattern).
The class hierarchy is now this:
- SyncSourceBase: interface for common utility code, all other
classes are derived from it and thus can use that code
- SyncSource: base class which implements SyncSourceBase and
hooks a datasource into the SyncEvolution core;
its "struct Operations" holds the function objects which
can be implemented in different ways
- TestingSyncSource: combines some of the following classes
into an interface that is expected by the client-test
program; backends only have to derive from (and implement this)
if they want to use the automated testing
- TrackingSyncSource: provides the same functionality as
before (change tracking via revision strings, item import/export
as string) in a single interface; the description of the pure
virtual methods are duplicated so that developers can go through
this class and find everything they need to know to implement
it
The following classes contain the code that was previously
found in the EvolutionSyncSource base class. Implementors
can derive from them and call the init() methods to inherit
and activate the functionality:
- SyncSourceSession: binds Synthesis session callbacks to
virtual methods beginSync(), endSync()
- SyncSourceChanges: implements Synthesis item tracking callbacks
with set of LUIDs that the user of the class has to fill
- SyncSourceDelete: binds Synthesis delete callback to
virtual method
- SyncSourceRaw: read and write items in the backends format,
used for testing and backup/restore
- SyncSourceSerialize: exchanges items with Synthesis engine
using a string representation of the data; this is how
EvolutionSyncSource has traditionally worked, so much of the
same virtual methods are now in this class
- SyncSourceRevisions: utility class which does change tracking
via some kind of "revision" string which changes each time
an item is modified; this code was previously in the
TrackingSyncSource
2009-08-25 09:27:46 +02:00
|
|
|
SyncSourceParams params(name,
|
2010-10-08 15:00:08 +02:00
|
|
|
nodes,
|
|
|
|
context);
|
2010-08-27 12:47:16 +02:00
|
|
|
const RegisterSyncSourceTest *test = m_configs[name];
|
2008-08-02 17:46:23 +02:00
|
|
|
ClientTestConfig testConfig;
|
|
|
|
getSourceConfig(test, testConfig);
|
2007-08-13 22:46:49 +02:00
|
|
|
|
redesigned SyncSource base class + API
The main motivation for this change is that it allows the implementor
of a backend to choose the implementations for the different aspects
of a datasource (change tracking, item import/export, logging, ...)
independently of each other. For example, change tracking via revision
strings can now be combined with exchanging data with the Synthesis
engine via a single string (the traditional method in SyncEvolution)
and with direct access to the Synthesis field list (now possible for
the first time).
The new backend API is based on the concept of providing
implementations for certain functionality via function objects instead
of implementing certain virtual methods. The advantage is that
implementors can define their own, custom interfaces and mix and match
implementations of the different groups of functionality.
Logging (see SyncSourceLogging in a later commit) can be done by
wrapping some arbitrary other item import/export function objects
(decorator design pattern).
The class hierarchy is now this:
- SyncSourceBase: interface for common utility code, all other
classes are derived from it and thus can use that code
- SyncSource: base class which implements SyncSourceBase and
hooks a datasource into the SyncEvolution core;
its "struct Operations" holds the function objects which
can be implemented in different ways
- TestingSyncSource: combines some of the following classes
into an interface that is expected by the client-test
program; backends only have to derive from (and implement this)
if they want to use the automated testing
- TrackingSyncSource: provides the same functionality as
before (change tracking via revision strings, item import/export
as string) in a single interface; the description of the pure
virtual methods are duplicated so that developers can go through
this class and find everything they need to know to implement
it
The following classes contain the code that was previously
found in the EvolutionSyncSource base class. Implementors
can derive from them and call the init() methods to inherit
and activate the functionality:
- SyncSourceSession: binds Synthesis session callbacks to
virtual methods beginSync(), endSync()
- SyncSourceChanges: implements Synthesis item tracking callbacks
with set of LUIDs that the user of the class has to fill
- SyncSourceDelete: binds Synthesis delete callback to
virtual method
- SyncSourceRaw: read and write items in the backends format,
used for testing and backup/restore
- SyncSourceSerialize: exchanges items with Synthesis engine
using a string representation of the data; this is how
EvolutionSyncSource has traditionally worked, so much of the
same virtual methods are now in this class
- SyncSourceRevisions: utility class which does change tracking
via some kind of "revision" string which changes each time
an item is modified; this code was previously in the
TrackingSyncSource
2009-08-25 09:27:46 +02:00
|
|
|
PersistentSyncSourceConfig sourceConfig(params.m_name, params.m_nodes);
|
2011-09-02 09:42:19 +02:00
|
|
|
sourceConfig.setSourceType(SourceType(testConfig.m_type));
|
redesigned SyncSource base class + API
The main motivation for this change is that it allows the implementor
of a backend to choose the implementations for the different aspects
of a datasource (change tracking, item import/export, logging, ...)
independently of each other. For example, change tracking via revision
strings can now be combined with exchanging data with the Synthesis
engine via a single string (the traditional method in SyncEvolution)
and with direct access to the Synthesis field list (now possible for
the first time).
The new backend API is based on the concept of providing
implementations for certain functionality via function objects instead
of implementing certain virtual methods. The advantage is that
implementors can define their own, custom interfaces and mix and match
implementations of the different groups of functionality.
Logging (see SyncSourceLogging in a later commit) can be done by
wrapping some arbitrary other item import/export function objects
(decorator design pattern).
The class hierarchy is now this:
- SyncSourceBase: interface for common utility code, all other
classes are derived from it and thus can use that code
- SyncSource: base class which implements SyncSourceBase and
hooks a datasource into the SyncEvolution core;
its "struct Operations" holds the function objects which
can be implemented in different ways
- TestingSyncSource: combines some of the following classes
into an interface that is expected by the client-test
program; backends only have to derive from (and implement this)
if they want to use the automated testing
- TrackingSyncSource: provides the same functionality as
before (change tracking via revision strings, item import/export
as string) in a single interface; the description of the pure
virtual methods are duplicated so that developers can go through
this class and find everything they need to know to implement
it
The following classes contain the code that was previously
found in the EvolutionSyncSource base class. Implementors
can derive from them and call the init() methods to inherit
and activate the functionality:
- SyncSourceSession: binds Synthesis session callbacks to
virtual methods beginSync(), endSync()
- SyncSourceChanges: implements Synthesis item tracking callbacks
with set of LUIDs that the user of the class has to fill
- SyncSourceDelete: binds Synthesis delete callback to
virtual method
- SyncSourceRaw: read and write items in the backends format,
used for testing and backup/restore
- SyncSourceSerialize: exchanges items with Synthesis engine
using a string representation of the data; this is how
EvolutionSyncSource has traditionally worked, so much of the
same virtual methods are now in this class
- SyncSourceRevisions: utility class which does change tracking
via some kind of "revision" string which changes each time
an item is modified; this code was previously in the
TrackingSyncSource
2009-08-25 09:27:46 +02:00
|
|
|
|
|
|
|
// downcasting here: anyone who registers his sources for testing
|
|
|
|
// must ensure that they are indeed TestingSyncSource instances
|
|
|
|
SyncSource *ss = SyncSource::createSource(params);
|
|
|
|
return static_cast<TestingSyncSource *>(ss);
|
2006-12-01 23:50:17 +01:00
|
|
|
}
|
2010-08-25 08:12:58 +02:00
|
|
|
|
|
|
|
// push source into localsource2config if it doesn't exist in the vector
|
|
|
|
void pushLocalSource2Config(const string &source) {
|
|
|
|
bool finded = false;
|
|
|
|
BOOST_FOREACH(string element, m_localSource2Config) {
|
|
|
|
if (boost::iequals(element, source)) {
|
|
|
|
finded = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!finded) {
|
|
|
|
m_localSource2Config.push_back (source);
|
|
|
|
}
|
|
|
|
}
|
2010-08-27 12:47:16 +02:00
|
|
|
|
2010-09-01 18:05:27 +02:00
|
|
|
void checkEvolutionSource(std::string &name)
|
2010-08-27 12:47:16 +02:00
|
|
|
{
|
|
|
|
string basename;
|
|
|
|
|
|
|
|
// hard-coded names as used by src/backends/evolution;
|
|
|
|
// if some other backend reuses them, it gets the
|
|
|
|
// same treatment, which shouldn't cause any harm
|
2011-05-24 15:27:53 +02:00
|
|
|
if (name == "eds_contact") {
|
2010-08-27 12:47:16 +02:00
|
|
|
basename = "ebook";
|
2011-05-05 14:15:55 +02:00
|
|
|
} else if (name == "eds_event" ||
|
2010-09-01 18:05:27 +02:00
|
|
|
name == "text") {
|
2010-08-27 12:47:16 +02:00
|
|
|
basename = "ecal";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!basename.empty() &&
|
|
|
|
lockEvolution.find(basename) == lockEvolution.end()) {
|
2011-03-02 11:50:40 +01:00
|
|
|
lockEvolution[basename].reset(createNamedSource(name, true));
|
2010-08-27 12:47:16 +02:00
|
|
|
lockEvolution[basename]->open();
|
2010-09-01 18:01:19 +02:00
|
|
|
ClientTest::registerCleanup(CleanupSources);
|
2010-08-27 12:47:16 +02:00
|
|
|
}
|
|
|
|
}
|
2006-12-01 23:50:17 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
static class RegisterTestEvolution {
|
|
|
|
public:
|
2006-12-07 23:27:18 +01:00
|
|
|
RegisterTestEvolution() :
|
|
|
|
testClient("1") {
|
2006-12-01 23:50:17 +01:00
|
|
|
testClient.registerTests();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
TestEvolution testClient;
|
|
|
|
|
|
|
|
} testEvolution;
|
2009-10-02 17:23:53 +02:00
|
|
|
|
|
|
|
SE_END_CXX
|