Skip to content

Commit f198ac2

Browse files
authored
Fix security-enabled test workflow. (#1494)
* Reconfigured security test workflow for 3.0-alpha1. Signed-off-by: AWSHurneyt <[email protected]> * Fix test workflow. Signed-off-by: AWSHurneyt <[email protected]> * Fixed spotless error. Signed-off-by: AWSHurneyt <[email protected]> --------- Signed-off-by: AWSHurneyt <[email protected]>
1 parent b631924 commit f198ac2

File tree

4 files changed

+254
-71
lines changed

4 files changed

+254
-71
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ on:
66
pull_request:
77
branches:
88
- "*"
9-
env:
10-
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
119

1210
jobs:
1311
Get-CI-Image-Tag:
@@ -18,9 +16,14 @@ jobs:
1816
build-linux:
1917
needs: Get-CI-Image-Tag
2018
strategy:
19+
# This setting says that all jobs should finish, even if one fails
20+
fail-fast: false
2121
matrix:
2222
java: [21, 23]
23-
os: [ ubuntu-latest ]
23+
os:
24+
- ubuntu-24.04-arm # arm64-preview
25+
- ubuntu-24.04 # x64
26+
2427
name: Build and Test security-analytics with JDK ${{ matrix.java }} on ${{ matrix.os }}
2528
runs-on: ${{ matrix.os }}
2629
container:
@@ -33,12 +36,14 @@ jobs:
3336
steps:
3437
- name: Run start commands
3538
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
39+
3640
- name: Checkout
3741
uses: actions/checkout@v4
3842

3943
- name: Setup Java ${{ matrix.java }}
40-
uses: actions/setup-java@v1
44+
uses: actions/setup-java@v4
4145
with:
46+
distribution: temurin # Temurin is a distribution of adoptium
4247
java-version: ${{ matrix.java }}
4348

4449
- name: Build and Test
@@ -91,7 +96,7 @@ jobs:
9196
runs-on: ${{ matrix.os }}
9297

9398
steps:
94-
- name: Checkout
99+
- name: Checkout Branch
95100
uses: actions/checkout@v4
96101

97102
# This is a hack, but this step creates a link to the X: mounted drive, which makes the path

.github/workflows/security-test-workflow.yml

Lines changed: 30 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -12,80 +12,49 @@ env:
1212
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
1313

1414
jobs:
15-
build:
15+
Get-CI-Image-Tag:
16+
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
17+
with:
18+
product: opensearch
19+
20+
build-linux:
1621
strategy:
1722
matrix:
1823
java: [ 21 ]
19-
# Job name
20-
name: Build and test SecurityAnalytics
24+
needs: Get-CI-Image-Tag
2125
# This job runs on Linux
2226
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+
options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }}
32+
33+
name: Build and test SecurityAnalytics with security-enabled
2334
steps:
35+
- name: Run start commands
36+
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
37+
2438
# This step uses the setup-java Github action: https://github.com/actions/setup-java
2539
- name: Set Up JDK ${{ matrix.java }}
26-
uses: actions/setup-java@v1
40+
uses: actions/setup-java@v4
2741
with:
42+
distribution: temurin # Temurin is a distribution of adoptium
2843
java-version: ${{ matrix.java }}
44+
2945
# This step uses the checkout Github action: https://github.com/actions/checkout
3046
- name: Checkout Branch
3147
uses: actions/checkout@v4
32-
# This step uses the setup-java Github action: https://github.com/actions/setup-java
33-
- name: Set Up JDK ${{ matrix.java }}
34-
uses: actions/setup-java@v1
35-
with:
36-
java-version: ${{ matrix.java }}
37-
- name: Build SecurityAnalytics
38-
# Only assembling since the full build is governed by other workflows
39-
run: ./gradlew assemble
4048

41-
- name: Pull and Run Docker
49+
- name: Run integration tests
4250
run: |
43-
plugin=`basename $(ls build/distributions/*.zip)`
44-
list_of_files=`ls`
45-
list_of_all_files=`ls build/distributions/`
46-
version=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-3`
47-
plugin_version=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-4`
48-
qualifier=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-1`
49-
candidate_version=`echo $plugin|awk -F- '{print $5}'| cut -d. -f 1-1`
50-
docker_version=$version
51+
chown -R 1000:1000 `pwd`
52+
su `id -un 1000` -c "./gradlew integTest -Dsecurity=true -Dhttps=true --tests '*IT'"
5153
52-
[[ -z $candidate_version ]] && candidate_version=$qualifier && qualifier=""
53-
54-
echo plugin version plugin_version qualifier candidate_version docker_version
55-
echo "($plugin) ($version) ($plugin_version) ($qualifier) ($candidate_version) ($docker_version)"
56-
echo $ls $list_of_all_files
57-
58-
if docker pull opensearchstaging/opensearch:$docker_version
59-
then
60-
echo "FROM opensearchstaging/opensearch:$docker_version" >> Dockerfile
61-
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-security-analytics ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-security-analytics; fi" >> Dockerfile
62-
echo "ADD build/distributions/$plugin /tmp/" >> Dockerfile
63-
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/$plugin" >> Dockerfile
64-
65-
docker build -t opensearch-security-analytics:test .
66-
echo "imagePresent=true" >> $GITHUB_ENV
67-
else
68-
echo "imagePresent=false" >> $GITHUB_ENV
69-
fi
70-
71-
- name: Run Docker Image
72-
if: env.imagePresent == 'true'
73-
run: |
74-
cd ..
75-
docker run -p 9200:9200 -d -p 9600:9600 -e OPENSEARCH_INITIAL_ADMIN_PASSWORD=${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -e "discovery.type=single-node" opensearch-security-analytics:test
76-
sleep 120
77-
78-
- name: Run SecurityAnalytics Test for security enabled test cases
79-
if: env.imagePresent == 'true'
80-
run: |
81-
cluster_running=`curl -XGET https://localhost:9200/_cat/plugins -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} --insecure`
82-
echo $cluster_running
83-
security=`curl -XGET https://localhost:9200/_cat/plugins -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} --insecure |grep opensearch-security|wc -l`
84-
echo $security
85-
if [ $security -gt 0 ]
86-
then
87-
echo "Security plugin is available"
88-
./gradlew :integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername=docker-cluster -Dhttps=true -Duser=admin -Dpassword=${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }}
89-
else
90-
echo "Security plugin is NOT available skipping this run as tests without security have already been run"
91-
fi
54+
- name: Upload failed logs
55+
uses: actions/upload-artifact@v4
56+
if: failure()
57+
with:
58+
name: logs
59+
overwrite: 'true'
60+
path: build/testclusters/integTest-*/logs/*

0 commit comments

Comments
 (0)