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

Fix snapshot build using OpenSearch 1.1. #53

Merged
merged 3 commits into from
Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
40 changes: 21 additions & 19 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,46 +13,48 @@ jobs:
runs-on: [ubuntu-latest]
name: Building PA package
steps:
- name: Checkout Performance Analyzer package
uses: actions/checkout@v2
with:
path: ./tmp/pa
# fetch the main branch to make it available for spotless ratcheting
- name: Fetch 'main' branch
working-directory: ./tmp/pa
run: git fetch --depth=1 origin main
- name: Set up JDK 1.12
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 1.12
java-version: 14
# dependencies: OpenSearch
- name: Checkout OpenSearch
uses: actions/checkout@v2
with:
repository: 'opensearch-project/OpenSearch'
path: OpenSearch
ref: '1.0'
ref: '1.x'
- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal -Dbuild.snapshot=false
run: ./gradlew publishToMavenLocal

# Performance Analyzer in ./tmp/performance-analyzer
- name: Checkout Performance Analyzer package
uses: actions/checkout@v2
with:
path: ./tmp/performance-analyzer
# Explicitly set the docker-compose program path so that our build scripts in RCA can run the program
# This is necessary because of the Github Actions environment and the workingDir of the Gradle environment
- name: Set docker-compose path
run: DOCKER_COMPOSE_LOCATION=$(which docker-compose)
# Set the vm.max_map_count system property to the minimum required to run OpenSearch
- name: Set vm.max_map_count
run: sudo sysctl -w vm.max_map_count=262144
- name: Build PA and run Unit Tests
working-directory: ./tmp/pa
run: ./gradlew build -Dperformance-analyzer-rca.build=true -Dperformance-analyzer-rca.branch=main
- name: Build Performance Analyzer and run Unit Tests
working-directory: ./tmp/performance-analyzer
run: |
./gradlew build -Dperformance-analyzer-rca.build=true \
-Dperformance-analyzer-rca.repo="https://github.com/dblock/performance-analyzer-rca.git" \
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we change this to the main repo before merging?

Copy link
Member Author

@dblock dblock Aug 20, 2021

Choose a reason for hiding this comment

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

Sure, but it will break the build. So, we can't. And if I merge opensearch-project/performance-analyzer-rca#55 it's the same problem for that PR. I think the safe thing to do is to merge this PR and opensearch-project/performance-analyzer-rca#55 and then go and change on both sides carefully (which I will do).

