From 4b4967ba0d654210fa683b20c303a21bc8a029de Mon Sep 17 00:00:00 2001 From: Kerkesni Date: Thu, 15 Dec 2022 11:33:01 +0100 Subject: [PATCH] BB-295 - fix functional tests --- .github/workflows/tests.yaml | 7 +++---- package.json | 1 + tests/functional/lib/BackbeatClient.spec.js | 12 ++++++------ tests/functional/lib/BackbeatConsumer.spec.js | 4 ++-- .../NotificationConfigManager.spec.js | 17 ++++++++++++++++- .../replication/queueProcessor.spec.js | 5 +++-- 6 files changed, 31 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index a3b2d9900..233d512d9 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -134,11 +134,10 @@ jobs: BACKBEAT_CONFIG_FILE: "tests/config.json" - name: run backbeat notification feature tests run: yarn run ft_test:notification - - name: run ballooning tests for lifecycle conductor - run: yarn jest tests/performance/lifecycle/conductor-check-memory-balloon.js + run: .github/scripts/run_ft_tests.bash perf_test:lifecycle env: - # Constrain heap long-lived heap size to 150MB, so that pushing 200K messages + # Constrain heap long-lived heap size to 200MB, so that pushing 200K messages # will crash if they end up in memory all at the same time (circuit breaking # ineffective) while waiting to be committed to the kafka topic. - NODE_OPTIONS: '--max-old-space-size=150' + NODE_OPTIONS: '--max-old-space-size=200' \ No newline at end of file diff --git a/package.json b/package.json index 24fbac902..a82d8586a 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "ft_test:ingestion": "jest /functional/ingestion --forceExit --testTimeout 30000", "ft_test:api:routes": "jest /functional/api/routes.spec.js --forceExit --testTimeout 30000", "ft_test:api:retry": "jest /functional/api/retry.spec.js --forceExit --testTimeout 30000", + "perf_test:lifecycle": "jest /performance/lifecycle/ --forceExit --testTimeout 30000", "bh_test": "jest /behavior", "lint": "eslint $(git ls-files '*.js')", "lint_md": "mdlint $(git ls-files '[^bucket-scanner/]*.md')", diff --git a/tests/functional/lib/BackbeatClient.spec.js b/tests/functional/lib/BackbeatClient.spec.js index 507921b16..69bb79f41 100644 --- a/tests/functional/lib/BackbeatClient.spec.js +++ b/tests/functional/lib/BackbeatClient.spec.js @@ -69,7 +69,7 @@ describe('BackbeatClient unit tests with mock server', () => { const destReq = backbeatClient.getRaftId({ Bucket: bucketName, }); - return destReq.send((err, data) => { + destReq.send((err, data) => { assert.ifError(err); assert.strictEqual(data[0], '1'); return done(); @@ -80,7 +80,7 @@ describe('BackbeatClient unit tests with mock server', () => { const destReq = backbeatClient.getRaftLog({ LogId: '1', }); - return destReq.send((err, data) => { + destReq.send((err, data) => { assert.ifError(err); assert.deepStrictEqual(data, expectedLogs); return done(); @@ -91,7 +91,7 @@ describe('BackbeatClient unit tests with mock server', () => { const destReq = backbeatClient.getBucketMetadata({ Bucket: bucketName, }); - return destReq.send((err, data) => { + destReq.send((err, data) => { assert.ifError(err); const bucketMd = dummyBucketMD[bucketName]; const expectedBucketMD = new BucketInfo(bucketMd.name, @@ -119,7 +119,7 @@ describe('BackbeatClient unit tests with mock server', () => { const destReq = backbeatClient.getObjectList({ Bucket: bucketName, }); - return destReq.send((err, data) => { + destReq.send((err, data) => { assert.ifError(err); assert.deepStrictEqual(data, expectedObjectList); return done(); @@ -131,7 +131,7 @@ describe('BackbeatClient unit tests with mock server', () => { Bucket: bucketName, Key: objectName, }); - return destReq.send((err, data) => { + destReq.send((err, data) => { assert.ifError(err); assert(data.Body); const dataValue = JSON.parse(data.Body); @@ -144,7 +144,7 @@ describe('BackbeatClient unit tests with mock server', () => { const destReq = backbeatClient.getBucketCseq({ Bucket: bucketName, }); - return destReq.send((err, data) => { + destReq.send((err, data) => { assert.ifError(err); assert(data[0] && data[0].cseq); assert.strictEqual(data[0].cseq, 7); diff --git a/tests/functional/lib/BackbeatConsumer.spec.js b/tests/functional/lib/BackbeatConsumer.spec.js index cecfee006..b4cf913a3 100644 --- a/tests/functional/lib/BackbeatConsumer.spec.js +++ b/tests/functional/lib/BackbeatConsumer.spec.js @@ -121,7 +121,7 @@ describe('BackbeatConsumer main tests', () => { setTimeout(() => { _checkZkMetrics(() => { consumeCb(); - consumer.unsubscribe(); + consumer.pause(); }); }, 5000); assert.deepStrictEqual( @@ -142,7 +142,7 @@ describe('BackbeatConsumer main tests', () => { 'messages from the previous offset', done => { let totalConsumed = 0; const kafkaConsumer = consumer._consumer; - consumer.subscribe(); + consumer.resume(); async.series([ next => { diff --git a/tests/functional/notification/NotificationConfigManager.spec.js b/tests/functional/notification/NotificationConfigManager.spec.js index 758b3e245..68689b7e8 100644 --- a/tests/functional/notification/NotificationConfigManager.spec.js +++ b/tests/functional/notification/NotificationConfigManager.spec.js @@ -31,6 +31,21 @@ const notificationConfigurationVariant = { ], }; +class MockChangeStream extends events.EventEmitter { + constructor() { + super(); + this.closed = false; + } + + isClosed() { + return this.closed; + } + + close() { + this.closed = true; + } +} + describe('NotificationConfigManager ::', () => { const params = { mongoConfig, @@ -42,7 +57,7 @@ describe('NotificationConfigManager ::', () => { manager = new NotificationConfigManager(params); const getCollectionStub = sinon.stub().returns({ // mock change stream - watch: () => new events.EventEmitter(), + watch: () => new MockChangeStream(), // mock bucket notification configuration findOne: () => ( { diff --git a/tests/functional/replication/queueProcessor.spec.js b/tests/functional/replication/queueProcessor.spec.js index 2959da139..096e23ca4 100644 --- a/tests/functional/replication/queueProcessor.spec.js +++ b/tests/functional/replication/queueProcessor.spec.js @@ -879,7 +879,7 @@ describe('queue processor functional tests with mocking', () => { afterAll(done => { httpServer.close(); - async.parallel([ + async.series([ done => queueProcessorSF.stop(done), done => queueProcessorAzure.stop(done), done => replicationStatusProcessor.stop(done), @@ -905,7 +905,8 @@ describe('queue processor functional tests with mocking', () => { nbParts: 2, encrypted: true }, { caption: 'empty object', - nbParts: 0 }].forEach(testCase => describe(testCase.caption, () => { + nbParts: 0 }, + ].forEach(testCase => describe(testCase.caption, () => { beforeAll(() => { s3mock.setParam('nbParts', testCase.nbParts); if (testCase.encrypted) {