Skip to content

Commit

Permalink
Add cross-cluster search errors functional tests (elastic#170916)
Browse files Browse the repository at this point in the history
## Summary

Part of elastic#166705.

### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces—unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes—Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
lukasolson authored Nov 16, 2023
1 parent 810db49 commit 36dfaf9
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
101 changes: 101 additions & 0 deletions test/functional/apps/discover/ccs_compatibility/_search_errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

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

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const config = getService('config');
const filterBar = getService('filterBar');
const kibanaServer = getService('kibanaServer');
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']);

const isCcsTest = config.get('esTestCluster.ccs');
const archiveDirectory = isCcsTest
? 'test/functional/fixtures/kbn_archiver/ccs/discover.json'
: 'test/functional/fixtures/kbn_archiver/discover.json';
const esNode = isCcsTest
? getService('remoteEsArchiver' as 'esArchiver')
: getService('esArchiver');

const defaultIndex = isCcsTest ? 'ftr-remote:logstash-*' : 'logstash-*';

describe('discover search errors', () => {
before(async () => {
await kibanaServer.importExport.load(archiveDirectory);
await esNode.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
});

after(async () => {
await kibanaServer.importExport.unload(archiveDirectory);
await esNode.unload('test/functional/fixtures/es_archiver/logstash_functional');
});

it('exception on single shard shows warning and results', async () => {
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern(defaultIndex);
await PageObjects.timePicker.setDefaultAbsoluteRange();
await retry.try(async () => {
const hitCount = await PageObjects.discover.getHitCount();
expect(hitCount).to.be('14,004');
});
await filterBar.addDslFilter(`
{
"query": {
"error_query": {
"indices": [
{
"name": "${defaultIndex.slice(0, defaultIndex.length - 1)}2015.09.20",
"error_type": "exception",
"message": "'Watch out!'"
}
]
}
}
}`);

// Ensure documents are still returned for the successful shards
await retry.try(async function tryingForTime() {
const hitCount = await PageObjects.discover.getHitCount();
expect(hitCount).to.be('9,247');
});

// Ensure a warning is shown
await testSubjects.exists('searchResponseWarningsCallout');
});

it('exception on all shards shows error', async () => {
await PageObjects.common.navigateToApp('discover');
await PageObjects.discover.selectIndexPattern(defaultIndex);
await PageObjects.timePicker.setDefaultAbsoluteRange();
await retry.try(async () => {
const hitCount = await PageObjects.discover.getHitCount();
expect(hitCount).to.be('14,004');
});
await filterBar.addDslFilter(`
{
"query": {
"error_query": {
"indices": [
{
"name": "${defaultIndex}",
"error_type": "exception",
"message": "'Watch out!'"
}
]
}
}
}`);

// Ensure an error is shown
await testSubjects.exists('searchResponseWarningsEmptyPrompt');
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/discover/ccs_compatibility/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {

loadTestFile(require.resolve('./_data_view_editor'));
loadTestFile(require.resolve('./_saved_queries'));
loadTestFile(require.resolve('./_search_errors'));
});
}
14 changes: 14 additions & 0 deletions test/functional/services/filter_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type Filter = FilterLeaf | FilterNode;

export class FilterBarService extends FtrService {
private readonly comboBox = this.ctx.getService('comboBox');
private readonly monacoEditor = this.ctx.getService('monacoEditor');
private readonly testSubjects = this.ctx.getService('testSubjects');
private readonly common = this.ctx.getPageObject('common');
private readonly header = this.ctx.getPageObject('header');
Expand Down Expand Up @@ -315,6 +316,19 @@ export class FilterBarService extends FtrService {
await this.addFilterAndSelectDataView(null, filter);
}

public async addDslFilter(value: string) {
await this.testSubjects.click('addFilter');
await this.testSubjects.click('editQueryDSL');
await this.monacoEditor.waitCodeEditorReady('addFilterPopover');
await this.monacoEditor.setCodeEditorValue(value);
await this.testSubjects.scrollIntoView('saveFilter');
await this.testSubjects.clickWhenNotDisabled('saveFilter');
await this.retry.try(async () => {
await this.testSubjects.waitForDeleted('saveFilter');
});
await this.header.waitUntilLoadingHasFinished();
}

/**
* Activates filter editing
* @param key field name
Expand Down

0 comments on commit 36dfaf9

Please sign in to comment.