summaryrefslogtreecommitdiff
path: root/tests
Commit message (Collapse)AuthorAgeFilesLines
* tests: Make portal functional test use absolute IRIsCarlos Garnacho2022-11-211-38/+38
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make serialization API tests use absolute IRIsCarlos Garnacho2022-11-215-28/+28
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make insertion functional test use absolute IRIsCarlos Garnacho2022-11-211-1/+1
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make ontology-rollback functional test use absolute IRIsCarlos Garnacho2022-11-211-10/+10
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Use absolute IRIs in ontology-change testsCarlos Garnacho2022-11-2119-40/+40
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make CONSTRAINT tests use absolute IRIsCarlos Garnacho2022-11-2113-22/+23
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make property-path tests use absolute IRIsCarlos Garnacho2022-11-212-4/+4
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make turtle tests use absolute IRIsCarlos Garnacho2022-11-211-4/+4
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make RDF list tests use absolute IRIsCarlos Garnacho2022-11-212-2/+2
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make langstring tests use absolute IRIsCarlos Garnacho2022-11-216-10/+10
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make FILTER expression tests use absolute IRIsCarlos Garnacho2022-11-213-5/+5
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make DESCRIBE tests use absolute IRIsCarlos Garnacho2022-11-216-55/+55
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* tests: Make CONSTRUCT tests use absolute IRIsCarlos Garnacho2022-11-214-34/+34
| | | | Do not rely on our loose interpretation of IRIs to make tests work.
* ontologies: Move fts: prefix definition to base ontologyCarlos Garnacho2022-09-271-0/+1
| | | | | | | | | | | | | | This prefix is used in some of our base SPARQL API (e.g. fts:match and the misc functions to deal with results), but the prefix is currently defined in the Nepomuk ontology side. This makes applications that want to use FTS with custom ontologies either need to declare the prefix themselves, or help queries with `PREFIX` syntax to add the missing stock prefix. Move this prefix definition to the base ontology, so all databases inherit the builtin fts: prefix and it can be used right away in FTS queries.
* libtracker-sparql: Fix off by one in checks for escaped IRIsCarlos Garnacho2022-09-041-0/+6
| | | | | | | | | | | | | The 0x20 character should also be escaped as per the SPARQL reference, and it correctly is when setting a TrackerResource IRI. Even though, the fast path check for the presence of characters that should be escaped is missing it, so it would be possible to let IRIs that only have this invalid character as valid. Since 0x20 (whitespace) is possibly the most ubiquitous character that should be escaped, it's a bit of an oversight. Fixes: 33031007c ("libtracker-sparql: Escape illegal characters in IRIREF...")
* libtracker-sparql: Escape illegal characters in IRIREF from TrackerResourceCarlos Garnacho2022-09-021-0/+32
| | | | | | | | | | | | | | | | | | | | | | | Currently, all IRIREF going through SPARQL updates will be validated for the characters being in the expected set (https://www.w3.org/TR/sparql11-query/#rIRIREF), meanwhile TrackerResource is pretty liberal in the characters used by a TrackerResource identifier or IRI reference. This disagreement causes has 2 possible outcomes: - If the resource is inserted via print_sparql_update(), print_rdf() or alike while containing illegal characters, it will find errors when handling the SPARQL update. - If the resource is directly inserted via TrackerBatch or update_resource(), the validation step will be bypassed, ending up with an IRI that contains illegal characters as per the SPARQL grammar. In order to make TrackerResource friendly to e.g. sloppy IRI composition and avoid these ugly situations when an illegal char sneaks in, make it escape the IRIs as defined by IRIREF in the SPARQL grammar definition. This way every method of insertion will succeed and be most correct with the given input. Also, add tests for this behavior, to ensure we escape what should be escaped.
* tests: Remove unused variablesCarlos Garnacho2022-08-301-2/+0
|
* core: Refactor buffering of database updatesCarlos Garnacho2022-08-302-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, our caching of triples does have a number of nested structures: - In the buffer there is a struct for each graph - In the graph struct there is a set of changed resource - In the resource struct there is a set of modified tables - In the table struct there is a set of modified properties - In the property struct there is a list of values This incurs in a maintenance cost that is higher than desired, adding and removing elements here becomes a fair chunk of the time spent in updates, since there is a number of allocations and list/hashtable updates performed for batches that deal with a fair amount of different resources (i.e. most of them). In order to improve this, keep use two arrays to buffer this data: - A "properties" array, that keeps individual predicate/object pairs. This is used to store the values of properties being inserted or deleted for single-valued and multivalued properties. This struct is "linked" with (i.e. references) other elements in the array, so that e.g. class updates may reference multiple properties/values being updated. - An "update log" array, containing structs that are a event_type/graph/ subject tuple, plus optionally a link to one of the properties in the previous array, all other properties are fetched through iterating through the linked properties. These log entries are valid for class table updates (i.e. single-valued properties) or multi-valued property tables. These arrays make allocating the buffer a one-time operation (buffer size is fixed, and the arrays are reused during the processing of a TrackerBatch) and insertions into the log largely O(1) as opposed to a number of array/hashtable lookups and inserts. But we still want to coalesce updates to a same class table (e.g. changes to several single-valued properties in the same table), for that there is an additional hashtable set that uses these log entries as keys themselves, with special hash/equal functions, lookups for prior events modifying the same TrackerClass is also quite fast. Overall, this makes the maintenance of this buffer less expensive in the big picture. Even though there are still some remnants of the previous caching for graphs and resources, this plays less of a role. Since this changes the ordering of updates, some tests that rely on implicit ordering (DESCRIBE ones) had to be adapted for this change.
* libtracker-sparql/core: Set nrl:modified/added consistentlyCarlos Garnacho2022-08-301-1/+0
| | | | | | | | | | | | | | | For nrl:modified, we had some double handling since the modifier was pushed as a property change, but also dealt with directly when flushing the buffer. Since these are essentially properties (even though changed automatically), it makes sense to stick to the former, also for nrl:added. Do that, and drop the special handling of these 2 properties when flushing the buffer. This commit also changes the expected output of a serialization test, since nrl:added is added now on more graphs than the first one that sees a resource, this slightly changes the spacing after filtering the test filters nrl:added/nrl:modified.
* tests: Invert order of assertsCarlos Garnacho2022-07-131-2/+2
| | | | | | When checking a function with a return value and a GError out argument, it often gives better clues to check the error first, then the return value.
* tests: Specify missing order in testCarlos Garnacho2022-07-031-0/+1
| | | | | | | | | The order of the returned resultset was implicit and up to SQLite, but the order for this test started changing starting with SQLite 3.39.0. Make the order explicit, so that SQLite implementation details don't leak up here. Closes: https://gitlab.gnome.org/GNOME/tracker/-/issues/370
* tests: Add tests for deserializationCarlos Garnacho2022-06-308-0/+1375
| | | | | | These tests take some RDF, deserialize into a local connection, serialize it again, and deserializes it into a dbus connection. Then queries are run on both connections to verify data matches.
* libtracker-sparql: Drop line/column information in error messageCarlos Garnacho2022-06-303-3/+3
| | | | | We already wrap this with a prefix that adds location/line/col, so this is inconsistently duplicated info.
* tests: Comment out turtle parsing test with base/prefix changesCarlos Garnacho2022-06-301-0/+2
| | | | | | | | | | | | This test is currently ineffective (finds an error handling a duplicate @prefix, but the test doesn't quite catch it or test anything worthwhile), and it will actually break with the changes to come (arguably for the better, since the error is actually propagated). Comment out this test so far, we do need to handle @prefix possibly overwriting a previous value, and we need to test this behavior properly. Avoid making deserializers depend on this just because error propagation was fixed in this place. This will be improved in the future.
* Merge branch 'wip/carlosg/fts-consistence-fixes' into 'master'Sam Thursfield2022-05-0911-0/+26
|\ | | | | | | | | | | | | libtracker-sparql: Fix handling of partial FTS deletion Closes #361 See merge request GNOME/tracker!510
| * tests: Add FTS tests for partial updates and INSERT OR REPLACE changesCarlos Garnacho2022-05-0411-0/+26
| | | | | | | | Test paths fixed by the previous commits.
* | Merge branch 'wip/carlosg/remote-namespace-manager' into 'master'Sam Thursfield2022-05-072-0/+224
|\ \ | | | | | | | | | | | | Implement TrackerNamespaceManager for remote connections See merge request GNOME/tracker!508
| * | tests: Add tests for TrackerNamespaceManager APICarlos Garnacho2022-05-072-0/+224
| |/ | | | | | | | | | | Ensure all namespaces that can be obtained through public API (the deprecated default, but also for each type of SPARQL connection) contains everything that is expected.
* | tests: Add tests for queries around blank nodesCarlos Garnacho2022-05-061-0/+265
|/ | | | | | | | | | | | | | | | | | | | | | | We have 2 behaviors to test here, the default non-standard behavior that treats blank nodes as the equivalent of a lazy IRI generator, and the spec-compliant behavior that was made possible through the TRACKER_SPARQL_CONNECTION_FLAGS_ANONYMOUS_BNODES in 3.3.x. In the former, we expect the engine to treat blank nodes like IRIs when passed as literals, e.g.: SELECT (<urn:bnode:...> AS ?u) { } SELECT ?p ?o { <urn:bnode:...> ?p ?o } should identify the correct resource from the blank node name and return data around it, making it effectively identifiable. In the latter, blank nodes are tightly scoped to the result set, a blank node existing in a result set just means something exists that matches the graph patter, but it cannot be kept and poked around in future queries like the above. Add tests to ensure that both behaviors are gotten right.
* tests: Assert that cursors have the right connection assignedCarlos Garnacho2022-05-012-9/+15
| | | | | Test for tracker_sparql_cursor_get_connection() returning the right thing on cursor and statement tests.
* tests: Test both JSON and XML cursorsCarlos Garnacho2022-05-013-7/+28
| | | | | | | | | | | | | There is no exposed mechanism to decide what cursor format do an endpoint/cursor negotiate between themselves, as a result we are currently only testing the JSON cursor format. Add a test-only environment variable so that TrackerEndpointHttp prefers a given TrackerSerializerFormat, and run cursor tests twice to ensure we test all cursor paths on HTTP connections. This additionally also exercises the XML serializer on the HTTP endpoint side.
* tests: Rename testCarlos Garnacho2022-05-011-3/+3
| | | | | | The original bug was a sigpipe in the dbus connection, but this now simply tests that cursors can be closed before all results are read.
* tests: Compare cursors more exhaustively in cursor testsCarlos Garnacho2022-05-011-3/+25
| | | | | | In some cursor tests we compare the output of specific connections with the output of a direct connection. Poke harder around both cursors looking exactly the same.
* tests: Run cursor tests on all connection typesCarlos Garnacho2022-05-011-85/+89
| | | | | Run the cursor tests on all of direct/bus/http connections, in order to ensure consistent behavior across all connection types.
* tests: Refactor static variable usageCarlos Garnacho2022-05-011-15/+15
| | | | | We do not want these variables static, as we want to spawn tests several times, and want to avoid each run to affect the next.
* tests: Do not use separate test to poke cursors after last next()Carlos Garnacho2022-05-011-28/+2
| | | | | | | | | | | | Currently, the behavior of tracker_sparql_cursor_get*() over an already finished cursor is inconsistent. All return NULL, but some trigger a warning and some don't. Since we want to run these tests on all connections, at the moment drop this test that asserted for failures/warnings. We might want to find a consistent behavior and test for it, and if it turns out to involve runtime warnings, it is best to use g_test_expect_message() than subprocesses.
* tests: Refactor cursors testCarlos Garnacho2022-05-011-51/+60
| | | | | Separate g_test_add() calls to a separate function, so that we can test different connections and cursors in future commits.
* tests: Merge cursor tests into their own executableCarlos Garnacho2022-05-014-541/+648
| | | | | | | At tests/libtracker-sparql there is a few scattered tests that check for high-level cursor behavior. We'll want to run those for all connection types, and cursor formats. So far separate them all to a distinct test executable so they can be refactored together.
* tests: Do not leak cursorsCarlos Garnacho2022-05-011-0/+1
| | | | These may lead to FD leaks and other misbehaviors.
* tests: Rename libtracker-data tests to 'core'Carlos Garnacho2022-04-03924-20/+20
| | | | Abandon the static library name for these tests.
* tests: Update libtracker-data tests to use high-level library APICarlos Garnacho2022-04-037-117/+113
| | | | | | | | | These tests poke at libtracker-data internals that have a 1:1 mapping on the high-level API, we can use that and avoid relying on internal API. This is accessory now, but libtracker-data will stop being a static library during build.
* tests: Rename libtracker-fts tests directory to ftsCarlos Garnacho2022-04-0361-8/+5
| | | | | | This does not refer to static libraries anymore, generalize the testsuite name. While at it, drop the unnecessary libtracker-data dependency.
* libtracker-data: Drop crc32 utility functionCarlos Garnacho2022-04-032-48/+0
| | | | This was only used by its own test.
* tests: Add tests for negated property pathsCarlos Garnacho2022-03-2723-0/+36
|
* tests: Add basic test around long string literalsCarlos Garnacho2022-03-273-0/+3
| | | | | Ensure these are parsed correctly, and are able to contain quotes of the same nature.
* tests: Fix libtracker-sparql/tracker-serialize-test on macOSDaniele Nicolodi2022-03-261-1/+1
| | | | | | echo -n is not portable and most notably it is not implemented by the bultin echo in the old version of bash used to implement /bin/sh on macOS. Use printf to supprtess the newline character.
* tests: Add more tests for TrackerSparqlCursor APICarlos Garnacho2022-03-131-0/+84
| | | | Add tests for column names, and value types.
* tests: Add more thorough portal testsCarlos Garnacho2022-03-131-6/+318
| | | | | Test all corners in graph lookups, and whether visibility changes accordingly with graph modifications.
* tests: Add 3-way alternative path testCarlos Garnacho2022-03-133-0/+22
|
* tests: Add more aggregate function testsCarlos Garnacho2022-03-1315-0/+61
|