-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Reporting/Config] allow string representations of duration settings #74202
[Reporting/Config] allow string representations of duration settings #74202
Conversation
c0e0ff2
to
b83c5f3
Compare
b83c5f3
to
7064e7a
Compare
7064e7a
to
b7e2301
Compare
b7e2301
to
5af986a
Compare
pollEnabled: schema.boolean({ defaultValue: true }), | ||
pollInterval: schema.number({ defaultValue: 3000 }), | ||
pollIntervalErrorMultiplier: schema.number({ defaultValue: 10 }), | ||
timeout: schema.number({ defaultValue: moment.duration(2, 'm').asMilliseconds() }), | ||
timeout: schema.oneOf([schema.number(), schema.duration()], { defaultValue: 120000 }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defaultValue has to be a value that satisfies both schemas, so it must be a number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's odd, seems like it should just need to satisfy one
5af986a
to
c455384
Compare
@@ -25,7 +25,7 @@ const getCompletedItemsCount = ({ renderCompleteSelector }: SelectorArgs) => { | |||
export const waitForVisualizations = async ( | |||
captureConfig: CaptureConfig, | |||
browser: HeadlessChromiumDriver, | |||
itemsCount: number, | |||
toEqual: number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed the variable so that the code compresses better below
@@ -8,7 +8,6 @@ import moment, { unitOfTime } from 'moment'; | |||
|
|||
export const intervals = ['year', 'month', 'week', 'day', 'hour', 'minute']; | |||
|
|||
// TODO: This helper function can be removed by using `schema.duration` objects in the reporting config schema |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was not true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TERMINATED
c455384
to
0472d45
Compare
@@ -134,25 +129,12 @@ test(`uses basePath from server if job doesn't have a basePath when creating sav | |||
}); | |||
|
|||
describe('config formatting', () => { | |||
test(`lowercases server.host`, async () => { | |||
const mockConfigGet = sinon.stub().withArgs('server', 'host').returns('COOL-HOSTNAME'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test runs the same code as the "lowercase" test right below. It was only passing because of the an odd way the stub function worked.
@elasticmachine merge upstream |
f744f87
to
2fdaf88
Compare
Thanks @joelgriffith - that feedback definitely helped! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work on the schema_utils, happy it's useful!
There was a webpack issue with calling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sucks about the webpack gotcha, but still LGTM
…lastic#74202) * [Reporting/Config] use better schema methods * add createMockConfig * update documentation * fix observable.test * add docs links to common options page * make the schema match the docs * wording edits per feedback * self edits * todo comment * fix tests * feedback change 1 * schema utils * fix goof * use objects for the defaults when available * fix pollInterval * fix snapshots * Update report_listing.tsx * call new ByteSizeValue on server side only * revert xpack.reporting.poll * fix ts * fix snapshot * use correct input for duration * revert reorganize imports Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
…74202) (#77807) * [Reporting/Config] use better schema methods * add createMockConfig * update documentation * fix observable.test * add docs links to common options page * make the schema match the docs * wording edits per feedback * self edits * todo comment * fix tests * feedback change 1 * schema utils * fix goof * use objects for the defaults when available * fix pollInterval * fix snapshots * Update report_listing.tsx * call new ByteSizeValue on server side only * revert xpack.reporting.poll * fix ts * fix snapshot * use correct input for duration * revert reorganize imports Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
💔 Build Failed
Failed CI StepsTest FailuresX-Pack Endpoint Functional Tests.x-pack/test/security_solution_endpoint/apps/endpoint/policy_details·ts.endpoint When on the Endpoint Policy Details Page when on Ingest Policy Edit Package Policy page "before each" hook for "should show a link to Policy Details"Standard Out
Stack Trace
X-Pack Endpoint Functional Tests.x-pack/test/security_solution_endpoint/apps/endpoint/policy_details·ts.endpoint When on the Endpoint Policy Details Page when on Ingest Policy Edit Package Policy page "before each" hook for "should show a link to Policy Details"Standard Out
Stack Trace
Metrics [docs]@kbn/optimizer bundle module count
distributable file count
page load bundle size
History
To update your PR or re-run it, just comment with: |
Summary
Goal: as part of instrumenting Reporting with Task Manager, we want a seamless way to pass our config values (milliseconds) to Task Manager (requires "time unit string").
This PR expands the allowed value types for millisecond values in Reporting config to allow either milliseconds or time units. Additionally, byte size values can now be number of bytes or "bytes unit string" (for example, "12mb").
Time units: https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units
Byte size units: https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#byte-units
The original value types were limited to
number
(milliseconds for duration, and number of bytes for byte size). Those values are still valid, which makes this not a breaking change.The changes impacted a lot of unit tests that were going about mocking the config in a very casual way. I added a helper function that creates mock configs that have a valid schema.
For maintainers
Release Note
Reporting configuration settings for time duration values allow "time unit" strings to be specified as well as number of milliseconds. For byte size values, "byte size" strings are allowed as well as number of bytes. See the Reporting configuration documentation for more details.