Skip to content

[Do not merge]remove ITs to test code coverage #3672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
268 changes: 134 additions & 134 deletions .github/workflows/CI-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,102 +98,102 @@ jobs:
path: ./jacocoTestReport.xml


Test-ml-linux-docker:
needs: [Get-Require-Approval, Build-ml-linux, spotless]
strategy:
matrix:
java: [21, 23]

name: Test MLCommons Plugin on linux docker
if: github.repository == 'opensearch-project/ml-commons'
environment: ${{ needs.Get-Require-Approval.outputs.is-require-approval }}
runs-on: ubuntu-latest

steps:
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.ML_ROLE }}
aws-region: us-west-2

- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Checkout MLCommons
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/download-artifact@v4
with:
name: ml-plugin-linux-${{ matrix.java }}

- name: Pull and Run Docker
run: |
plugin=${{ needs.Build-ml-linux.outputs.build-test-linux }}
version=`echo $plugin|awk -F- '{print $3}'| cut -d. -f 1-3`
plugin_version=`echo $plugin|awk -F- '{print $3}'| cut -d. -f 1-4`
qualifier=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-1`

if [ -n "$qualifier" ] && [ "$qualifier" != "SNAPSHOT" ]; then
qualifier=-${qualifier}
else
qualifier=""
fi

docker_version=$version$qualifier

echo plugin version plugin_version qualifier docker_version
echo "($plugin) ($version) ($plugin_version) ($qualifier) ($docker_version)"

pwd && ls -l ./$plugin

if docker pull opensearchstaging/opensearch:$docker_version
then
echo "FROM opensearchstaging/opensearch:$docker_version" >> Dockerfile
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-skills ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-skills; fi" >> Dockerfile
echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-ml ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-ml; fi" >> Dockerfile
echo "COPY $plugin /tmp/" >> Dockerfile
echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/$plugin" >> Dockerfile
docker build -t opensearch-ml:test .
echo "imagePresent=true" >> $GITHUB_ENV
else
echo "imagePresent=false" >> $GITHUB_ENV
fi
- name: Generate Password For Admin
id: genpass
run: |
PASSWORD=$(openssl rand -base64 20 | tr -dc 'A-Za-z0-9!@#$%^&*()_+=-')
echo "password={$PASSWORD}" >> $GITHUB_OUTPUT
- name: Run Docker Image
if: env.imagePresent == 'true'
run: |
cd ..
docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" -e OPENSEARCH_INITIAL_ADMIN_PASSWORD=${{ steps.genpass.outputs.password }} opensearch-ml:test
sleep 90
- name: Run MLCommons Test
if: env.imagePresent == 'true'
run: |
security=`curl -XGET https://localhost:9200/_cat/plugins?v -u admin:${{ steps.genpass.outputs.password }} --insecure |grep opensearch-security|wc -l`
export OPENAI_KEY=$(aws secretsmanager get-secret-value --secret-id github_openai_key --query SecretString --output text)
export COHERE_KEY=$(aws secretsmanager get-secret-value --secret-id github_cohere_key --query SecretString --output text)
echo "::add-mask::$OPENAI_KEY"
echo "::add-mask::$COHERE_KEY"
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=${{ steps.genpass.outputs.password }} -x spotlessJava
else
echo "Security plugin is NOT available"
./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster" -x spotlessJava
fi

