-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Beats Management] add more tests, update types, break out ES into it's own adapter #20566
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
Merged
mattapperson
merged 24 commits into
elastic:feature/x-pack/management/beats
from
mattapperson:beats-cm-add-more-tests
Jul 12, 2018
Merged
Changes from 14 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
36fef75
inital effort to move to JWT and added jest based tests on libs
mattapperson aac4632
assign beats tests all passing
mattapperson 9acb876
token tests now pass
mattapperson dd634b9
add more tests
mattapperson de2c4cc
all tests now green
mattapperson 7c3c53a
move enrollment token back to a hash
mattapperson 480fae5
remove un-needed comment
mattapperson 03544e3
alias lodash get to avoid confusion
mattapperson 3a7bdac
isolated hash creation
mattapperson 5575ab5
Add initial efforts for backend framework adapter testing
mattapperson f17046e
move ES code to a DatabaseAdapter from BackendAdapter and add a TON o…
mattapperson d328dd3
re-typed
mattapperson d169319
renamed types to match pattern
mattapperson e430b44
aditional renames
mattapperson 6334d76
adapter tests should always just use adapterSetup();
mattapperson 95e5764
database now uses InternalRequest
mattapperson 06568ca
corrected spelling of framework
mattapperson b7dc1e7
fix typings
mattapperson 0b42c23
remove CRUFT
mattapperson 69a2439
RequestOrInternal
mattapperson cfbc1a1
Dont pass around request objects everywhere, just pass the user. Also…
mattapperson 8533c1b
fix tests, add test, removed extra comment
mattapperson ab88e51
fix auth
mattapperson ea26917
updated lock file
mattapperson 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 hidden or 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,31 @@ | ||
| /* | ||
| * 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 { ConfigurationBlockTypes } from './constants'; | ||
|
|
||
| export interface ConfigurationBlock { | ||
| type: ConfigurationBlockTypes; | ||
| block_yml: string; | ||
| } | ||
|
|
||
| export interface CMBeat { | ||
| id: string; | ||
| access_token: string; | ||
| verified_on?: string; | ||
| type: string; | ||
| version?: string; | ||
| host_ip: string; | ||
| host_name: string; | ||
| ephemeral_id?: string; | ||
| local_configuration_yml?: string; | ||
| tags?: string[]; | ||
| central_configuration_yml?: string; | ||
| metadata?: {}; | ||
| } | ||
|
|
||
| export interface BeatTag { | ||
| id: string; | ||
| configuration_blocks: ConfigurationBlock[]; | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| # Documentation for Beats CM in x-pack kibana | ||
|
|
||
| ### Run tests | ||
| ### Run tests (from x-pack dir) | ||
|
|
||
| Functional tests | ||
|
|
||
| ``` | ||
| node scripts/jest.js plugins/beats --watch | ||
| ``` | ||
|
|
||
| Functional API tests | ||
|
|
||
| ``` | ||
| node scripts/functional_tests --config test/api_integration/config | ||
| ``` |
45 changes: 45 additions & 0 deletions
45
x-pack/plugins/beats/server/lib/adapters/beats/adapter_types.ts
This file contains hidden or 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,45 @@ | ||
| /* | ||
| * 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 { CMBeat } from '../../../../common/domain_types'; | ||
| import { FrameworkRequest } from '../famework/adapter_types'; | ||
|
|
||
| // FIXME: fix getBeatsWithIds return type | ||
| export interface CMBeatsAdapter { | ||
| insert(beat: CMBeat): Promise<void>; | ||
| update(beat: CMBeat): Promise<void>; | ||
| get(id: string): any; | ||
| getAll(req: FrameworkRequest): any; | ||
| getWithIds(req: FrameworkRequest, beatIds: string[]): any; | ||
| verifyBeats(req: FrameworkRequest, beatIds: string[]): any; | ||
| removeTagsFromBeats( | ||
| req: FrameworkRequest, | ||
| removals: BeatsTagAssignment[] | ||
| ): Promise<BeatsTagAssignment[]>; | ||
| assignTagsToBeats( | ||
| req: FrameworkRequest, | ||
| assignments: BeatsTagAssignment[] | ||
| ): Promise<BeatsTagAssignment[]>; | ||
| } | ||
|
|
||
| export interface BeatsTagAssignment { | ||
| beatId: string; | ||
| tag: string; | ||
| idxInRequest?: number; | ||
| } | ||
|
|
||
| interface BeatsReturnedTagAssignment { | ||
| status: number | null; | ||
| result?: string; | ||
| } | ||
|
|
||
| export interface CMAssignmentReturn { | ||
| assignments: BeatsReturnedTagAssignment[]; | ||
| } | ||
|
|
||
| export interface BeatsRemovalReturn { | ||
| removals: BeatsReturnedTagAssignment[]; | ||
| } |
This file contains hidden or 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 hidden or 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
34 changes: 34 additions & 0 deletions
34
x-pack/plugins/beats/server/lib/adapters/database/__tests__/kibana.test.ts
This file contains hidden or 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,34 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
| // file.skip | ||
|
|
||
| // @ts-ignore | ||
| import { createEsTestCluster } from '@kbn/test'; | ||
| // @ts-ignore | ||
| import * as kbnTestServer from '../../../../../../../../src/test_utils/kbn_server'; | ||
| import { DatabaseKbnESPlugin } from '../adapter_types'; | ||
| import { KibanaDatabaseAdapter } from '../kibana_database_adapter'; | ||
| import { contractTests } from './test_contract'; | ||
|
|
||
| const kbnServer = kbnTestServer.createServerWithCorePlugins(); | ||
| const es = createEsTestCluster({}); | ||
|
|
||
| contractTests('Kibana Database Adapter', { | ||
| before: async () => { | ||
| await es.start(); | ||
| await kbnServer.ready(); | ||
|
|
||
| return await kbnServer.server.plugins.elasticsearch.waitUntilReady(); | ||
| }, | ||
| after: async () => { | ||
| await kbnServer.close(); | ||
| return await es.cleanup(); | ||
| }, | ||
| adapterSetup: () => { | ||
| return new KibanaDatabaseAdapter(kbnServer.server.plugins | ||
| .elasticsearch as DatabaseKbnESPlugin); | ||
| }, | ||
| }); | ||
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.
It could be problematic to use this api here, because it might not honor the user's selection of the source to obtain Elasticsearch from (snapshot, source, etc) as our test runner usually do. That will probably lead to problems on our CI systems as well. I would recommend to talk to the @elastic/kibana-platform team to integrate it properly into the test runner.
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.
Per kibana-platform, this should be fine as-is as it uses process.env.TEST_ES_FROM internally.
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.
interesting, thanks for clarifying that