Skip to content

Commit

Permalink
[UII] Add retries to starting Kibana for jest preconfiguration integr…
Browse files Browse the repository at this point in the history
…ation tests (#191318)

## Summary

Resolves #172759
Resolves #172760
Resolves #172761

Add retries to starting Kibana for this test suite to hopefully mitigate
future flakiness.


### Checklist

- ~~[Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed~~ Doesn't seem like I can run Jest integration
tests here.
  • Loading branch information
jen-huang authored Aug 27, 2024
1 parent 2441e9a commit 0a8d6a0
Showing 1 changed file with 61 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,56 +49,74 @@ describe('Fleet cloud preconfiguration', () => {

esServer = await startES();
const startOrRestartKibana = async (kbnConfig: any = defaultKbnConfig) => {
if (kbnServer) {
await kbnServer.stop();
}

const root = createRootWithCorePlugins(
{
xpack: {
...kbnConfig.xpack,
fleet: {
...kbnConfig.xpack.fleet,
registryUrl,
const maxTries = 3;
let currentTry = 0;

const startOrRestart = async () => {
if (kbnServer) {
await kbnServer.stop();
}

const root = createRootWithCorePlugins(
{
xpack: {
...kbnConfig.xpack,
fleet: {
...kbnConfig.xpack.fleet,
registryUrl,
},
},
},
logging: {
appenders: {
file: {
type: 'file',
fileName: logFilePath,
layout: {
type: 'json',
logging: {
appenders: {
file: {
type: 'file',
fileName: logFilePath,
layout: {
type: 'json',
},
},
},
loggers: [
{
name: 'root',
appenders: ['file'],
},
{
name: 'plugins.fleet',
level: 'all',
},
],
},
loggers: [
{
name: 'root',
appenders: ['file'],
},
{
name: 'plugins.fleet',
level: 'all',
},
],
},
},
{ oss: false }
);

await root.preboot();
const coreSetup = await root.setup();
const coreStart = await root.start();

kbnServer = {
root,
coreSetup,
coreStart,
stop: async () => await root.shutdown(),
{ oss: false }
);

await root.preboot();
const coreSetup = await root.setup();
const coreStart = await root.start();

kbnServer = {
root,
coreSetup,
coreStart,
stop: async () => await root.shutdown(),
};

await waitForFleetSetup(kbnServer.root);
};
await waitForFleetSetup(kbnServer.root);

try {
currentTry++;
await startOrRestart();
} catch (e) {
if (currentTry < maxTries) {
await startOrRestart();
} else {
throw e;
}
}
};

await startOrRestartKibana();

return {
Expand Down

0 comments on commit 0a8d6a0

Please sign in to comment.