Skip to content

Commit

Permalink
Fix snapshot build, upgrade to OpenSearch 1.1. (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock authored Aug 23, 2021
1 parent f798b0e commit 34f53b7
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 77 deletions.
74 changes: 40 additions & 34 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,30 @@ jobs:
runs-on: [ubuntu-latest]
name: Building RCA package
steps:
- name: Checkout RCA package
uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
path: ./tmp/performance-analyzer-rca
# fetch the main branch to make it available for spotless ratcheting
- name: Fetch 'main' branch
working-directory: ./tmp/performance-analyzer-rca
run: git fetch --depth=1 origin main
- name: Checkout Performance Analyzer package
java-version: 14

# PA depends on OpenSearch. Checkout and publish to maven local for PA build.
- name: Checkout OpenSearch
uses: actions/checkout@v2
with:
repository: opensearch-project/performance-analyzer
path: ./tmp/pa
- name: Set up JDK 1.12
uses: actions/setup-java@v1
repository: 'opensearch-project/OpenSearch'
path: OpenSearch
ref: '1.x'
- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal

# RCA in ./tmp/performance-analyzer-rca
- name: Checkout RCA
uses: actions/checkout@v2
with:
java-version: 1.12
- name: Build RCA with Gradle
path: ./tmp/performance-analyzer-rca
- name: Build RCA
working-directory: ./tmp/performance-analyzer-rca
run: ./gradlew build --stacktrace
run: ./gradlew build --stacktrace -Dopensearch.version=1.1.0-SNAPSHOT
- name: Upload reports
uses: actions/upload-artifact@v2
with:
Expand All @@ -49,34 +53,36 @@ jobs:
run: bash <(curl -s https://codecov.io/bash) -f ./build/reports/jacoco/test/jacocoTestReport.xml
- name: Publish RCA jar to maven local
working-directory: ./tmp/performance-analyzer-rca
run: ./gradlew publishToMavenLocal
- name: Build PA gradle using the new RCA jar
working-directory: ./tmp/pa
run: rm -f licenses/performanceanalyzer-rca-1.0.0.0.jar.sha1
# PA depends on OpenSearch. Checkout and publish to maven local for PA build.
- name: Checkout OpenSearch
run: ./gradlew publishToMavenLocal -Dopensearch.version=1.1.0-SNAPSHOT

# PA in ./tmp/performance-analyzer
- name: Checkout Performance Analyzer
uses: actions/checkout@v2
with:
repository: 'opensearch-project/OpenSearch'
path: OpenSearch
ref: '1.0'
- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal -Dbuild.snapshot=false
repository: dblock/performance-analyzer
ref: fix-snapshot-build
path: ./tmp/performance-analyzer
- name: Build PA gradle using the new RCA jar
working-directory: ./tmp/performance-analyzer
run: rm -f licenses/performanceanalyzer-rca-*.jar.sha1
- name: Update SHA
working-directory: ./tmp/pa
run: ./gradlew updateShas
working-directory: ./tmp/performance-analyzer
run: ./gradlew updateShas -Dopensearch.version=1.1.0-SNAPSHOT
- name: Set docker-compose path
run: echo "DOCKER_COMPOSE_LOCATION=$(which docker-compose)" >> $GITHUB_ENV
# 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 -i
working-directory: ./tmp/performance-analyzer
run: ./gradlew build -i -Dopensearch.version=1.1.0-SNAPSHOT

# Enable RCA for Integration Tests
- name: Spin up Docker cluster for integ testing
working-directory: ./tmp/performance-analyzer-rca
run: ./gradlew enableRca
run: ./gradlew enableRca -Dopensearch.version=1.1.0-SNAPSHOT

# Run Integration Tests in PA
- name: Run integration tests
working-directory: ./tmp/pa
run: ./gradlew integTest --info --stacktrace -Dtests.enableIT=true
working-directory: ./tmp/performance-analyzer
run: ./gradlew integTest --info --stacktrace -Dtests.enableIT=true -Dopensearch.version=1.1.0-SNAPSHOT
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ You can use the packaged Dockerfile and docker-compose.yml files [here](./docker

2. Build and tag the Docker image with our RCA framework.

`docker build -t odfe-opensearch/pa-rca:1.0 .`
`docker build -t opensearch/pa-rca:1.1 .`

3. Spin up a two node cluster as follows:

Expand Down
69 changes: 35 additions & 34 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,11 @@ distributions {
}
}

distZip {
archiveName 'performance-analyzer-rca.zip'
}

publishing {
publications {
maven(MavenPublication) {
groupId = 'org.opensearch'
artifactId = 'performanceanalyzer-rca'
version = '1.0.0.0'
from components.java
}
}
}

ext {
rca_version = '1.0'
opensearch_version = System.getProperty("opensearch.version", "1.1.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
gitDefaultBranch = 'main'
gitPaBranch = 'main'
gitPaRepo = "https://github.com/opensearch-project/performance-analyzer.git"
}

spotless {
Expand Down Expand Up @@ -196,7 +182,7 @@ jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.8
minimum = 0.7
}
}
}
Expand All @@ -205,18 +191,33 @@ jacocoTestCoverageVerification {
// to run coverage verification during the build (and fail when appropriate)
check.dependsOn jacocoTestCoverageVerification


version = "${rca_version}.0.0"
version = opensearch_version - '-SNAPSHOT' + '.0'
if (isSnapshot) {
version += "-SNAPSHOT"
}

distZip {
archiveName "performance-analyzer-rca-${version}.zip"
}

publishing {
publications {
maven(MavenPublication) {
groupId = 'org.opensearch'
artifactId = 'performanceanalyzer-rca'
from components.java
}
}
}

test {
filter { // Ignore failing tests
// Test testMissingHeapMetrics failed
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.integTests.tests.jvmsizing.HeapSizeIncreaseMissingMetricsTest'
// Test testJvmActions failed
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.integTests.tests.consolidate_tuning.JvmFlipFlopITest'
filter {
// TODO: slow integration tests were disabled
// see https://github.com/opensearch-project/performance-analyzer-rca/issues/57
excludeTestsMatching 'org.opensearch.performanceanalyzer.reader.OSMetricsSnapshotTests'
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.RcaControllerTest'
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.persistence.SQLitePersistorTest'
excludeTestsMatching 'org.opensearch.performanceanalyzer.rca.integTests.*'
}
enabled = true
retry {
Expand Down Expand Up @@ -360,7 +361,7 @@ String paDir
String dockerBuildDir
String dockerArtifactsDir

task cloneGitRepo(type: GitClone) {
task clonePaGitRepo(type: GitClone) {
dockerBuildDir = Paths.get(getProject().getBuildDir().toString(), "docker-build").toString()
mkdir dockerBuildDir
if (localPaDir != null && !localPaDir.empty) {
Expand All @@ -372,16 +373,16 @@ task cloneGitRepo(type: GitClone) {
}

def destination = file(paDir)
uri = "https://github.com/opensearch-project/performance-analyzer.git"
branch = gitDefaultBranch
uri = gitPaRepo
branch = gitPaBranch
destinationPath = destination
bare = false
enabled = !destination.exists() //to clone only once
}

task removeLicenses(type: Delete) {
dependsOn(cloneGitRepo)
def toDelete = Paths.get(paDir, 'licenses', 'performanceanalyzer-rca-1.0.0.0.jar.sha1')
dependsOn(clonePaGitRepo)
def toDelete = Paths.get(paDir, 'licenses', "performanceanalyzer-rca-${version}.jar.sha1")
delete(toDelete)
}

Expand All @@ -395,16 +396,16 @@ task buildPa(type: Exec) {
dependsOn(assemble, publishToMavenLocal, regenerateLicenses)
workingDir paDir
println String.format('pa in dir: (%s) will be built.', paDir)
commandLine './gradlew', 'assemble'
commandLine './gradlew', 'assemble', "-Dopensearch.version=${opensearch_version}"
println "PA repo located at '" + paDir + "' will be used."
}

task copyAllArtifacts(type: Copy) {
dependsOn(buildPa)
def projectPathStr = getProjectDir().toPath().toString()
def dockerArtifacts = Paths.get(projectPathStr, 'docker').toString()
def rcaArtifacts = Paths.get(projectPathStr, 'build', 'distributions', 'performance-analyzer-rca.zip')
def paArtifacts = Paths.get(paDir, 'build', 'distributions', 'opensearch-performance-analyzer-1.0.0.0-SNAPSHOT.zip')
def rcaArtifacts = Paths.get(projectPathStr, 'build', 'distributions', "performance-analyzer-rca-${version}.zip")
def paArtifacts = Paths.get(paDir, 'build', 'distributions', "opensearch-performance-analyzer-${version}.zip")

dockerArtifactsDir = Paths.get(dockerBuildDir, 'rca-docker')
from(dockerArtifacts)
Expand All @@ -426,7 +427,7 @@ task buildDocker(type: Exec) {
dependsOn(copyAllArtifacts)

workingDir(dockerArtifactsDir)
commandLine 'docker', 'build', '-t', 'odfe-opensearch/pa-rca:1.0', '.'
commandLine 'docker', 'build', '-t', 'opensearch/pa-rca:1.1', '.'
}

task runDocker(type: Exec) {
Expand Down
12 changes: 6 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ WORKDIR /usr/share/opensearch
ENV BUST_CACHE 1576286189

# Download and extract defined OpenSearch version.
RUN curl -fsSL https://artifacts.opensearch.org/snapshots/core/opensearch/1.0.0-SNAPSHOT/opensearch-min-1.0.0-SNAPSHOT-linux-arm64-latest.tar.gz | \
RUN curl -fsSL https://artifacts.opensearch.org/snapshots/core/opensearch/1.1.0-SNAPSHOT/opensearch-min-1.1.0-SNAPSHOT-linux-arm64-latest.tar.gz | \
tar zx --strip-components=1

RUN set -ex && for opensearchdirs in config data logs; do \
Expand All @@ -58,20 +58,20 @@ RUN set -ex && for opensearchdirs in config data logs; do \

COPY --chown=1000:0 opensearch.yml log4j2.properties config/

COPY --chown=1000:0 performance-analyzer-rca.zip config/
COPY --chown=1000:0 performance-analyzer-rca-1.1.0.0-SNAPSHOT.zip config/

COPY --chown=1000:0 opensearch-performance-analyzer-1.0.0.0-SNAPSHOT.zip /tmp/
COPY --chown=1000:0 opensearch-performance-analyzer-1.1.0.0-SNAPSHOT.zip /tmp/

RUN opensearch-plugin install --batch file:///tmp/opensearch-performance-analyzer-1.0.0.0-SNAPSHOT.zip; \
rm /tmp/opensearch-performance-analyzer-1.0.0.0-SNAPSHOT.zip
RUN opensearch-plugin install --batch file:///tmp/opensearch-performance-analyzer-1.1.0.0-SNAPSHOT.zip; \
rm /tmp/opensearch-performance-analyzer-1.1.0.0-SNAPSHOT.zip

USER 0

# Set gid to 0 for opensearch and make group permission similar to that of user
RUN chown -R opensearch:0 . && \
chmod -R g=u /usr/share/opensearch

RUN unzip config/performance-analyzer-rca.zip
RUN unzip config/performance-analyzer-rca-1.1.0.0-SNAPSHOT.zip

RUN cp -r performance-analyzer-rca/* plugins/opensearch-performance-analyzer/
RUN chmod 755 /usr/share/opensearch/plugins/opensearch-performance-analyzer/pa_bin/performance-analyzer-agent
Expand Down
4 changes: 2 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ version: '2.1'
services:
opensearch1:
container_name: opensearch1
image: odfe-opensearch/pa-rca:1.0
image: opensearch/pa-rca:1.1
mem_limit: 4g
networks:
opensearchnet:
Expand All @@ -53,7 +53,7 @@ services:
container_name: opensearch2
environment:
- node.master=false
image: odfe-opensearch/pa-rca:1.0
image: opensearch/pa-rca:1.1
mem_limit: 4g
networks:
- opensearchnet
Expand Down

0 comments on commit 34f53b7

Please sign in to comment.