diff --git a/CHANGELOG.md b/CHANGELOG.md index ecdc0789b..a47e5795c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Make fields in `BulkOperation` optional to match OpenSearch Bulk API requirements ([#378](https://github.com/opensearch-project/opensearch-js/pull/378)) ### Deprecated ### Removed +- Remove waitCluster in Integration Tests ([#422](https://github.com/opensearch-project/opensearch-js/issues/422)) ### Fixed - Added missing types for AwsSigv4SignerOptions.service ([#377](https://github.com/opensearch-project/opensearch-js/pull/377)) - Fixed deprecated folder mapping "./" in the "exports" field module resolution ([#416](https://github.com/opensearch-project/opensearch-js/pull/416)) diff --git a/test/integration/helpers-secure/search.test.js b/test/integration/helpers-secure/search.test.js index 891f96269..0e3ff61d3 100644 --- a/test/integration/helpers-secure/search.test.js +++ b/test/integration/helpers-secure/search.test.js @@ -14,7 +14,7 @@ const { createReadStream } = require('fs'); const { join } = require('path'); const split = require('split2'); const { test, beforeEach, afterEach } = require('tap'); -const { waitCluster } = require('../../utils'); + const { Client } = require('../../..'); const INDEX = `test-helpers-${process.pid}`; @@ -30,7 +30,6 @@ const client = new Client({ }); beforeEach(async () => { - await waitCluster(client); await client.indices.create({ index: INDEX }); const stream = createReadStream(join(__dirname, '..', '..', 'fixtures', 'stackoverflow.ndjson')); const result = await client.helpers.bulk({ diff --git a/test/integration/helpers/bulk.test.js b/test/integration/helpers/bulk.test.js index 3f9a086e6..8fd9ac825 100644 --- a/test/integration/helpers/bulk.test.js +++ b/test/integration/helpers/bulk.test.js @@ -33,7 +33,6 @@ const { createReadStream } = require('fs'); const { join } = require('path'); const split = require('split2'); const { test, beforeEach, afterEach } = require('tap'); -const { waitCluster } = require('../../utils'); const { Client } = require('../../../'); const datasetPath = join(__dirname, '..', '..', 'fixtures', 'stackoverflow.ndjson'); @@ -43,7 +42,6 @@ const client = new Client({ }); beforeEach(async () => { - await waitCluster(client); await client.indices.create({ index: INDEX }); }); diff --git a/test/integration/helpers/msearch.test.js b/test/integration/helpers/msearch.test.js index 5432010a9..c3495e04e 100644 --- a/test/integration/helpers/msearch.test.js +++ b/test/integration/helpers/msearch.test.js @@ -33,7 +33,7 @@ const { createReadStream } = require('fs'); const { join } = require('path'); const split = require('split2'); const { test, beforeEach, afterEach } = require('tap'); -const { waitCluster } = require('../../utils'); + const { Client, errors } = require('../../../'); const INDEX = `test-helpers-${process.pid}`; @@ -42,7 +42,6 @@ const client = new Client({ }); beforeEach(async () => { - await waitCluster(client); await client.indices.create({ index: INDEX }); const stream = createReadStream(join(__dirname, '..', '..', 'fixtures', 'stackoverflow.ndjson')); const result = await client.helpers.bulk({ diff --git a/test/integration/helpers/scroll.test.js b/test/integration/helpers/scroll.test.js index b0251ae87..6b4b80a3f 100644 --- a/test/integration/helpers/scroll.test.js +++ b/test/integration/helpers/scroll.test.js @@ -33,7 +33,7 @@ const { createReadStream } = require('fs'); const { join } = require('path'); const split = require('split2'); const { test, beforeEach, afterEach } = require('tap'); -const { waitCluster } = require('../../utils'); + const { Client } = require('../../../'); const INDEX = `test-helpers-${process.pid}`; @@ -42,7 +42,6 @@ const client = new Client({ }); beforeEach(async () => { - await waitCluster(client); await client.indices.create({ index: INDEX }); const stream = createReadStream(join(__dirname, '..', '..', 'fixtures', 'stackoverflow.ndjson')); const result = await client.helpers.bulk({ diff --git a/test/integration/helpers/search.test.js b/test/integration/helpers/search.test.js index 45e1a88bd..213db0a1a 100644 --- a/test/integration/helpers/search.test.js +++ b/test/integration/helpers/search.test.js @@ -33,7 +33,7 @@ const { createReadStream } = require('fs'); const { join } = require('path'); const split = require('split2'); const { test, beforeEach, afterEach } = require('tap'); -const { waitCluster } = require('../../utils'); + const { Client } = require('../../../'); const INDEX = `test-helpers-${process.pid}`; @@ -42,7 +42,6 @@ const client = new Client({ }); beforeEach(async () => { - await waitCluster(client); await client.indices.create({ index: INDEX }); const stream = createReadStream(join(__dirname, '..', '..', 'fixtures', 'stackoverflow.ndjson')); const result = await client.helpers.bulk({ diff --git a/test/integration/index.js b/test/integration/index.js index 04dbaf6b5..d1978d0c9 100644 --- a/test/integration/index.js +++ b/test/integration/index.js @@ -40,7 +40,6 @@ const yaml = require('js-yaml'); const ms = require('ms'); const { Client } = require('../../index'); const build = require('./test-runner'); -const { sleep } = require('./helper'); const createJunitReporter = require('./reporter'); const downloadArtifacts = require('../../scripts/download-artifacts'); @@ -81,22 +80,8 @@ function runner(opts = {}) { }); } -async function waitCluster(client, times = 0) { - try { - await client.cluster.health({ waitForStatus: 'green', timeout: '50s' }); - } catch (err) { - if (++times < 10) { - await sleep(5000); - return waitCluster(client, times); - } - console.error(err); - process.exit(1); - } -} - async function start({ client }) { log('Waiting for OpenSearch'); - await waitCluster(client); const { body } = await client.info(); const { number: version, build_hash: hash } = body.version; diff --git a/test/utils/index.js b/test/utils/index.js index 8452bac25..6d7098d11 100644 --- a/test/utils/index.js +++ b/test/utils/index.js @@ -29,29 +29,12 @@ 'use strict'; -const { promisify } = require('util'); -const sleep = promisify(setTimeout); const buildServer = require('./buildServer'); const buildCluster = require('./buildCluster'); const buildProxy = require('./buildProxy'); const connection = require('./MockConnection'); const { Client } = require('../../'); -async function waitCluster(client, waitForStatus = 'green', timeout = '50s', times = 0) { - if (!client) { - throw new Error('waitCluster helper: missing client instance'); - } - try { - await client.cluster.health({ waitForStatus, timeout }); - } catch (err) { - if (++times < 10) { - await sleep(5000); - return waitCluster(client, waitForStatus, timeout, times); - } - throw err; - } -} - function skipCompatibleCheck(client) { const tSymbol = Object.getOwnPropertySymbols(client.transport || client).filter( (symbol) => symbol.description === 'compatible check' @@ -71,7 +54,6 @@ module.exports = { buildCluster, buildProxy, connection, - waitCluster, skipCompatibleCheck, Client: NoCompatibleCheckClient, };