/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
buildscript {
ext {
opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT")
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
buildVersionQualifier = System.getProperty("build.version_qualifier", "")
default_bwc_version = System.getProperty("bwc.version", "2.9.0.0")
pa_bwc_version = System.getProperty("tests.bwc.version", default_bwc_version)
baseName = "paBwcCluster"
// The PA Commons (https://github.com/opensearch-project/performance-analyzer-commons)
// is a library dependency with hardcoded versioning in PA and RCA repos.
paCommonsVersion = "1.0.0"
// 3.0.0-SNAPSHOT -> 3.0.0.0-SNAPSHOT
version_tokens = opensearch_version.tokenize('-')
opensearch_build = version_tokens[0] + '.0'
if (buildVersionQualifier) {
opensearch_build += "-${buildVersionQualifier}"
}
if (isSnapshot) {
opensearch_build += "-SNAPSHOT"
paCommonsVersion += "-SNAPSHOT"
}
}
// Used to resolve build file dependencies
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
classpath "org.opensearch.gradle:build-tools:${opensearch_version}"
classpath 'org.ajoberstar:gradle-git:0.2.3'
}
}
plugins {
id 'java'
id 'nebula.ospackage' version "8.3.0"
id 'com.github.spotbugs' version '5.0.13'
id 'jacoco'
id 'com.diffplug.spotless' version '5.11.0'
id 'checkstyle'
id 'org.ajoberstar.grgit' version '5.0.0'
id 'org.gradle.test-retry' version '1.5.2'
}
checkstyle {
toolVersion = '10.12.1'
configFile file("checkstyle/checkstyle.xml")
}
spotbugsMain {
excludeFilter = file("checkstyle/findbugs-exclude.xml")
effort = 'max'
ignoreFailures = true
reports {
xml.enabled = false
html.enabled = true
}
}
spotbugsTest {
ignoreFailures = true
}
ext {
// 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")
rcaProjectFetch = System.getProperty("performance-analyzer-rca.fetch", "origin")
rcaProjectBranch = System.getProperty("performance-analyzer-rca.branch", "${rcaProjectFetch}/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 = System.getProperty("performance-analyzer-rca.path", "../performance-analyzer-rca")
}
allprojects {
group = "org.opensearch"
version = opensearch_build
}
apply plugin: 'opensearch.opensearchplugin'
apply plugin: 'opensearch.pluginzip'
licenseFile = rootProject.file('LICENSE.txt')
noticeFile = rootProject.file('NOTICE.txt')
spotless {
java {
licenseHeaderFile(file('license-header'))
googleJavaFormat('1.12.0').aosp()
importOrder()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
// add support for spotless:off and spotless:on tags to exclude sections of code
toggleOffOn()
}
}
test {
enabled = true
systemProperty 'tests.security.manager', 'false'
retry {
failOnPassedAfterRetry = false
maxRetries = 3
maxFailures = 10
}
}
licenseHeaders.enabled = true
validateNebulaPom.enabled = false
loggerUsageCheck.enabled = false
def _numNodes = findProperty('numNodes') as Integer ?: 1
opensearchplugin {
name 'opensearch-performance-analyzer'
description 'OpenSearch Performance Analyzer Plugin'
classname 'org.opensearch.performanceanalyzer.PerformanceAnalyzerPlugin'
}
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
compileJava {
dependsOn spotlessApply
}
javadoc {
}
project.afterEvaluate {
JavaVersion targetVersion = JavaVersion.toVersion(targetCompatibility)
// cannot contain the first version
// should be '8' or '11' etc.
String version = targetVersion.toString()
if (version.length() > 2) {
version = targetVersion.toString().substring(2)
}
compileJava.options.compilerArgs.removeAll(['--release', version])
}
publishing {
repositories {
maven {
name = "Snapshots"
url = "https://aws.oss.sonatype.org/content/repositories/snapshots"
credentials {
username "$System.env.SONATYPE_USERNAME"
password "$System.env.SONATYPE_PASSWORD"
}
}
}
publications {
pluginZip(MavenPublication) { publication ->
pom {
name = "performance-analyzer"
description = "OpenSearch performance-analyzer plugin"
groupId = "org.opensearch.plugin"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
name = "OpenSearch"
url = "https://github.com/opensearch-project/performance-analyzer"
}
}
}
}
}
}
repositories {
mavenLocal()
maven { url "https://aws.oss.sonatype.org/content/repositories/snapshots" }
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
}
configurations {
includeJars
zipArchive
}
tasks.withType(JavaCompile) {
options.warnings = false
}
jacoco {
toolVersion = "0.8.7"
}
jacocoTestReport {
reports {
xml.enabled true
html.enabled true
csv.enabled false
}
afterEvaluate {
classDirectories.from = files(classDirectories.files.collect {
fileTree(dir: it,
include: [
'**/org/opensearch/performanceanalyzer/**',
],
exclude: [
'**/FaultDetectionMetricsCollector.class',
'**/ClusterManagerThrottlingMetricsCollector.class',
'**/ClusterSettingsManager.class',
])
})
}
}
jacocoTestCoverageVerification {
afterEvaluate {
classDirectories.from = files(classDirectories.files.collect {
fileTree(dir: it,
include: [
'**/org/opensearch/performanceanalyzer/**',
],
exclude: [
])
})
}
violationRules {
rule {
limit {
minimum = 0.6
}
}
}
}
// to run coverage verification during the build (and fail when appropriate)
check.dependsOn jacocoTestCoverageVerification
checkstyleMain.enabled = false
checkstyleTest.enabled = false
dependencies {
def junitVersion = "${versions.junit}"
def jacksonVersion = "${versions.jackson}"
def jacksonDataBindVersion = "${versions.jackson_databind}"
def guavaVersion = "${versions.guava}"
def log4jVersion = "${versions.log4j}"
def protobufVersion = "${versions.protobuf}"
def nettyVersion = "${versions.netty}"
configurations {
// jarHell reports class name conflicts between securemock and mockito-core
// has to disable one of them.
// Need to continue exclude this group until we figure out how to get rid of
// this exclusion with opensearch
all*.exclude group: "org.elasticsearch", module: "securemock"
all*.exclude group: "org.jboss.spec.javax.annotation", module: "jboss-annotations-api_1.2_spec"
}
configurations.all {
resolutionStrategy {
force "junit:junit:${junitVersion}"
force "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
force "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
force "com.fasterxml.jackson.core:jackson-databind:${jacksonDataBindVersion}"
force "com.fasterxml.jackson.module:jackson-module-paranamer:${jacksonVersion}"
force "com.fasterxml.jackson.dataformat:jackson-dataformat-smile:${jacksonVersion}"
force "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonVersion}"
force "com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:${jacksonVersion}"
force "org.apache.commons:commons-lang3:3.12.0"
force "org.slf4j:slf4j-api:2.0.0"
force "org.apache.bcel:bcel:6.6.0" // This line should be removed once Spotbugs is upgraded to 4.7.4
}
}
implementation 'org.jooq:jooq:3.10.8'
implementation 'org.apache.commons:commons-lang3:3.9'
implementation 'org.bouncycastle:bcprov-jdk15to18:1.74'
implementation 'org.bouncycastle:bcpkix-jdk15on:1.70'
implementation "org.opensearch:performance-analyzer-commons:${paCommonsVersion}"
implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonDataBindVersion}"
implementation "com.fasterxml.jackson.module:jackson-module-paranamer:${jacksonVersion}"
implementation(group: 'org.apache.logging.log4j', name: 'log4j-api', version: "${log4jVersion}")
implementation(group: 'org.apache.logging.log4j', name: 'log4j-core', version: "${log4jVersion}")
implementation("com.google.guava:guava:${guavaVersion}") {
version {
strictly "${guavaVersion}"
}
}
implementation(group: 'com.google.errorprone', name: 'error_prone_annotations') {
version {
strictly "2.9.0"
}
}
implementation(group: 'com.google.protobuf', name:'protobuf-java') {
version {
strictly "${protobufVersion}"
}
}
implementation("io.netty:netty-buffer") {
version {
strictly "${nettyVersion}"
}
}
implementation("io.netty:netty-codec:") {
version {
strictly "${nettyVersion}"
}
}
implementation("io.netty:netty-codec-http") {
version {
strictly "${nettyVersion}"
}
}
implementation("io.netty:netty-common") {
version {
strictly "${nettyVersion}"
}
}
implementation("io.netty:netty-handler") {
version {
strictly "${nettyVersion}"
}
}
implementation("io.netty:netty-resolver") {
version {
strictly "${nettyVersion}"
}
}
implementation("io.netty:netty-transport") {
version {
strictly "${nettyVersion}"
}
}
implementation("io.netty:netty-codec-http2") {
version {
strictly "${nettyVersion}"
}
}
implementation("io.netty:netty-codec-socks") {
version {
strictly "${nettyVersion}"
}
}
implementation("io.netty:netty-handler-proxy") {
version {
strictly "${nettyVersion}"
}
}
implementation("io.netty:netty-transport-native-unix-common") {
version {
strictly "${nettyVersion}"
}
}
implementation("org.checkerframework:checker-qual") {
version {
strictly "3.29.0"
}
}
// JDK9+ has to run powermock 2+. https://github.com/powermock/powermock/issues/888
testImplementation group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.0'
testImplementation(group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.0') {
exclude(group: 'org.hamcrest', module: 'hamcrest-core')
}
implementation("org.mockito:mockito-core") {
version {
strictly "2.23.0"
}
}
// Dependency to mock final classes.
testImplementation group: 'org.mockito', name: 'mockito-inline', version: '2.13.0'
testImplementation group: 'org.powermock', name: 'powermock-core', version: '2.0.0'
testImplementation group: 'org.powermock', name: 'powermock-api-support', version: '2.0.0'
testImplementation(group: 'org.powermock', name: 'powermock-module-junit4-common', version: '2.0.0') {
exclude(group: 'org.hamcrest', module: 'hamcrest-core')
}
testImplementation group: 'org.javassist', name: 'javassist', version: '3.24.0-GA'
testImplementation group: 'org.powermock', name: 'powermock-reflect', version: '2.0.0'
//minimum byte-buddy version to be compatible with mockito-core 2.23.0 is 1.9.7+. https://github.com/mockito/mockito/issues/1606
implementation("net.bytebuddy:byte-buddy") {
version {
strictly "1.9.7"
}
}
implementation("net.bytebuddy:byte-buddy-agent") {
version {
strictly "1.9.7"
}
}
implementation("org.objenesis:objenesis") {
version {
strictly "3.0.1"
}
}
implementation("com.google.code.gson:gson") {
version {
strictly "2.9.0"
}
}
// Needed for BWC tests
zipArchive group: 'org.opensearch.plugin', name:'performance-analyzer', version: "${pa_bwc_version}-SNAPSHOT"
}
dependencyLicenses {
mapping from: /jackson-.*/, to: 'jackson'
}
dependencyLicenses.doFirst {
def licenseDir = "$projectDir/licenses"
exec {
workingDir("$licenseDir")
commandLine 'rm', "-f", "performance-analyzer-commons-${paCommonsVersion}.jar.sha1"
}
updateShas.updateShas()
}
gradle.startParameter.excludedTaskNames += [ "forbiddenApisMain",
"forbiddenApisTest",
"thirdPartyAudit",
"testingConventions"]
import java.util.concurrent.Callable
import org.ajoberstar.grgit.Grgit
import org.opensearch.gradle.test.RestIntegTestTask
import org.opensearch.gradle.testclusters.StandaloneRestIntegTestTask
static def propEnabled(property) {
return System.getProperty(property) != null && System.getProperty(property).toLowerCase().equals("true")
}
// The following Gradle tasks are used to create a PA/RCA enabled OpenSearch cluster
// Pass the -Dtests.enableIT property to Gradle to run ITs
/**
* cloneRcaGitRepo clones the performance-analyzer-rca repo if the -Dtests.enableIT=true flag is passed
* to the Gradle JVM
*/
task cloneRcaGitRepo() {
def destination = file(rcaProjectDir)
def uri = rcaProjectRepo
def fetch = rcaProjectFetch
def branch = rcaProjectBranch
if (!branch.startsWith(fetch)) { // to avoid checking out origin/origin/branch
branch = rcaProjectFetch + "/" + rcaProjectBranch
}
doFirst {
println "Cloning performance-analyzer-rca into ${rcaProjectDir} from ${rcaProjectRepo}#${rcaProjectBranch}"
}
doLast {
if (destination.exists() && destination.isDirectory()) { // If directory exists, use this instead.
def grgit = Grgit.open(dir: destination.toString())
} else { // Otherwise pull it from git.
def grgit = Grgit.clone(dir: destination.toString(), uri: uri)
grgit.fetch(remote: fetch)
grgit.checkout(branch: branch)
}
}
}
task buildRca() {
dependsOn(cloneRcaGitRepo)
doFirst {
logger.info("Building performance-analyzer-rca project in ${rcaProjectDir} with -Dopensearch.version=${opensearch_version}")
}
doLast {
exec {
workingDir("$rcaProjectDir")
if (buildVersionQualifier == null || buildVersionQualifier == '' || buildVersionQualifier == 'null') {
commandLine './gradlew', 'build', '-x', 'test', '-x', 'jacocoTestCoverageVerification', "-Dopensearch.version=${opensearch_version}", "-Dbuild.snapshot=${isSnapshot}"
}
else {
commandLine './gradlew', 'build', '-x', 'test', '-x', 'jacocoTestCoverageVerification', "-Dopensearch.version=${opensearch_version}", "-Dbuild.snapshot=${isSnapshot}", "-Dbuild.version_qualifier=${buildVersionQualifier}"
}
}
exec {
workingDir("$rcaProjectDir")
if (buildVersionQualifier == null || buildVersionQualifier == '' || buildVersionQualifier == 'null') {
commandLine './gradlew', 'publishToMavenLocal', "-Dopensearch.version=${opensearch_version}", "-Dbuild.snapshot=${isSnapshot}"
}
else {
commandLine './gradlew', 'publishToMavenLocal', "-Dopensearch.version=${opensearch_version}", "-Dbuild.snapshot=${isSnapshot}", "-Dbuild.version_qualifier=${buildVersionQualifier}"
}
}
exec {
def licenseDir = "$projectDir/licenses"
workingDir("$licenseDir")
commandLine 'rm', "-f", "performanceanalyzer-rca-${version}.jar.sha1"
}
}
}
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-${version}.zip")) {
}
into "$rcaProjectDir/build/distributions"
rcaArtifactsDir = "$rcaProjectDir/build/distributions/performance-analyzer-rca/"
doLast {
logger.info("Unpacked performance-analyzer-rca artifacts into ${rcaProjectDir}")
}
}
tasks.withType(Test) {
jvmArgs('--add-opens=java.base/sun.security.jca=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.util.concurrent=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.io=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.nio.file=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.lang=ALL-UNNAMED')
jvmArgs('--add-opens=java.base/java.util=ALL-UNNAMED')
}
bundlePlugin {
dependsOn 'unpackRca'
from("$rcaArtifactsDir/config") {
into "config"
}
from("$rcaArtifactsDir/bin") {
into "bin"
include "performance-analyzer-agent"
}
from("$rcaArtifactsDir") {
into "performance-analyzer-rca"
}
from("packaging") {
include "performance-analyzer-agent-cli"
into "bin"
}
from('build/resources/main/') {
include "plugin-security.policy"
}
from("config/opensearch-performance-analyzer") {
into "config"
}
}
/**
* 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 cloneRcaGitRepo task.
*/
task setupOpenSearchCluster() {
dependsOn(cloneRcaGitRepo)
onlyIf = {
propEnabled("tests.enableIT")
}
doLast {
exec {
workingDir(rcaProjectDir)
commandLine './gradlew', 'enableRca'
}
sleep(30000)
}
}
/**
* integTest is a task provided by the OpenSearch test framework, which allows us to spin up clients
* and test API calls against a local or remote OpenSearch cluster.
*
* The simplest way to run this task in a way that "just works" is to invoke
* ./gradlew integTest -Dtests.enableIT=true -Dtests.useDockerCluster=true
* which will spin up a local 2 node OpenSearch cluster on your machine, then execute the test suite against it
*
* A full list of options is provided below. Check our gradle.properties file for the defaults for
* each of these properties.
*
* -Dtests.rest.cluster the OpenSearch REST endpoint that test clients should hit
* -Dtests.cluster the OpenSearch transport
* endpoint that test clients should hit
* -Dtests.enableIT a flag to enable integration testing, by default this is false
* -Dtests.useDockerCluster if true, spin up a local 2 node cluster before executing tests
* NOTE: if you specify this, don't specify -Dtests.rest.cluster or -Dtests.cluster
* -Dtests.pa.port the port number of the PerformanceAnalyzer REST endpoint
* -Dtests.https either true or false, if true, then instantiate REST and transport clients using
* the https:// protocol and basic authentication via the -Dtests.user and -Dtests.password properties
* -Dtests.user the username of the admin user, this is used in conjunction with -Dtests.https and
* -Dtests.password to authenticate requests in the opensearch-security context
* -Dtests.password the password of the admin user specified by -Dtests.user
*/
task integTest(type: RestIntegTestTask) {
onlyIf = {
propEnabled("tests.enableIT")
}
if (propEnabled("tests.useDockerCluster")) {
dependsOn(setupOpenSearchCluster)
}
systemProperty 'tests.security.manager', 'false'
description = "Run integration tests against integTest cluster"
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
if (System.getProperty("tests.rest.bwcsuite") == null) {
filter {
excludeTestsMatching "org.opensearch.performanceanalyzer.bwc.*IT"
}
}
}
tasks.named("check").configure { dependsOn(integTest) }
Zip bundle = (Zip) project.getTasks().getByName("bundlePlugin");
integTest.dependsOn(bundle)
integTest.getClusters().forEach{c -> c.plugin(project.getObjects().fileProperty().value(bundle.getArchiveFile()))}
def opensearch_tmp_dir = rootProject.file('build/private/opensearch_tmp').absoluteFile
opensearch_tmp_dir.mkdirs()
task integTestRemote(type: RestIntegTestTask) {
onlyIf = {
propEnabled("tests.enableIT")
}
if (System.getProperty("tests.rest.bwcsuite") == null) {
filter {
excludeTestsMatching "org.opensearch.performanceanalyzer.bwc.*IT"
}
}
if (propEnabled("tests.useDockerCluster")) {
dependsOn(setupOpenSearchCluster)
}
testClassesDirs = sourceSets.test.output.classesDirs
classpath = sourceSets.test.runtimeClasspath
systemProperty 'tests.security.manager', 'false'
systemProperty 'java.io.tmpdir', opensearch_tmp_dir.absolutePath
systemProperty "https", System.getProperty("https")
systemProperty "user", System.getProperty("user")
systemProperty "password", System.getProperty("password")
}
// Creates two test clusters of previous version and loads opensearch plugin of pa_bwc_version
2.times {i ->
testClusters {
"${baseName}$i" {
testDistribution = "ARCHIVE"
versions = ["2.9.0-SNAPSHOT", opensearch_version]
numberOfNodes = 3
plugin(provider(new Callable() {
@Override
RegularFile call() throws Exception {
return new RegularFile() {
@Override
File getAsFile() {
return configurations.zipArchive.asFileTree.matching {
include '**/performance-analyzer*'
}.singleFile
}
}
}
}))
setting 'path.repo', "${buildDir}/cluster/shared/repo/${baseName}"
setting 'http.content_type.required', 'true'
}
}
}
List> plugins = []
// Ensure the artifact for the current project version is available to be used for the bwc tests
task prepareBwcTests {
dependsOn bundle
doLast {
plugins = [ project.getObjects().fileProperty().value(bundle.getArchiveFile()) ]
}
}
// Creates 2 test clusters with 3 nodes of the old version.
2.times {i ->
task "${baseName}#oldVersionClusterTask$i"(type: StandaloneRestIntegTestTask) {
dependsOn 'prepareBwcTests'
useCluster testClusters."${baseName}$i"
filter {
includeTestsMatching "org.opensearch.performanceanalyzer.bwc.*IT"
}
systemProperty 'tests.rest.bwcsuite', 'old_cluster'
systemProperty 'tests.rest.bwcsuite_round', 'old'
systemProperty 'tests.plugin_bwc_version', pa_bwc_version
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}$i".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}$i".getName()}")
}
}
// Upgrades one node of the old cluster to new OpenSearch version with upgraded plugin version
// This results in a mixed cluster with 2 nodes on the old version and 1 upgraded node.
// This is also used as a one third upgraded cluster for a rolling upgrade.
task "${baseName}#mixedClusterTask"(type: StandaloneRestIntegTestTask) {
useCluster testClusters."${baseName}0"
dependsOn "${baseName}#oldVersionClusterTask0"
doFirst {
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
testClusters."${baseName}0".waitForAllConditions()
}
filter {
includeTestsMatching "org.opensearch.performanceanalyzer.bwc.*IT"
}
systemProperty 'tests.rest.bwcsuite', 'mixed_cluster'
systemProperty 'tests.rest.bwcsuite_round', 'first'
systemProperty 'tests.plugin_bwc_version', pa_bwc_version
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
systemProperty 'tests.security.manager', 'false'
}
// Upgrades the second node to new OpenSearch version with upgraded plugin version after the first node is upgraded.
// This results in a mixed cluster with 1 node on the old version and 2 upgraded nodes.
// This is used for rolling upgrade.
task "${baseName}#twoThirdsUpgradedClusterTask"(type: StandaloneRestIntegTestTask) {
dependsOn "${baseName}#mixedClusterTask"
useCluster testClusters."${baseName}0"
doFirst {
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
testClusters."${baseName}0".waitForAllConditions()
}
filter {
includeTestsMatching "org.opensearch.performanceanalyzer.bwc.*IT"
}
systemProperty 'tests.rest.bwcsuite', 'mixed_cluster'
systemProperty 'tests.rest.bwcsuite_round', 'second'
systemProperty 'tests.plugin_bwc_version', pa_bwc_version
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
systemProperty 'tests.security.manager', 'false'
}
// Upgrades the third node to new OpenSearch version with upgraded plugin version after the second node is upgraded.
// This results in a fully upgraded cluster.
// This is used for rolling upgrade.
task "${baseName}#rollingUpgradeClusterTask"(type: StandaloneRestIntegTestTask) {
dependsOn "${baseName}#twoThirdsUpgradedClusterTask"
useCluster testClusters."${baseName}0"
doFirst {
testClusters."${baseName}0".upgradeNodeAndPluginToNextVersion(plugins)
testClusters."${baseName}0".waitForAllConditions()
}
filter {
includeTestsMatching "org.opensearch.performanceanalyzer.bwc.*IT"
}
mustRunAfter "${baseName}#mixedClusterTask"
systemProperty 'tests.rest.bwcsuite', 'mixed_cluster'
systemProperty 'tests.rest.bwcsuite_round', 'third'
systemProperty 'tests.plugin_bwc_version', pa_bwc_version
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}0".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}0".getName()}")
systemProperty 'tests.security.manager', 'false'
}
// Upgrades all the nodes of the old cluster to new OpenSearch version with upgraded plugin version
// at the same time resulting in a fully upgraded cluster.
task "${baseName}#fullRestartClusterTask"(type: StandaloneRestIntegTestTask) {
dependsOn "${baseName}#oldVersionClusterTask1"
useCluster testClusters."${baseName}1"
doFirst {
testClusters."${baseName}1".upgradeAllNodesAndPluginsToNextVersion(plugins)
testClusters."${baseName}1".waitForAllConditions()
}
filter {
includeTestsMatching "org.opensearch.performanceanalyzer.bwc.*IT"
}
systemProperty 'tests.rest.bwcsuite', 'upgraded_cluster'
systemProperty 'tests.plugin_bwc_version', pa_bwc_version
nonInputProperties.systemProperty('tests.rest.cluster', "${-> testClusters."${baseName}1".allHttpSocketURI.join(",")}")
nonInputProperties.systemProperty('tests.clustername', "${-> testClusters."${baseName}1".getName()}")
systemProperty 'tests.security.manager', 'false'
}
// A bwc test suite which runs all the bwc tasks combined.
task bwcTestSuite(type: StandaloneRestIntegTestTask) {
exclude '**/*Test*'
exclude '**/*IT*'
dependsOn tasks.named("${baseName}#mixedClusterTask")
dependsOn tasks.named("${baseName}#rollingUpgradeClusterTask")
dependsOn tasks.named("${baseName}#fullRestartClusterTask")
}
run {
doFirst {
// There seems to be an issue when running multi node run or integ tasks with unicast_hosts
// not being written, the waitForAllConditions ensures it's written
getClusters().forEach { cluster ->
cluster.waitForAllConditions()
}
}
useCluster testClusters.integTest
}
// This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name
afterEvaluate {
ospackage {
packageName = "opensearch-performance-analyzer"
release = isSnapshot ? "0.1" : '1'
version = "${project.version}"
into '/usr/share/opensearch/plugins'
from(zipTree(bundlePlugin.archivePath)) {
into opensearchplugin.name
}
configurationFile '/usr/lib/systemd/system/opensearch.service'
into('/usr/lib/systemd/system') {
fileType CONFIG | NOREPLACE
from "packaging/opensearch-performance-analyzer.service"
fileMode 0644
}
into('/usr/share/opensearch/bin') {
from ('packaging/performance-analyzer-agent-cli') {
fileMode 0755
}
}
user 'root'
permissionGroup 'root'
fileMode 0644
dirMode 0755
requires('opensearch-oss', versions.opensearch, EQUAL)
packager = 'Amazon'
vendor = 'Amazon'
os = 'LINUX'
prefix '/usr'
license 'ASL-2.0'
maintainer 'OpenSearch '
url 'https://opensearch.org/downloads.html'
summary '''
Performance Analyzer plugin for OpenSearch.
Reference documentation can be found at https://opensearch.org/docs/.
'''.stripIndent().replace('\n', ' ').trim()
}
buildRpm {
arch = 'NOARCH'
postInstall file('packaging/rpm/postinst')
postUninstall file('packaging/rpm/postrm')
dependsOn 'assemble'
finalizedBy 'renameRpm'
task renameRpm(type: Copy) {
from("$buildDir/distributions")
into("$buildDir/distributions")
include archiveName
rename archiveName, "${packageName}-${version}.rpm"
doLast {
delete file("$buildDir/distributions/$archiveName")
}
}
}
buildDeb {
arch = 'all'
postInstall file('packaging/deb/postinst')
postUninstall file('packaging/deb/postrm')
dependsOn 'assemble'
finalizedBy 'renameDeb'
task renameDeb(type: Copy) {
from("$buildDir/distributions")
into("$buildDir/distributions")
include archiveName
rename archiveName, "${packageName}-${version}.deb"
doLast {
delete file("$buildDir/distributions/$archiveName")
}
}
}
task buildPackages(type: GradleBuild) {
tasks = ['build', 'buildRpm', 'buildDeb']
}
}
bundlePlugin.mustRunAfter unpackRca
// updateVersion: Task to auto increment to the next development iteration
task updateVersion {
onlyIf { System.getProperty('newVersion') }
doLast {
ext.newVersion = System.getProperty('newVersion')
println "Setting version to ${newVersion}."
// String tokenization to support -SNAPSHOT
ant.replaceregexp(match: opensearch_version.tokenize('-')[0], replace: newVersion.tokenize('-')[0], flags:'g', byline:true) {
fileset(dir: projectDir) {
// Include the required files that needs to be updated with new Version
include(name: "src/main/resources/plugin-descriptor.properties")
}
}
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
}
}