Skip to content
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

Separated out tests in a different GHA workflow #84

Closed
wants to merge 10 commits into from

Conversation

owaiskazi19
Copy link
Member

Description

Separated out test, integTest and yamRestTest in a different GHA workflow

Issues Resolved

Part of #73

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

dbwiddis
dbwiddis previously approved these changes Oct 12, 2023
Copy link
Member

@dbwiddis dbwiddis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

See also this link for a potential fix for the flaky integ test.

run: |
./gradlew check
./gradlew check -x test -x integTest -x yamlRestTest
- name: Upload Coverage Report
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually... codecov may depend on the tests being run. Does this still work?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It didn't run on this PR. That's something to think about. Do you think I should try moving codecov to tests.yml?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. I'm still not clear on the motivation to split everything out from "check" which did it all anyway.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also since each step in the tests.yml does its own checkout, I'm not sure if the coverage would be cumulative for all the steps.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yaay! Codecov worked!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The motivation behind is to run the tests and build in parallel and reduce the CI time overall when our plugin will become more heavy.

Copy link
Member

@dbwiddis dbwiddis Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run the tests and build in parallel

Hmm.

Full gradle check gives a total time of 50.570s.
Gradle check without the tests takes 9.819s.
Running the tests separately gives 42.721s, because you're still running them sequentially.

You could get them to run in parallel by putting them up under the highest level jobs: label.

Task Duration
:integTest 14.761s
:test 14.051s
:yamlRestTest 10.518s

Note jacoco is only considering unit tests, so you could (for now) put jacoco in that job and run the other two jobs without jacoco.

jacocoTestReport {
    dependsOn test
    reports {
        xml.required = true
    }
}

There are ways to get jacoco to combine others: https://docs.gradle.org/7.4-rc-1/userguide/test_report_aggregation_plugin.html but I'm not sure that's needed.

Signed-off-by: Owais Kazi <[email protected]>
Signed-off-by: Owais Kazi <[email protected]>
@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Merging #84 (dad496b) into main (014475d) will increase coverage by 0.17%.
The diff coverage is n/a.

@@             Coverage Diff              @@
##               main      #84      +/-   ##
============================================
+ Coverage     81.68%   81.85%   +0.17%     
- Complexity      285      287       +2     
============================================
  Files            30       30              
  Lines          1119     1119              
  Branches        125      125              
============================================
+ Hits            914      916       +2     
  Misses          160      160              
+ Partials         45       43       -2     

see 2 files with indirect coverage changes

Comment on lines 11 to 42
test:
strategy:
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
java:
- 17
if: github.repository == 'opensearch-project/opensearch-ai-flow-framework'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin

- name: Test
run: ./gradlew test

- name: YamlRestTest
run:
./gradlew yamlRestTest

- name: integTest
run:
./gradlew integTest

- name: Run Tests with Coverage
run:
./gradlew test jacocoTestReport --info

- name: Upload Coverage Report
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
with:
file: ./build/reports/jacoco/test/jacocoTestReport.xml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
test:
strategy:
matrix:
os:
- ubuntu-latest
- macOS-latest
- windows-latest
java:
- 17
if: github.repository == 'opensearch-project/opensearch-ai-flow-framework'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
- name: Test
run: ./gradlew test
- name: YamlRestTest
run:
./gradlew yamlRestTest
- name: integTest
run:
./gradlew integTest
- name: Run Tests with Coverage
run:
./gradlew test jacocoTestReport --info
- name: Upload Coverage Report
if: matrix.os == 'ubuntu-latest'
uses: codecov/codecov-action@v3
with:
file: ./build/reports/jacoco/test/jacocoTestReport.xml
test:
if: github.repository == 'opensearch-project/opensearch-ai-flow-framework'
strategy:
matrix:
test:
- test jacocoTestReport
- integTest
- yamlRestTest
os:
- ubuntu-latest
- macOS-latest
- windows-latest
java:
- 17
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: temurin
- name: Test
run: ./gradlew ${{ matrix.test }}
- name: Upload Coverage Report
if: matrix.os == 'ubuntu-latest' && matrix.test == 'test jacocoTestReport'
uses: codecov/codecov-action@v3
with:
file: ./build/reports/jacoco/test/jacocoTestReport.xml

Copy link
Member Author

@owaiskazi19 owaiskazi19 Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could have raised the PR directly :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably not the right way to go, just pointing out how to achieve what you're trying to do :)

Signed-off-by: Owais Kazi <[email protected]>
uses: codecov/codecov-action@v3
with:
file: ./build/reports/jacoco/test/jacocoTestReport.xml
./gradlew check -x test -x integTest -x yamlRestTest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just wondering, why not use gradlew build here?

Copy link
Member Author

@owaiskazi19 owaiskazi19 Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can. I don't have any strong opinion here. We had check before I kept the same.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am good with either, ./gradlew build means we also run assemble which runs the :compileJava, :processResources which check does also but this does it into a jar.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it to build.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should step back and figure out all the dependencies and figure out what we are trying to optimize here. With the current PR we're shifting the tests somewhere else (still in series so not really gaining much) but duplicating compile/build stuff in parallel.

My general preference would be for CI to keep all the check stuff and test and code coverage bits, and just spin off the integ tests and yaml tests into another job in parallel (or just put them in the CI yaml at the top level under "jobs").

Lots of different ways to do it, haven't really been convinced we have a problem that needs solving yet :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you. I will go ahead and close the PR. We can always come back and open it back when the plugin becomes heavy.

- macOS-latest
- windows-latest
java:
- 17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember in AD we had to test on 11, 17, 20. Should we do that here too? I think default for 2.x is jdk 11 still but could be wrong

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbwiddis WDYT? Since you worked on the CI initially.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://opensearch.org/docs/latest/install-and-configure/install-opensearch/index/#java-compatibility this is what we have documented and i think java 20 is going to be for 3.x

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pushed the change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably match whatever OpenSearch tests.

test:
- test jacocoTestReport
- integTest
- yamlRestTest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also just for understanding, what are yamlRestTests for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for testing the rest-api-spec yaml files. We don't have right now for our plugin, but we would in the future.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Signed-off-by: Owais Kazi <[email protected]>
@owaiskazi19
Copy link
Member Author

Closing this PR, as the plugin is quite lightweight now and doesn't take much time to process. This PR has some good discussion for the CI. We can always revisit this later later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport PRs to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants