Skip to content

Commit

Permalink
Updating test
Browse files Browse the repository at this point in the history
  • Loading branch information
doakalexi committed Aug 1, 2024
1 parent 74bdf34 commit dd9ff57
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions x-pack/plugins/task_manager/server/lib/task_partitioner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
createDiscoveryServiceMock,
createFindSO,
} from '../kibana_discovery_service/mock_kibana_discovery_service';
import { TaskPartitioner } from './task_partitioner';
import { CACHE_INTERVAL, TaskPartitioner } from './task_partitioner';

const POD_NAME = 'test-pod';

Expand Down Expand Up @@ -79,19 +79,16 @@ describe('getPartitions()', () => {

test('correctly caches the partitions on 10 second interval ', async () => {
const taskPartitioner = new TaskPartitioner(POD_NAME, discoveryServiceMock);
await taskPartitioner.getPartitions();
jest.advanceTimersByTime(3000);
const shorterInterval = CACHE_INTERVAL / 2;

await taskPartitioner.getPartitions();
jest.advanceTimersByTime(3000);

jest.advanceTimersByTime(shorterInterval);
await taskPartitioner.getPartitions();
jest.advanceTimersByTime(3000);

jest.advanceTimersByTime(shorterInterval);
await taskPartitioner.getPartitions();
jest.advanceTimersByTime(3000);

await taskPartitioner.getPartitions();
expect(discoveryServiceMock.getActiveKibanaNodes).toHaveBeenCalledTimes(2);
});
});
2 changes: 1 addition & 1 deletion x-pack/plugins/task_manager/server/lib/task_partitioner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function range(start: number, end: number) {
}

export const MAX_PARTITIONS = 256;
const CACHE_INTERVAL = 10000;
export const CACHE_INTERVAL = 10000;

export class TaskPartitioner {
private readonly allPartitions: number[];
Expand Down

0 comments on commit dd9ff57

Please sign in to comment.