-Dperformance-analyzer-rca.branch=fix-snapshot-build \
-Dopensearch.version=1.1.0-SNAPSHOT
- name: Generate Jacoco coverage report
working-directory: ./tmp/pa
working-directory: ./tmp/performance-analyzer
run: ./gradlew jacocoTestReport
- name: Upload coverage report
working-directory: ./tmp/pa
working-directory: ./tmp/performance-analyzer
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
run: bash <(curl -s https://codecov.io/bash) -f ./build/reports/jacoco/test/jacocoTestReport.xml
- name: Run Integration Tests
working-directory: ./tmp/pa
run: ./gradlew integTest -Dtests.enableIT -Dtests.useDockerCluster
working-directory: ./tmp/performance-analyzer
run: ./gradlew integTest -Dtests.enableIT -Dtests.useDockerCluster -Dopensearch.version=1.1.0-SNAPSHOT
39 changes: 20 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
buildscript {

ext {
opensearch_version = System.getProperty("opensearch.version", "1.0.0")
opensearch_version = System.getProperty("opensearch.version", "1.1.0-SNAPSHOT")
}

// Used to resolve build file dependencies
Expand Down Expand Up @@ -68,21 +68,21 @@ spotbugsTest {
}

ext {
opensearchVersion = '1.0.0'
isSnapshot = "true" == System.getProperty("build.snapshot", "true")

// The RCA branch that will be built. Default value is main.
rcaProjectBranch = findProperty("performance-analyzer-rca.branch") ?: "main"
// The RCA branch that will be built. Default branch is main.
rcaProjectRepo = System.getProperty("performance-analyzer-rca.repo", "https://github.com/opensearch-project/performance-analyzer-rca.git")
rcaProjectBranch = System.getProperty("performance-analyzer-rca.branch", "main")

// If true, then the build will clone the RCA Project into $rcaProjectDir
cloneRcaProject = "true" == System.getProperty("performance-analyzer-rca.build", "true")

// By default we will look for RCA in a peer directory
rcaProjectDir = findProperty("performance-analyzer-rca.path") ?: "../performance-analyzer-rca"
rcaProjectDir = System.getProperty("performance-analyzer-rca.path", "../performance-analyzer-rca")
}

group = "org.opensearch"
version = "${opensearchVersion}.0"
version = opensearch_version - '-SNAPSHOT' + '.0'
if (isSnapshot) {
version += "-SNAPSHOT"
}
Expand Down Expand Up @@ -248,7 +248,7 @@ dependencies {
compile 'org.apache.commons:commons-lang3:3.9'
compile 'org.bouncycastle:bcprov-jdk15on:1.68'
compile 'org.bouncycastle:bcpkix-jdk15on:1.68'
compile 'org.opensearch:performanceanalyzer-rca:1.0.0.0'
compile "org.opensearch:performanceanalyzer-rca:${version}"
compile "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
compile "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
compile "com.fasterxml.jackson.module:jackson-module-paranamer:${jacksonVersion}"
Expand Down Expand Up @@ -311,53 +311,54 @@ static def propEnabled(property) {
// Pass the -Dtests.enableIT property to Gradle to run ITs

/**
* cloneGitRepo clones the performance-analyzer-rca repo if the -Dtests.enableIT=true flag is passed
* cloneRcaGitRepo clones the performance-analyzer-rca repo if the -Dtests.enableIT=true flag is passed
* to the Gradle JVM
*/
task cloneGitRepo(type: GitClone) {
task cloneRcaGitRepo(type: GitClone) {
def destination = file(rcaProjectDir)
uri = "https://github.com/opensearch-project/performance-analyzer-rca.git"
uri = rcaProjectRepo
branch = rcaProjectBranch
destinationPath = destination
bare = false
enabled = cloneRcaProject && !destination.exists() // to clone only once

doFirst {
logger.info("Cloning performance-analyzer-rca into ${rcaProjectDir}")
logger.info("Cloning performance-analyzer-rca into ${rcaProjectDir} from ${rcaProjectRepo}#${rcaProjectBranch}")
}
}

task buildRca() {
dependsOn(cloneGitRepo)
dependsOn(cloneRcaGitRepo)

doFirst {
logger.info("Building performance-analyzer-rca project in ${rcaProjectDir}")
logger.info("Building performance-analyzer-rca project in ${rcaProjectDir} with -Dopensearch.version=${opensearch_version}")
}

doLast {
exec {
workingDir("$rcaProjectDir")
commandLine './gradlew', 'build', '-x', 'test'
commandLine './gradlew', 'build', '-x', 'test', "-Dopensearch.version=${opensearch_version}"
}
exec {
workingDir("$rcaProjectDir")
commandLine './gradlew', 'publishToMavenLocal'
commandLine './gradlew', 'publishToMavenLocal', "-Dopensearch.version=${opensearch_version}"
}
exec {
def licenseDir = "$projectDir/licenses"
workingDir("$licenseDir")
commandLine 'rm', "-f", "performanceanalyzer-rca-1.0.0.0.jar.sha1"
commandLine 'rm', "-f", "performanceanalyzer-rca-${project.version}.jar.sha1"
Copy link
Contributor

@sruti1312 sruti1312 Aug 20, 2021

Choose a reason for hiding this comment

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

version or opensearch.version?

}
}
}

buildRca.finalizedBy updateShas

// This value is set by the unpackRca task
def rcaArtifactsDir

task unpackRca(type: Copy) {
dependsOn(buildRca)
from(zipTree("$rcaProjectDir/build/distributions/performance-analyzer-rca.zip")) {
from(zipTree("$rcaProjectDir/build/distributions/performance-analyzer-rca-${version}.zip")) {
}
into "$rcaProjectDir/build/distributions"
rcaArtifactsDir = "$rcaProjectDir/build/distributions/performance-analyzer-rca/"
Expand Down Expand Up @@ -402,10 +403,10 @@ bundlePlugin {

/**
* setupOpenSearchCluster spins up a local 2 node OpenSearch cluster using the enableRca task in the performance-analyzer-rca
* repo. The performance-analyzer-rca repo is cloned as part of the cloneGitRepo task.
* repo. The performance-analyzer-rca repo is cloned as part of the cloneRcaGitRepo task.
*/
task setupOpenSearchCluster() {
dependsOn(cloneGitRepo)
dependsOn(cloneRcaGitRepo)
onlyIf = {
propEnabled("tests.enableIT")
}
Expand Down