Skip to content

Commit

Permalink
rename arg in retry service to testFn
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko committed Aug 26, 2024
1 parent 2bed553 commit 3b98c57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions x-pack/test/alerting_api_integration/common/retry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { ToolingLog } from '@kbn/tooling-log';
* Example usage:
* ```ts
const fleetResponse = await retry<InstallPackageResponse>({
test: async () => {
testFn: async () => {
const testResponse = await supertest
.post(`/api/fleet/epm/packages/security_detection_engine`)
.set('kbn-xsrf', 'xxxx')
Expand All @@ -45,15 +45,15 @@ import type { ToolingLog } from '@kbn/tooling-log';
* @returns The response from the test
*/
export const retry = async <T>({
test,
testFn,
retryService,
utilityName,
retries = 3,
timeout = 30000,
retryDelay = 200,
logger,
}: {
test: () => Promise<T>;
testFn: () => Promise<T>;
utilityName: string;
retryService: RetryService;
retries?: number;
Expand All @@ -77,8 +77,7 @@ export const retry = async <T>({

retryAttempt = retryAttempt + 1;

// eslint-disable-next-line mocha/no-empty-description
return await test();
return await testFn();
},
undefined,
retryDelay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export async function waitForRuleStatus({
logger: ToolingLog;
}): Promise<Record<string, any>> {
const ruleResponse = await retry<Record<string, any>>({
test: async () => {
testFn: async () => {
const response = await supertest.get(`/api/alerting/rule/${id}`);
const { execution_status: executionStatus } = response.body || {};
const { status } = executionStatus || {};
Expand Down Expand Up @@ -74,7 +74,7 @@ export async function waitForDocumentInIndex<T>({
retryDelay?: number;
}): Promise<SearchResponse<T, Record<string, AggregationsAggregate>>> {
return await retry<SearchResponse<T, Record<string, AggregationsAggregate>>>({
test: async () => {
testFn: async () => {
const response = await esClient.search<T>({
index: indexName,
rest_total_hits_as_int: true,
Expand Down Expand Up @@ -112,7 +112,7 @@ export async function waitForAlertInIndex<T>({
logger: ToolingLog;
}): Promise<SearchResponse<T, Record<string, AggregationsAggregate>>> {
return await retry<SearchResponse<T, Record<string, AggregationsAggregate>>>({
test: async () => {
testFn: async () => {
const response = await esClient.search<T>({
index: indexName,
body: {
Expand Down

0 comments on commit 3b98c57

Please sign in to comment.