Skip to content

Commit

Permalink
Fixed most tests for comunica V4
Browse files Browse the repository at this point in the history
  • Loading branch information
maartyman committed Nov 2, 2024
1 parent 6f3e298 commit 10932ab
Show file tree
Hide file tree
Showing 53 changed files with 3,624 additions and 1,677 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"@id": "urn:comunica:default:query-operation/actors#distinct",
"@type": "ActorQueryOperationIncrementalDistinctHash",
"mediatorQueryOperation": { "@id": "urn:comunica:default:query-operation/mediators#main" },
"mediatorHashBindings": { "@id": "urn:comunica:default:hash-bindings/mediators#main" }
"mediatorHashBindings": { "@id": "urn:comunica:default:hash-bindings/mediators#main" },
"mediatorHashQuads": { "@id": "urn:comunica:default:hash-quads/mediators#main" }
}
]
}
3 changes: 3 additions & 0 deletions engines/config-query-sparql-incremental/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,8 @@
"build": "npm run build:ts && npm run build:components",
"build:ts": "node \"../../node_modules/typescript/bin/tsc\"",
"build:components": "componentsjs-generator"
},
"dependencies": {
"@comunica/config-query-sparql": "^4.0.1"
}
}
33 changes: 1 addition & 32 deletions engines/query-sparql-incremental/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,10 @@
"@comunica/actor-optimize-query-operation-rewrite-add": "^4.0.2",
"@comunica/actor-optimize-query-operation-rewrite-copy": "^4.0.2",
"@comunica/actor-optimize-query-operation-rewrite-move": "^4.0.2",
"@comunica/actor-query-operation-ask": "^4.0.2",
"@comunica/actor-query-operation-bgp-join": "^4.0.2",
"@comunica/actor-query-operation-construct": "^4.0.2",
"@comunica/actor-query-operation-extend": "^4.0.2",
"@comunica/actor-query-operation-from-quad": "^4.0.2",
"@comunica/actor-query-operation-group": "^4.0.2",
"@comunica/actor-query-operation-join": "^4.0.2",
"@comunica/actor-query-operation-leftjoin": "^4.0.2",
"@comunica/actor-query-operation-minus": "^4.0.2",
"@comunica/actor-query-operation-nop": "^4.0.2",
"@comunica/actor-query-operation-path-alt": "^4.0.2",
"@comunica/actor-query-operation-path-inv": "^4.0.2",
"@comunica/actor-query-operation-path-link": "^4.0.2",
Expand All @@ -203,9 +197,6 @@
"@comunica/actor-query-operation-path-zero-or-more": "^4.0.2",
"@comunica/actor-query-operation-path-zero-or-one": "^4.0.2",
"@comunica/actor-query-operation-project": "^4.0.2",
"@comunica/actor-query-operation-reduced-hash": "^4.0.2",
"@comunica/actor-query-operation-service": "^4.0.2",
"@comunica/actor-query-operation-slice": "^4.0.2",
"@comunica/actor-query-operation-source": "^4.0.2",
"@comunica/actor-query-operation-union": "^4.0.2",
"@comunica/actor-query-operation-values": "^4.0.2",
Expand All @@ -226,12 +217,10 @@
"@comunica/actor-query-result-serialize-table": "^4.0.2",
"@comunica/actor-query-result-serialize-tree": "^4.0.2",
"@comunica/actor-query-source-identify-hypermedia": "^4.0.2",
"@comunica/actor-query-source-identify-rdfjs": "^4.0.2",
"@comunica/actor-query-source-identify-serialized": "^4.0.2",
"@comunica/actor-rdf-join-entries-sort-cardinality": "^4.0.2",
"@comunica/actor-rdf-join-inner-multi-empty": "^4.0.2",
"@comunica/actor-rdf-join-inner-multi-smallest": "^4.0.2",
"@comunica/actor-rdf-join-inner-multi-smallest-filter-bindings": "^4.0.2",
"@comunica/actor-rdf-join-inner-none": "^4.0.2",
"@comunica/actor-rdf-join-inner-single": "^4.0.2",
"@comunica/actor-rdf-join-selectivity-variable-counting": "^4.0.2",
Expand All @@ -246,7 +235,6 @@
"@comunica/actor-rdf-metadata-extract-patch-sparql-update": "^4.0.2",
"@comunica/actor-rdf-metadata-extract-put-accepted": "^4.0.2",
"@comunica/actor-rdf-metadata-extract-request-time": "^4.0.2",
"@comunica/actor-rdf-metadata-extract-sparql-service": "^4.0.2",
"@comunica/actor-rdf-metadata-primary-topic": "^4.0.2",
"@comunica/actor-rdf-parse-html": "^4.0.2",
"@comunica/actor-rdf-parse-html-microdata": "^4.0.2",
Expand All @@ -266,8 +254,6 @@
"@comunica/bus-function-factory": "^4.0.2",
"@comunica/bus-http-invalidate": "^4.0.2",
"@comunica/bus-query-operation": "^4.0.2",
"@comunica/bus-term-comparator-factory": "^4.0.2",
"@comunica/config-query-sparql": "^4.0.1",
"@comunica/core": "^4.0.2",
"@comunica/logger-void": "^4.0.1",
"@comunica/mediator-all": "^4.0.1",
Expand All @@ -291,24 +277,7 @@
"@incremunica/actor-rdf-metadata-extract-guard-data": "^1.3.0",
"@incremunica/actor-resource-watch-polling": "^1.3.0",
"@incremunica/actor-resource-watch-solid-notification-websockets": "^1.3.0",
"@incremunica/bus-guard": "^1.3.0",
"@incremunica/bus-resource-watch": "^1.3.0",
"@incremunica/config-query-sparql-incremental": "^1.3.0",
"@incremunica/context-entries": "^1.3.0",
"@incremunica/incremental-inner-join": "^1.3.0",
"@incremunica/incremental-rdf-streaming-store": "^1.3.0",
"@incremunica/incremental-types": "^1.3.0",

