generated from amazon-archives/__template_Custom
-
Couldn't load subscription status.
- Fork 130
[Feature] Supporting Exclusion pattern in index pattern in ISM #1509
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
Open
Tarun-kishore
wants to merge
7
commits into
opensearch-project:main
Choose a base branch
from
Tarun-kishore:feature/exclusion-pattern-support
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f16afb6
[Feature] Supporting Exclusion pattern in index pattern in ISM
Tarun-kishore 784023f
Updating empty check
Tarun-kishore 2737bee
Adding unit tests
Tarun-kishore cd8c447
Update src/main/kotlin/org/opensearch/indexmanagement/indexstatemanag…
Tarun-kishore 6c9438e
Fixed linting errors
Tarun-kishore 1cfb6ab
Merge branch 'main' into feature/exclusion-pattern-support
Tarun-kishore 95d2b72
Triggering CI builds
Tarun-kishore 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
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
98 changes: 98 additions & 0 deletions
98
...est/kotlin/org/opensearch/indexmanagement/indexstatemanagement/ISMTemplateServiceTests.kt
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,98 @@ | ||
| /* | ||
| * Copyright OpenSearch Contributors | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| package org.opensearch.indexmanagement.indexstatemanagement | ||
|
|
||
| import org.opensearch.indexmanagement.util.IndexManagementException | ||
| import org.opensearch.test.OpenSearchTestCase | ||
|
|
||
| class ISMTemplateServiceTests : OpenSearchTestCase() { | ||
| fun `test validateFormat with pattern containing hash`() { | ||
| val patterns = listOf("log#*") | ||
| val exception = validateFormat(patterns) | ||
| assertNotNull("Expected validation error for pattern with #", exception) | ||
| assertTrue(exception is IndexManagementException) | ||
| assertTrue(exception!!.message!!.contains("must not contain a '#'")) | ||
| } | ||
|
|
||
| fun `test validateFormat with exclusion pattern containing hash`() { | ||
| val patterns = listOf("log-*", "-test#*") | ||
| val exception = validateFormat(patterns) | ||
| assertNotNull("Expected validation error for exclusion pattern with #", exception) | ||
| assertTrue(exception is IndexManagementException) | ||
| assertTrue(exception!!.message!!.contains("must not contain a '#'")) | ||
| } | ||
|
|
||
| fun `test validateFormat with pattern containing colon`() { | ||
| val patterns = listOf("log:*") | ||
| val exception = validateFormat(patterns) | ||
| assertNotNull("Expected validation error for pattern with :", exception) | ||
| assertTrue(exception is IndexManagementException) | ||
| assertTrue(exception!!.message!!.contains("must not contain a ':'")) | ||
| } | ||
|
|
||
| fun `test validateFormat with exclusion pattern containing colon`() { | ||
| val patterns = listOf("log-*", "-test:*") | ||
| val exception = validateFormat(patterns) | ||
| assertNotNull("Expected validation error for exclusion pattern with :", exception) | ||
| assertTrue(exception is IndexManagementException) | ||
| assertTrue(exception!!.message!!.contains("must not contain a ':'")) | ||
| } | ||
|
|
||
| fun `test validateFormat with pattern starting with underscore`() { | ||
| val patterns = listOf("_log*") | ||
| val exception = validateFormat(patterns) | ||
| assertNotNull("Expected validation error for pattern starting with _", exception) | ||
| assertTrue(exception is IndexManagementException) | ||
| assertTrue(exception!!.message!!.contains("must not start with '_'")) | ||
| } | ||
|
|
||
| fun `test validateFormat with exclusion pattern starting with underscore`() { | ||
| val patterns = listOf("log-*", "-_test*") | ||
| val exception = validateFormat(patterns) | ||
| assertNotNull("Expected validation error for exclusion pattern starting with _", exception) | ||
| assertTrue(exception is IndexManagementException) | ||
| assertTrue(exception!!.message!!.contains("must not start with '_'")) | ||
| } | ||
|
|
||
| fun `test validateFormat with empty exclusion pattern`() { | ||
| val patterns = listOf("log-*", "-") | ||
| val exception = validateFormat(patterns) | ||
| assertNotNull("Expected validation error for empty exclusion pattern", exception) | ||
| assertTrue(exception is IndexManagementException) | ||
| assertTrue(exception!!.message!!.contains("must have content after '-' exclusion prefix")) | ||
| } | ||
|
|
||
| fun `test validateFormat with only exclusion patterns`() { | ||
| val patterns = listOf("-log-test-*", "-log-debug-*") | ||
| val exception = validateFormat(patterns) | ||
| assertNotNull("Expected validation error for only exclusion patterns", exception) | ||
| assertTrue(exception is IndexManagementException) | ||
| assertTrue(exception!!.message!!.contains("must contain at least one inclusion pattern")) | ||
| } | ||
|
|
||
| fun `test validateFormat with valid inclusion and exclusion patterns`() { | ||
| val patterns = listOf("log-*", "-log-test-*", "-log-*-debug-*") | ||
| val exception = validateFormat(patterns) | ||
| assertNull("Expected no validation error for valid patterns", exception) | ||
| } | ||
|
|
||
| fun `test validateFormat with valid inclusion patterns only`() { | ||
| val patterns = listOf("log-*", "app-*") | ||
| val exception = validateFormat(patterns) | ||
| assertNull("Expected no validation error for valid inclusion patterns", exception) | ||
| } | ||
|
|
||
| fun `test validateFormat with empty string pattern`() { | ||
| val patterns = listOf("") | ||
| val exception = validateFormat(patterns) | ||
| // Empty string is treated as an inclusion pattern, so it should not fail the "only exclusions" check | ||
| // It may fail other validations depending on Strings.validFileNameExcludingAstrix | ||
| // For now, we're just testing that it doesn't fail the exclusion-only check | ||
| if (exception != null) { | ||
| assertFalse(exception.message!!.contains("must contain at least one inclusion pattern")) | ||
| } | ||
| } | ||
| } |
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
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.