Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## Summary

This reverts commit 24fd951 (elastic#169041).

This PR caused additional test flakiness and introduced a situation in
which the Kibana server could crash. We already have
elastic#168929 to make sure ES|QL queries
cannot run longer than 2 mins, so we have some space to revisit the
changes in that PR.

Resolves elastic#169654.
Resolves elastic#169653.
Resolves elastic#169652.
Resolves elastic#169528.
Resolves elastic#169526.
Resolves elastic#169459.
Resolves elastic#169458.
Resolves elastic#169454.
Resolves elastic#169434.
Resolves elastic#169151.

Flaky tests runs:
- test/functional/apps/discover/group1/config.ts:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3750
- test/functional/apps/discover/group2/config.ts:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3751
- test/functional/apps/discover/group3/config.ts:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3752
- test/functional/apps/discover/group4/config.ts:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3746

### 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 and bryce-b committed Oct 30, 2023
1 parent 7a4023f commit dbe0b42
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 83 deletions.
4 changes: 1 addition & 3 deletions src/plugins/data/common/search/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ export const isAbortResponse = (response?: IKibanaSearchResponse) => {
/**
* @returns true if request is still running
*/
export const isRunningResponse = (response?: IKibanaSearchResponse) => {
return response?.isRunning ?? false;
};
export const isRunningResponse = (response?: IKibanaSearchResponse) => response?.isRunning ?? false;

export const getUserTimeZone = (
getConfig: AggTypesDependencies['getConfig'],
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/data/server/search/routes/bsearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { catchError } from 'rxjs/operators';
import { BfetchServerSetup } from '@kbn/bfetch-plugin/server';
import type { ExecutionContextSetup } from '@kbn/core/server';
import apm from 'elastic-apm-node';
import { getRequestAbortedSignal } from '../..';
import {
IKibanaSearchRequest,
IKibanaSearchResponse,
Expand All @@ -29,7 +28,6 @@ export function registerBsearchRoute(
IKibanaSearchResponse
>('/internal/bsearch', (request) => {
const search = getScoped(request);
const abortSignal = getRequestAbortedSignal(request.events.aborted$);
return {
/**
* @param requestOptions
Expand All @@ -41,7 +39,7 @@ export function registerBsearchRoute(
apm.addLabels(executionContextService.getAsLabels());

return firstValueFrom(
search.search(requestData, { ...restOptions, abortSignal }).pipe(
search.search(requestData, restOptions).pipe(
catchError((err) => {
// Re-throw as object, to get attributes passed to the client
// eslint-disable-next-line no-throw-literal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,38 +260,6 @@ describe('ES search strategy', () => {

expect(mockApiCaller).toBeCalledTimes(0);
});

it('should delete when aborted', async () => {
mockSubmitCaller.mockResolvedValueOnce({
...mockAsyncResponse,
body: {
...mockAsyncResponse.body,
is_running: true,
},
});

const params = { index: 'logstash-*', body: { query: {} } };
const esSearch = await enhancedEsSearchStrategyProvider(
mockLegacyConfig$,
mockSearchConfig,
mockLogger
);
const abortController = new AbortController();
const abortSignal = abortController.signal;

// Abort after an incomplete first response is returned
setTimeout(() => abortController.abort(), 100);

let err: KbnServerError | undefined;
try {
await esSearch.search({ params }, { abortSignal }, mockDeps).toPromise();
} catch (e) {
err = e;
}
expect(mockSubmitCaller).toBeCalled();
expect(err).not.toBeUndefined();
expect(mockDeleteCaller).toBeCalled();
});
});

describe('with sessionId', () => {
Expand Down Expand Up @@ -399,44 +367,6 @@ describe('ES search strategy', () => {
expect(request).toHaveProperty('wait_for_completion_timeout');
expect(request).not.toHaveProperty('keep_alive');
});

it('should not delete a saved session when aborted', async () => {
mockSubmitCaller.mockResolvedValueOnce({
...mockAsyncResponse,
body: {
...mockAsyncResponse.body,
is_running: true,
},
});

const params = { index: 'logstash-*', body: { query: {} } };
const esSearch = await enhancedEsSearchStrategyProvider(
mockLegacyConfig$,
mockSearchConfig,
mockLogger
);
const abortController = new AbortController();
const abortSignal = abortController.signal;

// Abort after an incomplete first response is returned
setTimeout(() => abortController.abort(), 100);

let err: KbnServerError | undefined;
try {
await esSearch
.search(
{ params },
{ abortSignal, sessionId: '1', isSearchStored: true, isStored: true },
mockDeps
)
.toPromise();
} catch (e) {
err = e;
}
expect(mockSubmitCaller).toBeCalled();
expect(err).not.toBeUndefined();
expect(mockDeleteCaller).not.toBeCalled();
});
});

it('throws normalized error if ResponseError is thrown', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const enhancedEsSearchStrategyProvider = (
};

const cancel = async () => {
if (id && !options.isStored) {
if (id) {
await cancelAsyncSearch(id, esClient);
}
};
Expand Down
4 changes: 1 addition & 3 deletions test/functional/apps/discover/group4/_adhoc_data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await PageObjects.dashboard.waitForRenderComplete();
};

// FLAKY: https://github.com/elastic/kibana/issues/169434
// FLAKY: https://github.com/elastic/kibana/issues/169454
describe.skip('adhoc data views', function () {
describe('adhoc data views', function () {
before(async () => {
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']);
await kibanaServer.importExport.load('test/functional/fixtures/kbn_archiver/discover.json');
Expand Down
4 changes: 1 addition & 3 deletions test/functional/apps/discover/group4/_chart_hidden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
defaultIndex: 'logstash-*',
};

// FLAKY: https://github.com/elastic/kibana/issues/169458
// FLAKY: https://github.com/elastic/kibana/issues/169459
describe.skip('discover show/hide chart test', function () {
describe('discover show/hide chart test', function () {
before(async function () {
await security.testUser.setRoles(['kibana_admin', 'test_logstash_reader']);
log.debug('load kibana index with default index pattern');
Expand Down

0 comments on commit dbe0b42

Please sign in to comment.