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

[Search] Functional tests for async search #78703

Merged
merged 15 commits into from
Oct 7, 2020
Merged
7 changes: 6 additions & 1 deletion src/plugins/data/public/search/errors/timeout_error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ export class SearchTimeoutError extends KbnError {
<>
<EuiSpacer size="s" />
<EuiText textAlign="right">
<EuiButton color="danger" onClick={() => this.onClick(application)} size="s">
<EuiButton
color="danger"
onClick={() => this.onClick(application)}
size="s"
data-test-subj="searchTimeoutError"
>
{actionText}
</EuiButton>
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ export function EmbeddableErrorLabel(props: Props) {
return (
<div className="embPanel__labelWrapper">
<div className="embPanel__label">
<EuiToolTip content={props.error.message}>
<EuiBadge color="danger">{labelText}</EuiBadge>
<EuiToolTip data-test-subj="embeddableErrorMessage" content={props.error.message}>
<EuiBadge data-test-subj="embeddableErrorLabel" color="danger">
{labelText}
</EuiBadge>
</EuiToolTip>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions test/common/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export default function () {
`--elasticsearch.username=${kibanaServerTestUser.username}`,
`--elasticsearch.password=${kibanaServerTestUser.password}`,
`--home.disableWelcomeScreen=true`,
// Needed for async search functional tests to introduce a delay
`--data.search.aggs.shardDelay.enabled=true`,
`--security.showInsecureClusterWarning=false`,
'--telemetry.banner=false',
'--telemetry.optIn=false',
Expand Down
41 changes: 41 additions & 0 deletions x-pack/test/functional/apps/dashboard/async_search/async_search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common', 'header', 'dashboard', 'visChart']);

describe('dashboard with async search', () => {
it('not delayed should load', async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.gotoDashboardEditMode('Not Delayed');
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.missingOrFail('embeddableErrorLabel');
const data = await PageObjects.visChart.getBarChartData('Sum of bytes');
expect(data.length).to.be(5);
});

it('delayed should load', async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.gotoDashboardEditMode('Delayed 5s');
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.missingOrFail('embeddableErrorLabel');
const data = await PageObjects.visChart.getBarChartData('');
expect(data.length).to.be(5);
lukasolson marked this conversation as resolved.
Show resolved Hide resolved
});

it('timed out should show error', async () => {
await PageObjects.common.navigateToApp('dashboard');
await PageObjects.dashboard.gotoDashboardEditMode('Delayed 15s');
await PageObjects.header.waitUntilLoadingHasFinished();
await testSubjects.existOrFail('embeddableErrorLabel');
await testSubjects.existOrFail('searchTimeoutError');
});
});
}
26 changes: 26 additions & 0 deletions x-pack/test/functional/apps/dashboard/async_search/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { FtrProviderContext } from '../../../ftr_provider_context';

export default function ({ loadTestFile, getService }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver');

describe('async search', function () {
before(async () => {
await esArchiver.loadIfNeeded('logstash_functional');
await esArchiver.load('dashboard/async_search');
await kibanaServer.uiSettings.replace({ defaultIndex: 'logstash-*' });
await kibanaServer.uiSettings.replace({ 'search:timeout': 10000 });
});

after(async () => {
await esArchiver.unload('dashboard/async_search');
});

loadTestFile(require.resolve('./async_search'));
});
}
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/dashboard/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default function ({ loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./preserve_url'));
loadTestFile(require.resolve('./reporting'));
loadTestFile(require.resolve('./drilldowns'));
loadTestFile(require.resolve('./async_search'));
loadTestFile(require.resolve('./_async_dashboard'));
});
}
197 changes: 197 additions & 0 deletions x-pack/test/functional/es_archives/dashboard/async_search/data.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
{
"type": "index",
"value": {
"index": ".kibana",
"mappings": {
"properties": {
"config": {
"dynamic": "true",
"properties": {
"buildNum": {
"type": "keyword"
}
}
},
"dashboard": {
"dynamic": "strict",
"properties": {
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"optionsJSON": {
"type": "text"
},
"panelsJSON": {
"type": "text"
},
"refreshInterval": {
"properties": {
"display": {
"type": "keyword"
},
"pause": {
"type": "boolean"
},
"section": {
"type": "integer"
},
"value": {
"type": "integer"
}
}
},
"timeFrom": {
"type": "keyword"
},
"timeRestore": {
"type": "boolean"
},
"timeTo": {
"type": "keyword"
},
"title": {
"type": "text"
},
"uiStateJSON": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"index-pattern": {
"dynamic": "strict",
"properties": {
"fieldFormatMap": {
"type": "text"
},
"fields": {
"type": "text"
},
"intervalName": {
"type": "keyword"
},
"notExpandable": {
"type": "boolean"
},
"sourceFilters": {
"type": "text"
},
"timeFieldName": {
"type": "keyword"
},
"title": {
"type": "text"
}
}
},
"search": {
"dynamic": "strict",
"properties": {
"columns": {
"type": "keyword"
},
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"sort": {
"type": "keyword"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"server": {
"dynamic": "strict",
"properties": {
"uuid": {
"type": "keyword"
}
}
},
"timelion-sheet": {
"dynamic": "strict",
"properties": {
"description": {
"type": "text"
},
"hits": {
"type": "integer"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"timelion_chart_height": {
"type": "integer"
},
"timelion_columns": {
"type": "integer"
},
"timelion_interval": {
"type": "keyword"
},
"timelion_other_interval": {
"type": "keyword"
},
"timelion_rows": {
"type": "integer"
},
"timelion_sheet": {
"type": "text"
},
"title": {
"type": "text"
},
"version": {
"type": "integer"
}
}
},
"type": {
"type": "keyword"
},
"url": {
"dynamic": "strict",
"properties": {
"accessCount": {
"type": "long"
},
"accessDate": {
"type": "date"
},
"createDate": {
"type": "date"
},
"url": {
"fields": {
"keyword": {
"ignore_above": 2048,
"type": "keyword"
}
},
"type": "text"
}
}
},
"visualization": {
"dynamic": "strict",
"properties": {
"description": {
"type": "text"
},
"kibanaSavedObjectMeta": {
"properties": {
"searchSourceJSON": {
"type": "text"
}
}
},
"savedSearchId": {
"type": "keyword"
},
"title": {
"type": "text"
},
"uiStateJSON": {
"type": "text"
},
"version": {
"type": "integer"
},
"visState": {
"type": "text"
}
}
}
}
},
"settings": {
"index": {
"number_of_replicas": "1",
"number_of_shards": "1"
}
}
}
}