-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68f7d34
commit 826299e
Showing
3 changed files
with
78 additions
and
20 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
x-pack/legacy/plugins/ml/public/services/__mocks__/ml_info_response.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"defaults": { | ||
"anomaly_detectors": { | ||
"model_memory_limit": "128mb", | ||
"categorization_examples_limit": 4, | ||
"model_snapshot_retention_days": 1 | ||
}, | ||
"datafeeds": { | ||
"scroll_size": 1000 | ||
} | ||
}, | ||
"upgrade_mode": false, | ||
"native_code": { | ||
"version": "8.0.0-SNAPSHOT", | ||
"build_hash": "4cde1d7c50fc28" | ||
}, | ||
"limits": { | ||
"max_model_memory_limit": "128mb" | ||
}, | ||
"cloudId": "cloud_message_test:ZXUtd2VzdC0yLmF3cy5jbG91ZC5lcy5pbyQ4NWQ2NjZmMzM1MGM0NjllOGMzMjQyZDc2YTdmNDU5YyQxNmI1ZDM2ZGE1Mzk0YjlkYjIyZWJlNDk1OWY1OGQzMg==" | ||
} |
57 changes: 57 additions & 0 deletions
57
x-pack/legacy/plugins/ml/public/services/ml_server_info.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
loadMlServerInfo, | ||
cloudDeploymentId, | ||
isCloud, | ||
newJobDefaults, | ||
newJobLimits, | ||
} from './ml_server_info'; | ||
import mockMlInfoResponse from './__mocks__/ml_info_response.json'; | ||
|
||
jest.mock('./ml_api_service', () => ({ | ||
ml: { | ||
mlInfo: jest.fn(() => Promise.resolve(mockMlInfoResponse)), | ||
}, | ||
})); | ||
|
||
describe('ml_server_info', () => { | ||
it('server info not loaded ', async done => { | ||
expect(isCloud()).toBe(false); | ||
expect(cloudDeploymentId()).toBe(null); | ||
|
||
// now load the info for the other tests | ||
await loadMlServerInfo(); | ||
done(); | ||
}); | ||
|
||
describe('cloud information', () => { | ||
it('can get could deployment id', () => { | ||
expect(isCloud()).toBe(true); | ||
expect(cloudDeploymentId()).toBe('85d666f3350c469e8c3242d76a7f459c'); | ||
}); | ||
}); | ||
|
||
describe('defaults', () => { | ||
it('can get defaults', () => { | ||
const defaults = newJobDefaults(); | ||
|
||
expect(defaults.anomaly_detectors.model_memory_limit).toBe('128mb'); | ||
expect(defaults.anomaly_detectors.categorization_examples_limit).toBe(4); | ||
expect(defaults.anomaly_detectors.model_snapshot_retention_days).toBe(1); | ||
expect(defaults.datafeeds.scroll_size).toBe(1000); | ||
}); | ||
}); | ||
|
||
describe('limits', () => { | ||
it('can get limits', () => { | ||
const limits = newJobLimits(); | ||
|
||
expect(limits.max_model_memory_limit).toBe('128mb'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters