Skip to content

Commit 2068d71

Browse files
authored
Add github action for security enabled integ tests (#49)
Signed-off-by: Chenyang Ji <cyji@amazon.com>
1 parent b31ed11 commit 2068d71

File tree

2 files changed

+91
-3
lines changed

2 files changed

+91
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Security Plugin IT
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches-ignore:
7+
- 'dependabot/**'
8+
paths:
9+
- 'integ-test/**'
10+
- '.github/workflows/integ-tests-with-security.yml'
11+
12+
jobs:
13+
Get-CI-Image-Tag:
14+
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
15+
with:
16+
product: opensearch
17+
18+
security-it-linux:
19+
needs: Get-CI-Image-Tag
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
java: [ 21 ]
24+
env:
25+
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
26+
runs-on: ubuntu-latest
27+
container:
28+
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
29+
# this image tag is subject to change as more dependencies and updates will arrive over time
30+
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
31+
# need to switch to root so that github actions can install runner binary on container without permission issues.
32+
options: --user root
33+
34+
steps:
35+
- uses: actions/checkout@v3
36+
37+
- name: Set up JDK ${{ matrix.java }}
38+
uses: actions/setup-java@v3
39+
with:
40+
distribution: 'temurin'
41+
java-version: ${{ matrix.java }}
42+
43+
- name: Build with Gradle
44+
run: |
45+
chown -R 1000:1000 `pwd`
46+
su `id -un 1000` -c "./gradlew integTestWithSecurity"
47+
48+
- name: Upload test reports
49+
if: ${{ always() }}
50+
uses: actions/upload-artifact@v2
51+
continue-on-error: true
52+
with:
53+
name: test-reports-${{ matrix.os }}-${{ matrix.java }}
54+
path: |
55+
integ-test/build/reports/**
56+
integ-test/build/testclusters/*/logs/*
57+
integ-test/build/testclusters/*/config/*
58+
59+
security-it-windows-macos:
60+
strategy:
61+
fail-fast: false
62+
matrix:
63+
os: [ windows-latest, macos-13 ]
64+
java: [ 21 ]
65+
66+
runs-on: ${{ matrix.os }}
67+
68+
steps:
69+
- uses: actions/checkout@v3
70+
71+
- name: Set up JDK ${{ matrix.java }}
72+
uses: actions/setup-java@v3
73+
with:
74+
distribution: 'temurin'
75+
java-version: ${{ matrix.java }}
76+
77+
- name: Build with Gradle
78+
run: ./gradlew integTestWithSecurity
79+
80+
- name: Upload test reports
81+
if: ${{ always() }}
82+
uses: actions/upload-artifact@v2
83+
continue-on-error: true
84+
with:
85+
name: test-reports-${{ matrix.os }}-${{ matrix.java }}
86+
path: |
87+
integ-test/build/reports/**
88+
integ-test/build/testclusters/*/logs/*
89+
integ-test/build/testclusters/*/config/*

build.gradle

+2-3
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ test {
198198
tasks.named("check").configure { dependsOn(integTest) }
199199

200200
integTest {
201+
useCluster testClusters.integTest
201202
// The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable
202203
if (System.getProperty("test.debug") != null) {
203204
jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005'
@@ -243,15 +244,13 @@ integTest {
243244
filter {
244245
includeTestsMatching 'org.opensearch.plugin.insights.rules.resthandler.top_queries.TopQueriesRestIT'
245246
}
247+
246248
if (System.getProperty("security.enabled") == "true") {
247-
useCluster testClusters.integTestWithSecurity
248249
getClusters().forEach { cluster ->
249250
configureSecurityPlugin(cluster)
250251
}
251252
systemProperty "user", "admin"
252253
systemProperty "password", "admin"
253-
} else {
254-
useCluster testClusters.integTest
255254
}
256255
}
257256

0 commit comments

Comments
 (0)