Skip to content

Commit

Permalink
Update to Gradle 8.5
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed Feb 6, 2024
1 parent 70222ba commit fe2ee1b
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 52 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/gauntlet-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ jobs:
build_rca_pkg:
runs-on: [ubuntu-latest]
name: Build and Run Gauntlet tests
strategy:
matrix:
java:
- 17
steps:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 14
java-version: ${{matrix.java}}
# RCA in ./tmp/performance-analyzer-rca
- name: Checkout RCA
uses: actions/checkout@v2
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
strategy:
matrix:
java:
- 11
- 17
fail-fast: false
runs-on: [ubuntu-latest]
Expand Down
43 changes: 22 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ plugins {
id 'java'
id 'application'
id 'maven-publish'
id 'com.google.protobuf' version '0.8.18'
id 'com.google.protobuf' version '0.9.4'
id 'jacoco'
id 'idea'
id 'com.github.spotbugs' version '5.0.13'
id "de.undercouch.download" version "4.0.4"
id 'com.adarshr.test-logger' version '2.1.0'
id 'org.gradle.test-retry' version '1.5.2'
id 'eclipse'
id 'com.github.spotbugs' version '6.0.7'
id "de.undercouch.download" version "5.5.0"
id 'com.adarshr.test-logger' version '4.0.0'
id 'org.gradle.test-retry' version '1.5.8'
id 'com.diffplug.spotless' version '5.11.0'
}

