|
1 |
| -name: Security test workflow for Anomaly Detection |
| 1 | +name: Security test workflow |
| 2 | +# This workflow is triggered on pull requests to main |
2 | 3 | on:
|
3 |
| - push: |
4 |
| - branches: |
5 |
| - - "*" |
6 | 4 | pull_request:
|
7 | 5 | branches:
|
8 |
| - - "*" |
9 |
| - |
10 |
| -env: |
11 |
| - ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true |
| 6 | + - "**" |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - "**" |
12 | 10 |
|
13 | 11 | 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 |
14 | 16 | Build-ad:
|
| 17 | + needs: Get-CI-Image-Tag |
15 | 18 | strategy:
|
16 | 19 | matrix:
|
17 | 20 | java: [11,17,21]
|
18 | 21 | fail-fast: false
|
19 | 22 |
|
20 | 23 | name: Security test workflow for Anomaly Detection
|
21 | 24 | 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 }} |
22 | 30 |
|
23 | 31 | 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 |
26 | 37 | with:
|
27 |
| - distribution: 'temurin' |
| 38 | + distribution: temurin # Temurin is a distribution of adoptium |
28 | 39 | java-version: ${{ matrix.java }}
|
29 |
| - |
30 |
| - # time-series-analytics |
31 |
| - - name: Checkout AD |
| 40 | + # index-management |
| 41 | + - name: Checkout Branch |
32 | 42 | uses: actions/checkout@v4
|
33 |
| - |
34 |
| - - name: Build Anomaly Detection |
| 43 | + - name: Run integration tests |
35 | 44 | 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/* |
0 commit comments