Skip to content

Commit

Permalink
[CCI] Remove waitCluster in Integration Tests (#423)
Browse files Browse the repository at this point in the history
Remove "waitCluster" from test/utils

Signed-off-by: Didar Tursunov <[email protected]>
  • Loading branch information
Wielmany authored Mar 13, 2023
1 parent 2fbb08d commit 7faaf40
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 43 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 1 addition & 2 deletions test/integration/helpers-secure/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand All @@ -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({
Expand Down
2 changes: 0 additions & 2 deletions test/integration/helpers/bulk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -43,7 +42,6 @@ const client = new Client({
});

beforeEach(async () => {
await waitCluster(client);
await client.indices.create({ index: INDEX });
});

Expand Down
3 changes: 1 addition & 2 deletions test/integration/helpers/msearch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand All @@ -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({
Expand Down
3 changes: 1 addition & 2 deletions test/integration/helpers/scroll.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand All @@ -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({
Expand Down
3 changes: 1 addition & 2 deletions test/integration/helpers/search.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand All @@ -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({
Expand Down
15 changes: 0 additions & 15 deletions test/integration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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;
Expand Down
18 changes: 0 additions & 18 deletions test/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -71,7 +54,6 @@ module.exports = {
buildCluster,
buildProxy,
connection,
waitCluster,
skipCompatibleCheck,
Client: NoCompatibleCheckClient,
};

0 comments on commit 7faaf40

Please sign in to comment.