Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CCI] Remove waitCluster in Integration Tests #423

Merged
merged 6 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,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))
### Security
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,
};