- name: Upload Coverage Report
uses: codecov/codecov-action@v4
with:
flags: ml-commons
token: ${{ secrets.CODECOV_TOKEN }}
# Test-ml-linux-docker:
# needs: [Get-Require-Approval, Build-ml-linux, spotless]
# strategy:
# matrix:
# java: [21, 23]
#
# name: Test MLCommons Plugin on linux docker
# if: github.repository == 'opensearch-project/ml-commons'
# environment: ${{ needs.Get-Require-Approval.outputs.is-require-approval }}
# runs-on: ubuntu-latest
#
# steps:
# - uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: ${{ secrets.ML_ROLE }}
# aws-region: us-west-2
#
# - name: Setup Java ${{ matrix.java }}
# uses: actions/setup-java@v1
# with:
# java-version: ${{ matrix.java }}
#
# - name: Checkout MLCommons
# uses: actions/checkout@v4
# with:
# ref: ${{ github.event.pull_request.head.sha }}
#
# - uses: actions/download-artifact@v4
# with:
# name: ml-plugin-linux-${{ matrix.java }}
#
# - name: Pull and Run Docker
# run: |
# plugin=${{ needs.Build-ml-linux.outputs.build-test-linux }}
# version=`echo $plugin|awk -F- '{print $3}'| cut -d. -f 1-3`
# plugin_version=`echo $plugin|awk -F- '{print $3}'| cut -d. -f 1-4`
# qualifier=`echo $plugin|awk -F- '{print $4}'| cut -d. -f 1-1`
#
# if [ -n "$qualifier" ] && [ "$qualifier" != "SNAPSHOT" ]; then
# qualifier=-${qualifier}
# else
# qualifier=""
# fi
#
# docker_version=$version$qualifier
#
# echo plugin version plugin_version qualifier docker_version
# echo "($plugin) ($version) ($plugin_version) ($qualifier) ($docker_version)"
#
# pwd && ls -l ./$plugin
#
# if docker pull opensearchstaging/opensearch:$docker_version
# then
# echo "FROM opensearchstaging/opensearch:$docker_version" >> Dockerfile
# echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-skills ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-skills; fi" >> Dockerfile
# echo "RUN if [ -d /usr/share/opensearch/plugins/opensearch-ml ]; then /usr/share/opensearch/bin/opensearch-plugin remove opensearch-ml; fi" >> Dockerfile
# echo "COPY $plugin /tmp/" >> Dockerfile
# echo "RUN /usr/share/opensearch/bin/opensearch-plugin install --batch file:/tmp/$plugin" >> Dockerfile
# docker build -t opensearch-ml:test .
# echo "imagePresent=true" >> $GITHUB_ENV
# else
# echo "imagePresent=false" >> $GITHUB_ENV
# fi
# - name: Generate Password For Admin
# id: genpass
# run: |
# PASSWORD=$(openssl rand -base64 20 | tr -dc 'A-Za-z0-9!@#$%^&*()_+=-')
# echo "password={$PASSWORD}" >> $GITHUB_OUTPUT
# - name: Run Docker Image
# if: env.imagePresent == 'true'
# run: |
# cd ..
# docker run -p 9200:9200 -d -p 9600:9600 -e "discovery.type=single-node" -e OPENSEARCH_INITIAL_ADMIN_PASSWORD=${{ steps.genpass.outputs.password }} opensearch-ml:test
# sleep 90
# - name: Run MLCommons Test
# if: env.imagePresent == 'true'
# run: |
# security=`curl -XGET https://localhost:9200/_cat/plugins?v -u admin:${{ steps.genpass.outputs.password }} --insecure |grep opensearch-security|wc -l`
# export OPENAI_KEY=$(aws secretsmanager get-secret-value --secret-id github_openai_key --query SecretString --output text)
# export COHERE_KEY=$(aws secretsmanager get-secret-value --secret-id github_cohere_key --query SecretString --output text)
# echo "::add-mask::$OPENAI_KEY"
# echo "::add-mask::$COHERE_KEY"
# 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=${{ steps.genpass.outputs.password }} -x spotlessJava
# else
# echo "Security plugin is NOT available"
# ./gradlew integTest -Dtests.rest.cluster=localhost:9200 -Dtests.cluster=localhost:9200 -Dtests.clustername="docker-cluster" -x spotlessJava
# fi
#
# - name: Upload Coverage Report
# uses: codecov/codecov-action@v4
# with:
# flags: ml-commons
# token: ${{ secrets.CODECOV_TOKEN }}

Precommit-codecov:
needs: Build-ml-linux
Expand All @@ -213,44 +213,44 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./jacocoTestReport.xml

Build-ml-windows:
strategy:
matrix:
java: [21, 23]
name: Build and Test MLCommons Plugin on Windows
if: github.repository == 'opensearch-project/ml-commons'
needs: [Get-Require-Approval, spotless]
environment: ${{ needs.Get-Require-Approval.outputs.is-require-approval }}
runs-on: windows-latest

