From 05c4ce9a8e42b4ea557ed7242b33073176684cab Mon Sep 17 00:00:00 2001 From: Eugen Klymniuk Date: Sat, 27 Apr 2024 14:29:02 +0100 Subject: [PATCH] chore: removed unneeded kafkaHelper; excluded some files from test-coverage check (#1015) --- .nycrc.yml | 9 ++ .../handlers/transfers/handlers.test.js | 2 - test/integration/helpers/kafkaHelper.js | 127 ------------------ test/scripts/test-integration.sh | 10 +- 4 files changed, 14 insertions(+), 134 deletions(-) delete mode 100644 test/integration/helpers/kafkaHelper.js diff --git a/.nycrc.yml b/.nycrc.yml index cad931d8e..fa84bd3ac 100644 --- a/.nycrc.yml +++ b/.nycrc.yml @@ -20,4 +20,13 @@ exclude: [ '**/bulk*/**', 'src/shared/logger/**', 'src/shared/constants.js', + 'src/domain/position/index.js', + 'src/domain/position/binProcessor.js', + 'src/handlers/positions/handler.js', + 'src/handlers/transfers/createRemittanceEntity.js', + 'src/handlers/transfers/FxFulfilService.js', + 'src/models/position/batch.js', + 'src/models/fxTransfer/**', + 'src/shared/fspiopErrorFactory.js' ] +## todo: increase test coverage before merging feat/fx-impl to main branch diff --git a/test/integration-override/handlers/transfers/handlers.test.js b/test/integration-override/handlers/transfers/handlers.test.js index 13a37dc2b..fd178227d 100644 --- a/test/integration-override/handlers/transfers/handlers.test.js +++ b/test/integration-override/handlers/transfers/handlers.test.js @@ -45,7 +45,6 @@ const { wrapWithRetries } = require('#test/util/helpers') const TestConsumer = require('#test/integration/helpers/testConsumer') -const KafkaHelper = require('#test/integration/helpers/kafkaHelper') const ParticipantCached = require('#src/models/participant/participantCached') const ParticipantCurrencyCached = require('#src/models/participant/participantCurrencyCached') @@ -328,7 +327,6 @@ Test('Handlers test', async handlersTest => { // Set up the testConsumer here await testConsumer.startListening() - await KafkaHelper.producers.connect() // TODO: MIG - Disabling these handlers to test running the CL as a separate service independently. await new Promise(resolve => setTimeout(resolve, rebalanceDelay)) diff --git a/test/integration/helpers/kafkaHelper.js b/test/integration/helpers/kafkaHelper.js deleted file mode 100644 index efdc78d15..000000000 --- a/test/integration/helpers/kafkaHelper.js +++ /dev/null @@ -1,127 +0,0 @@ -/***** - License - -------------- - Copyright © 2017 Bill & Melinda Gates Foundation - The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. - Contributors - -------------- - This is the official list of the Mojaloop project contributors for this file. - Names of the original copyright holders (individuals or organizations) - should be listed with a '*' in the first column. People who have - contributed from an organization can be listed under the organization - that actually holds the copyright for their contributions (see the - Gates Foundation organization for an example). Those individuals should have - their names indented and be marked with a '-'. Email address can be added - optionally within square brackets . - * Gates Foundation - - Name Surname - - * Miguel de Barros - -------------- - **********/ - -const Producer = require('@mojaloop/central-services-stream').Util.Producer -const Consumer = require('@mojaloop/central-services-stream').Util.Consumer - -const topics = [ - 'topic-transfer-prepare', - 'topic-transfer-position', - 'topic-transfer-fulfil', - 'topic-notification-event' -] - -exports.topics = topics - -exports.producers = { - connect: async (assert) => { - // lets make sure all our Producers are already connected if they have already been defined. - for (const topic of topics) { - try { - // lets make sure check if any of our Producers are already connected if they have already been defined. - console.log(`Producer[${topic}] checking connectivity!`) - const isConnected = await Producer.isConnected(topic) - if (!isConnected) { - try { - console.log(`Producer[${topic}] is connecting`) - await Producer.getProducer(topic).connect() - console.log(`Producer[${topic}] is connected`) - if (assert) assert.pass(`Producer[${topic}] is connected`) - } catch (err) { - console.log(`Producer[${topic}] connection failed!`) - if (assert) assert.fail(err) - console.error(err) - } - } else { - console.log(`Producer[${topic}] is ALREADY connected`) - } - } catch (err) { - console.log(`Producer[${topic}] has not been initialized`) - if (assert) assert.fail(err) - console.error(err) - } - } - }, - - disconnect: async (assert) => { - for (const topic of topics) { - try { - console.log(`Producer[${topic}] disconnecting`) - await Producer.getProducer(topic).disconnect() - if (assert) assert.pass(`Producer[${topic}] is disconnected`) - console.log(`Producer[${topic}] disconnected`) - } catch (err) { - if (assert) assert.fail(err.message) - console.log(`Producer[${topic}] disconnection failed`) - console.error(err) - } - } - } -} - -exports.consumers = { - connect: async (assert) => { - // lets make sure all our Consumers are already connected if they have already been defined. - for (const topic of topics) { - try { - // lets make sure check if any of our Consumers are already connected if they have already been defined. - console.log(`Consumer[${topic}] checking connectivity!`) - const isConnected = await Consumer.isConnected(topic) - if (!isConnected) { - try { - console.log(`Consumer[${topic}] is connecting`) - await Consumer.getConsumer(topic).connect() - console.log(`Consumer[${topic}] is connected`) - if (assert) assert.pass(`Consumer[${topic}] is connected`) - } catch (err) { - console.log(`Consumer[${topic}] connection failed!`) - if (assert) assert.fail(`Consumer[${topic}] connection failed!`) - console.error(err) - } - } else { - console.log(`Consumer[${topic}] is ALREADY connected`) - } - } catch (err) { - console.log(`Consumer[${topic}] has not been initialized`) - if (assert) assert.fail(`Consumer[${topic}] has not been initialized`) - console.error(err) - } - } - }, - - disconnect: async (assert) => { - for (const topic of topics) { - try { - console.log(`Consumer[${topic}] disconnecting`) - await Consumer.getConsumer(topic).disconnect() - if (assert) assert.pass(`Consumer[${topic}] is disconnected`) - console.log(`Consumer[${topic}] disconnected`) - } catch (err) { - if (assert) assert.fail(err.message) - console.log(`Consumer[${topic}] disconnection failed`) - console.error(err) - } - } - } -} diff --git a/test/scripts/test-integration.sh b/test/scripts/test-integration.sh index faffe3988..5224f3b73 100644 --- a/test/scripts/test-integration.sh +++ b/test/scripts/test-integration.sh @@ -49,8 +49,8 @@ echo "==> integration tests exited with code: $INTEGRATION_TEST_EXIT_CODE" ## Kill service echo "Stopping Service with Process ID=$PID" -kill $(cat /tmp/int-test-service.pid) -kill $(lsof -t -i:3001) +kill -9 $(cat /tmp/int-test-service.pid) +kill -9 $(lsof -t -i:3001) ## Give some time before restarting service for override tests sleep $WAIT_FOR_REBALANCE @@ -91,10 +91,10 @@ echo "==> override integration tests exited with code: $OVERRIDE_INTEGRATION_TES ## Kill service echo "Stopping Service with Process ID=$PID1" -kill $(cat /tmp/int-test-service.pid) -kill $(lsof -t -i:3001) +kill -9 $(cat /tmp/int-test-service.pid) +kill -9 $(lsof -t -i:3001) echo "Stopping Service with Process ID=$PID2" -kill $(cat /tmp/int-test-handler.pid) +kill -9 $(cat /tmp/int-test-handler.pid) ## Shutdown the backend services if [ $INT_TEST_SKIP_SHUTDOWN == true ]; then