Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] fix endpoint list + metadata api FTR tests #170489

Merged
merged 2 commits into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) ||
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no_shard_available_action_exception encompasses multiple status codes and sometimes can be 500 which is a bit too wide to include. just checking the message allows for a more narrow check.

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';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Endpoint package spec/unattended upgrade has been bumped from 8.12.x

export function isEndpointPackageV2(version: string) {
return semverLte(MIN_ENDPOINT_PACKAGE_V2_VERSION, version);
const parsedVersion = parseSemver(version);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We weren't catching preview versions previously meaning all preview versions were returning false.

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