Skip to content

Commit 5c1b044

Browse files
cwperksamitgalitz
authored andcommitted
Use testclusters when testing with security (#1414)
* Use testclusters when testing with security Signed-off-by: Craig Perkins <[email protected]> * Add download plugin Signed-off-by: Craig Perkins <[email protected]> * Get js and security plugin Signed-off-by: Craig Perkins <[email protected]> * Add opensearchPlugin Signed-off-by: Craig Perkins <[email protected]> * Remove duplicate Signed-off-by: Craig Perkins <[email protected]> * Wait for yellow Signed-off-by: Craig Perkins <[email protected]> * Fix tests Signed-off-by: Craig Perkins <[email protected]> * Fix bwc test Signed-off-by: Craig Perkins <[email protected]> * Add prepareBwcTests Signed-off-by: Craig Perkins <[email protected]> * Add to developer guide Signed-off-by: Craig Perkins <[email protected]> * Add to CHANGELOG Signed-off-by: Craig Perkins <[email protected]> --------- Signed-off-by: Craig Perkins <[email protected]>
1 parent 5cc2cfc commit 5c1b044

File tree

5 files changed

+320
-131
lines changed

5 files changed

+320
-131
lines changed

.github/workflows/test_security.yml

+34-66
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,53 @@
1-
name: Security test workflow for Anomaly Detection
1+
name: Security test workflow
2+
# This workflow is triggered on pull requests to main
23
on:
3-
push:
4-
branches:
5-
- "*"
64
pull_request:
75
branches:
8-
- "*"
9-
10-
env:
11-
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
6+
- "**"
7+
push:
8+
branches:
9+
- "**"
1210

1311
jobs:
12+
Get-CI-Image-Tag:
13+
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
14+
with:
15+
product: opensearch
1416
Build-ad:
17+
needs: Get-CI-Image-Tag
1518
strategy:
1619
matrix:
1720
java: [11,17,21]
1821
fail-fast: false
1922

2023
name: Security test workflow for Anomaly Detection
2124
runs-on: ubuntu-latest
25+
container:
26+
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
27+
# this image tag is subject to change as more dependencies and updates will arrive over time
28+
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
29+
options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }}
2230

2331
steps:
24-
- name: Setup Java ${{ matrix.java }}
25-
uses: actions/setup-java@v3
32+
- name: Run start commands
33+
run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }}
34+
# This step uses the setup-java Github action: https://github.com/actions/setup-java
35+
- name: Set Up JDK
36+
uses: actions/setup-java@v4
2637
with:
27-
distribution: 'temurin'
38+
distribution: temurin # Temurin is a distribution of adoptium
2839
java-version: ${{ matrix.java }}
29-
30-
# time-series-analytics
31-
- name: Checkout AD
40+
# index-management
41+
- name: Checkout Branch
3242
uses: actions/checkout@v4
33-
34-
- name: Build Anomaly Detection
43+
- name: Run integration tests
3544
run: |
36-
./gradlew assemble
37-
# example of variables:
38-
# plugin = opensearch-time-series-analytics-2.10.0.0-SNAPSHOT.zip
39-
# version = 2.10.0, plugin_version = 2.10.0.0, qualifier = SNAPSHOT
40-
- name: Pull and Run Docker
41-
run: |
42-
plugin=`basename $(ls build/distributions/*.zip)`
43-
version=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-3`
44-
plugin_version=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-4`
45-
qualifier=`echo $plugin|awk -F- '{print $5}'| cut -d. -f 1-1`
46-
47-
if $qualifier!=SNAPSHOT
48-
then
49-
docker_version=$version-$qualifier
50-
else
51-
docker_version=$version
52-
fi
53-
echo plugin version plugin_version qualifier docker_version
54-
echo "($plugin) ($version) ($plugin_version) ($qualifier) ($docker_version)"
55-
56-
cd ..
57-
if docker pull opensearchstaging/opensearch:$docker_version
58-
then
59-
echo "FROM opensearchstaging/opensearch:$docker_version" >> Dockerfile
60-
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-anomaly-detection ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-anomaly-detection; fi" >> Dockerfile
61-
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-time-series-analytics ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-time-series-analytics; fi" >> Dockerfile
62-
echo "ADD anomaly-detection/build/distributions/$plugin /tmp/" >> Dockerfile
63-
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/$plugin" >> Dockerfile
64-
docker build -t opensearch-ad:test .
65-
echo "imagePresent=true" >> $GITHUB_ENV
66-
else
67-
echo "imagePresent=false" >> $GITHUB_ENV
68-
fi
69-
- name: Run Docker Image
70-
if: env.imagePresent == 'true'
71-
run: |
72-
cd ..
73-
docker run -p 9200:9200 -d -p 9600:9600 -e "OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123!" -e "discovery.type=single-node" opensearch-ad:test
74-
sleep 90
75-
- name: Run AD Test
76-
if: env.imagePresent == 'true'
77-
run: |
78-
security=`curl -XGET https://localhost:9200/_cat/plugins?v -u admin:myStrongPassword123! --insecure |grep opensearch-security|wc -l`
79-
if [ $security -gt 0 ]
80-
then
81-
echo "Security plugin is available"
82-
./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster" -Dhttps=true -Duser=admin -Dpassword=myStrongPassword123!
83-
else
84-
echo "Security plugin is NOT available, skipping integration tests"
85-
fi
45+
chown -R 1000:1000 `pwd`
46+
su `id -un 1000` -c "./gradlew integTest -Dsecurity=true -Dhttps=true --tests '*IT'"
47+
- name: Upload failed logs
48+
uses: actions/upload-artifact@v4
49+
if: failure()
50+
with:
51+
name: logs
52+
overwrite: 'true'
53+
path: build/testclusters/integTest-*/logs/*

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.1.0/)
66
## [Unreleased 3.0](https://github.com/opensearch-project/anomaly-detection/compare/2.x...HEAD)
77
### Features
88
### Enhancements
9+
- Use testclusters when testing with security ([#1414](https://github.com/opensearch-project/anomaly-detection/pull/1414))
910
### Bug Fixes
1011
### Infrastructure
1112

DEVELOPER_GUIDE.md

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Currently we just put RCF jar in lib as dependency. Plan to publish to Maven and
5151
10. `./gradlew bwcTestSuite -Dtests.security.manager=false` runs all the above bwc tests combined.
5252
11. `./gradlew ':test' --tests "org.opensearch.ad.ml.HCADModelPerfTests" -Dtests.seed=2AEBDBBAE75AC5E0 -Dtests.security.manager=false -Dtests.locale=es-CU -Dtests.timezone=Chile/EasterIsland -Dtest.logs=true -Dmodel-benchmark=true` launches HCAD model performance tests and logs the result in the standard output
5353
12. `./gradlew integTest --tests "org.opensearch.ad.e2e.SingleStreamModelPerfIT" -Dtests.seed=60CDDB34427ACD0C -Dtests.security.manager=false -Dtests.locale=kab-DZ -Dtests.timezone=Asia/Hebron -Dtest.logs=true -Dmodel-benchmark=true` launches single stream AD model performance tests and logs the result in the standard output
54+
13. `./gradlew integTest -Dsecurity=true -Dhttps=true --tests '*IT'` runs integration tests against a secure cluster
5455

5556
When launching a cluster using one of the above commands logs are placed in `/build/cluster/run node0/opensearch-<version>/logs`. Though the logs are teed to the console, in practices it's best to check the actual log file.
5657

0 commit comments

Comments
 (0)