Skip to content

Commit

Permalink
[Infra] Attempt to fix flaky test (#192091)
Browse files Browse the repository at this point in the history
fixes [#191806](#191806)

## Summary

It was a weird problem that could only be reproduced by running the
host_view test after the node_details test. The cause was that the
synthtrace data was not fully cleaned in between tests
  • Loading branch information
crespocarlos authored Sep 6, 2024
1 parent 6bef580 commit 7ad92ba
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export class InfraSynthtraceEsClient extends SynthtraceEsClient<InfraDocument> {
'metrics-kubernetes*',
'metrics-docker*',
'metrics-aws*',
'metricbeat-*',
'logs-*',
];
}
}
Expand Down
14 changes: 7 additions & 7 deletions x-pack/test/functional/apps/infra/home_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,16 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('Home page', function () {
this.tags('includeFirefox');
let synthEsClient: InfraSynthtraceEsClient;

before(async () => {
synthEsClient = await getInfraSynthtraceEsClient(esClient);
await kibanaServer.savedObjects.cleanStandardList();
return synthEsClient.clean();
});

after(() => synthEsClient.clean());

describe('without metrics present', () => {
it('renders an empty data prompt and redirects to the onboarding page', async () => {
await pageObjects.common.navigateToApp('infraOps');
Expand Down Expand Up @@ -110,10 +115,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

describe('with metrics present', () => {
let synthEsClient: InfraSynthtraceEsClient;
before(async () => {
synthEsClient = await getInfraSynthtraceEsClient(esClient);
await synthEsClient.clean();
await synthEsClient.index([
generateHostData({
from: DATE_WITH_HOSTS_DATA_FROM,
Expand All @@ -134,10 +136,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.common.navigateToApp('infraOps');
await pageObjects.infraHome.waitForLoading();
});
after(async () => {
await browser.removeLocalStorageItem(KUBERNETES_TOUR_STORAGE_KEY);
await synthEsClient.clean();
});

after(async () => browser.removeLocalStorageItem(KUBERNETES_TOUR_STORAGE_KEY));

it('renders the correct page title', async () => {
await pageObjects.header.waitUntilLoadingHasFinished();
Expand Down
59 changes: 34 additions & 25 deletions x-pack/test/functional/apps/infra/hosts_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,38 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
(await pageObjects.infraHostsView.isKPIChartsLoaded())
);

// Failing: See https://github.com/elastic/kibana/issues/191806
describe.skip('Hosts View', function () {
describe('Hosts View', function () {
let synthEsInfraClient: InfraSynthtraceEsClient;
let syntEsLogsClient: LogsSynthtraceEsClient;
let synthtraceApmClient: ApmSynthtraceEsClient;

before(async () => {
synthEsInfraClient = await getInfraSynthtraceEsClient(esClient);
syntEsLogsClient = await getLogsSynthtraceEsClient(esClient);
const version = (await apmSynthtraceKibanaClient.installApmPackage()).version;
synthtraceApmClient = await getApmSynthtraceEsClient({
client: esClient,
packageVersion: version,
});

return Promise.all([
synthtraceApmClient.clean(),
synthEsInfraClient.clean(),
syntEsLogsClient.clean(),
]);
});

after(async () => {
return Promise.all([
apmSynthtraceKibanaClient.uninstallApmPackage(),
synthtraceApmClient.clean(),
synthEsInfraClient.clean(),
syntEsLogsClient.clean(),
]);
});

describe('#Onboarding', function () {
before(async () => {
synthEsInfraClient = await getInfraSynthtraceEsClient(esClient);
await synthEsInfraClient.clean();
await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH);
});

Expand All @@ -325,14 +348,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

describe('#With data', function () {
let synthtraceApmClient: ApmSynthtraceEsClient;
before(async () => {
synthEsInfraClient = await getInfraSynthtraceEsClient(esClient);
syntEsLogsClient = await getLogsSynthtraceEsClient(esClient);
const version = (await apmSynthtraceKibanaClient.installApmPackage()).version;
synthtraceApmClient = await getApmSynthtraceEsClient({
client: esClient,
packageVersion: version,
const hosts = generateHostData({
from: DATE_WITH_HOSTS_DATA_FROM,
to: DATE_WITH_HOSTS_DATA_TO,
hosts: SYNTH_HOSTS,
});

const services = generateAddServicesToExistingHost({
Expand All @@ -350,26 +370,15 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

await browser.setWindowSize(1600, 1200);

return Promise.all([
await Promise.all([
synthEsInfraClient.index(hosts),
synthtraceApmClient.index(services),
synthEsInfraClient.index(
generateHostData({
from: DATE_WITH_HOSTS_DATA_FROM,
to: DATE_WITH_HOSTS_DATA_TO,
hosts: SYNTH_HOSTS,
})
),
syntEsLogsClient.index(logs),
]);
});

after(async () => {
return Promise.all([
apmSynthtraceKibanaClient.uninstallApmPackage(),
synthtraceApmClient.clean(),
synthEsInfraClient.clean(),
browser.removeLocalStorageItem(HOSTS_LINK_LOCAL_STORAGE_KEY),
]);
return browser.removeLocalStorageItem(HOSTS_LINK_LOCAL_STORAGE_KEY);
});

describe('#Single Host Flyout', () => {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/test/functional/apps/infra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ export default ({ loadTestFile }: FtrProviderContext) => {

describe('Metrics UI', function () {
loadTestFile(require.resolve('./home_page'));
loadTestFile(require.resolve('./metrics_source_configuration'));
loadTestFile(require.resolve('./metrics_anomalies'));
loadTestFile(require.resolve('./metrics_explorer'));
loadTestFile(require.resolve('./node_details'));
loadTestFile(require.resolve('./hosts_view'));
// keep this test last as it can potentially break other tests
loadTestFile(require.resolve('./metrics_source_configuration'));
});

describe('Logs UI', function () {
Expand Down
23 changes: 14 additions & 9 deletions x-pack/test/functional/apps/infra/metrics_source_configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,22 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const kibanaServer = getService('kibanaServer');

describe('Infrastructure Source Configuration', function () {
before(async () => kibanaServer.savedObjects.cleanStandardList());
after(async () => kibanaServer.savedObjects.cleanStandardList());
before(async () =>
Promise.all([
esArchiver.load('x-pack/test/functional/es_archives/infra/alerts'),
esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'),
kibanaServer.savedObjects.cleanStandardList(),
])
);
after(async () =>
Promise.all([
esArchiver.unload('x-pack/test/functional/es_archives/infra/alerts'),
esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'),
kibanaServer.savedObjects.cleanStandardList(),
])
);

describe('with metrics present', () => {
before(async () =>
esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs')
);
after(async () =>
esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs')
);

it('renders the waffle map', async () => {
await pageObjects.common.navigateToApp('infraOps');
await pageObjects.infraHome.goToTime(DATE_WITH_DATA);
Expand Down
30 changes: 7 additions & 23 deletions x-pack/test/functional/apps/infra/node_details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,40 +139,32 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
let synthEsClient: InfraSynthtraceEsClient;
before(async () => {
synthEsClient = await getInfraSynthtraceEsClient(esClient);
await synthEsClient.clean();
await kibanaServer.savedObjects.cleanStandardList();
await browser.setWindowSize(1600, 1200);
});

after(async () => {
await synthEsClient.clean();
return synthEsClient.clean();
});

after(() => synthEsClient.clean());

describe('#Asset Type: host', () => {
before(async () => {
synthEsClient = await getInfraSynthtraceEsClient(esClient);
await synthEsClient.clean();
await synthEsClient.index(
generateHostData({
from: DATE_WITH_HOSTS_DATA_FROM,
to: DATE_WITH_HOSTS_DATA_TO,
hosts: HOSTS,
})
);

await navigateToNodeDetails('host-1', 'host', {
name: 'host-1',
});

await pageObjects.header.waitUntilLoadingHasFinished();
await pageObjects.timePicker.setAbsoluteRange(
START_HOST_DATE.format(DATE_PICKER_FORMAT),
END_HOST_DATE.format(DATE_PICKER_FORMAT)
);
});

after(async () => {
await synthEsClient.clean();
});
after(() => synthEsClient.clean());

it('preserves selected tab between page reloads', async () => {
await testSubjects.missingOrFail('infraAssetDetailsMetadataTable');
Expand Down Expand Up @@ -633,8 +625,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('#Asset type: host with kubernetes section', () => {
before(async () => {
synthEsClient = await getInfraSynthtraceEsClient(esClient);
await synthEsClient.clean();
await synthEsClient.index(
generateHostsWithK8sNodeData({
from: DATE_WITH_HOSTS_DATA_FROM,
Expand All @@ -651,9 +641,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
);
});

after(async () => {
await synthEsClient.clean();
});
after(() => synthEsClient.clean());

describe('Overview Tab', () => {
before(async () => {
Expand Down Expand Up @@ -727,8 +715,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {

describe('#Asset Type: container', () => {
before(async () => {
synthEsClient = await getInfraSynthtraceEsClient(esClient);
await synthEsClient.clean();
await synthEsClient.index(
generateDockerContainersData({
from: DATE_WITH_DOCKER_DATA_FROM,
Expand All @@ -744,9 +730,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
);
});

after(async () => {
await synthEsClient.clean();
});
after(() => synthEsClient.clean());

describe('when container asset view is disabled', () => {
before(async () => {
Expand Down

0 comments on commit 7ad92ba

Please sign in to comment.