Skip to content

Commit

Permalink
[EDR Workflows] Improve on unavailable shard exception flakiness in c…
Browse files Browse the repository at this point in the history
…ypress (elastic#197864)

## Summary

The cypress task `cy.task('indexEndpointHosts')` sometimes throws
`no_shard_available_action_exception`, when transforms are stopped. This
looks like a temporary issue, and in other tests it is simply retried.

This PR adds the retry logic for this type of error, and unskips some
tests.

closes elastic#194135
closes elastic#191914

### Checklist

Delete any items that are not applicable to this PR.
- [x] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
  • Loading branch information
gergoabraham authored Oct 29, 2024
1 parent e5eb58a commit db18039
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ const loginWithoutAccess = (url: string) => {
loadPage(url);
};

// Failing: See https://github.com/elastic/kibana/issues/191914
describe.skip('Artifacts pages', { tags: ['@ess', '@serverless', '@skipInServerlessMKI'] }, () => {
describe('Artifacts pages', { tags: ['@ess', '@serverless', '@skipInServerlessMKI'] }, () => {
let endpointData: ReturnTypeFromChainable<typeof indexEndpointHosts> | undefined;

before(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ describe('Event Filters', { tags: ['@ess', '@serverless', '@skipInServerlessMKI'
removeAllArtifacts();
});

// FLAKY: https://github.com/elastic/kibana/issues/194135
describe.skip('when editing event filter value', () => {
describe('when editing event filter value', () => {
let eventFiltersMock: ArtifactsFixtureType;
beforeEach(() => {
login();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import type { KbnClient } from '@kbn/test';
import pRetry from 'p-retry';
import { kibanaPackageJson } from '@kbn/repo-info';
import type { ToolingLog } from '@kbn/tooling-log';
import {
RETRYABLE_TRANSIENT_ERRORS,
retryOnError,
} from '../../../../../common/endpoint/data_loaders/utils';
import { fetchFleetLatestAvailableAgentVersion } from '../../../../../common/endpoint/utils/fetch_fleet_version';
import { dump } from '../../../../../scripts/endpoint/common/utils';
import { STARTED_TRANSFORM_STATES } from '../../../../../common/constants';
Expand Down Expand Up @@ -158,28 +162,32 @@ const stopTransform = async (
): Promise<void> => {
log.debug(`Stopping transform id: ${transformId}`);

await esClient.transform
.stopTransform({
transform_id: `${transformId}*`,
force: true,
wait_for_completion: true,
allow_no_match: true,
})
.catch((e) => {
Error.captureStackTrace(e);
log.verbose(dump(e, 8));
throw e;
});
await retryOnError(
() =>
esClient.transform.stopTransform({
transform_id: `${transformId}*`,
force: true,
wait_for_completion: true,
allow_no_match: true,
}),
RETRYABLE_TRANSIENT_ERRORS,
log
);
};

const startTransform = async (
esClient: Client,
log: ToolingLog,
transformId: string
): Promise<void> => {
const transformsResponse = await esClient.transform.getTransformStats({
transform_id: `${transformId}*`,
});
const transformsResponse = await retryOnError(
() =>
esClient.transform.getTransformStats({
transform_id: `${transformId}*`,
}),
RETRYABLE_TRANSIENT_ERRORS,
log
);

log.verbose(
`Transform status found for [${transformId}*] returned:\n${dump(transformsResponse)}`
Expand All @@ -193,7 +201,11 @@ const startTransform = async (

log.debug(`Staring transform id: [${transform.id}]`);

return esClient.transform.startTransform({ transform_id: transform.id });
return retryOnError(
() => esClient.transform.startTransform({ transform_id: transform.id }),
RETRYABLE_TRANSIENT_ERRORS,
log
);
})
);
};
Expand Down

0 comments on commit db18039

Please sign in to comment.