Skip to content

Commit 98ff9fa

Browse files
Fixes version reader in demo config installer and fixes a type CI workflow
Signed-off-by: Darshit Chanpura <dchanp@amazon.com>
1 parent 3c89602 commit 98ff9fa

File tree

3 files changed

+94
-15
lines changed

3 files changed

+94
-15
lines changed

.github/workflows/ci.yml

+81-7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ jobs:
5050
./gradlew :opensearch-security-common:publishToMavenLocal -Dbuild.snapshot=false
5151
./gradlew :opensearch-security-client:publishToMavenLocal -Dbuild.snapshot=false
5252
53+
- name: Cache artifacts for dependent jobs
54+
uses: actions/cache@v4.2.2
55+
with:
56+
path: ~/.m2/repository
57+
key: maven-local-${{ github.run_id }}
58+
restore-keys: |
59+
maven-local-
60+
5361
test:
5462
name: test
5563
needs: [generate-test-list, publish-components-to-maven-local]
@@ -71,6 +79,14 @@ jobs:
7179
- name: Checkout security
7280
uses: actions/checkout@v4
7381

82+
- name: Restore Maven Local Cache
83+
uses: actions/cache@v4.2.2
84+
with:
85+
path: ~/.m2/repository
86+
key: maven-local-${{ github.run_id }}
87+
restore-keys: |
88+
maven-local-
89+
7490
- name: Build and Test
7591
uses: gradle/gradle-build-action@v3
7692
with:
@@ -129,6 +145,14 @@ jobs:
129145
- name: Checkout security
130146
uses: actions/checkout@v4
131147

148+
- name: Restore Maven Local Cache
149+
uses: actions/cache@v4.2.2
150+
with:
151+
path: ~/.m2/repository
152+
key: maven-local-${{ github.run_id }}
153+
restore-keys: |
154+
maven-local-
155+
132156
- name: Run Integration Tests
133157
uses: gradle/gradle-build-action@v3
134158
with:
@@ -150,6 +174,48 @@ jobs:
150174
path: |
151175
./build/reports/
152176
177+
spi-tests:
178+
name: spi-tests
179+
needs: publish-components-to-maven-local
180+
strategy:
181+
fail-fast: false
182+
matrix:
183+
jdk: [21]
184+
platform: [ubuntu-latest, windows-latest]
185+
runs-on: ${{ matrix.platform }}
186+
187+
steps:
188+
- name: Set up JDK for build and test
189+
uses: actions/setup-java@v4
190+
with:
191+
distribution: temurin # Temurin is a distribution of adoptium
192+
java-version: ${{ matrix.jdk }}
193+
194+
- name: Checkout security
195+
uses: actions/checkout@v4
196+
197+
- name: Restore Maven Local Cache
198+
uses: actions/cache@v4.2.2
199+
with:
200+
path: ~/.m2/repository
201+
key: maven-local-${{ github.run_id }}
202+
restore-keys: |
203+
maven-local-
204+
205+
- name: Run SPI Tests
206+
uses: gradle/gradle-build-action@v3
207+
with:
208+
cache-disabled: true
209+
arguments: |
210+
:opensearch-resource-sharing-spi:test -Dbuild.snapshot=false
211+
212+
- uses: actions/upload-artifact@v4
213+
if: always()
214+
with:
215+
name: spi-${{ matrix.platform }}-JDK${{ matrix.jdk }}-reports
216+
path: |
217+
./build/reports/
218+
153219
resource-tests:
154220
env:
155221
CI_ENVIRONMENT: resource-test
@@ -171,6 +237,14 @@ jobs:
171237
- name: Checkout security
172238
uses: actions/checkout@v4
173239

240+
- name: Restore Maven Local Cache
241+
uses: actions/cache@v4.2.2
242+
with:
243+
path: ~/.m2/repository
244+
key: maven-local-${{ github.run_id }}
245+
restore-keys: |
246+
maven-local-
247+
174248
- name: Run Resource Tests
175249
uses: gradle/gradle-build-action@v3
176250
with:
@@ -277,31 +351,31 @@ jobs:
277351
278352
# Publish Client
279353
./gradlew :opensearch-security-client:publishToMavenLocal && test -s ./client/build/libs/opensearch-security-client-$security_plugin_version.jar
280-
./gradlew :opensearch-security-client-spi:publishToMavenLocal -Dbuild.snapshot=false && test -s ./client/build/libs/opensearch-security-client-$security_plugin_version_no_snapshot.jar
354+
./gradlew :opensearch-security-client:publishToMavenLocal -Dbuild.snapshot=false && test -s ./client/build/libs/opensearch-security-client-$security_plugin_version_no_snapshot.jar
281355
./gradlew :opensearch-security-client:publishToMavenLocal -Dbuild.snapshot=false -Dbuild.version_qualifier=$test_qualifier && test -s ./client/build/libs/opensearch-security-client-$security_plugin_version_only_number-$test_qualifier.jar
282356
./gradlew :opensearch-security-client:publishToMavenLocal -Dbuild.version_qualifier=$test_qualifier && test -s ./client/build/libs/opensearch-security-client-$security_plugin_version_only_number-$test_qualifier-SNAPSHOT.jar
283357
284358
# Build artifacts
285-
./gradlew clean assemble && \
359+
./gradlew assemble && \
286360
test -s ./build/distributions/opensearch-security-$security_plugin_version.zip && \
287361
test -s ./sample-resource-plugin/build/distributions/opensearch-sample-resource-plugin-$security_plugin_version.zip
288362
289-
./gradlew clean assemble -Dbuild.snapshot=false && \
363+
./gradlew assemble -Dbuild.snapshot=false && \
290364
test -s ./build/distributions/opensearch-security-$security_plugin_version_no_snapshot.zip && \
291365
test -s ./sample-resource-plugin/build/distributions/opensearch-sample-resource-plugin-$security_plugin_version_no_snapshot.zip
292366
293-
./gradlew clean assemble -Dbuild.snapshot=false -Dbuild.version_qualifier=$test_qualifier && \
367+
./gradlew assemble -Dbuild.snapshot=false -Dbuild.version_qualifier=$test_qualifier && \
294368
test -s ./build/distributions/opensearch-security-$security_plugin_version_only_number-$test_qualifier.zip && \
295369
test -s ./sample-resource-plugin/build/distributions/opensearch-sample-resource-plugin-$security_plugin_version_only_number-$test_qualifier.zip
296370
297-
./gradlew clean assemble -Dbuild.version_qualifier=$test_qualifier && \
371+
./gradlew assemble -Dbuild.version_qualifier=$test_qualifier && \
298372
test -s ./build/distributions/opensearch-security-$security_plugin_version_only_number-$test_qualifier-SNAPSHOT.zip && \
299373
test -s ./sample-resource-plugin/build/distributions/opensearch-sample-resource-plugin-$security_plugin_version_only_number-$test_qualifier-SNAPSHOT.zip
300374
301-
./gradlew clean publishPluginZipPublicationToZipStagingRepository && \
375+
./gradlew publishPluginZipPublicationToZipStagingRepository && \
302376
test -s ./build/distributions/opensearch-security-$security_plugin_version.zip && \
303377
test -s ./build/distributions/opensearch-security-$security_plugin_version.pom
304378
305379
- name: List files in build directory on failure
306380
if: failure()
307-
run: ls -al ./build/distributions/ ./*/build/libs
381+
run: ls -al ./*/build/libs/ ./build/distributions/

