|
12 | 12 | ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
|
13 | 13 |
|
14 | 14 | 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: |
16 | 21 | strategy:
|
17 | 22 | matrix:
|
18 | 23 | java: [ 21 ]
|
19 |
| - # Job name |
20 |
| - name: Build and test SecurityAnalytics |
| 24 | + needs: Get-CI-Image-Tag |
21 | 25 | # This job runs on Linux
|
22 | 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 | + options: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-options }} |
| 32 | + |
| 33 | + name: Build and test SecurityAnalytics with security-enabled |
23 | 34 | steps:
|
| 35 | + - name: Run start commands |
| 36 | + run: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-start-command }} |
| 37 | + |
24 | 38 | # This step uses the setup-java Github action: https://github.com/actions/setup-java
|
25 | 39 | - name: Set Up JDK ${{ matrix.java }}
|
26 |
| - uses: actions/setup-java@v1 |
| 40 | + uses: actions/setup-java@v4 |
27 | 41 | with:
|
| 42 | + distribution: temurin # Temurin is a distribution of adoptium |
28 | 43 | java-version: ${{ matrix.java }}
|
| 44 | + |
29 | 45 | # This step uses the checkout Github action: https://github.com/actions/checkout
|
30 | 46 | - name: Checkout Branch
|
31 | 47 | 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 |
40 | 48 |
|
41 |
| - - name: Pull and Run Docker |
| 49 | + - name: Run integration tests |
42 | 50 | 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'" |
51 | 53 |
|
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