nightly testing: workaround for Evolution 2.30 storage shutdown (BMC #5864)

The D-Bus based Evolution Data Server calendar and contact daemons
(e-calendar-factory and e-contact-factory) shut down after 10 seconds of
inactivity.

Normally libecal/libebook detect that, but not when the client only uses the
synchronous API ("destroyed" signal not delivered, see e-cal.c). That affects
SyncEvolution.

This patch ensures that a EvolutionContactSource resp. EvolutionCalendarSource
remains open throughout the lifetime of the client-test app. This prevents
the storages from shutting down.

This instances are created on demand and deleted when the process quits.
This might be too late for ORBit based Evolution; there were error messages
after all tests succeeded and an assertion failure in ORBit, leading to
a nonzero return code.
This commit is contained in:
Patrick Ohly 2010-08-27 18:47:16 +08:00
parent 2353ee20ba
commit 614f0390b0
1 changed files with 51 additions and 6 deletions

View File

@ -101,6 +101,19 @@ private:
}
};
/**
* 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
* around for each of ical20 and vcard21/30, if they ever were used
* during testing.
*/
static map<string, boost::shared_ptr<TestingSyncSource> > lockEvolution;
/**
* This code uses the ClientTest and and information provided by
* the backends in their RegisterSyncSourceTest instances to test
@ -373,6 +386,7 @@ public:
PrettyPrintSyncMode(options.m_syncMode);
for(int i = 0; sources[i] >= 0; i++) {
client.setConfigFilter(false, m_syncSource2Config[sources[i]], filter);
checkEvolutionSource(sources[i]);
}
SyncReport report;
@ -406,26 +420,35 @@ private:
}
return m_evoPrefix + configName + "_" + m_clientID;
}
/** called by test frame work */
static TestingSyncSource *createSource(ClientTest &client, int source, bool isSourceA) {
TestEvolution &evClient((TestEvolution &)client);
string name = evClient.m_localSource2Config[source];
string database = evClient.getDatabaseName(name);
// implement Evolution shutdown workaround (see lockEvolution above)
evClient.checkEvolutionSource(source);
return evClient.createSource(name, isSourceA);
}
/** called internally in this class */
TestingSyncSource *createSource(const string &name, bool isSourceA) {
string database = getDatabaseName(name);
SyncConfig config("client-test-changes");
SyncSourceNodes nodes = config.getSyncSourceNodes(name,
string("_") + ((TestEvolution &)client).m_clientID +
string("_") + m_clientID +
"_" + (isSourceA ? "A" : "B"));
// always set this property: the name might have changes since last test run
nodes.getProperties()->setProperty("evolutionsource", database.c_str());
nodes.getProperties()->setProperty("evolutionuser", evClient.m_evoUser.c_str());
nodes.getProperties()->setProperty("evolutionpassword", evClient.m_evoPassword.c_str());
nodes.getProperties()->setProperty("evolutionuser", m_evoUser.c_str());
nodes.getProperties()->setProperty("evolutionpassword", m_evoPassword.c_str());
SyncSourceParams params(name,
nodes);
const RegisterSyncSourceTest *test = evClient.m_configs[name];
const RegisterSyncSourceTest *test = m_configs[name];
ClientTestConfig testConfig;
getSourceConfig(test, testConfig);
@ -451,6 +474,28 @@ private:
m_localSource2Config.push_back (source);
}
}
void checkEvolutionSource(int source)
{
string name = m_localSource2Config[source];
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
if (name == "vcard21" ||
name == "vcard30") {
basename = "ebook";
} else if (name == "ical20") {
basename = "ecal";
}
if (!basename.empty() &&
lockEvolution.find(basename) == lockEvolution.end()) {
lockEvolution[basename].reset(createSource(name, true));
lockEvolution[basename]->open();
}
}
};
static void handler(int sig)