Skip to content

Commit

Permalink
Merge branch 'main' into migrations/security_solution-timelines
Browse files Browse the repository at this point in the history
  • Loading branch information
wayneseymour authored Nov 3, 2022
2 parents a41bd94 + 1a1ee54 commit b8abedf
Show file tree
Hide file tree
Showing 43 changed files with 1,804 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const journey = new Journey({
await page.waitForSelector('#dashboardListingHeading');
})

.step('Go to Ecommerce Dashboard with Saved Search only', async ({ page }) => {
.step('Go to Ecommerce Dashboard with Saved Search only', async ({ page, log }) => {
await page.click(subj('dashboardListingTitleLink-[eCommerce]-Saved-Search-Dashboard'));
await waitForVisualizations(page, 1);
await waitForVisualizations(page, log, 1);
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const journey = new Journey({
await page.waitForSelector('#dashboardListingHeading');
})

.step('Go to Ecommerce Dashboard with TSVB Gauge only', async ({ page }) => {
.step('Go to Ecommerce Dashboard with TSVB Gauge only', async ({ page, log }) => {
await page.click(subj('dashboardListingTitleLink-[eCommerce]-TSVB-Gauge-Only-Dashboard'));
await waitForVisualizations(page, 1);
await waitForVisualizations(page, log, 1);
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { GetCategoriesResponse } from '../types';
export function useCategories(prerelease?: boolean) {
const [data, setData] = useState<GetCategoriesResponse | undefined>();
const [error, setError] = useState<RequestError | undefined>();
const [isLoading, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [isPrereleaseEnabled, setIsPrereleaseEnabled] = useState(prerelease);

const fetchData = useCallback(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type { GetPackagesResponse } from '../types';
export function usePackages(prerelease?: boolean) {
const [data, setData] = useState<GetPackagesResponse | undefined>();
const [error, setError] = useState<RequestError | undefined>();
const [isLoading, setIsLoading] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [isPrereleaseEnabled, setIsPrereleaseEnabled] = useState(prerelease);

const fetchData = useCallback(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import type { Observable } from 'rxjs';
import type { CoreTheme, OverlayStart } from '@kbn/core/public';
import { css } from '@emotion/react';
import { numberValidator } from '@kbn/ml-agg-utils';
import { isCloud } from '../../services/ml_server_info';
import { composeValidators, requiredValidator } from '../../../../common/util/validators';

interface StartDeploymentSetup {
Expand Down Expand Up @@ -224,30 +223,6 @@ export const StartDeploymentModal: FC<StartDeploymentModalProps> = ({
</EuiModalHeader>

<EuiModalBody>
{isCloud() ? (
<>
<EuiCallOut
size={'s'}
title={
<FormattedMessage
id="xpack.ml.trainedModels.modelsList.startDeployment.cloudWarningHeader"
defaultMessage="In the future Cloud deployments will autoscale to have the required number of processors."
/>
}
iconType="iInCircle"
color={'warning'}
>
<p>
<FormattedMessage
id="xpack.ml.trainedModels.modelsList.startDeployment.cloudWarningText"
defaultMessage="However, in this release you must increase the size of your ML nodes manually in the Cloud console to get more processors."
/>
</p>
</EuiCallOut>
<EuiSpacer size={'m'} />
</>
) : null}

<EuiCallOut
size={'s'}
title={
Expand Down
27 changes: 27 additions & 0 deletions x-pack/plugins/task_manager/server/lib/adhoc_task_counter.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { AdHocTaskCounter } from './adhoc_task_counter';

describe('AdHocTaskCounter', () => {
const counter = new AdHocTaskCounter();

afterAll(() => {
counter.reset();
});

it('increments counter', async () => {
counter.increment(10);
await expect(counter.count).toEqual(10);
});

it('resets counter', async () => {
counter.increment(10);
counter.reset();
await expect(counter.count).toEqual(0);
});
});
36 changes: 36 additions & 0 deletions x-pack/plugins/task_manager/server/lib/adhoc_task_counter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

/**
* Keeps track of how many tasks have been created.
*
* @export
* @class AdHocTaskCounter
*
*/
export class AdHocTaskCounter {
/**
* Gets the number of created tasks.
*/
public get count() {
return this._count;
}

private _count: number;

constructor() {
this._count = 0;
}

public increment(by: number = 1) {
this._count += by;
}

public reset() {
this._count = 0;
}
}
39 changes: 39 additions & 0 deletions x-pack/plugins/task_manager/server/lib/intervals.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
secondsFromDate,
asInterval,
maxIntervalFromDate,
parseIntervalAsMinute,
} from './intervals';

let fakeTimer: sinon.SinonFakeTimers;
Expand Down Expand Up @@ -65,6 +66,44 @@ describe('taskIntervals', () => {
});
});

describe('parseIntervalAsMinute', () => {
test('it accepts intervals in the form `Nm`', () => {
expect(() => parseIntervalAsMinute(`${_.random(1, 1000)}m`)).not.toThrow();
});

test('it accepts intervals in the form `Ns`', () => {
expect(() => parseIntervalAsMinute(`${_.random(1, 1000)}s`)).not.toThrow();
});

test('it rejects 0 based intervals', () => {
expect(() => parseIntervalAsMinute('0m')).toThrow(
/Invalid interval "0m"\. Intervals must be of the form {number}m. Example: 5m/
);
expect(() => parseIntervalAsMinute('0s')).toThrow(
/Invalid interval "0s"\. Intervals must be of the form {number}m. Example: 5m/
);
});

test('it rejects intervals are not of the form `Nm` or `Ns`', () => {
expect(() => parseIntervalAsMinute(`5m 2s`)).toThrow(
/Invalid interval "5m 2s"\. Intervals must be of the form {number}m. Example: 5m/
);
expect(() => parseIntervalAsMinute(`hello`)).toThrow(
/Invalid interval "hello"\. Intervals must be of the form {number}m. Example: 5m/
);
});

test('returns an interval as m', () => {
expect(parseIntervalAsMinute('5s')).toEqual(5 / 60);
expect(parseIntervalAsMinute('15s')).toEqual(15 / 60);
expect(parseIntervalAsMinute('20m')).toEqual(20);
expect(parseIntervalAsMinute('61m')).toEqual(61);
expect(parseIntervalAsMinute('90m')).toEqual(90);
expect(parseIntervalAsMinute('2h')).toEqual(2 * 60);
expect(parseIntervalAsMinute('9d')).toEqual(9 * 60 * 24);
});
});

describe('parseIntervalAsMillisecond', () => {
test('it accepts intervals in the form `Nm`', () => {
expect(() => parseIntervalAsMillisecond(`${_.random(1, 1000)}m`)).not.toThrow();
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugins/task_manager/server/lib/intervals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ export const parseIntervalAsSecond = memoize((interval: Interval): number => {
return Math.round(parseIntervalAsMillisecond(interval) / 1000);
});

export const parseIntervalAsMinute = memoize((interval: Interval): number => {
return parseIntervalAsMillisecond(interval) / (1000 * 60);
});

export const parseIntervalAsMillisecond = memoize((interval: Interval): number => {
const numericAsStr: string = interval.slice(0, -1);
const numeric: number = parseInt(numericAsStr, 10);
Expand Down
Loading

0 comments on commit b8abedf

Please sign in to comment.