"process": "^0.11.10"
},
"devDependencies": {
"@incremunica/dev-tools": "^1.3.0",
"@incremunica/incremental-jest": "^1.3.0",
"@playwright/test": "^1.47.2",
"arrayify-stream": "^2.0.1",
"jest-rdf": "^1.7.1",
"rdf-data-factory": "^1.1.2",
"rdf-quad": "^1.5.0"
"@incremunica/config-query-sparql-incremental": "^1.3.0"
},
"browser": {
"./lib/index.js": "./lib/index-browser.js"
Expand Down
37 changes: 18 additions & 19 deletions engines/query-sparql-incremental/test-browser/QuerySparql-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
// Needed to undo automock from actor-http-native, cleaner workarounds do not appear to be working.
import 'jest-rdf';
import '@incremunica/incremental-jest';
import type { EventEmitter } from 'node:events';
import type { EventEmitter } from 'events';
import type { BindingsStream, QueryStringContext } from '@comunica/types';
import type { BindingsFactory } from '@comunica/utils-bindings-factory';
import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-context-is-addition';
import { DevTools } from '@incremunica/dev-tools';
import { StreamingStore } from '@incremunica/incremental-rdf-streaming-store';
import type { Quad } from '@incremunica/incremental-types';
import { expect } from '@playwright/test';
import { DataFactory } from 'rdf-data-factory';
import { QueryEngine } from '../lib/QueryEngine';
import { usePolly } from '../test/util';
Expand Down Expand Up @@ -40,7 +39,7 @@ describe('System test: QuerySparql (without polly)', () => {

beforeEach(async() => {
engine = new QueryEngine();
BF = await DevTools.createBindingsFactory(DF);
BF = await DevTools.createTestBindingsFactory(DF);
});

describe('using Streaming Store', () => {
Expand Down Expand Up @@ -80,7 +79,7 @@ describe('System test: QuerySparql (without polly)', () => {
[ DF.variable('s'), DF.namedNode('s3') ],
[ DF.variable('p'), DF.namedNode('p3') ],
[ DF.variable('o'), DF.namedNode('o3') ],
]),
]).setContextEntry(new ActionContextKeyIsAddition(), true),
]);

streamingStore.removeQuad(quad('s3', 'p3', 'o3'));
Expand Down Expand Up @@ -126,7 +125,7 @@ describe('System test: QuerySparql (without polly)', () => {
[ DF.variable('o1'), DF.namedNode('o1') ],
[ DF.variable('p2'), DF.namedNode('p3') ],
[ DF.variable('o2'), DF.namedNode('o3') ],
]),
]).setContextEntry(new ActionContextKeyIsAddition(), true),
]);