Expand Down Expand Up @@ -126,7 +127,8 @@ testlogger {

spotbugsMain {
excludeFilter = file("checkstyle/findbugs-exclude.xml")
effort = 'max'

effort = com.github.spotbugs.snom.Effort.MAX
ignoreFailures = true // TODO: Set this to false later as they are too many warnings to be fixed.

reports {
Expand All @@ -145,14 +147,14 @@ check {
}

jacoco {
toolVersion = "0.8.7"
toolVersion = "0.8.11"
}

jacocoTestReport {
reports {
xml.enabled true
html.enabled true
csv.enabled false
xml.required = true
html.required = true
csv.required = false
}

afterEvaluate {
Expand Down Expand Up @@ -208,7 +210,7 @@ check.dependsOn jacocoTestCoverageVerification
version = opensearch_build

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

publishing {
Expand Down Expand Up @@ -260,6 +262,9 @@ tasks.withType(Test) {
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')
if (JavaVersion.current().compareTo(JavaVersion.VERSION_17) > 0) {
jvmArgs += ["-Djava.security.manager=allow"]
}
}

task rcaTest(type: Test) {
Expand Down Expand Up @@ -367,30 +372,26 @@ dependencies {
implementation group: 'com.google.protobuf', name: 'protobuf-java', version: "${protobufVersion}"
implementation 'io.grpc:grpc-netty:1.56.1'
implementation 'io.grpc:grpc-protobuf:1.56.1'
implementation("io.netty:netty-codec-http2:${nettyVersion}") {
force = 'true'
}
implementation("io.netty:netty-handler-proxy:${nettyVersion}") {
force = 'true'
}
implementation("io.netty:netty-codec-http2:${nettyVersion}")
implementation("io.netty:netty-handler-proxy:${nettyVersion}")
implementation 'io.grpc:grpc-stub:1.52.1'
implementation "jakarta.annotation:jakarta.annotation-api:${jakartaVersion}"

// 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'
implementation("org.mockito:mockito-core") {
testImplementation("org.mockito:mockito-core") {
version {
strictly "2.23.0"
}
}
testImplementation group: 'org.powermock', name: 'powermock-core', version: '2.0.2'
testImplementation group: 'org.powermock', name: 'powermock-api-support', version: '2.0.2'
testImplementation group: 'org.powermock', name: 'powermock-module-junit4-common', version: '2.0.2'
testImplementation group: 'org.javassist', name: 'javassist', version: '3.28.0-GA'
testImplementation group: 'org.powermock', name: 'powermock-reflect', version: '2.0.2'
testImplementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.9.3'
testImplementation group: 'org.objenesis', name: 'objenesis', version: '3.0.1'
testImplementation group: 'org.javassist', name: 'javassist', version: '3.28.0-GA'
testImplementation group: 'net.bytebuddy', name: 'byte-buddy', version: '1.14.7'
testImplementation group: 'org.objenesis', name: 'objenesis', version: '3.2'
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.1'
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.1'
testImplementation group: 'junit', name: 'junit', version: "${junitVersion}"
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
public class CompactNodeSummary extends GenericSummary {

private static final Logger LOG = LogManager.getLogger(CompactNodeSummary.class);

/** This will determine the name of the SQLite when this summary is persisted. */
public static final String TABLE_NAME = CompactNodeSummary.class.getSimpleName();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public ResourceFlowUnit<HotNodeSummary> operate() {
return new ResourceFlowUnit<>(this.clock.millis());
}
}

/**
* read threshold values from rca.conf
*
Expand Down Expand Up @@ -270,6 +271,7 @@ public NamedSummarizedWindow(SummarizedWindow summarizedWindow, IndexShardKey in
this.indexShardKey = indexShardKey;
}
}

/* Comparators for SummarizedWindow, comparing by different metrics.
This way already existing structures can be recycled. */
class SummarizedWindowCPUComparator implements Comparator<NamedSummarizedWindow> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

public class ClusterDetailsEventProcessor implements EventProcessor {
private static final Logger LOG = LogManager.getLogger(ClusterDetailsEventProcessor.class);

/** keep a volatile immutable list to make the read/write to this list thread safe. */
private volatile ImmutableList<NodeDetails> nodesDetails = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.opensearch.performanceanalyzer.commons.config.PluginSettings;
import org.opensearch.performanceanalyzer.config.PluginSettings;

public class PerformanceAnalyzerWebServerTest {
private static final String BIND_HOST = "localhost";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.powermock.api.mockito.PowerMockito.mockStatic;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
Expand All @@ -19,17 +18,12 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.opensearch.performanceanalyzer.AppContext;
import org.opensearch.performanceanalyzer.rca.framework.util.InstanceDetails;
import org.opensearch.performanceanalyzer.rca.store.rca.cluster.NodeKey;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
@PrepareForTest({HeapSizeIncreaseAction.class, HeapSizeIncreaseActionTest.class})
public class HeapSizeIncreaseActionTest {
@Mock private AppContext mockAppContext;

Expand All @@ -45,7 +39,6 @@ public class HeapSizeIncreaseActionTest {
@Before
public void setUp() {
initMocks(this);
mockStatic(Runtime.class);
myNodeKey = getNodeKeyFor(selfId, selfIp);
Mockito.when(mockAppContext.getMyInstanceDetails())
.thenReturn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,15 @@
public class Host {
private static final Logger LOG = LogManager.getLogger(Host.class);
private final boolean useHttps;

/** Each host has its own AppContext instance. */
private final AppContext appContext;

private final HostTag myTag;

/** This uniquely identifies a host. */
private final int hostId;

/**
* For Integration tests, where all the virtual nodes are part of the same JVM, Ip string does
* not matter. But for the sake of having this value filled, the string is 127.0.0.(hostId).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,14 @@
import org.jooq.impl.DSL;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.opensearch.performanceanalyzer.PerformanceAnalyzerApp;
import org.opensearch.performanceanalyzer.commons.metrics.AllMetrics;
import org.opensearch.performanceanalyzer.commons.metrics.PerformanceAnalyzerMetrics;
import org.opensearch.performanceanalyzer.config.TroubleshootingConfig;
import org.opensearch.performanceanalyzer.metricsdb.Dimensions;
import org.opensearch.performanceanalyzer.metricsdb.MetricsDB;
import org.powermock.api.mockito.PowerMockito;

// @PowerMockIgnore({ "org.apache.logging.log4j.*" })
// @RunWith(PowerMockRunner.class)
// @PrepareForTest({ TroubleshootingConfig.class })
public class MetricsEmitterTests extends AbstractReaderTests {
public MetricsEmitterTests() throws SQLException, ClassNotFoundException {
super();
Expand Down Expand Up @@ -118,12 +114,10 @@ public void testMetricsEmitter() throws Exception {
assertEquals(0.164465243055556d, cpu.doubleValue(), 0);
}

@Ignore("https://github.com/opensearch-project/performance-analyzer-rca/issues/529")
@Test(expected = Exception.class)
public void testMetricsEmitterInvalidData() throws Exception {
//
PowerMockito.mockStatic(TroubleshootingConfig.class);
PowerMockito.when(TroubleshootingConfig.getEnableDevAssert()).thenReturn(true);

Connection conn = DriverManager.getConnection(DB_URL);
ShardRequestMetricsSnapshot rqMetricsSnap =
new ShardRequestMetricsSnapshot(conn, 1535065195000L);
Expand Down

0 comments on commit fe2ee1b

Please sign in to comment.