Skip to content

Commit bc79b45

Browse files
fix for windows ktlint issue (#585) (#624)
Signed-off-by: Subhobrata Dey <[email protected]>
1 parent 88ae55a commit bc79b45

File tree

3 files changed

+216
-36
lines changed

3 files changed

+216
-36
lines changed

.github/workflows/test-workflow.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,36 +10,56 @@ on:
1010

1111
jobs:
1212
build:
13+
env:
14+
BUILD_ARGS: ${{ matrix.os_build_args }}
15+
WORKING_DIR: ${{ matrix.working_directory }}.
1316
strategy:
1417
matrix:
1518
java: [11, 17]
19+
os: [ ubuntu-latest, windows-latest, macos-latest ]
20+
include:
21+
- os: windows-latest
22+
os_build_args: -x integTest -x jacocoTestReport
23+
working_directory: X:\
24+
os_java_options: -Xmx4096M
25+
- os: macos-latest
26+
os_build_args: -x integTest -x jacocoTestReport
1627
# Job name
17-
name: Build Alerting with JDK ${{ matrix.java }}
28+
name: Build Alerting with JDK ${{ matrix.java }} on ${{ matrix.os }}
1829
# This job runs on Linux
19-
runs-on: ubuntu-latest
30+
runs-on: ${{ matrix.os }}
2031
steps:
2132
# This step uses the checkout Github action: https://github.com/actions/checkout
2233
- name: Checkout Branch
2334
uses: actions/checkout@v2
35+
# This is a hack, but this step creates a link to the X: mounted drive, which makes the path
36+
# short enough to work on Windows
37+
- name: Shorten Path
38+
if: ${{ matrix.os == 'windows-latest' }}
39+
run: subst 'X:' .
2440
# This step uses the setup-java Github action: https://github.com/actions/setup-java
2541
- name: Set Up JDK ${{ matrix.java }}
2642
uses: actions/setup-java@v1
2743
with:
2844
java-version: ${{ matrix.java }}
2945
- name: Build and run with Gradle
30-
run: ./gradlew build
46+
working-directory: ${{ env.WORKING_DIR }}
47+
run: ./gradlew build ${{ env.BUILD_ARGS }}
48+
env:
49+
_JAVA_OPTIONS: ${{ matrix.os_java_options }}
3150
- name: Create Artifact Path
3251
run: |
3352
mkdir -p alerting-artifacts
3453
cp ./alerting/build/distributions/*.zip alerting-artifacts
3554
# This step uses the codecov-action Github action: https://github.com/codecov/codecov-action
3655
- name: Upload Coverage Report
56+
if: ${{ matrix.os == 'ubuntu-latest' }}
3757
uses: codecov/codecov-action@v1
3858
with:
3959
token: ${{ secrets.CODECOV_TOKEN }}
4060
# This step uses the upload-artifact Github action: https://github.com/actions/upload-artifact
4161
- name: Upload Artifacts
4262
uses: actions/upload-artifact@v1
4363
with:
44-
name: alerting-plugin
64+
name: alerting-plugin-${{ matrix.os }}
4565
path: alerting-artifacts

alerting/src/test/kotlin/org/opensearch/alerting/TriggerServiceTests.kt

Lines changed: 190 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,75 @@ class TriggerServiceTests : OpenSearchTestCase() {
3737
val trigger = randomBucketLevelTrigger(bucketSelector = bucketSelectorExtAggregationBuilder)
3838
val monitor = randomBucketLevelMonitor(triggers = listOf(trigger))
3939

40-
val inputResultsStr = "{\"_shards\":" +
41-
"{\"total\":1,\"failed\":0,\"successful\":1,\"skipped\":0},\"hits\":{\"hits\":" +
42-
"[{\"_index\":\"sample-http-responses\",\"_type\":\"http\",\"_source\":" +
43-
"{\"status_code\":100,\"http_4xx\":0,\"http_3xx\":0,\"http_5xx\":0,\"http_2xx\":0," +
44-
"\"timestamp\":100000,\"http_1xx\":1},\"_id\":1,\"_score\":1}],\"total\":{\"value\":4,\"relation\":\"eq\"}," +
45-
"\"max_score\":1},\"took\":37,\"timed_out\":false,\"aggregations\":{\"status_code\":" +
46-
"{\"doc_count_error_upper_bound\":0,\"sum_other_doc_count\":0,\"buckets\":[{\"doc_count\":2,\"key\":100}," +
47-
"{\"doc_count\":1,\"key\":102},{\"doc_count\":1,\"key\":201}]},\"${trigger.id}\":{\"parent_bucket_path\":" +
48-
"\"status_code\",\"bucket_indices\":[0,1,2]}}}"
49-
50-
val parser = XContentType.JSON.xContent().createParser(
51-
NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, inputResultsStr
52-
)
40+
val inputResultsStr = "{\n" +
41+
" \"_shards\": {\n" +
42+
" \"total\": 1,\n" +
43+
" \"failed\": 0,\n" +
44+
" \"successful\": 1,\n" +
45+
" \"skipped\": 0\n" +
46+
" },\n" +
47+
" \"hits\": {\n" +
48+
" \"hits\": [\n" +
49+
" {\n" +
50+
" \"_index\": \"sample-http-responses\",\n" +
51+
" \"_type\": \"http\",\n" +
52+
" \"_source\": {\n" +
53+
" \"status_code\": 100,\n" +
54+
" \"http_4xx\": 0,\n" +
55+
" \"http_3xx\": 0,\n" +
56+
" \"http_5xx\": 0,\n" +
57+
" \"http_2xx\": 0,\n" +
58+
" \"timestamp\": 100000,\n" +
59+
" \"http_1xx\": 1\n" +
60+
" },\n" +
61+
" \"_id\": 1,\n" +
62+
" \"_score\": 1\n" +
63+
" }\n" +
64+
" ],\n" +
65+
" \"total\": {\n" +
66+
" \"value\": 4,\n" +
67+
" \"relation\": \"eq\"\n" +
68+
" },\n" +
69+
" \"max_score\": 1\n" +
70+
" },\n" +
71+
" \"took\": 37,\n" +
72+
" \"timed_out\": false,\n" +
73+
" \"aggregations\": {\n" +
74+
" \"status_code\": {\n" +
75+
" \"doc_count_error_upper_bound\": 0,\n" +
76+
" \"sum_other_doc_count\": 0,\n" +
77+
" \"buckets\": [\n" +
78+
" {\n" +
79+
" \"doc_count\": 2,\n" +
80+
" \"key\": 100\n" +
81+
" },\n" +
82+
" {\n" +
83+
" \"doc_count\": 1,\n" +
84+
" \"key\": 102\n" +
85+
" },\n" +
86+
" {\n" +
87+
" \"doc_count\": 1,\n" +
88+
" \"key\": 201\n" +
89+
" }\n" +
90+
" ]\n" +
91+
" },\n" +
92+
" \"${trigger.id}\": {\n" +
93+
" \"parent_bucket_path\": \"status_code\",\n" +
94+
" \"bucket_indices\": [\n" +
95+
" 0,\n" +
96+
" 1,\n" +
97+
" 2\n" +
98+
" ]\n" +
99+
" }\n" +
100+
" }\n" +
101+
"}"
102+
103+
val parser = XContentType.JSON.xContent()
104+
.createParser(
105+
NamedXContentRegistry.EMPTY,
106+
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
107+
inputResultsStr
108+
)
53109

54110
val inputResults = parser.map()
55111

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

73-
val inputResultsStr = "{\"_shards\":{\"total\":1, \"failed\":0, \"successful\":1, \"skipped\":0}, \"hits\":{\"hits\":" +
74-
"[{\"_index\":\"sample-http-responses\", \"_type\":\"http\", \"_source\":{\"status_code\":100, \"http_4xx\":0," +
75-
" \"http_3xx\":0, \"http_5xx\":0, \"http_2xx\":0, \"timestamp\":100000, \"http_1xx\":1}, \"_id\":1, \"_score\":1.0}, " +
76-
"{\"_index\":\"sample-http-responses\", \"_type\":\"http\", \"_source\":{\"status_code\":102, \"http_4xx\":0, " +
77-
"\"http_3xx\":0, \"http_5xx\":0, \"http_2xx\":0, \"timestamp\":160000, \"http_1xx\":1}, \"_id\":2, \"_score\":1.0}, " +
78-
"{\"_index\":\"sample-http-responses\", \"_type\":\"http\", \"_source\":{\"status_code\":100, \"http_4xx\":0, " +
79-
"\"http_3xx\":0, \"http_5xx\":0, \"http_2xx\":0, \"timestamp\":220000, \"http_1xx\":1}, \"_id\":4, \"_score\":1.0}, " +
80-
"{\"_index\":\"sample-http-responses\", \"_type\":\"http\", \"_source\":{\"status_code\":201, \"http_4xx\":0, " +
81-
"\"http_3xx\":0, \"http_5xx\":0, \"http_2xx\":1, \"timestamp\":280000, \"http_1xx\":0}, \"_id\":5, \"_score\":1.0}]," +
82-
" \"total\":{\"value\":4, \"relation\":\"eq\"}, \"max_score\":1.0}, \"took\":15, \"timed_out\":false, \"aggregations\":" +
83-
"{\"${trigger.id}\":{\"parent_bucket_path\":\"status_code\", \"bucket_indices\":[0, 1, 2]}, \"status_code\":{\"buckets\":" +
84-
"[{\"doc_count\":2, \"key\":{\"status_code\":100}}, {\"doc_count\":1, \"key\":{\"status_code\":102}}, {\"doc_count\":1," +
85-
" \"key\":{\"status_code\":201}}], \"after_key\":{\"status_code\":201}}}}"
86-
87-
val parser = XContentType.JSON.xContent().createParser(
88-
NamedXContentRegistry.EMPTY, DeprecationHandler.THROW_UNSUPPORTED_OPERATION, inputResultsStr
89-
)
129+
val inputResultsStr = "{\n" +
130+
" \"_shards\": {\n" +
131+
" \"total\": 1,\n" +
132+
" \"failed\": 0,\n" +
133+
" \"successful\": 1,\n" +
134+
" \"skipped\": 0\n" +
135+
" },\n" +
136+
" \"hits\": {\n" +
137+
" \"hits\": [\n" +
138+
" {\n" +
139+
" \"_index\": \"sample-http-responses\",\n" +
140+
" \"_type\": \"http\",\n" +
141+
" \"_source\": {\n" +
142+
" \"status_code\": 100,\n" +
143+
" \"http_4xx\": 0,\n" +
144+
" \"http_3xx\": 0,\n" +
145+
" \"http_5xx\": 0,\n" +
146+
" \"http_2xx\": 0,\n" +
147+
" \"timestamp\": 100000,\n" +
148+
" \"http_1xx\": 1\n" +
149+
" },\n" +
150+
" \"_id\": 1,\n" +
151+
" \"_score\": 1\n" +
152+
" },\n" +
153+
" {\n" +
154+
" \"_index\": \"sample-http-responses\",\n" +
155+
" \"_type\": \"http\",\n" +
156+
" \"_source\": {\n" +
157+
" \"status_code\": 102,\n" +
158+
" \"http_4xx\": 0,\n" +
159+
" \"http_3xx\": 0,\n" +
160+
" \"http_5xx\": 0,\n" +
161+
" \"http_2xx\": 0,\n" +
162+
" \"timestamp\": 160000,\n" +
163+
" \"http_1xx\": 1\n" +
164+
" },\n" +
165+
" \"_id\": 2,\n" +
166+
" \"_score\": 1\n" +
167+
" },\n" +
168+
" {\n" +
169+
" \"_index\": \"sample-http-responses\",\n" +
170+
" \"_type\": \"http\",\n" +
171+
" \"_source\": {\n" +
172+
" \"status_code\": 100,\n" +
173+
" \"http_4xx\": 0,\n" +
174+
" \"http_3xx\": 0,\n" +
175+
" \"http_5xx\": 0,\n" +
176+
" \"http_2xx\": 0,\n" +
177+
" \"timestamp\": 220000,\n" +
178+
" \"http_1xx\": 1\n" +
179+
" },\n" +
180+
" \"_id\": 4,\n" +
181+
" \"_score\": 1\n" +
182+
" },\n" +
183+
" {\n" +
184+
" \"_index\": \"sample-http-responses\",\n" +
185+
" \"_type\": \"http\",\n" +
186+
" \"_source\": {\n" +
187+
" \"status_code\": 201,\n" +
188+
" \"http_4xx\": 0,\n" +
189+
" \"http_3xx\": 0,\n" +
190+
" \"http_5xx\": 0,\n" +
191+
" \"http_2xx\": 1,\n" +
192+
" \"timestamp\": 280000,\n" +
193+
" \"http_1xx\": 0\n" +
194+
" },\n" +
195+
" \"_id\": 5,\n" +
196+
" \"_score\": 1\n" +
197+
" }\n" +
198+
" ],\n" +
199+
" \"total\": {\n" +
200+
" \"value\": 4,\n" +
201+
" \"relation\": \"eq\"\n" +
202+
" },\n" +
203+
" \"max_score\": 1\n" +
204+
" },\n" +
205+
" \"took\": 15,\n" +
206+
" \"timed_out\": false,\n" +
207+
" \"aggregations\": {\n" +
208+
" \"${trigger.id}\": {\n" +
209+
" \"parent_bucket_path\": \"status_code\",\n" +
210+
" \"bucket_indices\": [\n" +
211+
" 0,\n" +
212+
" 1,\n" +
213+
" 2\n" +
214+
" ]\n" +
215+
" },\n" +
216+
" \"status_code\": {\n" +
217+
" \"buckets\": [\n" +
218+
" {\n" +
219+
" \"doc_count\": 2,\n" +
220+
" \"key\": {\n" +
221+
" \"status_code\": 100\n" +
222+
" }\n" +
223+
" },\n" +
224+
" {\n" +
225+
" \"doc_count\": 1,\n" +
226+
" \"key\": {\n" +
227+
" \"status_code\": 102\n" +
228+
" }\n" +
229+
" },\n" +
230+
" {\n" +
231+
" \"doc_count\": 1,\n" +
232+
" \"key\": {\n" +
233+
" \"status_code\": 201\n" +
234+
" }\n" +
235+
" }\n" +
236+
" ],\n" +
237+
" \"after_key\": {\n" +
238+
" \"status_code\": 201\n" +
239+
" }\n" +
240+
" }\n" +
241+
" }\n" +
242+
"}"
243+
244+
val parser = XContentType.JSON.xContent()
245+
.createParser(
246+
NamedXContentRegistry.EMPTY,
247+
DeprecationHandler.THROW_UNSUPPORTED_OPERATION,
248+
inputResultsStr
249+
)
90250

91251
val inputResults = parser.map()
92252

scripts/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,14 @@ fi
6666

6767
mkdir -p $OUTPUT/plugins
6868

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

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

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

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

0 commit comments

Comments
 (0)