From ce5a98b16fb6dfa54a0f69aca1c43433de8aadd3 Mon Sep 17 00:00:00 2001 From: Joachim Van Herwegen Date: Thu, 31 Mar 2022 14:55:49 +0200 Subject: [PATCH] test: Add integration test that simulates running 2 hours --- test/integration/ExpiringDataCleanup.test.ts | 39 ++++++++++++++++++++ test/util/Util.ts | 1 + 2 files changed, 40 insertions(+) create mode 100644 test/integration/ExpiringDataCleanup.test.ts diff --git a/test/integration/ExpiringDataCleanup.test.ts b/test/integration/ExpiringDataCleanup.test.ts new file mode 100644 index 000000000..921019422 --- /dev/null +++ b/test/integration/ExpiringDataCleanup.test.ts @@ -0,0 +1,39 @@ +import fetch from 'cross-fetch'; +import type { App } from '../../src/init/App'; +import { getPort } from '../util/Util'; +import { + getDefaultVariables, + getTestConfigPath, + instantiateFromConfig, +} from './Config'; + +jest.useFakeTimers('legacy'); + +const port = getPort('ExpiringDataCleanup'); +const baseUrl = `http://localhost:${port}/`; + +describe('A server with expiring storage', (): void => { + let app: App; + + beforeAll(async(): Promise => { + const instances = await instantiateFromConfig( + 'urn:solid-server:test:Instances', + getTestConfigPath('server-memory.json'), + getDefaultVariables(port, baseUrl), + ) as Record; + ({ app } = instances); + await app.start(); + }); + + afterAll(async(): Promise => { + await app.stop(); + }); + + it('does not crash after the interval timeout.', async(): Promise => { + // Default timeout is 1 hour + // This test would fail if something goes wrong in an interval timer + jest.advanceTimersByTime(2 * 60 * 60 * 1000); + const res = await fetch(baseUrl, { method: 'HEAD' }); + expect(res.status).toBe(200); + }); +}); diff --git a/test/util/Util.ts b/test/util/Util.ts index dc2a3590d..9e89229fd 100644 --- a/test/util/Util.ts +++ b/test/util/Util.ts @@ -7,6 +7,7 @@ const portNames = [ 'Conditions', 'ContentNegotiation', 'DynamicPods', + 'ExpiringDataCleanup', 'GlobalQuota', 'Identity', 'LpdHandlerWithAuth',