Fix missing params from search strategy polling requests causing validation 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)
This commit is contained in:
Davis McPhee 2024-11-08 17:34:35 -04:00 committed by GitHub
parent 0ee022eb80
commit 116cd9d170
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 9 additions and 44 deletions

View file

@ -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;

View file

@ -1,15 +0,0 @@
/*
* 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; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import request from 'superagent';
export function parseBfetchResponse(resp: request.Response): Array<Record<string, any>> {
return resp.text
.trim()
.split('\n')
.map((item) => JSON.parse(item));
}

View file

@ -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}` : ``;
};
@ -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;

View file

@ -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', () => {

View file

@ -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', () => {

View file

@ -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 };
@ -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;