ddq-backend-tests

2.0.0 • Public • Published

DDQ Backend Functional Tests

npm version Build Status Dependencies Dev Dependencies

Contains functional tests meant to be used by DDQ backend plugins. One example is DDQ MySQL Plugin.

Tests

  • ddqBackendTests.tests.deduplicationTest ensures when a duplicate message is sent, it is not inserted and the original message is "requeued" and processed again.

  • ddqBackendTests.tests.mutlipleListenerTest sets up multiple listeners and makes certain messages are not emitted to both listeners. It then requeues the message from the listener to first process the message, the second processor of the message then removes it.

  • ddqBackendTests.tests.wrappedMessageTest is the more basic of these tests. It tests requeue, heartbeat, and remove. After heartbeat it ensures the heartbeat lifetime elapsed before the message is removed.

Usage

Add this package under devDependencies and use the module to run solitary tests or all at once.

var BackendTester, exit, tester;

exit = process.exit;
BackendTester = require("ddq-backend-tests")();
tester = new BackendTester();
tester.runAllTests((testErr) => {
    if (testErr) {
        console.error("Error occurred running DDQ backend functional tests.");

        throw testErr;
    }

    console.log("Successfully ran backend plugin functional tests");
    exit(0);
});

// For a single test.
tester.tests.wrappedMessageTest(() => {});

The test queue must be setup prior to running these tests. We wrote one plugin in MySQL and here is how we setup our test queue.

DROP DATABASE IF EXISTS testQueue;
CREATE DATABASE testQueue;
USE testQueue;
CREATE TABLE queue (
    hash CHAR(64),
    PRIMARY KEY(hash),
    message VARCHAR(120) NOT NULL,
    requeued BOOLEAN DEFAULT FALSE,
    heartbeatDate DATETIME,
    owner VARCHAR(256),
    isProcessing BOOLEAN DEFAULT FALSE,
    INDEX isProcessing(isProcessing),
    topic VARCHAR(256),
    messageBase64 VARCHAR(256)
);

The configuration that is used for functional tests can be found here.

Package Sidebar

Install

npm i ddq-backend-tests

Weekly Downloads

2

Version

2.0.0

License

MIT

Last publish

Collaborators

  • andy.gertjejansen