Commit 98611c1a authored by Sam Thursfield's avatar Sam Thursfield

Merge branch 'sam/functional-tests-removal' into 'master'

tests: Remove some functional tests

See merge request !72
parents 8c1cbf7f 3155f39d
Pipeline #71202 passed with stage
in 2 minutes and 12 seconds
......@@ -9,58 +9,6 @@ insert_or_replace_test = executable('test-insert-or-replace',
test('functional-ipc-insert-or-replace', insert_or_replace_test,
env: test_env)
busy_handling_test = executable('test-busy-handling',
'test-busy-handling.vala',
dependencies: [tracker_common_dep, tracker_sparql_dep])
direct_query_test = executable('test-direct-query',
'test-direct-query.vala',
'test-shared-query.vala',
dependencies: [tracker_common_dep, tracker_sparql_dep])
test('functional-ipc-direct-query', direct_query_test,
env: test_env)
bus_query_test = executable('test-bus-query',
'test-bus-query.vala',
'test-shared-query.vala',
link_with: [libtracker_bus],
dependencies: [tracker_common_dep, tracker_sparql_dep, tracker_sparql_bus_dep])
test('functional-ipc-bus-query', bus_query_test,
env: test_env)
default_update_test = executable('test-default-update',
'test-default-update.vala',
'test-shared-update.vala',
dependencies: [tracker_common_dep, tracker_sparql_dep])
test('functional-ipc-default-update', default_update_test,
env: test_env)
bus_update_test = executable('test-bus-update',
'test-bus-update.vala',
'test-shared-update.vala',
link_with: [libtracker_bus],
dependencies: [tracker_common_dep, tracker_sparql_dep, tracker_sparql_bus_dep])
test('functional-ipc-bus-update', bus_update_test,
env: test_env)
class_signal_test = executable('test-class-signal',
'test-class-signal.vala',
dependencies: [tracker_common_dep, tracker_sparql_dep])
class_signal_performance_test = executable('test-class-signal-performance',
'test-class-signal-performance.vala',
dependencies: [tracker_common_dep, tracker_sparql_dep])
class_signal_performance_batch_test = executable('test-class-signal-performance-batch',
'test-class-signal-performance-batch.vala',
dependencies: [tracker_common_dep, tracker_sparql_dep])
update_array_performance_test = executable('test-update-array-performance',
'test-update-array-performance.c',
dependencies: [tracker_common_dep, tracker_sparql_dep])
test('functional-ipc-update-array-performance', update_array_performance_test,
env: test_env)
bus_query_cancellation_test = executable('test-bus-query-cancellation',
'test-bus-query-cancellation.c',
c_args: functional_ipc_test_c_args,
......
using Tracker;
using Tracker.Sparql;
int
main( string[] args )
{
try {
TestApp app = new TestApp (new Tracker.Bus.Connection ("org.freedesktop.Tracker1", null, true));
return app.run ();
} catch (GLib.Error e) {
warning ("Couldn't perform test: %s", e.message);
return 1;
}
}
using Tracker;
using Tracker.Sparql;
int
main( string[] args )
{
try {
TestApp app = new TestApp (new Tracker.Bus.Connection ("org.freedesktop.Tracker1", null, true));
return app.run ();
} catch (GLib.Error e) {
warning ("Couldn't perform test: %s", e.message);
return 1;
}
}
/*
* Copyright (C) 2008, Nokia <ivan.frade@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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
* General Public License for more details.
*
* You should have received a copy of the GNU Library 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.
*/
// To run this test:
// -===-------------
//
// tracker daemon -k
// rm ~/.cache/tracker/meta.db
// export TRACKER_DEBUG_MAKE_JOURNAL_READER_GO_VERY_SLOW=yes
// tracker-store
// ./busy-handling-test
[DBus (name = "org.freedesktop.Tracker1.Resources")]
private interface Resources : DBusProxy {
[DBus (name = "SparqlQuery", timeout = 99999999999)]
public abstract async string[,] sparql_query (string query) throws GLib.Error, DBusError;
}
[DBus (name = "org.freedesktop.Tracker1.Status")]
private interface Status: DBusProxy {
public signal void progress (string status, double progress);
public abstract double get_progress () throws GLib.Error, DBusError;
public abstract string get_status () throws GLib.Error, DBusError;
}
public class TestApp {
static Resources resources_object;
static Status status_object;
int res = -1;
int users = 0;
MainLoop loop;
bool initialized = false;
bool ready = false;
public TestApp ()
requires (!initialized) {
try {
double progress;
string status;
resources_object = GLib.Bus.get_proxy_sync (BusType.SESSION,
"org.freedesktop.Tracker1",
"/org/freedesktop/Tracker1/Resources",
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS);
status_object = GLib.Bus.get_proxy_sync (BusType.SESSION,
"org.freedesktop.Tracker1",
"/org/freedesktop/Tracker1/Status",
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS);
status_object.progress.connect (on_status_cb);
progress = status_object.get_progress ();
status = status_object.get_status ();
ready = (progress == 1.0 && status == "Idle");
} catch (GLib.Error e) {
warning ("Could not connect to D-Bus service: %s", e.message);
initialized = false;
res = -1;
return;
}
initialized = true;
}
void on_status_cb (string status, double progress) {
print ("%s: %f\n", status, progress);
// Don't use status here, it'll be "Journal replaying" when progress = 1
if (progress == 1.0) {
ready = true;
}
}
async void do_query_tests_async (string test_name) {
try {
int cnt = 0;
string[,] results = yield resources_object.sparql_query ("SELECT ?u { ?u a rdfs:Resource }");
foreach (string res in results) {
cnt++;
}
print ("%s: Saw %d strings in result\n", test_name, cnt);
} catch (GLib.Error e) {
print ("Fail: %s\n", e.message);
res = -1;
}
}
void check_shutdown () {
users--;
if (users == 0) {
print ("Async tests done, now I can quit the mainloop\n");
loop.quit ();
}
}
async void do_async_query_tests () {
print ("Test 1: Just launch the query and let it wait\nTest 1: query launches immediately\n");
users++;
yield do_query_tests_async ("Test 1");
check_shutdown ();
}
async void jumper_async () {
yield do_query_tests_async ("Test 2");
check_shutdown ();
}
bool test_ready () {
if (ready) {
print ("Test 2: query launches now\n");
jumper_async.begin ();
}
return !ready;
}
bool in_mainloop () {
do_async_query_tests.begin ();
print ("Test 2: Wait for the status signal to indicate readyness\n");
users++;
if (!ready) {
Timeout.add (1, test_ready);
} else {
test_ready ();
}
return false;
}
public int run () {
loop = new MainLoop (null, false);
Idle.add (in_mainloop);
loop.run ();
return res;
}
}
int main (string[] args) {
TestApp app = new TestApp ();
return app.run ();
}
/*
* Copyright (C) 2008, Nokia <ivan.frade@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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
* General Public License for more details.
*
* You should have received a copy of the GNU Library 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.
*/
using Tracker;
using Tracker.Sparql;
const int max_signals = 1000;
const string title_data = "title";
public struct Event {
int graph_id;
int subject_id;
int pred_id;
int object_id;
}
[DBus (name = "org.freedesktop.Tracker1.Resources")]
private interface Resources : DBusProxy {
[DBus (name = "GraphUpdated")]
public signal void graph_updated (string class_name, Event[] deletes, Event[] inserts);
[DBus (name = "BatchSparqlUpdate")]
public abstract async void batch_sparql_update_async (string query) throws GLib.Error, Sparql.Error, DBusError;
[DBus (name = "SparqlUpdate")]
public abstract async void sparql_update_async (string query) throws GLib.Error, Sparql.Error, DBusError;
}
public class TestApp {
static Resources resources_object;
MainLoop loop;
bool initialized = false;
Sparql.Connection con;
int count = 0;
GLib.Timer t;
public TestApp ()
requires (!initialized) {
try {
con = Tracker.Sparql.Connection.get();
resources_object = GLib.Bus.get_proxy_sync (BusType.SESSION,
"org.freedesktop.Tracker1",
"/org/freedesktop/Tracker1/Resources",
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS);
resources_object.graph_updated.connect (on_graph_updated_received);
t = new GLib.Timer ();
} catch (GLib.Error e) {
warning ("Could not connect to D-Bus service: %s", e.message);
initialized = false;
return;
}
initialized = true;
}
private void on_graph_updated_received (string class_name, Event[] deletes, Event[] inserts) {
foreach (Event insert in inserts)
count++;
print ("New class signal count=%d time=%lf\n", count, t.elapsed ());
}
private void insert_data () {
int i;
for (i = 0; i <= max_signals; i++) {
string upqry = "DELETE { <%d> a rdfs:Resource }".printf(i);
resources_object.sparql_update_async.begin (upqry);
}
t.start();
for (i = 0; i <= max_signals; i++) {
string upqry = "INSERT { <%d> a nmm:MusicPiece ; nie:title '%s %d' }".printf(i, title_data, i);
if (i == max_signals / 2) {
resources_object.sparql_update_async.begin (upqry);
} else {
resources_object.batch_sparql_update_async.begin (upqry);
}
}
}
private bool in_mainloop () {
insert_data ();
return false;
}
public int run () {
loop = new MainLoop (null, false);
Idle.add (in_mainloop);
loop.run ();
return 0;
}
}
int main (string[] args) {
TestApp app = new TestApp ();
return app.run ();
}
/*
* Copyright (C) 2008, Nokia <ivan.frade@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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
* General Public License for more details.
*
* You should have received a copy of the GNU Library 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.
*/
using Tracker;
using Tracker.Sparql;
const int max_signals = 1000;
// const int max_signals = 10000;
const string title_data = "title";
// Always start this test AFTER DOING tracker-control -r. The test IS NOT
// deleting existing resources, so you CAN'T RUN IT TWICE unless you clear
// the database before starting it the second time.
// Testreport of Aug 25, 2010 by Philip
// ------------------------------------
// On Aug 25 the difference between using tracker-store on master and the
// tracker-store of class-signal, and then letting this wait until all 10000
// (in case of max_signals = 10000) insert queries' signals arrived (you'll
// have in total 20002 events in the signals in both tracker-store versions)
// was: 20s for class-signals (new class signal) and 23s for master (old class
// signals). Measured using this performance test.
//
// Memory usage of class-signal (new class signal)'s tracker-store:
// Low: VmRSS: 8860 Kb -- Max: VmRSS: 14116 kB
//
// Memory usage of master (old class signal)'s tracker-store:
// Low: VmRSS: 8868 Kb -- Max: VmRSS: 14060 kB
public struct Event {
int graph_id;
int subject_id;
int pred_id;
int object_id;
}
[DBus (name = "org.freedesktop.Tracker1.Resources")]
private interface Resources : DBusProxy {
[DBus (name = "GraphUpdated")]
public signal void graph_updated (string class_name, Event[] deletes, Event[] inserts);
[DBus (name = "SparqlUpdate")]
public abstract async void sparql_update_async (string query) throws GLib.Error, Sparql.Error, DBusError;
}
[DBus (name = "org.freedesktop.Tracker1.Resources.Class")]
private interface ResourcesClass : DBusProxy {
[DBus (name = "SubjectsAdded")]
public signal void subjects_added (string [] subjects);
[DBus (name = "SubjectsChanged")]
public signal void subjects_changed (string [] subjects, string [] preds);
}
public class TestApp {
static Resources resources_object;
static ResourcesClass class_object;
MainLoop loop;
bool initialized = false;
Sparql.Connection con;
int count = 0;
GLib.Timer t;
public TestApp ()
requires (!initialized) {
try {
con = Tracker.Sparql.Connection.get();
resources_object = GLib.Bus.get_proxy_sync (BusType.SESSION,
"org.freedesktop.Tracker1",
"/org/freedesktop/Tracker1/Resources",
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS);
class_object = GLib.Bus.get_proxy_sync (BusType.SESSION,
"org.freedesktop.Tracker1",
"/org/freedesktop/Tracker1/Resources/Classes/nmm/MusicPiece",
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS);
class_object.subjects_added.connect (on_subjects_added);
class_object.subjects_changed.connect (on_subjects_changed);
resources_object.graph_updated.connect (on_graph_updated_received);
t = new GLib.Timer ();
} catch (GLib.Error e) {
warning ("Could not connect to D-Bus service: %s", e.message);
initialized = false;
return;
}
initialized = true;
}
private void on_subjects_changed (string [] subjects, string [] preds) {
foreach (string s in subjects)
count++;
//if (count == 20002)
print ("Old class signal count=%d time=%lf\n", count, t.elapsed ());
}
private void on_subjects_added (string [] subjects) {
foreach (string s in subjects)
count++;
//if (count == 20002)
print ("Old class signal count=%d time=%lf\n", count, t.elapsed ());
}
private void on_graph_updated_received (string class_name, Event[] deletes, Event[] inserts) {
foreach (Event insert in inserts)
count++;
//if (count == 20002)
print ("New class signal count=%d time=%lf\n", count, t.elapsed ());
}
private void insert_data () {
int i;
t.start();
for (i = 0; i <= max_signals; i++) {
string upqry = "INSERT { <%d> a nmm:MusicPiece ; nie:title '%s %d' }".printf(i, title_data, i);
resources_object.sparql_update_async.begin (upqry);
}
}
private bool in_mainloop () {
insert_data ();
return false;
}
public int run () {
loop = new MainLoop (null, false);
Idle.add (in_mainloop);
loop.run ();
return 0;
}
}
int main (string[] args) {
TestApp app = new TestApp ();
return app.run ();
}
/*
* Copyright (C) 2008, Nokia <ivan.frade@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* 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
* General Public License for more details.
*
* You should have received a copy of the GNU Library 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.
*/
using Tracker;
using Tracker.Sparql;
const int max_signals = 10;
const string title_data = "title";
public struct Event {
int graph_id;
int subject_id;
int pred_id;
int object_id;
}
[DBus (name = "org.freedesktop.Tracker1.Resources")]
private interface Resources : DBusProxy {
[DBus (name = "GraphUpdated")]
public signal void graph_updated (string class_name, Event[] deletes, Event[] inserts);
[DBus (name = "SparqlUpdate")]
public abstract async void sparql_update_async (string query) throws GLib.Error, Sparql.Error, DBusError;
}
public class TestApp {
static Resources resources_object;
int res = -1;
MainLoop loop;
bool initialized = false;
Sparql.Connection signal_con;
Sparql.Connection con;
int total_signals_seen = 0;
public TestApp ()
requires (!initialized) {
try {
con = Tracker.Sparql.Connection.get();
// Switch between kinds of query connections here:
signal_con = con;
resources_object = GLib.Bus.get_proxy_sync (BusType.SESSION,
"org.freedesktop.Tracker1",
"/org/freedesktop/Tracker1/Resources",
DBusProxyFlags.DO_NOT_LOAD_PROPERTIES | DBusProxyFlags.DO_NOT_CONNECT_SIGNALS);
resources_object.graph_updated.connect (on_graph_updated_received);
} catch (GLib.Error e) {
warning ("Could not connect to D-Bus service: %s", e.message);
initialized = false;
res = -1;
return;
}
initialized = true;
}
// Query looks like this:
// SELECT ?r ?t { ?r a nmm:MusicPiece; nie:title ?t .
// FILTER (tracker:id (?r) IN (id1, id2, id3))
// }
private StringBuilder build_title_query (string class_name, Event[] ids) {
bool first = true;
StringBuilder builder = new StringBuilder ("SELECT ?r ?t { ?r a <");
builder.append (class_name);
builder.append (">; nie:title ?t . FILTER (tracker:id (?r) IN (");
foreach (Event event in ids) {
if (first)
builder.append_printf ("%d", event.subject_id);
else
builder.append_printf (" , %d", event.subject_id);
first = false;
}
builder.append (")) }");
return builder;
}
private int iter_cursor (string kind, Cursor cursor) {
try {
while (cursor.next()) {
string resource = cursor.get_string (0);
print ("%s <%s> nie:title '%s'\n",
kind,
resource,
cursor.get_string (1));
total_signals_seen++;
// We'll see ~ max_signals*2 things, (insert and delete, plus the
// resource creates too - so a little bit more)
if (total_signals_seen >= (max_signals*2)) {
loop.quit();
}
}
} catch (GLib.Error e) {
warning ("Couldn't iterate query results: %s", e.message);
res = -1;
return -1;
}
return (0);
}
private async void on_graph_updated_received_async (string dels_query, string ins_query) {
try {
Sparql.Cursor cursor1, cursor2;
cursor1 = yield signal_con.query_async (dels_query);
cursor2 = yield signal_con.query_async (ins_query);
res = iter_cursor ("delete of: ", cursor1);
if (res != -1)
res = iter_cursor ("insert of: ", cursor2);
} catch (GLib.Error e) {
warning ("Couldn't iterate query results: %s", e.message);
res = -1;
}
}
private void on_graph_updated_received (string class_name, Event[] deletes, Event[] inserts) {
string dels_qry = build_title_query (class_name, deletes).str;
string ins_qry = build_title_query (class_name, deletes).str;
on_graph_updated_received_async.begin (dels_qry, ins_qry);
}
private void insert_data () {
int i;
for (i = 0; i <= max_signals; i++) {
string upqry = "DELETE { <%d> a rdfs:Resource } INSERT { <%d> a nmm:MusicPiece ; nie:title '%s %d' }".printf(i, i, title_data, i);
resources_object.sparql_update_async.begin (upqry);
// Once the FD passing bug is fixed (running out of FDs), replace
// above with this:
// con.update_async (upqry);
}
}
private bool in_mainloop () {
insert_data ();
return false;
}
public int run () {
loop = new MainLoop (null, false);
Idle.add (in_mainloop);
loop.run ();
return res;
}
}
int main (string[] args) {
TestApp app = new TestApp ();
return app.run ();