streamingStore.removeQuad(quad('o1', 'p3', 'o3'));
Expand Down Expand Up @@ -166,7 +165,7 @@ describe('System test: QuerySparql (with polly)', () => {
?s ?p ?o.
}`, { sources: [ 'https://www.rubensworks.net/' ]});

expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);
});

it('repeated with the same engine', async() => {
Expand All @@ -176,22 +175,22 @@ describe('System test: QuerySparql (with polly)', () => {
const context: QueryStringContext = { sources: [ 'https://www.rubensworks.net/' ]};

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);
});

it('repeated with the same engine and wait a bit until the polling is removed', async() => {
Expand All @@ -201,12 +200,12 @@ describe('System test: QuerySparql (with polly)', () => {
const context: QueryStringContext = { sources: [ 'https://www.rubensworks.net/' ]};

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);

await new Promise<void>(resolve => setTimeout(() => resolve(), 10000));
await new Promise<void>(resolve => setTimeout(() => resolve(), 4000));

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
expect(await partialArrayifyStream(bindingStream, 100)).toHaveLength(100);
});

describe('simple SPS', () => {
Expand All @@ -215,7 +214,7 @@ describe('System test: QuerySparql (with polly)', () => {
?s ?p ?s.
}`, { sources: [ 'https://www.rubensworks.net/' ]});

expect((await partialArrayifyStream(bindingStream, 1)).length).toBeGreaterThan(0);
expect(await partialArrayifyStream(bindingStream, 1)).toHaveLength(1);
});
});

Expand All @@ -226,7 +225,7 @@ describe('System test: QuerySparql (with polly)', () => {
?v0 <http://xmlns.com/foaf/0.1/name> ?name.
}`, { sources: [ 'https://www.rubensworks.net/' ]});

expect((await partialArrayifyStream(bindingStream, 20)).length).toBeGreaterThan(20);
expect(await partialArrayifyStream(bindingStream, 20)).toHaveLength(20);
});

it('for the single source entry', async() => {
Expand All @@ -235,7 +234,7 @@ describe('System test: QuerySparql (with polly)', () => {
?v0 <http://xmlns.com/foaf/0.1/name> ?name.
}`, { sources: [ 'https://www.rubensworks.net/' ]});

expect((await partialArrayifyStream(bindingStream, 20)).length).toBeGreaterThan(20);
expect(await partialArrayifyStream(bindingStream, 20)).toHaveLength(20);
});

