Skip to content

Commit 378894d

Browse files
committed
fix: remove polly in integration tests + cleanup tests
1 parent e1d7754 commit 378894d

19 files changed

Lines changed: 127 additions & 3886 deletions

File tree

engines/query-sparql-incremental/test-browser/QuerySparql-test.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @jest-environment setup-polly-jest/jest-environment-node */
2-
31
// Needed to undo automock from actor-http-native, cleaner workarounds do not appear to be working.
42
import 'jest-rdf';
53
import '@incremunica/jest';
@@ -12,7 +10,6 @@ import type { Quad } from '@incremunica/types';
1210
import { DeferredEvaluation } from '@incremunica/user-tools';
1311
import { DataFactory } from 'rdf-data-factory';
1412
import { QueryEngine } from '../lib';
15-
import { usePolly } from '../test/util';
1613

1714
if (!globalThis.window) {
1815
jest.unmock('follow-redirects');
@@ -26,7 +23,7 @@ async function setServerData(testUuid: string, data: string): Promise<void> {
2623
await fetch(`http://localhost:3000/reset/${testUuid}`, { method: 'POST', body: data });
2724
}
2825

29-
describe('System test: QuerySparql (without polly)', () => {
26+
describe('System test: QuerySparql (without external network)', () => {
3027
let BF: BindingsFactory;
3128
let engine: QueryEngine;
3229

@@ -50,7 +47,6 @@ describe('System test: QuerySparql (without polly)', () => {
5047
?s ?p ?o.
5148
}`, {
5249
sources: [ streamingStore ],
53-
pollingPeriod: 500,
5450
});
5551

5652
expect(await partialArrayifyAsyncIterator(bindingStream, 2)).toBeIsomorphicBindingsArray([
@@ -98,7 +94,6 @@ describe('System test: QuerySparql (without polly)', () => {
9894
?o1 ?p2 ?o2.
9995
}`, {
10096
sources: [ streamingStore ],
101-
pollingPeriod: 500,
10297
});
10398

10499
expect(await partialArrayifyAsyncIterator(bindingStream, 1)).toBeIsomorphicBindingsArray([
@@ -233,9 +228,7 @@ describe('System test: QuerySparql (without polly)', () => {
233228
});
234229
});
235230

236-
describe('System test: QuerySparql (with polly)', () => {
237-
usePolly();
238-
231+
describe('System test: QuerySparql (with external network)', () => {
239232
let bindingStream: BindingsStream;
240233
let engine: QueryEngine;
241234
beforeEach(async() => {
@@ -253,7 +246,6 @@ describe('System test: QuerySparql (with polly)', () => {
253246
?s ?p ?o.
254247
}`, {
255248
sources: [ 'https://www.rubensworks.net/' ],
256-
pollingPeriod: 500,
257249
});
258250

259251
expect(await partialArrayifyAsyncIterator(bindingStream, 100)).toHaveLength(100);
@@ -265,7 +257,6 @@ describe('System test: QuerySparql (with polly)', () => {
265257
}`;
266258
const context: QueryStringContext = {
267259
sources: [ 'https://www.rubensworks.net/' ],
268-
pollingPeriod: 500,
269260
};
270261

271262
bindingStream = await engine.queryBindings(query, context);
@@ -293,7 +284,7 @@ describe('System test: QuerySparql (with polly)', () => {
293284
}`;
294285
const context: QueryStringContext = {
295286
sources: [ 'https://www.rubensworks.net/' ],
296-
pollingPeriod: 500,
287+
pollingPeriod: 1,
297288
};
298289

299290
bindingStream = await engine.queryBindings(query, context);
@@ -311,7 +302,6 @@ describe('System test: QuerySparql (with polly)', () => {
311302
?s ?p ?s.
312303
}`, {
313304
sources: [ 'https://www.rubensworks.net/' ],
314-
pollingPeriod: 500,
315305
});
316306

317307
expect(await partialArrayifyAsyncIterator(bindingStream, 1)).toHaveLength(1);
@@ -325,7 +315,6 @@ describe('System test: QuerySparql (with polly)', () => {
325315
?v0 <http://xmlns.com/foaf/0.1/name> ?name.
326316
}`, {
327317
sources: [ 'https://www.rubensworks.net/' ],
328-
pollingPeriod: 500,
329318
});
330319

331320
expect(await partialArrayifyAsyncIterator(bindingStream, 20)).toHaveLength(20);
@@ -337,7 +326,6 @@ describe('System test: QuerySparql (with polly)', () => {
337326
?v0 <http://xmlns.com/foaf/0.1/name> ?name.
338327
}`, {
339328
sources: [ 'https://www.rubensworks.net/' ],
340-
pollingPeriod: 1000,
341329
});
342330

343331
expect(await partialArrayifyAsyncIterator(bindingStream, 20)).toHaveLength(20);
@@ -352,7 +340,6 @@ describe('System test: QuerySparql (with polly)', () => {
352340
'https://raw.githubusercontent.com/w3c/data-shapes/gh-pages/shacl-compact-syntax/' +
353341
'tests/valid/basic-shape-iri.shaclc',
354342
],
355-
pollingPeriod: 1000,
356343
});
357344

358345
expect(await partialArrayifyAsyncIterator(bindingStream, 1)).toHaveLength(1);

engines/query-sparql-incremental/test-browser/util-browser.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

engines/query-sparql-incremental/test/QuerySparql-test.ts

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @jest-environment setup-polly-jest/jest-environment-node */
2-
31
// Needed to undo automock from actor-http-native, cleaner workarounds do not appear to be working.
42
import 'jest-rdf';
53
import '@incremunica/jest';
@@ -10,12 +8,12 @@ import type { BindingsFactory } from '@comunica/utils-bindings-factory';
108
import { KeysBindings } from '@incremunica/context-entries';
119
import { createTestBindingsFactory, partialArrayifyAsyncIterator } from '@incremunica/dev-tools';
1210
import { StreamingStore } from '@incremunica/streaming-store';
13-
import type { Quad } from '@incremunica/types';
11+
import type { ContextQuerySourceStream, Quad } from '@incremunica/types';
1412
import { ArrayIterator } from 'asynciterator';
1513
import { DataFactory } from 'rdf-data-factory';
1614
import { PassThrough } from 'readable-stream';
1715
import { QueryEngine, QueryEngineFactory } from '../lib';
18-
import { usePolly } from './util';
16+
import { fetch as cachedFetch } from './util';
1917

2018
if (!globalThis.window) {
2119
jest.unmock('follow-redirects');
@@ -25,7 +23,7 @@ const quad = require('rdf-quad');
2523

2624
const DF = new DataFactory();
2725

28-
describe('System test: QuerySparql (without polly)', () => {
26+
describe('System test: QuerySparql (without external network)', () => {
2927
let BF: BindingsFactory;
3028
let engine: QueryEngine;
3129

@@ -310,7 +308,6 @@ describe('System test: QuerySparql (without polly)', () => {
310308
?s ?p ?o.
311309
}`, {
312310
sources: [ 'http://localhost:8787' ],
313-
pollingPeriod: 1000,
314311
});
315312

316313
await expect(new Promise<Bindings>(resolve => bindingStream.once('data', (bindings) => {
@@ -333,17 +330,16 @@ describe('System test: QuerySparql (without polly)', () => {
333330
sources: [
334331
'http://localhost:8787',
335332
],
336-
pollingPeriod: 100,
337333
deferredEvaluationTrigger,
338334
});
339335

340-
await expect(new Promise<Bindings>(resolve => bindingStream.once('data', (bindings) => {
341-
resolve(bindings);
342-
}))).resolves.toEqualBindings(BF.bindings([
343-
[ DF.variable('s'), DF.namedNode('http://localhost:8787/s1') ],
344-
[ DF.variable('p'), DF.namedNode('http://localhost:8787/p1') ],
345-
[ DF.variable('o'), DF.namedNode('http://localhost:8787/o1') ],
346-
]).setContextEntry(KeysBindings.isAddition, true));
336+
await expect(partialArrayifyAsyncIterator(bindingStream, 1)).resolves.toEqualBindingsArray([
337+
BF.bindings([
338+
[ DF.variable('s'), DF.namedNode('http://localhost:8787/s1') ],
339+
[ DF.variable('p'), DF.namedNode('http://localhost:8787/p1') ],
340+
[ DF.variable('o'), DF.namedNode('http://localhost:8787/o1') ],
341+
]).setContextEntry(KeysBindings.isAddition, true),
342+
]);
347343

348344
fetchData.dataString = '<http://localhost:8787/s3> <http://localhost:8787/p3> <http://localhost:8787/o3> .';
349345
fetchData.etag = '1';
@@ -355,13 +351,13 @@ describe('System test: QuerySparql (without polly)', () => {
355351
}, 500);
356352
setTimeout(() => deferredEvaluationTrigger.emit('update'), 1000);
357353

358-
await expect(new Promise<Bindings>(resolve => bindingStream.once('data', (bindings) => {
359-
resolve(bindings);
360-
}))).resolves.toEqualBindings(BF.bindings([
361-
[ DF.variable('s'), DF.namedNode('http://localhost:8787/s2') ],
362-
[ DF.variable('p'), DF.namedNode('http://localhost:8787/p2') ],
363-
[ DF.variable('o'), DF.namedNode('http://localhost:8787/o2') ],
364-
]).setContextEntry(KeysBindings.isAddition, true));
354+
await expect(partialArrayifyAsyncIterator(bindingStream, 1)).resolves.toEqualBindingsArray([
355+
BF.bindings([
356+
[ DF.variable('s'), DF.namedNode('http://localhost:8787/s2') ],
357+
[ DF.variable('p'), DF.namedNode('http://localhost:8787/p2') ],
358+
[ DF.variable('o'), DF.namedNode('http://localhost:8787/o2') ],
359+
]).setContextEntry(KeysBindings.isAddition, true),
360+
]);
365361
});
366362

367363
it('simple query with a streaming source, addition and deletion', async() => {
@@ -380,7 +376,7 @@ describe('System test: QuerySparql (without polly)', () => {
380376
?s ?p ?o.
381377
}`, {
382378
sources: [ streamingStore, sourcesStream ],
383-
pollingPeriod: 1000,
379+
pollingPeriod: 1,
384380
});
385381

386382
await expect(partialArrayifyAsyncIterator(bindingStream, 1)).resolves.toEqualBindingsArray([
@@ -451,7 +447,7 @@ describe('System test: QuerySparql (without polly)', () => {
451447
?s ?p ?o.
452448
}`, {
453449
sources: [ 'http://localhost:8787' ],
454-
pollingPeriod: 1000,
450+
pollingPeriod: 1,
455451
});
456452

457453
await expect(new Promise<Bindings>(resolve => bindingStream.once('data', (bindings) => {
@@ -482,7 +478,7 @@ describe('System test: QuerySparql (without polly)', () => {
482478
OPTIONAL { ?s2 <http://localhost:8787/p2> ?o2 . }
483479
}`, {
484480
sources: [ 'http://localhost:8787' ],
485-
pollingPeriod: 1000,
481+
pollingPeriod: 1,
486482
});
487483

488484
await expect(new Promise<Bindings>(resolve => bindingStream.once('data', (bindings) => {
@@ -514,12 +510,11 @@ describe('System test: QuerySparql (without polly)', () => {
514510
});
515511
});
516512

517-
describe('System test: QuerySparql (with polly)', () => {
518-
usePolly();
519-
513+
describe('System test: QuerySparql (with external network)', () => {
520514
let bindingStream: BindingsStream;
521515
let engine: QueryEngine;
522516
beforeEach(async() => {
517+
globalThis.fetch = cachedFetch;
523518
engine = new QueryEngine();
524519
await engine.invalidateHttpCache();
525520
});
@@ -534,7 +529,6 @@ describe('System test: QuerySparql (with polly)', () => {
534529
?s ?p ?o.
535530
}`, {
536531
sources: [ 'https://www.rubensworks.net/' ],
537-
pollingPeriod: 1000,
538532
});
539533

540534
await expect((partialArrayifyAsyncIterator(bindingStream, 100))).resolves.toHaveLength(100);
@@ -544,14 +538,13 @@ describe('System test: QuerySparql (with polly)', () => {
544538
bindingStream = await engine.queryBindings(`SELECT * WHERE {
545539
?s ?p ?o.
546540
}`, {
547-
sources: [ new ArrayIterator([
541+
sources: [ <ContextQuerySourceStream> new ArrayIterator([
548542
'https://www.rubensworks.net/',
549543
{
550544
querySource: 'https://www.rubensworks.net/',
551545
isAddition: true,
552546
},
553547
]) ],
554-
pollingPeriod: 1000,
555548
});
556549

557550
await expect((partialArrayifyAsyncIterator(bindingStream, 100))).resolves.toHaveLength(100);
@@ -562,7 +555,6 @@ describe('System test: QuerySparql (with polly)', () => {
562555
?s ?p ?o.
563556
}`;
564557
const context: QueryStringContext = {
565-
pollingPeriod: 1000,
566558
sources: [ 'https://www.rubensworks.net/' ],
567559
};
568560

@@ -579,14 +571,14 @@ describe('System test: QuerySparql (with polly)', () => {
579571
}`;
580572
const context: QueryStringContext = {
581573
sources: [ 'https://www.rubensworks.net/' ],
582-
pollingPeriod: 1000,
574+
pollingPeriod: 1,
583575
};
584576

585577
bindingStream = await engine.queryBindings(query, context);
586578
await expect((partialArrayifyAsyncIterator(bindingStream, 100))).resolves.toHaveLength(100);
587579
bindingStream.destroy();
588580

589-
await new Promise<void>(resolve => setTimeout(() => resolve(), 1000));
581+
await new Promise<void>(resolve => setTimeout(() => resolve(), 2000));
590582

591583
bindingStream = await engine.queryBindings(query, context);
592584
await expect((partialArrayifyAsyncIterator(bindingStream, 100))).resolves.toHaveLength(100);
@@ -599,7 +591,6 @@ describe('System test: QuerySparql (with polly)', () => {
599591
?s ?p ?s.
600592
}`, {
601593
sources: [ 'https://www.rubensworks.net/' ],
602-
pollingPeriod: 1000,
603594
});
604595

605596
await expect((partialArrayifyAsyncIterator(bindingStream, 1))).resolves.toHaveLength(1);
@@ -613,7 +604,6 @@ describe('System test: QuerySparql (with polly)', () => {
613604
?v0 <http://xmlns.com/foaf/0.1/name> ?name.
614605
}`, {
615606
sources: [ 'https://www.rubensworks.net/' ],
616-
pollingPeriod: 1000,
617607
});
618608

619609
await expect((partialArrayifyAsyncIterator(bindingStream, 20))).resolves.toHaveLength(20);
@@ -625,7 +615,6 @@ describe('System test: QuerySparql (with polly)', () => {
625615
?v0 <http://xmlns.com/foaf/0.1/name> ?name.
626616
}`, {
627617
sources: [ 'https://www.rubensworks.net/' ],
628-
pollingPeriod: 1000,
629618
});
630619

631620
await expect((partialArrayifyAsyncIterator(bindingStream, 20))).resolves.toHaveLength(20);
@@ -640,7 +629,6 @@ describe('System test: QuerySparql (with polly)', () => {
640629
'https://raw.githubusercontent.com/w3c/data-shapes/gh-pages/shacl-compact-syntax/' +
641630
'tests/valid/basic-shape-iri.shaclc',
642631
],
643-
pollingPeriod: 1000,
644632
});
645633

646634
await expect((partialArrayifyAsyncIterator(bindingStream, 1))).resolves.toHaveLength(1);

engines/query-sparql-incremental/test/assets/http/System-test-QuerySparql-with-polly_3949941934/simple-SPO-on-a-raw-RDF-document_1555362862/repeated-with-the-same-engine-and-wait-a-bit-until-the-polling-is-removed_2084357116/recording.har

Lines changed: 0 additions & 1022 deletions
This file was deleted.

engines/query-sparql-incremental/test/assets/http/System-test-QuerySparql-with-polly_3949941934/simple-SPO-on-a-raw-RDF-document_1555362862/repeated-with-the-same-engine_3520447098/recording.har

Lines changed: 0 additions & 546 deletions
This file was deleted.

engines/query-sparql-incremental/test/assets/http/System-test-QuerySparql-with-polly_3949941934/simple-SPO-on-a-raw-RDF-document_1555362862/simple-SPS_2884807479/Raw-Source_2280469750/recording.har

Lines changed: 0 additions & 226 deletions
This file was deleted.

0 commit comments

Comments
 (0)