Skip to content

Commit

Permalink
fix for windows ktlint issue
Browse files Browse the repository at this point in the history
Signed-off-by: Subhobrata Dey <sbcd90@gmail.com>
  • Loading branch information
sbcd90 committed Oct 3, 2022
1 parent 3a844f8 commit d68f655
Show file tree
Hide file tree
Showing 2 changed files with 192 additions and 32 deletions.
220 changes: 190 additions & 30 deletions alerting/src/test/kotlin/org/opensearch/alerting/TriggerServiceTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,75 @@ class TriggerServiceTests : OpenSearchTestCase() {
val trigger = randomBucketLevelTrigger(bucketSelector = bucketSelectorExtAggregationBuilder)
val monitor = randomBucketLevelMonitor(triggers = listOf(trigger))

val inputResultsStr = "{\"_shards\":" +
"{\"total\":1,\"failed\":0,\"successful\":1,\"skipped\":0},\"hits\":{\"hits\":" +
"[{\"_index\":\"sample-http-responses\",\"_type\":\"http\",\"_source\":" +
"{\"status_code\":100,\"http_4xx\":0,\"http_3xx\":0,\"http_5xx\":0,\"http_2xx\":0," +
"\"timestamp\":100000,\"http_1xx\":1},\"_id\":1,\"_score\":1}],\"total\":{\"value\":4,\"relation\":\"eq\"}," +
"\"max_score\":1},\"took\":37,\"timed_out\":false,\"aggregations\":{\"status_code\":" +
"{\"doc_count_error_upper_bound\":0,\"sum_other_doc_count\":0,\"buckets\":[{\"doc_count\":2,\"key\":100}," +
"{\"doc_count\":1,\"key\":102},{\"doc_count\":1,\"key\":201}]},\"${trigger.id}\":{\"parent_bucket_path\":" +
"\"status_code\",\"bucket_indices\":[0,1,2]}}}"

val parser = XContentType.JSON.xContent().createParser(
NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, inputResultsStr
)
val inputResultsStr = "{\n" +
" \"_shards\": {\n" +
" \"total\": 1,\n" +
" \"failed\": 0,\n" +
" \"successful\": 1,\n" +
" \"skipped\": 0\n" +
" },\n" +
" \"hits\": {\n" +
" \"hits\": [\n" +
" {\n" +
" \"_index\": \"sample-http-responses\",\n" +
" \"_type\": \"http\",\n" +
" \"_source\": {\n" +
" \"status_code\": 100,\n" +
" \"http_4xx\": 0,\n" +
" \"http_3xx\": 0,\n" +
" \"http_5xx\": 0,\n" +
" \"http_2xx\": 0,\n" +
" \"timestamp\": 100000,\n" +
" \"http_1xx\": 1\n" +
" },\n" +
" \"_id\": 1,\n" +
" \"_score\": 1\n" +
" }\n" +
" ],\n" +
" \"total\": {\n" +
" \"value\": 4,\n" +
" \"relation\": \"eq\"\n" +
" },\n" +
" \"max_score\": 1\n" +
" },\n" +
" \"took\": 37,\n" +
" \"timed_out\": false,\n" +
" \"aggregations\": {\n" +
" \"status_code\": {\n" +
" \"doc_count_error_upper_bound\": 0,\n" +
" \"sum_other_doc_count\": 0,\n" +
" \"buckets\": [\n" +
" {\n" +
" \"doc_count\": 2,\n" +
" \"key\": 100\n" +
" },\n" +
" {\n" +
" \"doc_count\": 1,\n" +
" \"key\": 102\n" +
" },\n" +
" {\n" +
" \"doc_count\": 1,\n" +
" \"key\": 201\n" +
" }\n" +
" ]\n" +
" },\n" +
" \"${trigger.id}\": {\n" +
" \"parent_bucket_path\": \"status_code\",\n" +
" \"bucket_indices\": [\n" +
" 0,\n" +
" 1,\n" +
" 2\n" +
" ]\n" +
" }\n" +
" }\n" +
"}"

val parser = XContentType.JSON.xContent()
.createParser(
NamedXContentRegistry.EMPTY,
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
inputResultsStr
)

val inputResults = parser.map()

Expand All @@ -70,23 +126,127 @@ class TriggerServiceTests : OpenSearchTestCase() {
val trigger = randomBucketLevelTrigger(bucketSelector = bucketSelectorExtAggregationBuilder)
val monitor = randomBucketLevelMonitor(triggers = listOf(trigger))

val inputResultsStr = "{\"_shards\":{\"total\":1, \"failed\":0, \"successful\":1, \"skipped\":0}, \"hits\":{\"hits\":" +
"[{\"_index\":\"sample-http-responses\", \"_type\":\"http\", \"_source\":{\"status_code\":100, \"http_4xx\":0," +
" \"http_3xx\":0, \"http_5xx\":0, \"http_2xx\":0, \"timestamp\":100000, \"http_1xx\":1}, \"_id\":1, \"_score\":1.0}, " +
"{\"_index\":\"sample-http-responses\", \"_type\":\"http\", \"_source\":{\"status_code\":102, \"http_4xx\":0, " +
"\"http_3xx\":0, \"http_5xx\":0, \"http_2xx\":0, \"timestamp\":160000, \"http_1xx\":1}, \"_id\":2, \"_score\":1.0}, " +
"{\"_index\":\"sample-http-responses\", \"_type\":\"http\", \"_source\":{\"status_code\":100, \"http_4xx\":0, " +
"\"http_3xx\":0, \"http_5xx\":0, \"http_2xx\":0, \"timestamp\":220000, \"http_1xx\":1}, \"_id\":4, \"_score\":1.0}, " +
"{\"_index\":\"sample-http-responses\", \"_type\":\"http\", \"_source\":{\"status_code\":201, \"http_4xx\":0, " +
"\"http_3xx\":0, \"http_5xx\":0, \"http_2xx\":1, \"timestamp\":280000, \"http_1xx\":0}, \"_id\":5, \"_score\":1.0}]," +
" \"total\":{\"value\":4, \"relation\":\"eq\"}, \"max_score\":1.0}, \"took\":15, \"timed_out\":false, \"aggregations\":" +
"{\"${trigger.id}\":{\"parent_bucket_path\":\"status_code\", \"bucket_indices\":[0, 1, 2]}, \"status_code\":{\"buckets\":" +
"[{\"doc_count\":2, \"key\":{\"status_code\":100}}, {\"doc_count\":1, \"key\":{\"status_code\":102}}, {\"doc_count\":1," +
" \"key\":{\"status_code\":201}}], \"after_key\":{\"status_code\":201}}}}"

val parser = XContentType.JSON.xContent().createParser(
NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, inputResultsStr
)
val inputResultsStr = "{\n" +
" \"_shards\": {\n" +
" \"total\": 1,\n" +
" \"failed\": 0,\n" +
" \"successful\": 1,\n" +
" \"skipped\": 0\n" +
" },\n" +
" \"hits\": {\n" +
" \"hits\": [\n" +
" {\n" +
" \"_index\": \"sample-http-responses\",\n" +
" \"_type\": \"http\",\n" +
" \"_source\": {\n" +
" \"status_code\": 100,\n" +
" \"http_4xx\": 0,\n" +
" \"http_3xx\": 0,\n" +
" \"http_5xx\": 0,\n" +
" \"http_2xx\": 0,\n" +
" \"timestamp\": 100000,\n" +
" \"http_1xx\": 1\n" +
" },\n" +
" \"_id\": 1,\n" +
" \"_score\": 1\n" +
" },\n" +
" {\n" +
" \"_index\": \"sample-http-responses\",\n" +
" \"_type\": \"http\",\n" +
" \"_source\": {\n" +
" \"status_code\": 102,\n" +
" \"http_4xx\": 0,\n" +
" \"http_3xx\": 0,\n" +
" \"http_5xx\": 0,\n" +
" \"http_2xx\": 0,\n" +
" \"timestamp\": 160000,\n" +
" \"http_1xx\": 1\n" +
" },\n" +
" \"_id\": 2,\n" +
" \"_score\": 1\n" +
" },\n" +
" {\n" +
" \"_index\": \"sample-http-responses\",\n" +
" \"_type\": \"http\",\n" +
" \"_source\": {\n" +
" \"status_code\": 100,\n" +
" \"http_4xx\": 0,\n" +
" \"http_3xx\": 0,\n" +
" \"http_5xx\": 0,\n" +
" \"http_2xx\": 0,\n" +
" \"timestamp\": 220000,\n" +
" \"http_1xx\": 1\n" +
" },\n" +
" \"_id\": 4,\n" +
" \"_score\": 1\n" +
" },\n" +
" {\n" +
" \"_index\": \"sample-http-responses\",\n" +
" \"_type\": \"http\",\n" +
" \"_source\": {\n" +
" \"status_code\": 201,\n" +
" \"http_4xx\": 0,\n" +
" \"http_3xx\": 0,\n" +
" \"http_5xx\": 0,\n" +
" \"http_2xx\": 1,\n" +
" \"timestamp\": 280000,\n" +
" \"http_1xx\": 0\n" +
" },\n" +
" \"_id\": 5,\n" +
" \"_score\": 1\n" +
" }\n" +
" ],\n" +
" \"total\": {\n" +
" \"value\": 4,\n" +
" \"relation\": \"eq\"\n" +
" },\n" +
" \"max_score\": 1\n" +
" },\n" +
" \"took\": 15,\n" +
" \"timed_out\": false,\n" +
" \"aggregations\": {\n" +
" \"${trigger.id}\": {\n" +
" \"parent_bucket_path\": \"status_code\",\n" +
" \"bucket_indices\": [\n" +
" 0,\n" +
" 1,\n" +
" 2\n" +
" ]\n" +
" },\n" +
" \"status_code\": {\n" +
" \"buckets\": [\n" +
" {\n" +
" \"doc_count\": 2,\n" +
" \"key\": {\n" +
" \"status_code\": 100\n" +
" }\n" +
" },\n" +
" {\n" +
" \"doc_count\": 1,\n" +
" \"key\": {\n" +
" \"status_code\": 102\n" +
" }\n" +
" },\n" +
" {\n" +
" \"doc_count\": 1,\n" +
" \"key\": {\n" +
" \"status_code\": 201\n" +
" }\n" +
" }\n" +
" ],\n" +
" \"after_key\": {\n" +
" \"status_code\": 201\n" +
" }\n" +
" }\n" +
" }\n" +
"}"

val parser = XContentType.JSON.xContent()
.createParser(
NamedXContentRegistry.EMPTY,
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
inputResultsStr
)

val inputResults = parser.map()

Expand Down
4 changes: 2 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ fi

mkdir -p $OUTPUT/plugins

./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.version_qualifier=$QUALIFIER -Dbuild.snapshot=$SNAPSHOT -x ktlint
./gradlew assemble --no-daemon --refresh-dependencies -DskipTests=true -Dopensearch.version=$VERSION -Dbuild.version_qualifier=$QUALIFIER -Dbuild.snapshot=$SNAPSHOT

zipPath=$(find . -path \*build/distributions/*.zip)
distributions="$(dirname "${zipPath}")"

echo "COPY ${distributions}/*.zip"
cp ${distributions}/*.zip ./$OUTPUT/plugins

./gradlew publishPluginZipPublicationToZipStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER -x ktlint
./gradlew publishPluginZipPublicationToZipStagingRepository -Dopensearch.version=$VERSION -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER
mkdir -p $OUTPUT/maven/org/opensearch
cp -r ./build/local-staging-repo/org/opensearch/. $OUTPUT/maven/org/opensearch

0 comments on commit d68f655

Please sign in to comment.