Skip to content

Commit

Permalink
remove "waitCluster" from test/integration
Browse files Browse the repository at this point in the history
Signed-off-by: Didar Tursunov <89772209+Wielmany@users.noreply.github.com>
  • Loading branch information
Wielmany committed Mar 9, 2023
1 parent 3a48446 commit 6b59918
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 23 deletions.
4 changes: 2 additions & 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,7 @@ 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/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,7 @@ const client = new Client({
});

beforeEach(async () => {
await waitCluster(client);

await client.indices.create({ index: INDEX });
});

Expand Down
4 changes: 2 additions & 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,7 @@ 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
4 changes: 2 additions & 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,7 @@ 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
4 changes: 2 additions & 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,7 @@ 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
13 changes: 0 additions & 13 deletions test/integration/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,22 +81,9 @@ 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

0 comments on commit 6b59918

Please sign in to comment.