steps:
- name: Setup Java ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.ML_ROLE }}
aws-region: us-west-2

# ml-commons
- name: Checkout MLCommons
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Build and Run Tests
shell: bash
run: |
export OPENAI_KEY=$(aws secretsmanager get-secret-value --secret-id github_openai_key --query SecretString --output text)
export COHERE_KEY=$(aws secretsmanager get-secret-value --secret-id github_cohere_key --query SecretString --output text)
echo "::add-mask::$OPENAI_KEY"
echo "::add-mask::$COHERE_KEY"
./gradlew.bat build -x spotlessJava
- name: Publish to Maven Local
run: |
./gradlew publishToMavenLocal -x spotlessJava
# Build-ml-windows:
# strategy:
# matrix:
# java: [21, 23]
# name: Build and Test MLCommons Plugin on Windows
# if: github.repository == 'opensearch-project/ml-commons'
# needs: [Get-Require-Approval, spotless]
# environment: ${{ needs.Get-Require-Approval.outputs.is-require-approval }}
# runs-on: windows-latest
#
# steps:
# - name: Setup Java ${{ matrix.java }}
# uses: actions/setup-java@v1
# with:
# java-version: ${{ matrix.java }}
#
# - uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: ${{ secrets.ML_ROLE }}
# aws-region: us-west-2
#
# # ml-commons
# - name: Checkout MLCommons
# uses: actions/checkout@v4
# with:
# ref: ${{ github.event.pull_request.head.sha }}
#
# - name: Build and Run Tests
# shell: bash
# run: |
# export OPENAI_KEY=$(aws secretsmanager get-secret-value --secret-id github_openai_key --query SecretString --output text)
# export COHERE_KEY=$(aws secretsmanager get-secret-value --secret-id github_cohere_key --query SecretString --output text)
# echo "::add-mask::$OPENAI_KEY"
# echo "::add-mask::$COHERE_KEY"
# ./gradlew.bat build -x spotlessJava
# - name: Publish to Maven Local
# run: |
# ./gradlew publishToMavenLocal -x spotlessJava
# - name: Multi Nodes Integration Testing
# shell: bash
# run: |
Expand Down
12 changes: 6 additions & 6 deletions plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ integTest {
// Only rest case can run with remote cluster
if (System.getProperty("tests.rest.cluster") != null) {
filter {
includeTestsMatching "org.opensearch.ml.rest.*IT"
includeTestsMatching "org.opensearch.ml.tools.VisualizationsToolIT"
// mock LLM run in localhost, it will not reachable for docker or remote cluster
excludeTestsMatching "org.opensearch.ml.tools.VisualizationsToolIT"
// excludeTestsMatching "org.opensearch.ml.tools.VisualizationsToolIT"
}
}

Expand Down Expand Up @@ -292,9 +292,9 @@ task integTestRemote(type: RestIntegTestTask) {
// Only rest case can run with remote cluster
if (System.getProperty("tests.rest.cluster") != null) {
filter {
includeTestsMatching "org.opensearch.ml.rest.*IT"
includeTestsMatching "org.opensearch.ml.tools.VisualizationsToolIT"
// mock LLM run in localhost, it will not reachable for docker or remote cluster
excludeTestsMatching "org.opensearch.ml.tools.VisualizationsToolIT"
// excludeTestsMatching "org.opensearch.ml.tools.VisualizationsToolIT"
}
}
}
Expand Down Expand Up @@ -381,7 +381,7 @@ jacocoTestCoverageVerification {
excludes = jacocoExclusions
limit {
counter = 'BRANCH'
minimum = 0.7 //TODO: change this value to 0.7
minimum = 0.0 //TODO: change this value to 0.7
}
}
rule {
Expand All @@ -390,7 +390,7 @@ jacocoTestCoverageVerification {
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.8 //TODO: change this value to 0.8
minimum = 0.0 //TODO: change this value to 0.8
}
}
}
Expand Down
Loading
Loading