Skip to content
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

Fixing Issue #200 (Adding support for various ctx variable fields) #504

Closed
wants to merge 27 commits into from

Conversation

toepkerd-zz
Copy link
Contributor

@toepkerd-zz toepkerd-zz commented Jul 27, 2022

Signed-off-by: Dennis Toepker toepkerd@amazon.com

Issue #200

Added support for various ctx fields by implementing asTemplateArg() in various classes

CheckList:

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

opensearch-trigger-bot bot and others added 5 commits July 6, 2022 14:42
…#486)

* Added 2.1 release notes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Added 2.1 release notes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
(cherry picked from commit 9f3c393)

Co-authored-by: AWSHurneyt <hurneyt@amazon.com>
* Added 2.1 release notes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>

* Added 2.1 release notes.

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
…in various classes

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
@codecov-commenter
Copy link

codecov-commenter commented Jul 27, 2022

Codecov Report

Merging #504 (6ebfdce) into main (6d3fb50) will decrease coverage by 0.02%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##               main     #504      +/-   ##
============================================
- Coverage     76.89%   76.86%   -0.03%     
- Complexity      176      178       +2     
============================================
  Files           166      166              
  Lines          8370     8399      +29     
  Branches       1232     1232              
============================================
+ Hits           6436     6456      +20     
- Misses         1329     1340      +11     
+ Partials        605      603       -2     
Impacted Files Coverage Δ
...in/kotlin/org/opensearch/alerting/model/Trigger.kt 80.00% <ø> (ø)
.../kotlin/org/opensearch/alerting/util/IndexUtils.kt 70.83% <ø> (-2.09%) ⬇️
...kotlin/org/opensearch/alerting/core/model/Input.kt 75.00% <ø> (ø)
...selectorext/BucketSelectorExtAggregationBuilder.kt 56.71% <100.00%> (+2.45%) ⬆️
...rg/opensearch/alerting/model/BucketLevelTrigger.kt 89.23% <100.00%> (-1.54%) ⬇️
.../opensearch/alerting/model/DocumentLevelTrigger.kt 81.33% <100.00%> (+0.25%) ⬆️
...in/kotlin/org/opensearch/alerting/model/Monitor.kt 88.63% <100.00%> (+0.61%) ⬆️
...org/opensearch/alerting/model/QueryLevelTrigger.kt 85.91% <100.00%> (+0.62%) ⬆️
...lin/org/opensearch/alerting/model/action/Action.kt 86.59% <100.00%> (+0.57%) ⬆️
...nsearch/alerting/core/model/ClusterMetricsInput.kt 92.35% <100.00%> (+0.04%) ⬆️
... and 12 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@toepkerd-zz toepkerd-zz marked this pull request as ready for review July 27, 2022 01:38
@toepkerd-zz toepkerd-zz requested a review from a team July 27, 2022 01:38
@toepkerd-zz toepkerd-zz changed the title 2.1 Fixing Issue #200 (Adding support for various ctx variable fields) Jul 27, 2022
@@ -19,7 +20,7 @@ import org.opensearch.search.aggregations.pipeline.AbstractPipelineAggregationBu
import org.opensearch.search.aggregations.pipeline.BucketHelpers.GapPolicy
import org.opensearch.search.aggregations.pipeline.PipelineAggregator
import java.io.IOException
import java.util.Objects
import java.util.*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We typically avoid wildcard imports since they are very generic in the libraries they end up including. If you're using Intellij, it is probably doing this for you automatically. You can refer to this to disable that behavior.

@@ -66,11 +70,13 @@ data class DocumentLevelTrigger(
}

/** Returns a representation of the trigger suitable for passing into painless and mustache scripts. */
fun asTemplateArg(): Map<String, Any> {
override fun asTemplateArg(): Map<String, Any?> {
log.info("inside docleveltrigger astemplatearg")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this if it was only used for debugging purposes. Same goes for the other log.infos in asTemplateArg()s.

// WHEN
val templateArgs = monitor.asTemplateArg()

this.logger.info("template args in log: $templateArgs")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed.

Comment on lines 65 to 69
assertEquals(
"Template args monitor type does not match\nhere's templateArgs: $templateArgs \n" +
"here's monitor: $monitor \n here's toXContent: ${monitor.toXContent(XContentFactory.jsonBuilder(), ToXContent.EMPTY_PARAMS)}",
templateArgs[Monitor.MONITOR_TYPE_FIELD], monitor.monitorType.toString()
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the assertion method will output the expected and actual arguments when the assertion fails but if you do want to keep the message as-is, using a raw string with variable templating might be a cleaner solution.

Example:

assertEquals(
    """
        Template args monitor type does not match.
        Template args was: $templateArgs
        Monitor is: $monitor
    """.trimIndent(),
    templateArgs[Monitor.MONITOR_TYPE_FIELD], monitor.monitorType.toString()
)

@@ -0,0 +1,9 @@
## Version 2.1.0.0 2022-07-06
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may have been pulled into the PR because your dev branch is old. Could you rebase your dev branch with the current main?

Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
toepkerd-zz and others added 7 commits August 1, 2022 15:38
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
…ensearch-project#502)

* Version increment automation

Signed-off-by: pgodithi <pgodithi@amazon.com>

* Version increment automation: task rename updateVersion

Signed-off-by: pgodithi <pgodithi@amazon.com>
(cherry picked from commit 3b8bfe7)
Signed-off-by: prudhvigodithi <pgodithi@amazon.com>

Co-authored-by: Prudhvi Godithi <pgodithi@amazon.com>
….1.0.0 zip following deprecation of ODFE. (opensearch-project#510) (opensearch-project#511)

Signed-off-by: AWSHurneyt <hurneyt@amazon.com>
(cherry picked from commit fea6b4a)

Co-authored-by: AWSHurneyt <hurneyt@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
Signed-off-by: Dennis Toepker <toepkerd@amazon.com>
@lezzago
Copy link
Member

lezzago commented Jan 19, 2023

Closing this PR as there are many conflicts and many of the changes have been merged in this PR: opensearch-project/common-utils#318.

May need to reopen another PR to add support for anything else missing.

@lezzago lezzago closed this Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants