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

[8.16] [EDR Workflows] Improve on unavailable shard exception flakiness in cypress (#197864) #198137

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -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 @@ -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