-
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
Support for reindexing APM indices #29845
Merged
Merged
Changes from 1 commit
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
3be93b3
Support for reindexing APM indices
5158de9
Merge remote-tracking branch 'upstream/master' into apm-reindexing-7.0
ede668c
Fix types
c4c6a6e
Merge remote-tracking branch 'upstream/master' into apm-reindexing-7.0
28a4bd5
Fixes
d4f52ec
Fix tests
3f3126e
Update types
96f6f58
Updates messaging
03a6812
Merge remote-tracking branch 'upstream/master' into apm-reindexing-7.0
1d2d9b8
Merge remote-tracking branch 'upstream/master' into apm-reindexing-7.0
4d6af88
Updates APM reindex script/mapping
5895998
Merge remote-tracking branch 'upstream/master' into apm-reindexing-7.0
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export interface ApmOssPlugin { | ||
indexPatterns: string[]; | ||
} |
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
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 |
---|---|---|
|
@@ -49,4 +49,5 @@ export enum ReindexWarning { | |
booleanFields = 1, | ||
|
||
// 7.0 -> 8.0 warnings | ||
apmReindex, | ||
} |
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
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
117 changes: 117 additions & 0 deletions
117
x-pack/plugins/upgrade_assistant/server/lib/apm/index.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,117 @@ | ||
/* | ||
* 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 { getDeprecatedApmIndices, isLegacyApmIndex } from './'; | ||
|
||
function mockedCallWithRequest() { | ||
return jest.fn().mockImplementation(async () => { | ||
return { | ||
'foo-1': { | ||
mappings: {}, | ||
}, | ||
'foo-2': { | ||
mappings: { | ||
_meta: { | ||
version: '6.7.0', | ||
}, | ||
}, | ||
}, | ||
'foo-3': { | ||
mappings: { | ||
_meta: { | ||
version: '7.0.0', | ||
}, | ||
}, | ||
}, | ||
'foo-4': { | ||
mappings: { | ||
_meta: { | ||
version: '7.1.0', | ||
}, | ||
}, | ||
}, | ||
}; | ||
}); | ||
} | ||
|
||
describe('getDeprecatedApmIndices', () => { | ||
it('calls indices.getMapping', async () => { | ||
const callWithRequest = mockedCallWithRequest(); | ||
await getDeprecatedApmIndices(callWithRequest, {} as any, ['foo-*', 'bar-*']); | ||
|
||
expect(callWithRequest).toHaveBeenCalledWith({}, 'indices.getMapping', { | ||
index: 'foo-*,bar-*', | ||
filterPath: '*.mappings._meta.version,*.mappings.properties.@timestamp', | ||
}); | ||
}); | ||
|
||
it('includes mappings not yet at 7.0.0', async () => { | ||
const callWithRequest = mockedCallWithRequest(); | ||
const deprecations = await getDeprecatedApmIndices(callWithRequest, {} as any, ['foo-*']); | ||
|
||
expect(deprecations).toHaveLength(2); | ||
expect(deprecations[0].index).toEqual('foo-1'); | ||
expect(deprecations[1].index).toEqual('foo-2'); | ||
}); | ||
|
||
it('formats the deprecations', async () => { | ||
const callWithRequest = mockedCallWithRequest(); | ||
// @ts-ignore | ||
const [deprecation, _] = await getDeprecatedApmIndices(callWithRequest, {} as any, ['foo-*']); | ||
|
||
expect(deprecation.level).toEqual('critical'); | ||
expect(deprecation.message).toEqual('APM index needs converted to ECS format'); | ||
expect(deprecation.url).toEqual( | ||
'https://www.elastic.co/guide/en/apm/server/master/breaking-changes.html' | ||
); | ||
expect(deprecation.details).toEqual('This index was created prior to 7.0.'); | ||
expect(deprecation.reindex).toBe(true); | ||
}); | ||
}); | ||
|
||
describe.only('isLegacyApmIndex', () => { | ||
tylersmalley marked this conversation as resolved.
Show resolved
Hide resolved
|
||
it('is true when for no version', () => { | ||
expect(isLegacyApmIndex('foo-1', ['foo-*'], {})).toEqual(true); | ||
}); | ||
|
||
it('is true when version is less than 7.0.0', () => { | ||
expect( | ||
isLegacyApmIndex('foo-1', ['foo-*'], { | ||
_meta: { version: '6.7.0' }, | ||
}) | ||
).toEqual(true); | ||
}); | ||
|
||
it('is false when version is 7.0.0', () => { | ||
expect( | ||
isLegacyApmIndex('foo-1', ['foo-*'], { | ||
_meta: { version: '7.0.0' }, | ||
}) | ||
).toEqual(false); | ||
}); | ||
|
||
it('is false when version is greater than 7.0.0', () => { | ||
expect( | ||
isLegacyApmIndex('foo-1', ['foo-*'], { | ||
_meta: { version: '7.1.0' }, | ||
}) | ||
).toEqual(false); | ||
}); | ||
|
||
it('handles multiple index patterns', () => { | ||
expect( | ||
isLegacyApmIndex('bar-1', ['foo-*', 'bar-*'], { | ||
_meta: { version: '6.7.0' }, | ||
}) | ||
).toEqual(true); | ||
|
||
expect( | ||
isLegacyApmIndex('bar-1', ['foo-*', 'bar-*'], { | ||
_meta: { version: '7.0.0' }, | ||
}) | ||
).toEqual(false); | ||
}); | ||
}); |
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 was missing.