describe('SHACL Compact Syntax Serialisation', () => {
Expand All @@ -249,7 +248,7 @@ describe('System test: QuerySparql (with polly)', () => {
],
});

expect((await partialArrayifyStream(bindingStream, 1)).length).toBeGreaterThan(0);
expect(await partialArrayifyStream(bindingStream, 1)).toHaveLength(1);
});
});
});
Expand Down
42 changes: 16 additions & 26 deletions engines/query-sparql-incremental/test/QuerySparql-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { ActionContextKeyIsAddition } from '@incremunica/actor-merge-bindings-co
import { DevTools } from '@incremunica/dev-tools';
import { StreamingStore } from '@incremunica/incremental-rdf-streaming-store';
import type { Quad } from '@incremunica/incremental-types';
import { expect } from '@playwright/test';
import { DataFactory } from 'rdf-data-factory';
import { QueryEngine } from '../lib/QueryEngine';
import { usePolly } from './util';
Expand Down Expand Up @@ -41,7 +40,7 @@ describe('System test: QuerySparql (without polly)', () => {

beforeEach(async() => {
engine = new QueryEngine();
BF = await DevTools.createBindingsFactory(DF);
BF = await DevTools.createTestBindingsFactory(DF);
});

describe('using Streaming Store', () => {
Expand Down Expand Up @@ -318,7 +317,7 @@ describe('System test: QuerySparql (with polly)', () => {
?s ?p ?o.
}`, { sources: [ 'https://www.rubensworks.net/' ]});

expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
await expect((partialArrayifyStream(bindingStream, 100))).resolves.toHaveLength(100);
});

it('repeated with the same engine', async() => {
Expand All @@ -327,23 +326,11 @@ describe('System test: QuerySparql (with polly)', () => {
}`;
const context: QueryStringContext = { sources: [ 'https://www.rubensworks.net/' ]};

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
for (let i = 0; i < 5; i++) {
bindingStream = await engine.queryBindings(query, context);
await expect((partialArrayifyStream(bindingStream, 100))).resolves.toHaveLength(100);
bindingStream.destroy();
}
});

it('repeated with the same engine and wait a bit until the polling is removed', async() => {
Expand All @@ -353,12 +340,15 @@ describe('System test: QuerySparql (with polly)', () => {
const context: QueryStringContext = { sources: [ 'https://www.rubensworks.net/' ]};

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
await expect((partialArrayifyStream(bindingStream, 100))).resolves.toHaveLength(100);
bindingStream.destroy();

// TODO decrease this by adding polling time to context
await new Promise<void>(resolve => setTimeout(() => resolve(), 10000));

bindingStream = await engine.queryBindings(query, context);
expect((await partialArrayifyStream(bindingStream, 100)).length).toBeGreaterThan(100);
await expect((partialArrayifyStream(bindingStream, 100))).resolves.toHaveLength(100);
bindingStream.destroy();
});

describe('simple SPS', () => {
Expand All @@ -367,7 +357,7 @@ describe('System test: QuerySparql (with polly)', () => {
?s ?p ?s.
}`, { sources: [ 'https://www.rubensworks.net/' ]});

expect((await partialArrayifyStream(bindingStream, 1)).length).toBeGreaterThan(0);
await expect((partialArrayifyStream(bindingStream, 1))).resolves.toHaveLength(1);
});
});

Expand All @@ -378,7 +368,7 @@ describe('System test: QuerySparql (with polly)', () => {
?v0 <http://xmlns.com/foaf/0.1/name> ?name.
}`, { sources: [ 'https://www.rubensworks.net/' ]});

expect((await partialArrayifyStream(bindingStream, 20)).length).toBeGreaterThan(20);
await expect((partialArrayifyStream(bindingStream, 20))).resolves.toHaveLength(20);
});

it('for the single source entry', async() => {
Expand All @@ -387,7 +377,7 @@ describe('System test: QuerySparql (with polly)', () => {
?v0 <http://xmlns.com/foaf/0.1/name> ?name.
}`, { sources: [ 'https://www.rubensworks.net/' ]});

expect((await partialArrayifyStream(bindingStream, 20)).length).toBeGreaterThan(20);
await expect((partialArrayifyStream(bindingStream, 20))).resolves.toHaveLength(20);
});

describe('SHACL Compact Syntax Serialisation', () => {
Expand All @@ -401,7 +391,7 @@ describe('System test: QuerySparql (with polly)', () => {
],
});

expect((await partialArrayifyStream(bindingStream, 1)).length).toBeGreaterThan(0);
await expect((partialArrayifyStream(bindingStream, 1))).resolves.toHaveLength(1);
});
});
});
Expand Down
9 changes: 9 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = config([
// Default
'unicorn/consistent-destructuring': 'off',
'unicorn/no-array-callback-reference': 'off',
'unicorn/prefer-node-protocol': 'off',

// TODO: check if these can be enabled
'ts/naming-convention': 'off',
Expand Down Expand Up @@ -53,6 +54,14 @@ module.exports = config([
'unicorn/filename-case': 'off',
},
},
{
files: [
'**/test-browser/*-test.ts',
],
rules: {
'import/no-extraneous-dependencies': 'off',
},
},
{
// The config packages use an empty index.ts
files: [
Expand Down
4 changes: 3 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ module.exports = {
setupFilesAfterEnv: [ './setup-jest.js' ],
collectCoverage: true,
coveragePathIgnorePatterns: [
'/actor-query-operation-incremental-filter/',
'/node_modules/',
'/mocks/',
'/dev-tools/',
'engine-default.js',
'util.ts',
'index.js',
],
testEnvironment: 'node',
Expand Down
Loading

0 comments on commit 10932ab

Please sign in to comment.