src/main/java/org/opensearch/security/tools/democonfig/Installer.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -330,19 +330,21 @@ void setSecurityVariables() {
330330

331331
// Extract OpenSearch version and Security version
332332
File[] opensearchLibFiles = new File(OPENSEARCH_LIB_PATH).listFiles(
333-
pathname -> pathname.getName().matches("opensearch-core-(.*).jar")
333+
pathname -> pathname.getName().matches("opensearch-core-(\\d+(\\.\\d+)*(-[a-zA-Z0-9]+)?(-SNAPSHOT)?).jar")
334334
);
335335

336336
if (opensearchLibFiles != null && opensearchLibFiles.length > 0) {
337-
OPENSEARCH_VERSION = opensearchLibFiles[0].getName().replaceAll("opensearch-core-(.*).jar", "$1");
337+
OPENSEARCH_VERSION = opensearchLibFiles[0].getName()
338+
.replaceAll("opensearch-core-(\\d+(\\.\\d+)*(-[a-zA-Z0-9]+)?(-SNAPSHOT)?).jar", "$1");
338339
}
339340

340341
File[] securityFiles = new File(OPENSEARCH_PLUGINS_DIR + "opensearch-security").listFiles(
341-
pathname -> pathname.getName().startsWith("opensearch-security-") && pathname.getName().endsWith(".jar")
342+
pathname -> pathname.getName().matches("opensearch-security-\\d+(\\.\\d+)*(-[a-zA-Z0-9]+)?(-SNAPSHOT)?.jar")
342343
);
343344

344345
if (securityFiles != null && securityFiles.length > 0) {
345-
SECURITY_VERSION = securityFiles[0].getName().replaceAll("opensearch-security-(.*).jar", "$1");
346+
SECURITY_VERSION = securityFiles[0].getName()
347+
.replaceAll("opensearch-security-(\\d+(\\.\\d+)*(-[a-zA-Z0-9]+)?(-SNAPSHOT)?).jar", "$1");
346348
}
347349
}
348350

src/test/java/org/opensearch/security/tools/democonfig/InstallerTests.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@ public void testSetSecurityVariables() {
307307
setUpSecurityDirectories();
308308
installer.setSecurityVariables();
309309

310-
assertThat(installer.OPENSEARCH_VERSION, is(equalTo("osVersion")));
311-
assertThat(installer.SECURITY_VERSION, is(equalTo("version")));
310+
assertThat(installer.OPENSEARCH_VERSION, is(equalTo("3.0.0-Version")));
311+
assertThat(installer.SECURITY_VERSION, is(equalTo("3.0.0.0-version")));
312312
tearDownSecurityDirectories();
313313
}
314314

@@ -481,8 +481,11 @@ public void setUpSecurityDirectories() {
481481
createDirectory(installer.OPENSEARCH_LIB_PATH);
482482
createDirectory(installer.OPENSEARCH_CONF_DIR);
483483
createDirectory(installer.OPENSEARCH_PLUGINS_DIR + "opensearch-security");
484-
createFile(installer.OPENSEARCH_LIB_PATH + "opensearch-core-osVersion.jar");
485-
createFile(installer.OPENSEARCH_PLUGINS_DIR + "opensearch-security" + File.separator + "opensearch-security-version.jar");
484+
createFile(installer.OPENSEARCH_LIB_PATH + "opensearch-core-3.0.0-Version.jar");
485+
createFile(
486+
installer.OPENSEARCH_PLUGINS_DIR + "opensearch-security" + File.separator + "opensearch-security-common-3.0.0.0-version.jar"
487+
);
488+
createFile(installer.OPENSEARCH_PLUGINS_DIR + "opensearch-security" + File.separator + "opensearch-security-3.0.0.0-version.jar");
486489
createFile(installer.OPENSEARCH_CONF_DIR + File.separator + "securityadmin_demo.sh");
487490
}
488491

0 commit comments

Comments
 (0)