-
Notifications
You must be signed in to change notification settings - Fork 73
134 lines (118 loc) · 4.85 KB
/
CI.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Build and Test Anomaly detection
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
jobs:
Build-ad:
strategy:
matrix:
java: [14]
name: Build and Test Anomaly detection Plugin
runs-on: ubuntu-latest
steps:
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
# anomaly-detection
- name: Checkout AD
uses: actions/checkout@v2
# dependencies: OpenSearch
- name: Checkout OpenSearch
uses: actions/checkout@v2
with:
repository: 'opensearch-project/OpenSearch'
path: OpenSearch
ref: '1.0.0'
- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal -Dbuild.snapshot=false
# dependencies: common-utils
- name: Checkout common-utils
uses: actions/checkout@v2
with:
ref: '1.0'
repository: 'opensearch-project/common-utils'
path: common-utils
- name: Build common-utils
working-directory: ./common-utils
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0
# dependencies: job-scheduler
- name: Checkout job-scheduler
uses: actions/checkout@v2
with:
ref: '1.0'
repository: 'opensearch-project/job-scheduler'
path: job-scheduler
- name: Build job-scheduler
working-directory: ./job-scheduler
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.0.0 -Dbuild.snapshot=false
- name: Assemble job-scheduler
working-directory: ./job-scheduler
run: |
./gradlew assemble -Dopensearch.version=1.0.0 -Dbuild.snapshot=false
echo "Creating ../src/test/resources/job-scheduler ..."
mkdir -p ../src/test/resources/job-scheduler
pwd
echo "Copying ./build/distributions/*.zip to ../src/test/resources/job-scheduler ..."
ls ./build/distributions/
cp ./build/distributions/*.zip ../src/test/resources/job-scheduler
echo "Copied ./build/distributions/*.zip to ../src/test/resources/job-scheduler ..."
ls ../src/test/resources/job-scheduler
- name: Build and Run Tests
run: |
./gradlew build -Dopensearch.version=1.0.0
- name: Publish to Maven Local
run: |
./gradlew publishToMavenLocal -Dopensearch.version=1.0.0
- name: Multi Nodes Integration Testing
run: |
./gradlew integTest -PnumNodes=3
- name: Pull and Run Docker
run: |
## plugin=`ls build/distributions/*.zip`
## version=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-3`
## plugin_version=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-4`
## TODO: remove these two hard code versions below after GA release
version=1.0.0
plugin_version=1.0.0.0
echo $version
cd ..
if docker pull opensearchstaging/opensearch:$version
then
echo "FROM opensearchstaging/opensearch:$version" >> Dockerfile
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-anomaly-detection ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-anomaly-detection; fi" >> Dockerfile
echo "ADD anomaly-detection/build/distributions/opensearch-anomaly-detection-$plugin_version.zip /tmp/" >> Dockerfile
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/opensearch-anomaly-detection-$plugin_version.zip" >> Dockerfile
docker build -t opensearch-ad:test .
echo "imagePresent=true" >> $GITHUB_ENV
else
echo "imagePresent=false" >> $GITHUB_ENV
fi
- name: Run Docker Image
if: env.imagePresent == 'true'
run: |
cd ..
docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" opensearch-ad:test
sleep 90
- name: Run AD Test
if: env.imagePresent == 'true'
run: |
security=`curl -XGET https://localhost:9200/_cat/plugins?v -u admin:admin --insecure |grep opensearch-security|wc -l`
if [ $security -gt 0 ]
then
echo "Security plugin is available"
./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster" -Dhttps=true -Duser=admin -Dpassword=admin
else
echo "Security plugin is NOT available"
./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster"
fi
- name: Upload Coverage Report
uses: codecov/codecov-action@v1
with:
file: ./build/reports/jacoco/test/jacocoTestReport.xml
flags: plugin