Skip to content

Commit

Permalink
Fix missing params from search strategy polling requests causing vali…
Browse files Browse the repository at this point in the history
…dation errors in tests (#199539)

## Summary

This PR fixes an issue introduced in #196962 where search strategy
polling requests sent from some integration tests were missing necessary
body parameters, resulting in validation errors and test failures. This
issue was not caught by CI in the original PR because it only occurs
when a search request runs slow enough to return partial results (and
therefore requires polling), which is not common in test runs.

Fixes #199537
Fixes #199499
Fixes #199460
Fixes #199449
Fixes #199412
Fixes #199410
Fixes #199394
Fixes #199379
Fixes #199372
Fixes #199363
Fixes #199541
Fixes #199446
Fixes #199433
Fixes #199432
Fixes #199381
Fixes #199369
Fixes #199364

Flaky test runner x200:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7362.

### Checklist

- [ ] 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
- [x] [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
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [ ] 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)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)
- [ ] This will appear in the **Release Notes** and follow the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
  • Loading branch information
davismcphee authored Nov 8, 2024
1 parent 0ee022e commit 116cd9d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class SearchService extends FtrService {
.post(`${spaceUrl}/internal/search/${strategy}/${body.id}`)
.set('kbn-xsrf', 'true')
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.send()
.send(options)
.expect(200);
expect(resp.body.isRunning).equal(false);
return resp.body as T;
Expand Down
15 changes: 0 additions & 15 deletions x-pack/test/apm_api_integration/common/utils/parse_b_fetch.ts

This file was deleted.

15 changes: 3 additions & 12 deletions x-pack/test/common/services/search_secure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@
// but with the ability to provide custom auth

import expect from '@kbn/expect';
import request from 'superagent';
import type { IEsSearchResponse } from '@kbn/search-types';
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { BFETCH_ROUTE_VERSION_LATEST } from '@kbn/bfetch-plugin/common';
import { SupertestWithoutAuthProviderType } from '@kbn/ftr-common-functional-services';
import { FtrService } from '../ftr_provider_context';

const parseBfetchResponse = (resp: request.Response): Array<Record<string, any>> => {
return resp.text
.trim()
.split('\n')
.map((item) => JSON.parse(item));
};

const getSpaceUrlPrefix = (spaceId?: string): string => {
return spaceId && spaceId !== 'default' ? `/s/${spaceId}` : ``;
};
Expand Down Expand Up @@ -114,11 +106,10 @@ export class SearchSecureService extends FtrService {
.set('kbn-xsrf', 'true')
.set('x-elastic-internal-origin', 'Kibana')
.set(ELASTIC_HTTP_VERSION_HEADER, BFETCH_ROUTE_VERSION_LATEST)
.send()
.send(options)
.expect(200);
const [parsedResponse] = parseBfetchResponse(resp);
expect(parsedResponse.result.isRunning).equal(false);
return parsedResponse.result;
expect(resp.body.isRunning).equal(false);
return resp.body;
});

return result as T;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
const esArchiver = getService('esArchiver');
const utils = getService('securitySolutionUtils');

// Failing: See https://github.com/elastic/kibana/issues/199372
describe.skip('Network DNS', () => {
describe('Network DNS', () => {
let supertest: TestAgent;
let search: SearchService;
describe('With packetbeat', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export default function ({ getService }: FtrProviderContextWithSpaces) {
const esArchiver = getService('esArchiver');
const utils = getService('securitySolutionUtils');

// FLAKY: https://github.com/elastic/kibana/issues/199363
describe.skip('Network Top N Flow', () => {
describe('Network Top N Flow', () => {
let supertest: TestAgent;
let search: SearchService;
describe('With filebeat', () => {
Expand Down
15 changes: 3 additions & 12 deletions x-pack/test_serverless/shared/services/search_secure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,11 @@

import expect from '@kbn/expect';
import { GenericFtrService } from '@kbn/test';
import request from 'superagent';
import type { IEsSearchResponse } from '@kbn/search-types';
import { ELASTIC_HTTP_VERSION_HEADER } from '@kbn/core-http-common';
import { SupertestWithoutAuthProviderType } from '@kbn/ftr-common-functional-services';
import { FtrProviderContext } from '../../functional/ftr_provider_context';

const parseBfetchResponse = (resp: request.Response): Array<Record<string, any>> => {
return resp.text
.trim()
.split('\n')
.map((item) => JSON.parse(item));
};

export interface SendOptions {
supertestWithoutAuth: SupertestWithoutAuthProviderType;
apiKeyHeader: { Authorization: string };
Expand Down Expand Up @@ -108,11 +100,10 @@ export class SearchSecureService extends GenericFtrService<FtrProviderContext> {
.set('kbn-xsrf', 'true')
.set('x-elastic-internal-origin', 'Kibana')
.set(ELASTIC_HTTP_VERSION_HEADER, '1')
.send()
.send(options)
.expect(200);
const [parsedResponse] = parseBfetchResponse(resp);
expect(parsedResponse.result.isRunning).equal(false);
return parsedResponse.result;
expect(resp.body.isRunning).equal(false);
return resp.body;
});

return result as T;
Expand Down

0 comments on commit 116cd9d

Please sign in to comment.