-
Notifications
You must be signed in to change notification settings - Fork 93
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
adding constructor with optional comments indices args #674
Merged
AWSHurneyt
merged 5 commits into
opensearch-project:main
from
toepkerd:alerting-comments
Jun 10, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
38248a4
adding ctor with optional comments indices args
toepkerd-zz 6a15e38
removing throws IOException declaration above new ctor
toepkerd-zz 6dbc9f6
making reads and writes optional
toepkerd-zz 939cbd4
quick comment change
toepkerd-zz 25692f9
adding test for new ctor
toepkerd-zz 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
36 changes: 36 additions & 0 deletions
36
src/test/kotlin/org/opensearch/commons/alerting/model/DataSourcesTests.kt
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,36 @@ | ||
package org.opensearch.commons.alerting.model | ||
|
||
import org.junit.jupiter.api.Assertions | ||
import org.junit.jupiter.api.Test | ||
import org.opensearch.common.io.stream.BytesStreamOutput | ||
import org.opensearch.core.common.io.stream.StreamInput | ||
|
||
class DataSourcesTests { | ||
@Test | ||
fun `Test DataSources construction with no comments indices`() { | ||
val dataSources = DataSources( | ||
ScheduledJob.DOC_LEVEL_QUERIES_INDEX, | ||
".opensearch-alerting-finding-history-write", | ||
"<.opensearch-alerting-finding-history-{now/d}-1>", | ||
".opendistro-alerting-alerts", | ||
".opendistro-alerting-alert-history-write", | ||
"<.opendistro-alerting-alert-history-{now/d}-1>", | ||
mapOf(), | ||
false | ||
) | ||
Assertions.assertNotNull(dataSources) | ||
|
||
val out = BytesStreamOutput() | ||
dataSources.writeTo(out) | ||
val sin = StreamInput.wrap(out.bytes().toBytesRef().bytes) | ||
val newDataSources = DataSources(sin) | ||
Assertions.assertEquals(ScheduledJob.DOC_LEVEL_QUERIES_INDEX, newDataSources.queryIndex) | ||
Assertions.assertEquals(".opensearch-alerting-finding-history-write", newDataSources.findingsIndex) | ||
Assertions.assertEquals("<.opensearch-alerting-finding-history-{now/d}-1>", newDataSources.findingsIndexPattern) | ||
Assertions.assertEquals(".opendistro-alerting-alerts", newDataSources.alertsIndex) | ||
Assertions.assertEquals(".opendistro-alerting-alert-history-write", newDataSources.alertsHistoryIndex) | ||
Assertions.assertEquals("<.opendistro-alerting-alert-history-{now/d}-1>", newDataSources.alertsHistoryIndexPattern) | ||
Assertions.assertEquals(mapOf<String, Map<String, String>>(), newDataSources.queryIndexMappingsByType) | ||
Assertions.assertEquals(false, newDataSources.findingsEnabled) | ||
} | ||
} |
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.
https://github.com/opensearch-project/common-utils/pull/674/files#diff-97cf101698aba14b5844f08b1d5be6fcf2752671b9d7510d1a566efbeec20793R83
comments index should be using readOptionalString(), writeOptionalString, null check in parsing etc.
plz incorporate
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.
updating readOptional and writeOptional, parse adds an empty string placeholder for any comments that don't exist in the XContent, so leaving that be