Skip to content

Commit 6f8e46c

Browse files
spbjssAlex
authored andcommitted
Upgrade dependency version, apply spotless formatter, checkstyle and enable jacoco test coverage. (opensearch-project#39)
* Upgrade opensearch from beta1 to rc1 * Add code formatter, checkstyle and spotless to ml plugin. * Apply spotless formatter to source code, and enable jacoco test coverage verification Signed-off-by: Alex <pengsun@amazon.com> Co-authored-by: Alex <pengsun@amazon.com>
1 parent 851d49e commit 6f8e46c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+902
-567
lines changed

.eclipseformat.xml

+362
Large diffs are not rendered by default.

.github/workflows/CI-workflow.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ jobs:
2121
with:
2222
repository: 'opensearch-project/OpenSearch'
2323
path: OpenSearch
24-
ref: 1.0.0-beta1
24+
ref: '1.x'
2525

2626
- name: Build OpenSearch
2727
working-directory: ./OpenSearch
28-
run: ./gradlew publishToMavenLocal -Dbuild.version_qualifier=beta1 -Dbuild.snapshot=false
28+
run: ./gradlew publishToMavenLocal -Dbuild.version_qualifier=rc1 -Dbuild.snapshot=false
2929

3030
- name: Build with Gradle
3131
run: ./gradlew build

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ buildscript {
1414
ext {
1515
ext {
1616
opensearch_group = "org.opensearch"
17-
opensearch_version = "1.0.0-beta1"
17+
opensearch_version = "1.0.0-rc1"
1818
}
1919
}
2020

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
#
1111
#
1212

13-
opensearch_version=1.0.0-beta1
13+
opensearch_version=1.0.0-rc1
1414
opensearchBaseVersion=1.0.0

plugin/build.gradle

+36-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ plugins {
1515
id 'nebula.ospackage'
1616
id "io.freefair.lombok"
1717
id 'jacoco'
18+
id "com.diffplug.gradle.spotless" version "3.26.1"
19+
id 'checkstyle'
1820
}
1921
apply plugin: 'opensearch.opensearchplugin'
2022
apply plugin: 'opensearch.testclusters'
@@ -40,6 +42,7 @@ dependencies {
4042
compile("com.fasterxml.jackson.core:jackson-databind:${versions.jackson}")
4143
compile group: 'com.google.guava', name: 'guava', version:'29.0-jre'
4244

45+
checkstyle "com.puppycrawl.tools:checkstyle:${project.checkstyle.toolVersion}"
4346
}
4447

4548
test {
@@ -94,18 +97,34 @@ jacocoTestReport {
9497
dependsOn test
9598
}
9699

100+
List<String> jacocoExclusions = [
101+
// TODO: add more unit test to meet the minimal test coverage.
102+
'org.opensearch.ml.action.*',
103+
'org.opensearch.ml.constant.CommonValue',
104+
'org.opensearch.ml.indices.MLInputDatasetHandler',
105+
'org.opensearch.ml.plugin.*',
106+
'org.opensearch.ml.task.MLTaskRunner',
107+
]
108+
97109
jacocoTestCoverageVerification {
98110
violationRules {
99111
rule {
100-
limit {
101-
counter = 'LINE'
102-
minimum = 0.7
103-
}
112+
element = 'CLASS'
113+
excludes = jacocoExclusions
104114
limit {
105115
counter = 'BRANCH'
106116
minimum = 0.8
107117
}
108118
}
119+
rule {
120+
element = 'CLASS'
121+
excludes = jacocoExclusions
122+
limit {
123+
counter = 'LINE'
124+
value = 'COVEREDRATIO'
125+
minimum = 0.7
126+
}
127+
}
109128
}
110129
dependsOn jacocoTestReport
111130
}
@@ -115,4 +134,17 @@ configurations.all {
115134
resolutionStrategy.force 'junit:junit:4.12'
116135
resolutionStrategy.force 'org.apache.commons:commons-lang3:3.10'
117136
resolutionStrategy.force 'commons-logging:commons-logging:1.2'
137+
}
138+
139+
spotless {
140+
java {
141+
removeUnusedImports()
142+
importOrder 'java', 'javax', 'org', 'com'
143+
144+
eclipse().configFile rootProject.file('.eclipseformat.xml')
145+
}
146+
}
147+
148+
checkstyle {
149+
toolVersion = '8.29'
118150
}

plugin/src/main/java/org/opensearch/ml/action/prediction/MLPredictionTaskExecutionAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
package org.opensearch.ml.action.prediction;
1414

15-
import org.opensearch.ml.common.transport.prediction.MLPredictionTaskResponse;
1615
import org.opensearch.action.ActionType;
16+
import org.opensearch.ml.common.transport.prediction.MLPredictionTaskResponse;
1717

1818
public class MLPredictionTaskExecutionAction extends ActionType<MLPredictionTaskResponse> {
1919
public static MLPredictionTaskExecutionAction INSTANCE = new MLPredictionTaskExecutionAction();

plugin/src/main/java/org/opensearch/ml/action/prediction/MLPredictionTaskExecutionTransportAction.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212

1313
package org.opensearch.ml.action.prediction;
1414

15-
import org.opensearch.ml.task.MLTaskRunner;
16-
import org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest;
17-
import org.opensearch.ml.common.transport.prediction.MLPredictionTaskResponse;
1815
import org.opensearch.action.ActionListener;
1916
import org.opensearch.action.support.ActionFilters;
2017
import org.opensearch.action.support.HandledTransportAction;
2118
import org.opensearch.common.inject.Inject;
19+
import org.opensearch.ml.common.transport.prediction.MLPredictionTaskRequest;
20+
import org.opensearch.ml.common.transport.prediction.MLPredictionTaskResponse;
21+
import org.opensearch.ml.task.MLTaskRunner;
2222
import org.opensearch.tasks.Task;
2323
import org.opensearch.transport.TransportService;
2424

@@ -28,9 +28,9 @@ public class MLPredictionTaskExecutionTransportAction extends HandledTransportAc
2828

2929
@Inject
3030
public MLPredictionTaskExecutionTransportAction(
31-
ActionFilters actionFilters,
32-
TransportService transportService,
33-
MLTaskRunner mlTaskRunner
31+
ActionFilters actionFilters,
32+
TransportService transportService,
33+
MLTaskRunner mlTaskRunner
3434
) {
3535
super(MLPredictionTaskExecutionAction.NAME, transportService, actionFilters, MLPredictionTaskRequest::new);
3636
this.mlTaskRunner = mlTaskRunner;

plugin/src/main/java/org/opensearch/ml/action/prediction/TransportPredictionTaskAction.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import lombok.AccessLevel;
1616
import lombok.experimental.FieldDefaults;
1717
import lombok.extern.log4j.Log4j2;
18+
1819
import org.opensearch.action.ActionListener;
1920
import org.opensearch.action.ActionRequest;
2021
import org.opensearch.action.support.ActionFilters;
@@ -41,8 +42,7 @@ public TransportPredictionTaskAction(TransportService transportService, ActionFi
4142
}
4243

4344
@Override
44-
protected void doExecute(Task task, ActionRequest request,
45-
ActionListener<MLPredictionTaskResponse> listener) {
45+
protected void doExecute(Task task, ActionRequest request, ActionListener<MLPredictionTaskResponse> listener) {
4646
MLPredictionTaskRequest mlPredictionTaskRequest = MLPredictionTaskRequest.fromActionRequest(request);
4747
mlTaskRunner.runPrediction(mlPredictionTaskRequest, transportService, listener);
4848
}

plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodeRequest.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
*
1111
*/
1212

13-
1413
package org.opensearch.ml.action.stats;
1514

15+
import java.io.IOException;
16+
1617
import lombok.Getter;
18+
1719
import org.opensearch.action.support.nodes.BaseNodeRequest;
1820
import org.opensearch.common.io.stream.StreamInput;
1921
import org.opensearch.common.io.stream.StreamOutput;
2022

21-
import java.io.IOException;
22-
2323
public class MLStatsNodeRequest extends BaseNodeRequest {
2424
@Getter
2525
private MLStatsNodesRequest mlStatsNodesRequest;

plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodeResponse.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@
1010
*
1111
*/
1212

13-
1413
package org.opensearch.ml.action.stats;
1514

15+
import java.io.IOException;
16+
import java.util.Map;
17+
1618
import lombok.Getter;
19+
1720
import org.opensearch.action.support.nodes.BaseNodeResponse;
1821
import org.opensearch.cluster.node.DiscoveryNode;
1922
import org.opensearch.common.io.stream.StreamInput;
2023
import org.opensearch.common.io.stream.StreamOutput;
2124
import org.opensearch.common.xcontent.ToXContentFragment;
2225
import org.opensearch.common.xcontent.XContentBuilder;
2326

24-
import java.io.IOException;
25-
import java.util.Map;
26-
2727
public class MLStatsNodeResponse extends BaseNodeResponse implements ToXContentFragment {
2828
@Getter
2929
private Map<String, Object> statsMap;

plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodesAction.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,10 @@
1010
*
1111
*/
1212

13-
1413
package org.opensearch.ml.action.stats;
1514

16-
import org.opensearch.ml.constant.CommonValue;
1715
import org.opensearch.action.ActionType;
16+
import org.opensearch.ml.constant.CommonValue;
1817

1918
public class MLStatsNodesAction extends ActionType<MLStatsNodesResponse> {
2019
// Internal Action which is not used for public facing RestAPIs.

plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodesRequest.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
*
1111
*/
1212

13-
1413
package org.opensearch.ml.action.stats;
1514

15+
import java.io.IOException;
16+
import java.util.HashSet;
17+
import java.util.Set;
18+
1619
import lombok.Getter;
20+
1721
import org.opensearch.action.support.nodes.BaseNodesRequest;
1822
import org.opensearch.cluster.node.DiscoveryNode;
1923
import org.opensearch.common.io.stream.StreamInput;
2024
import org.opensearch.common.io.stream.StreamOutput;
2125

22-
import java.io.IOException;
23-
import java.util.HashSet;
24-
import java.util.Set;
25-
2626
public class MLStatsNodesRequest extends BaseNodesRequest<MLStatsNodesRequest> {
2727
/**
2828
* Key indicating all stats should be retrieved

plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodesResponse.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
*
1111
*/
1212

13-
1413
package org.opensearch.ml.action.stats;
1514

15+
import java.io.IOException;
16+
import java.util.List;
17+
1618
import org.opensearch.action.FailedNodeException;
1719
import org.opensearch.action.support.nodes.BaseNodesResponse;
1820
import org.opensearch.cluster.ClusterName;
@@ -22,9 +24,6 @@
2224
import org.opensearch.common.xcontent.ToXContentObject;
2325
import org.opensearch.common.xcontent.XContentBuilder;
2426

25-
import java.io.IOException;
26-
import java.util.List;
27-
2827
public class MLStatsNodesResponse extends BaseNodesResponse<MLStatsNodeResponse> implements ToXContentObject {
2928
private static final String NODES_KEY = "nodes";
3029

plugin/src/main/java/org/opensearch/ml/action/stats/MLStatsNodesTransportAction.java

+27-29
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,28 @@
1010
*
1111
*/
1212

13-
1413
package org.opensearch.ml.action.stats;
1514

16-
import org.opensearch.ml.stats.InternalStatNames;
17-
import org.opensearch.ml.stats.MLStats;
15+
import java.io.IOException;
16+
import java.util.HashMap;
17+
import java.util.List;
18+
import java.util.Map;
19+
import java.util.Set;
20+
1821
import org.opensearch.action.FailedNodeException;
1922
import org.opensearch.action.support.ActionFilters;
2023
import org.opensearch.action.support.nodes.TransportNodesAction;
2124
import org.opensearch.cluster.service.ClusterService;
2225
import org.opensearch.common.inject.Inject;
2326
import org.opensearch.common.io.stream.StreamInput;
27+
import org.opensearch.ml.stats.InternalStatNames;
28+
import org.opensearch.ml.stats.MLStats;
2429
import org.opensearch.monitor.jvm.JvmService;
2530
import org.opensearch.threadpool.ThreadPool;
2631
import org.opensearch.transport.TransportService;
2732

28-
import java.io.IOException;
29-
import java.util.HashMap;
30-
import java.util.List;
31-
import java.util.Map;
32-
import java.util.Set;
33-
3433
public class MLStatsNodesTransportAction extends
35-
TransportNodesAction<MLStatsNodesRequest, MLStatsNodesResponse, MLStatsNodeRequest, MLStatsNodeResponse> {
34+
TransportNodesAction<MLStatsNodesRequest, MLStatsNodesResponse, MLStatsNodeRequest, MLStatsNodeResponse> {
3635
private MLStats mlStats;
3736
private final JvmService jvmService;
3837

@@ -48,33 +47,33 @@ public class MLStatsNodesTransportAction extends
4847
*/
4948
@Inject
5049
public MLStatsNodesTransportAction(
51-
ThreadPool threadPool,
52-
ClusterService clusterService,
53-
TransportService transportService,
54-
ActionFilters actionFilters,
55-
MLStats mlStats,
56-
JvmService jvmService
50+
ThreadPool threadPool,
51+
ClusterService clusterService,
52+
TransportService transportService,
53+
ActionFilters actionFilters,
54+
MLStats mlStats,
55+
JvmService jvmService
5756
) {
5857
super(
59-
MLStatsNodesAction.NAME,
60-
threadPool,
61-
clusterService,
62-
transportService,
63-
actionFilters,
64-
MLStatsNodesRequest::new,
65-
MLStatsNodeRequest::new,
66-
ThreadPool.Names.MANAGEMENT,
67-
MLStatsNodeResponse.class
58+
MLStatsNodesAction.NAME,
59+
threadPool,
60+
clusterService,
61+
transportService,
62+
actionFilters,
63+
MLStatsNodesRequest::new,
64+
MLStatsNodeRequest::new,
65+
ThreadPool.Names.MANAGEMENT,
66+
MLStatsNodeResponse.class
6867
);
6968
this.mlStats = mlStats;
7069
this.jvmService = jvmService;
7170
}
7271

7372
@Override
7473
protected MLStatsNodesResponse newResponse(
75-
MLStatsNodesRequest request,
76-
List<MLStatsNodeResponse> responses,
77-
List<FailedNodeException> failures
74+
MLStatsNodesRequest request,
75+
List<MLStatsNodeResponse> responses,
76+
List<FailedNodeException> failures
7877
) {
7978
return new MLStatsNodesResponse(clusterService.getClusterName(), responses, failures);
8079
}
@@ -112,4 +111,3 @@ private MLStatsNodeResponse createMLStatsNodeResponse(MLStatsNodesRequest mlStat
112111
return new MLStatsNodeResponse(clusterService.localNode(), statValues);
113112
}
114113
}
115-

plugin/src/main/java/org/opensearch/ml/action/training/MLTrainingTaskExecutionAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
package org.opensearch.ml.action.training;
1414

15-
import org.opensearch.ml.common.transport.training.MLTrainingTaskResponse;
1615
import org.opensearch.action.ActionType;
16+
import org.opensearch.ml.common.transport.training.MLTrainingTaskResponse;
1717

1818
public class MLTrainingTaskExecutionAction extends ActionType<MLTrainingTaskResponse> {
1919

0 commit comments

Comments
 (0)