-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Fleet] fix index pattern recreation when removing experimental packages #81940
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
neptunian
merged 1 commit into
elastic:master
from
neptunian:80032-fix-index-pattern-experimental-packages
Oct 29, 2020
Merged
Changes from all commits
Commits
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
106 changes: 106 additions & 0 deletions
106
x-pack/test/ingest_manager_api_integration/apis/epm/install_remove_multiple.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,106 @@ | ||
| /* | ||
| * 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 expect from '@kbn/expect'; | ||
| import { FtrProviderContext } from '../../../api_integration/ftr_provider_context'; | ||
| import { skipIfNoDockerRegistry } from '../../helpers'; | ||
|
|
||
| export default function (providerContext: FtrProviderContext) { | ||
| const { getService } = providerContext; | ||
| const kibanaServer = getService('kibanaServer'); | ||
| const supertest = getService('supertest'); | ||
| const dockerServers = getService('dockerServers'); | ||
| const server = dockerServers.get('registry'); | ||
| const pkgName = 'all_assets'; | ||
| const pkgVersion = '0.1.0'; | ||
| const pkgKey = `${pkgName}-${pkgVersion}`; | ||
| const experimentalPkgName = 'experimental'; | ||
| const experimentalPkgKey = `${experimentalPkgName}-${pkgVersion}`; | ||
| const experimental2PkgName = 'experimental2'; | ||
| const experimental2PkgKey = `${experimental2PkgName}-${pkgVersion}`; | ||
|
|
||
| const uninstallPackage = async (pkg: string) => { | ||
| await supertest.delete(`/api/fleet/epm/packages/${pkg}`).set('kbn-xsrf', 'xxxx'); | ||
| }; | ||
| const installPackage = async (pkg: string) => { | ||
| await supertest | ||
| .post(`/api/fleet/epm/packages/${pkg}`) | ||
| .set('kbn-xsrf', 'xxxx') | ||
| .send({ force: true }); | ||
| }; | ||
|
|
||
| const installPackages = async (pkgs: string[]) => { | ||
| const installingPackagesPromise = pkgs.map((pkg) => installPackage(pkg)); | ||
| return Promise.all(installingPackagesPromise); | ||
| }; | ||
| const uninstallPackages = async (pkgs: string[]) => { | ||
| const uninstallingPackagesPromise = pkgs.map((pkg) => uninstallPackage(pkg)); | ||
| return Promise.all(uninstallingPackagesPromise); | ||
| }; | ||
| const expectPkgFieldToExist = async ( | ||
| fields: any[], | ||
| fieldName: string, | ||
| exists: boolean = true | ||
| ) => { | ||
| const fieldExists = fields.find((field: { name: string }) => field.name === fieldName); | ||
| if (exists) { | ||
| expect(fieldExists).not.to.be(undefined); | ||
| } else { | ||
| expect(fieldExists).to.be(undefined); | ||
| } | ||
| }; | ||
| describe('installs and uninstalls multiple packages side effects', async () => { | ||
| skipIfNoDockerRegistry(providerContext); | ||
| before(async () => { | ||
| if (!server.enabled) return; | ||
| await installPackages([pkgKey, experimentalPkgKey, experimental2PkgKey]); | ||
| }); | ||
| after(async () => { | ||
| if (!server.enabled) return; | ||
| await uninstallPackages([pkgKey, experimentalPkgKey, experimental2PkgKey]); | ||
| }); | ||
| it('should create index patterns from all installed packages, experimental or beta', async () => { | ||
| const resIndexPatternLogs = await kibanaServer.savedObjects.get({ | ||
| type: 'index-pattern', | ||
| id: 'logs-*', | ||
| }); | ||
|
|
||
| const fieldsLogs = JSON.parse(resIndexPatternLogs.attributes.fields); | ||
|
|
||
| expectPkgFieldToExist(fieldsLogs, 'logs_test_name'); | ||
| expectPkgFieldToExist(fieldsLogs, 'logs_experimental_name'); | ||
| expectPkgFieldToExist(fieldsLogs, 'logs_experimental2_name'); | ||
| const resIndexPatternMetrics = await kibanaServer.savedObjects.get({ | ||
| type: 'index-pattern', | ||
| id: 'metrics-*', | ||
| }); | ||
| const fieldsMetrics = JSON.parse(resIndexPatternMetrics.attributes.fields); | ||
| expectPkgFieldToExist(fieldsMetrics, 'metrics_test_name'); | ||
| expectPkgFieldToExist(fieldsMetrics, 'metrics_experimental_name'); | ||
| expectPkgFieldToExist(fieldsMetrics, 'metrics_experimental2_name'); | ||
| }); | ||
| it('should correctly recreate index patterns when a package is uninstalled', async () => { | ||
| await uninstallPackage(experimental2PkgKey); | ||
| const resIndexPatternLogs = await kibanaServer.savedObjects.get({ | ||
| type: 'index-pattern', | ||
| id: 'logs-*', | ||
| }); | ||
| const fields = JSON.parse(resIndexPatternLogs.attributes.fields); | ||
| expectPkgFieldToExist(fields, 'logs_test_name'); | ||
| expectPkgFieldToExist(fields, 'logs_experimental_name'); | ||
| expectPkgFieldToExist(fields, 'logs_experimental2_name', false); | ||
| const resIndexPatternMetrics = await kibanaServer.savedObjects.get({ | ||
| type: 'index-pattern', | ||
| id: 'metrics-*', | ||
| }); | ||
| const fieldsMetrics = JSON.parse(resIndexPatternMetrics.attributes.fields); | ||
|
|
||
| expectPkgFieldToExist(fieldsMetrics, 'metrics_test_name'); | ||
| expectPkgFieldToExist(fieldsMetrics, 'metrics_experimental_name'); | ||
| expectPkgFieldToExist(fieldsMetrics, 'metrics_experimental2_name', false); | ||
| }); | ||
| }); | ||
| } |
3 changes: 3 additions & 0 deletions
3
...ation/apis/fixtures/test_packages/experimental/0.1.0/data_stream/test_logs/fields/ecs.yml
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,3 @@ | ||
| - name: logs_experimental_name | ||
| title: logs_experimental_title | ||
| type: keyword |
16 changes: 16 additions & 0 deletions
16
...on/apis/fixtures/test_packages/experimental/0.1.0/data_stream/test_logs/fields/fields.yml
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,16 @@ | ||
| - name: data_stream.type | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream type. | ||
| - name: data_stream.dataset | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream dataset. | ||
| - name: data_stream.namespace | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream namespace. | ||
| - name: '@timestamp' | ||
| type: date | ||
| description: > | ||
| Event timestamp. |
9 changes: 9 additions & 0 deletions
9
...gration/apis/fixtures/test_packages/experimental/0.1.0/data_stream/test_logs/manifest.yml
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,9 @@ | ||
| title: Test Dataset | ||
|
|
||
| type: logs | ||
|
|
||
| elasticsearch: | ||
| index_template.mappings: | ||
| dynamic: false | ||
| index_template.settings: | ||
| index.lifecycle.name: reference |
3 changes: 3 additions & 0 deletions
3
...on/apis/fixtures/test_packages/experimental/0.1.0/data_stream/test_metrics/fields/ecs.yml
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,3 @@ | ||
| - name: metrics_experimental_name | ||
| title: metrics_experimental_title | ||
| type: keyword |
16 changes: 16 additions & 0 deletions
16
...apis/fixtures/test_packages/experimental/0.1.0/data_stream/test_metrics/fields/fields.yml
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,16 @@ | ||
| - name: data_stream.type | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream type. | ||
| - name: data_stream.dataset | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream dataset. | ||
| - name: data_stream.namespace | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream namespace. | ||
| - name: '@timestamp' | ||
| type: date | ||
| description: > | ||
| Event timestamp. |
3 changes: 3 additions & 0 deletions
3
...tion/apis/fixtures/test_packages/experimental/0.1.0/data_stream/test_metrics/manifest.yml
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,3 @@ | ||
| title: Test Dataset | ||
|
|
||
| type: metrics |
3 changes: 3 additions & 0 deletions
3
...r_api_integration/apis/fixtures/test_packages/experimental/0.1.0/docs/README.md
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,3 @@ | ||
| # Test package | ||
|
|
||
| For testing side effects when installing and removing multiple packages |
7 changes: 7 additions & 0 deletions
7
.../apis/fixtures/test_packages/experimental/0.1.0/img/logo_overrides_64_color.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions
20
...ngest_manager_api_integration/apis/fixtures/test_packages/experimental/0.1.0/manifest.yml
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,20 @@ | ||
| format_version: 1.0.0 | ||
| name: experimental | ||
| title: experimental integration | ||
| description: This is a test package for testing experimental packages | ||
| version: 0.1.0 | ||
| categories: [] | ||
| release: experimental | ||
| type: integration | ||
| license: basic | ||
|
|
||
| requirement: | ||
| elasticsearch: | ||
| versions: '>7.7.0' | ||
| kibana: | ||
| versions: '>7.7.0' | ||
|
|
||
| icons: | ||
| - src: '/img/logo_overrides_64_color.svg' | ||
| size: '16x16' | ||
| type: 'image/svg+xml' |
3 changes: 3 additions & 0 deletions
3
...tion/apis/fixtures/test_packages/experimental2/0.1.0/data_stream/test_logs/fields/ecs.yml
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,3 @@ | ||
| - name: logs_experimental2_name | ||
| title: logs_experimental2_title | ||
| type: keyword |
16 changes: 16 additions & 0 deletions
16
...n/apis/fixtures/test_packages/experimental2/0.1.0/data_stream/test_logs/fields/fields.yml
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,16 @@ | ||
| - name: data_stream.type | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream type. | ||
| - name: data_stream.dataset | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream dataset. | ||
| - name: data_stream.namespace | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream namespace. | ||
| - name: '@timestamp' | ||
| type: date | ||
| description: > | ||
| Event timestamp. |
9 changes: 9 additions & 0 deletions
9
...ration/apis/fixtures/test_packages/experimental2/0.1.0/data_stream/test_logs/manifest.yml
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,9 @@ | ||
| title: Test Dataset | ||
|
|
||
| type: logs | ||
|
|
||
| elasticsearch: | ||
| index_template.mappings: | ||
| dynamic: false | ||
| index_template.settings: | ||
| index.lifecycle.name: reference |
3 changes: 3 additions & 0 deletions
3
...n/apis/fixtures/test_packages/experimental2/0.1.0/data_stream/test_metrics/fields/ecs.yml
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,3 @@ | ||
| - name: metrics_experimental2_name | ||
| title: metrics_experimental2_title | ||
| type: keyword |
16 changes: 16 additions & 0 deletions
16
...pis/fixtures/test_packages/experimental2/0.1.0/data_stream/test_metrics/fields/fields.yml
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,16 @@ | ||
| - name: data_stream.type | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream type. | ||
| - name: data_stream.dataset | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream dataset. | ||
| - name: data_stream.namespace | ||
| type: constant_keyword | ||
| description: > | ||
| Data stream namespace. | ||
| - name: '@timestamp' | ||
| type: date | ||
| description: > | ||
| Event timestamp. |
3 changes: 3 additions & 0 deletions
3
...ion/apis/fixtures/test_packages/experimental2/0.1.0/data_stream/test_metrics/manifest.yml
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,3 @@ | ||
| title: Test Dataset | ||
|
|
||
| type: metrics |
3 changes: 3 additions & 0 deletions
3
..._api_integration/apis/fixtures/test_packages/experimental2/0.1.0/docs/README.md
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,3 @@ | ||
| # Test package | ||
|
|
||
| For testing side effects when installing and removing multiple packages |
7 changes: 7 additions & 0 deletions
7
...apis/fixtures/test_packages/experimental2/0.1.0/img/logo_overrides_64_color.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions
20
...gest_manager_api_integration/apis/fixtures/test_packages/experimental2/0.1.0/manifest.yml
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,20 @@ | ||
| format_version: 1.0.0 | ||
| name: experimental2 | ||
| title: experimental integration | ||
| description: This is a test package for testing experimental packages | ||
| version: 0.1.0 | ||
| categories: [] | ||
| release: experimental | ||
| type: integration | ||
| license: basic | ||
|
|
||
| requirement: | ||
| elasticsearch: | ||
| versions: '>7.7.0' | ||
| kibana: | ||
| versions: '>7.7.0' | ||
|
|
||
| icons: | ||
| - src: '/img/logo_overrides_64_color.svg' | ||
| size: '16x16' | ||
| type: 'image/svg+xml' |
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.
Uh oh!
There was an error while loading. Please reload this page.