Skip to content

Commit

Permalink
[8.12] [Security Solution] fix endpoint list + metadata api FTR tests (
Browse files Browse the repository at this point in the history
…#170489) (#173085)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[Security Solution] fix endpoint list + metadata api FTR tests
(#170489)](#170489)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Joey F.
Poon","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-12-11T16:59:53Z","message":"[Security
Solution] fix endpoint list + metadata api FTR tests
(#170489)","sha":"a50b97fb2382213c88f65bc7317caa792c3c0750","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","Team:Defend
Workflows","v8.12.0","v8.13.0"],"number":170489,"url":"https://github.com/elastic/kibana/pull/170489","mergeCommit":{"message":"[Security
Solution] fix endpoint list + metadata api FTR tests
(#170489)","sha":"a50b97fb2382213c88f65bc7317caa792c3c0750"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/170489","number":170489,"mergeCommit":{"message":"[Security
Solution] fix endpoint list + metadata api FTR tests
(#170489)","sha":"a50b97fb2382213c88f65bc7317caa792c3c0750"}}]}]
BACKPORT-->

Co-authored-by: Joey F. Poon <[email protected]>
  • Loading branch information
kibanamachine and joeypoon authored Dec 11, 2023
1 parent 79facce commit 5935014
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const retryResponseStatuses = [
410, // Gone
];

const retryMessages = ['no_shard_available_action_exception'];

const isRetryableError = (e: any, additionalResponseStatuses: number[] = []) =>
retryMessages.some((msg) => e.message.includes(msg)) ||
e instanceof EsErrors.NoLivingConnectionsError ||
e instanceof EsErrors.ConnectionError ||
e instanceof EsErrors.TimeoutError ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@

import semverLte from 'semver/functions/lte';

const MIN_ENDPOINT_PACKAGE_V2_VERSION = '8.12.0';
function parseSemver(semver: string) {
return semver.includes('-') ? semver.substring(0, semver.indexOf('-')) : semver;
}

const MIN_ENDPOINT_PACKAGE_V2_VERSION = '8.13.0';
export function isEndpointPackageV2(version: string) {
return semverLte(MIN_ENDPOINT_PACKAGE_V2_VERSION, version);
const parsedVersion = parseSemver(version);
return semverLte(MIN_ENDPOINT_PACKAGE_V2_VERSION, parsedVersion);
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.endpoint.navigateToEndpointList();
});

// FLAKY: https://github.com/elastic/kibana/issues/170357
describe.skip('when there is data,', () => {
describe('when there is data,', () => {
before(async () => {
indexedData = await endpointTestResources.loadEndpointData({ numHosts: 3 });
await pageObjects.endpoint.navigateToEndpointList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
);
};

describe('Response Actions Responder', function () {
// FLAKY: https://github.com/elastic/kibana/issues/153071
describe.skip('Response Actions Responder', function () {
targetTags(this, ['@ess', '@serverless']);

let indexedData: IndexedHostsAndAlertsResponse;
Expand Down
11 changes: 9 additions & 2 deletions x-pack/test/security_solution_endpoint/services/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { errors } from '@elastic/elasticsearch';
import { Client } from '@elastic/elasticsearch';
import { AGENTS_INDEX } from '@kbn/fleet-plugin/common';
import {
metadataCurrentIndexPattern,
metadataTransformPrefix,
Expand Down Expand Up @@ -94,7 +95,7 @@ export class EndpointTestResources extends FtrService {
* @param [options.enableFleetIntegration=true] When set to `true`, Fleet data will also be loaded (ex. Integration Policies, Agent Policies, "fake" Agents)
* @param [options.generatorSeed='seed`] The seed to be used by the data generator. Important in order to ensure the same data is generated on very run.
* @param [options.waitUntilTransformed=true] If set to `true`, the data loading process will wait until the endpoint hosts metadata is processed by the transform
* @param [options.waitTimeout=60000] If waitUntilTransformed=true, number of ms to wait until timeout
* @param [options.waitTimeout=120000] If waitUntilTransformed=true, number of ms to wait until timeout
* @param [options.customIndexFn] If provided, will use this function to generate and index data instead
*/
async loadEndpointData(
Expand All @@ -116,7 +117,7 @@ export class EndpointTestResources extends FtrService {
enableFleetIntegration = true,
generatorSeed = 'seed',
waitUntilTransformed = true,
waitTimeout = 60000,
waitTimeout = 120000,
customIndexFn,
} = options;

Expand Down Expand Up @@ -197,6 +198,12 @@ export class EndpointTestResources extends FtrService {

await this.retry.waitForWithTimeout(`endpoint hosts in ${index}`, timeout, async () => {
try {
if (index === METADATA_UNITED_INDEX) {
// United metadata transform occasionally can't find docs in .fleet-agents.
// Running a search on the index first eliminates this issue.
// Replacing the search with a refresh does not resolve flakiness.
await this.esClient.search({ index: AGENTS_INDEX });
}
const searchResponse = await this.esClient.search({
index,
size,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ export default function ({ getService }: FtrProviderContext) {
const endpointTestResources = getService('endpointTestResources');
const log = getService('log');

// Failing: See https://github.com/elastic/kibana/issues/151854
describe.skip('test metadata apis', function () {
describe('test metadata apis', function () {
targetTags(this, ['@ess', '@serverless']);

describe('list endpoints GET route', () => {
Expand Down

0 comments on commit 5935014

Please sign in to comment.