Skip to content

Commit

Permalink
[7.17] Wait between instances, but not after the last one (#190679) (#…
Browse files Browse the repository at this point in the history
…190702)

# Backport

This will backport the following commits from `main` to `7.17`:
- [Wait between instances, but not after the last one
(#190679)](#190679)

<!--- Backport version: 8.9.8 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Alejandro Fernández
Haro","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-08-19T12:46:15Z","message":"Wait
between instances, but not after the last one
(#190679)","sha":"965b0a675d537f3a83dcf7eaa6153a33af1b62f4","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","backport:all-open","v8.16.0"],"number":190679,"url":"https://github.com/elastic/kibana/pull/190679","mergeCommit":{"message":"Wait
between instances, but not after the last one
(#190679)","sha":"965b0a675d537f3a83dcf7eaa6153a33af1b62f4"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","labelRegex":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/190679","number":190679,"mergeCommit":{"message":"Wait
between instances, but not after the last one
(#190679)","sha":"965b0a675d537f3a83dcf7eaa6153a33af1b62f4"}},{"url":"https://github.com/elastic/kibana/pull/190694","number":190694,"branch":"8.15","state":"OPEN"}]}]
BACKPORT-->

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
afharo and elasticmachine authored Aug 20, 2024
1 parent 6fdbe03 commit 76109cd
Showing 1 changed file with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ async function createRoot({ logFileName }: CreateRootConfig) {
return root;
}

// FLAKY: https://github.com/elastic/kibana/issues/107864
describe.skip('migration v2', () => {
// suite is very long, the 10mins default can cause timeouts
jest.setTimeout(15 * 60 * 1000);

describe('migration v2', () => {
let esServer: kbnTestServer.TestElasticsearchUtils;
let rootA: Root;
let rootB: Root;
Expand All @@ -121,9 +123,7 @@ describe.skip('migration v2', () => {
},
};

afterAll(async () => {
await new Promise((resolve) => setTimeout(resolve, 10000));
});
const delay = (timeInMs: number) => new Promise((resolve) => setTimeout(resolve, timeInMs));

beforeEach(async () => {
await removeLogFiles();
Expand Down Expand Up @@ -157,23 +157,35 @@ describe.skip('migration v2', () => {
});

afterEach(async () => {
await Promise.all([rootA.shutdown(), rootB.shutdown(), rootC.shutdown()]);
try {
await Promise.all([rootA.shutdown(), rootB.shutdown(), rootC.shutdown()]);
} catch (e) {
/* trap */
}

if (esServer) {
await esServer.stop();
}
});

const delay = (timeInMs: number) => new Promise((resolve) => setTimeout(resolve, timeInMs));
const startWithDelay = async (instances: Root[], delayInSec: number) => {
const promises: Array<Promise<unknown>> = [];
const errors: string[] = [];
for (let i = 0; i < instances.length; i++) {
promises.push(instances[i].start());
if (i < instances.length - 1) {
promises.push(
instances[i].start().catch((err) => {
errors.push(err.message);
})
);
if (i < instances.length - 2) {
// We wait between instances, but not after the last one
await delay(delayInSec * 1000);
}
}
return Promise.all(promises);
await Promise.all(promises);
if (errors.length) {
throw new Error(`Failed to start all instances: ${errors.join(',')}`);
}
};

it('migrates saved objects normally when multiple Kibana instances are started at the same time', async () => {
Expand Down

0 comments on commit 76109cd

Please sign in to comment.