-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Switch Reporting to Task Manager #64853
Merged
Merged
Changes from 27 commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
d4deb04
[Reporting] Task Manager
tsullivan 4d14065
fix startup
tsullivan 5954017
use synchronous config for task registration
tsullivan c30a4a5
fix eslint
tsullivan 72a3918
Merge branch 'master' into reporting/switch-to-tm
tsullivan fff9cd2
pr-90365
tsullivan 3debc63
--wip-- [skip ci]
tsullivan c6b5b7f
Merge branch 'master' into reporting/switch-to-tm
kibanamachine 4478036
Merge branch 'reporting/switch-to-tm' of github.com:tsullivan/kibana …
tsullivan 7e7abf9
Merge branch 'master' into reporting/switch-to-tm
tsullivan f5e95e3
set maxConcurrency to 0 if pollEnabled is false
tsullivan 45c64df
add test for execute_report
tsullivan f41af01
remove unused test file
tsullivan 96afb39
more tests
tsullivan 6de9dd6
remove unused test files
tsullivan 5cdb489
remove priority
tsullivan 8d98f1c
logging cleanups
tsullivan dc466ee
fix for queue.pollEnabled: false
tsullivan b3f01bf
more logging fixes for less duplicated code
tsullivan 6a619a8
update jest snapshots
tsullivan 95f6a4e
polish
tsullivan 278268b
remove unnecessary
tsullivan f1198f3
Update mapping.ts
tsullivan 70441c1
polish
tsullivan 141ecca
fix bug if instance gets a monitoring task and pollEnabled is false
tsullivan ea66569
simplification
tsullivan 49a1478
Merge branch 'master' into reporting/switch-to-tm
kibanamachine e9dbbb1
Merge branch 'master' into reporting/switch-to-tm
tsullivan 8fc0afc
cosmetic
tsullivan aab4890
Merge branch 'master' into reporting/switch-to-tm
tsullivan 907d209
fix test
tsullivan 65d752d
stop monitoring task sabotage
tsullivan 425c623
Merge branch 'master' into reporting/switch-to-tm
tsullivan 8dbabd5
update api docs
tsullivan 2b7b49c
Merge branch 'master' into reporting/switch-to-tm
kibanamachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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,16 @@ | ||
/* | ||
* 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 moment from 'moment'; | ||
import { numberToDuration } from './schema_utils'; | ||
|
||
describe('Schema Utils', () => { | ||
it('numberToDuration converts a number/Duration into a Duration object', () => { | ||
expect(numberToDuration(500)).toMatchInlineSnapshot(`"PT0.5S"`); | ||
expect(numberToDuration(moment.duration(1, 'hour'))).toMatchInlineSnapshot(`"PT1H"`); | ||
}); | ||
}); |
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
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
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 |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
"management", | ||
"licensing", | ||
"uiActions", | ||
"taskManager", | ||
"embeddable", | ||
"share", | ||
"features" | ||
|
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
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 |
---|---|---|
|
@@ -5,47 +5,22 @@ | |
* 2.0. | ||
*/ | ||
|
||
import * as Rx from 'rxjs'; | ||
import { CoreSetup, PluginInitializerContext } from 'src/core/server'; | ||
import { coreMock } from 'src/core/server/mocks'; | ||
import { LevelLogger } from '../lib'; | ||
import { createMockConfigSchema } from '../test_helpers'; | ||
import { createConfig$ } from './create_config'; | ||
import { ReportingConfigType } from './schema'; | ||
|
||
interface KibanaServer { | ||
hostname?: string; | ||
port?: number; | ||
protocol?: string; | ||
} | ||
|
||
const makeMockInitContext = (config: { | ||
capture?: Partial<ReportingConfigType['capture']>; | ||
encryptionKey?: string; | ||
kibanaServer: Partial<ReportingConfigType['kibanaServer']>; | ||
}): PluginInitializerContext => | ||
({ | ||
config: { | ||
create: () => | ||
Rx.of({ | ||
...config, | ||
capture: config.capture || { browser: { chromium: { disableSandbox: false } } }, | ||
kibanaServer: config.kibanaServer || {}, | ||
}), | ||
}, | ||
} as PluginInitializerContext); | ||
|
||
const makeMockCoreSetup = (serverInfo: KibanaServer): CoreSetup => | ||
({ http: { getServerInfo: () => serverInfo } } as any); | ||
|
||
describe('Reporting server createConfig$', () => { | ||
let mockCoreSetup: CoreSetup; | ||
let mockInitContext: PluginInitializerContext; | ||
let mockLogger: LevelLogger; | ||
|
||
beforeEach(() => { | ||
mockCoreSetup = makeMockCoreSetup({ hostname: 'kibanaHost', port: 5601, protocol: 'http' }); | ||
mockInitContext = makeMockInitContext({ | ||
kibanaServer: {}, | ||
}); | ||
mockCoreSetup = coreMock.createSetup(); | ||
mockInitContext = coreMock.createPluginInitializerContext( | ||
createMockConfigSchema({ kibanaServer: {} }) | ||
); | ||
mockLogger = ({ | ||
warn: jest.fn(), | ||
debug: jest.fn(), | ||
|
@@ -58,14 +33,18 @@ describe('Reporting server createConfig$', () => { | |
}); | ||
|
||
it('creates random encryption key and default config using host, protocol, and port from server info', async () => { | ||
mockInitContext = coreMock.createPluginInitializerContext({ | ||
...createMockConfigSchema({ kibanaServer: {} }), | ||
encryptionKey: undefined, | ||
}); | ||
const mockConfig$: any = mockInitContext.config.create(); | ||
const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); | ||
|
||
expect(result.encryptionKey).toMatch(/\S{32,}/); // random 32 characters | ||
expect(result.kibanaServer).toMatchInlineSnapshot(` | ||
Object { | ||
"hostname": "kibanaHost", | ||
"port": 5601, | ||
"hostname": "localhost", | ||
"port": 80, | ||
"protocol": "http", | ||
} | ||
`); | ||
|
@@ -76,25 +55,28 @@ describe('Reporting server createConfig$', () => { | |
}); | ||
|
||
it('uses the user-provided encryption key', async () => { | ||
mockInitContext = makeMockInitContext({ | ||
encryptionKey: 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', | ||
kibanaServer: {}, | ||
}); | ||
mockInitContext = coreMock.createPluginInitializerContext( | ||
createMockConfigSchema({ | ||
encryptionKey: 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. iiiiiiiiiiiiiiiiiiiiii ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll move changes like this to a different PR :) Ideally this PR will just be a switchover to TM and removal of ESQueue code |
||
}) | ||
); | ||
const mockConfig$: any = mockInitContext.config.create(); | ||
const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); | ||
expect(result.encryptionKey).toMatch('iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii'); | ||
expect((mockLogger.warn as any).mock.calls.length).toBe(0); | ||
}); | ||
|
||
it('uses the user-provided encryption key, reporting kibanaServer settings to override server info', async () => { | ||
mockInitContext = makeMockInitContext({ | ||
encryptionKey: 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', | ||
kibanaServer: { | ||
hostname: 'reportingHost', | ||
port: 5677, | ||
protocol: 'httpsa', | ||
}, | ||
}); | ||
mockInitContext = coreMock.createPluginInitializerContext( | ||
createMockConfigSchema({ | ||
encryptionKey: 'iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii', | ||
kibanaServer: { | ||
hostname: 'reportingHost', | ||
port: 5677, | ||
protocol: 'httpsa', | ||
}, | ||
}) | ||
); | ||
const mockConfig$: any = mockInitContext.config.create(); | ||
const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); | ||
|
||
|
@@ -103,26 +85,36 @@ describe('Reporting server createConfig$', () => { | |
"capture": Object { | ||
"browser": Object { | ||
"chromium": Object { | ||
"disableSandbox": false, | ||
"disableSandbox": true, | ||
}, | ||
}, | ||
}, | ||
"csv": Object {}, | ||
"encryptionKey": "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii", | ||
"index": ".reporting", | ||
"kibanaServer": Object { | ||
"hostname": "reportingHost", | ||
"port": 5677, | ||
"protocol": "httpsa", | ||
}, | ||
"queue": Object { | ||
"indexInterval": "week", | ||
"pollEnabled": true, | ||
"pollInterval": 3000, | ||
"timeout": 120000, | ||
}, | ||
} | ||
`); | ||
expect((mockLogger.warn as any).mock.calls.length).toBe(0); | ||
}); | ||
|
||
it('uses user-provided disableSandbox: false', async () => { | ||
mockInitContext = makeMockInitContext({ | ||
encryptionKey: '888888888888888888888888888888888', | ||
capture: { browser: { chromium: { disableSandbox: false } } }, | ||
} as ReportingConfigType); | ||
mockInitContext = coreMock.createPluginInitializerContext( | ||
createMockConfigSchema({ | ||
encryptionKey: '888888888888888888888888888888888', | ||
capture: { browser: { chromium: { disableSandbox: false } } }, | ||
}) | ||
); | ||
const mockConfig$: any = mockInitContext.config.create(); | ||
const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); | ||
|
||
|
@@ -131,10 +123,12 @@ describe('Reporting server createConfig$', () => { | |
}); | ||
|
||
it('uses user-provided disableSandbox: true', async () => { | ||
mockInitContext = makeMockInitContext({ | ||
encryptionKey: '888888888888888888888888888888888', | ||
capture: { browser: { chromium: { disableSandbox: true } } }, | ||
} as ReportingConfigType); | ||
mockInitContext = coreMock.createPluginInitializerContext( | ||
createMockConfigSchema({ | ||
encryptionKey: '888888888888888888888888888888888', | ||
capture: { browser: { chromium: { disableSandbox: true } } }, | ||
}) | ||
); | ||
const mockConfig$: any = mockInitContext.config.create(); | ||
const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); | ||
|
||
|
@@ -143,9 +137,11 @@ describe('Reporting server createConfig$', () => { | |
}); | ||
|
||
it('provides a default for disableSandbox', async () => { | ||
mockInitContext = makeMockInitContext({ | ||
encryptionKey: '888888888888888888888888888888888', | ||
} as ReportingConfigType); | ||
mockInitContext = coreMock.createPluginInitializerContext( | ||
createMockConfigSchema({ | ||
encryptionKey: '888888888888888888888888888888888', | ||
}) | ||
); | ||
const mockConfig$: any = mockInitContext.config.create(); | ||
const result = await createConfig$(mockCoreSetup, mockConfig$, mockLogger).toPromise(); | ||
|
||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 change isn't very related to this PR, but this helper code now uses
coreMock