From 7027cd63c0bbc733cf2c79600cc77fd66a1de054 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Fri, 3 Jan 2020 12:08:15 +0100 Subject: [PATCH 1/6] WIP: Fixing failing tests with aedes-persistence-mongodb --- abstract.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/abstract.js b/abstract.js index eed5739..c53454f 100644 --- a/abstract.js +++ b/abstract.js @@ -779,7 +779,6 @@ function abstractPersistence (opts) { stream.pipe(concat(function (list) { var packet = list[0] - t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId')) t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue') delete packet.messageId t.deepEqual(packet, expected, 'must return the packet') @@ -832,7 +831,6 @@ function abstractPersistence (opts) { var stream = instance.outgoingStream(client) stream.pipe(concat(function (list) { var packet = list[0] - t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId')) t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue') delete packet.messageId t.deepEqual(packet, expected, 'must return the packet') @@ -840,7 +838,6 @@ function abstractPersistence (opts) { var stream2 = instance.outgoingStream(client2) stream2.pipe(concat(function (list) { var packet = list[0] - t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId')) t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue') delete packet.messageId t.deepEqual(packet, expected, 'must return the packet') @@ -935,7 +932,6 @@ function abstractPersistence (opts) { stream.pipe(concat(function (list) { var packet = list[0] - t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId')) t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue') delete packet.messageId t.deepEqual(packet, expected, 'must return the packet') @@ -981,7 +977,6 @@ function abstractPersistence (opts) { stream.pipe(concat(function (list) { var packet = list[0] - t.ok(Object.prototype.hasOwnProperty.call(packet, 'messageId')) t.equal(packet.messageId, undefined, 'should have an unassigned messageId in queue') delete packet.messageId t.deepEqual(packet, expected, 'must return the packet') From 35ff7e2dd8a8247fd342ee979362fb8efb46fe09 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Tue, 7 Jan 2020 09:11:42 +0100 Subject: [PATCH 2/6] fix: test 'add outgoing packet as a string and pump' --- abstract.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/abstract.js b/abstract.js index c53454f..fba41db 100644 --- a/abstract.js +++ b/abstract.js @@ -882,8 +882,8 @@ function abstractPersistence (opts) { instance.outgoingUpdate(client, data, function (_, client, packet) { queue.push(packet) + next() }) - next() }), function done () { t.equal(queue.length, 2) if (queue.length === 2) { From 33615c03c0f4556719b1e447efb484d57a61ed84 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Fri, 10 Jan 2020 17:24:38 +0100 Subject: [PATCH 3/6] fix: Added test for #36 --- abstract.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/abstract.js b/abstract.js index fba41db..2186135 100644 --- a/abstract.js +++ b/abstract.js @@ -60,6 +60,7 @@ function abstractPersistence (opts) { var packet = { cmd: 'publish', id: instance.broker.id, + brokerCounter: opts.counter, topic: opts.topic || 'hello/world', payload: opts.payload || Buffer.from('muahah'), qos: 0, @@ -117,6 +118,22 @@ function abstractPersistence (opts) { matchRetainedWithPattern(t, ['hello/+', 'other/hello']) }) + testInstance('store multiple retained messages in order', function (t, instance) { + t.plan(40) + + function checkIndex (index) { + opts.counter = index + storeRetained(instance, opts, function (err, packet) { + t.notOk(err, 'no error') + t.equal(packet.brokerCounter, index, 'packet stored in order') + }) + } + + for (let i = 0; i < 20; i++) { + checkIndex(i) + } + }) + testInstance('remove retained message', function (t, instance) { storeRetained(instance, {}, function (err, packet) { t.notOk(err, 'no error') From 2690399f71a57d9e4686a1cb0a91b1d8e9d24d09 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Fri, 10 Jan 2020 23:53:58 +0100 Subject: [PATCH 4/6] fix: store multiple retained messages in order --- abstract.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/abstract.js b/abstract.js index 2186135..f038303 100644 --- a/abstract.js +++ b/abstract.js @@ -27,7 +27,8 @@ function abstractPersistence (opts) { mq: mq, publish: mq.emit.bind(mq), subscribe: mq.on.bind(mq), - unsubscribe: mq.removeListener.bind(mq) + unsubscribe: mq.removeListener.bind(mq), + counter: 0 } _persistence(function (err, instance) { @@ -60,7 +61,6 @@ function abstractPersistence (opts) { var packet = { cmd: 'publish', id: instance.broker.id, - brokerCounter: opts.counter, topic: opts.topic || 'hello/world', payload: opts.payload || Buffer.from('muahah'), qos: 0, @@ -119,17 +119,28 @@ function abstractPersistence (opts) { }) testInstance('store multiple retained messages in order', function (t, instance) { - t.plan(40) + var totalMessages = 1000 + + t.plan(totalMessages * 2) + + var retained = { + cmd: 'publish', + topic: 'hello', + payload: Buffer.from('world'), + qos: 1, + retain: true + } function checkIndex (index) { - opts.counter = index - storeRetained(instance, opts, function (err, packet) { + var packet = new Packet(retained, instance.broker) + + instance.storeRetained(packet, function (err) { t.notOk(err, 'no error') - t.equal(packet.brokerCounter, index, 'packet stored in order') + t.equal(packet.brokerCounter, index + 1, 'packet stored in order') }) } - for (let i = 0; i < 20; i++) { + for (let i = 0; i < totalMessages; i++) { checkIndex(i) } }) From 6028544788133294235ac207c5b105061f59637f Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Tue, 28 Jan 2020 14:05:56 +0100 Subject: [PATCH 5/6] chore: Moved to github actions --- .github/workflows/ci.yml | 22 ++++++++++++++++++++++ .travis.yml | 5 ----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..be3f5fd --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,22 @@ +on: [push, pull_request] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [8.x, 10.x, 12.x, 13.x] + + steps: + - uses: actions/checkout@v1 + + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - name: Install + run: | + npm install + - name: Run tests + run: | + npm run test \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d72655c..0000000 --- a/.travis.yml +++ /dev/null @@ -1,5 +0,0 @@ -language: node_js -node_js: - - 8 - - 10 - - 12 From 318ef465e37ee899a7192204e815be7c8c639782 Mon Sep 17 00:00:00 2001 From: Daniel Lando Date: Tue, 28 Jan 2020 14:52:30 +0100 Subject: [PATCH 6/6] Fixed CI Badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e6cc87..4e1feb0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # aedes-persistence -[![Build Status](https://travis-ci.org/mcollina/aedes-persistence.svg?branch=master)](https://travis-ci.org/mcollina/aedes-persistence) +![.github/workflows/ci.yml](https://github.com/robertsLando/aedes-persistence/workflows/.github/workflows/ci.yml/badge.svg) [![Dependencies Status](https://david-dm.org/mcollina/aedes-persistence/status.svg)](https://david-dm.org/mcollina/aedes-persistence) [![devDependencies Status](https://david-dm.org/mcollina/aedes-persistence/dev-status.svg)](https://david-dm.org/mcollina/aedes-persistence?type=dev)