Skip to content

Commit 5ec6b0c

Browse files
committed
update tests to ES 7.16.x, fix most warnings
1 parent ed980ff commit 5ec6b0c

30 files changed

+100
-130
lines changed

build.gradle

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import com.github.mgk.gradle.*
2-
31
buildscript {
42
ext {
53
es_version = version.replaceAll(/\.[0-9]+(|-.+)$/, "")
@@ -28,6 +26,7 @@ plugins {
2826
apply plugin: 'java'
2927
apply plugin: 'idea'
3028
apply plugin: 'elasticsearch.esplugin'
29+
apply plugin: 'elasticsearch.yaml-rest-test'
3130
apply plugin: 'elasticsearch.testclusters'
3231

3332
// Uncomment if you want to use: System.out.println("Emergency!");
@@ -72,7 +71,7 @@ dependencies {
7271
implementation "org.elasticsearch:elasticsearch:${versions.elasticsearch}"
7372
implementation "io.prometheus:simpleclient:${versions.prometheus}"
7473
implementation "io.prometheus:simpleclient_common:${versions.prometheus}"
75-
implementation "org.apache.logging.log4j:log4j-api:${versions.log4j}"
74+
yamlRestTestRuntimeOnly "org.apache.logging.log4j:log4j-core:${versions.log4j}"
7675
testImplementation (group: 'junit', name: 'junit', version: "${versions.junit}") {
7776
exclude group:'org.hamcrest' //also included in ES test framework
7877
}
@@ -93,18 +92,6 @@ esplugin {
9392

9493
testClusters.all {
9594
numberOfNodes = 2
96-
97-
// There does not seem to be any easy way how to setup custom cluster name.
98-
99-
// This worked in ES 7.4.x, but now results in:
100-
// A problem occurred evaluating root project 'prometheus-exporter'.
101-
// > Cannot set the property 'clusterName' because the backing field is final.
102-
// clusterName = "PrometheusExporterITCluster"
103-
104-
// This does not work in ES 7.5.x too:
105-
// Execution failed for task ':integTestRunner'.
106-
// > Testclusters does not allow the following settings to be changed:[cluster.name] for node{::integTest-0}
107-
// setting 'cluster.name', 'PrometheusExporterITCluster'
10895
}
10996

11097
checkstyle {

src/main/java/org/elasticsearch/action/ClusterStatsData.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
import org.elasticsearch.ElasticsearchParseException;
2222
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
2323
import org.elasticsearch.cluster.metadata.Metadata;
24-
import org.elasticsearch.core.Nullable;
2524
import org.elasticsearch.common.io.stream.StreamInput;
2625
import org.elasticsearch.common.io.stream.StreamOutput;
2726
import org.elasticsearch.common.settings.ClusterSettings;
2827
import org.elasticsearch.common.settings.Settings;
2928
import org.elasticsearch.common.settings.SettingsException;
3029
import org.elasticsearch.common.unit.RatioValue;
30+
import org.elasticsearch.core.Nullable;
3131

3232
import java.io.IOException;
3333

src/main/java/org/elasticsearch/action/NodePrometheusMetricsResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
2323
import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
2424
import org.elasticsearch.action.admin.indices.stats.PackageAccessHelper;
25-
import org.elasticsearch.core.Nullable;
2625
import org.elasticsearch.common.io.stream.StreamInput;
2726
import org.elasticsearch.common.io.stream.StreamOutput;
2827
import org.elasticsearch.common.settings.ClusterSettings;
2928
import org.elasticsearch.common.settings.Settings;
29+
import org.elasticsearch.core.Nullable;
3030

3131
import java.io.IOException;
3232

src/main/java/org/elasticsearch/action/TransportNodePrometheusMetricsAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
import org.elasticsearch.action.support.HandledTransportAction;
3434
import org.elasticsearch.client.Client;
3535
import org.elasticsearch.client.Requests;
36-
import org.elasticsearch.core.Nullable;
3736
import org.elasticsearch.common.inject.Inject;
3837
import org.elasticsearch.common.settings.ClusterSettings;
3938
import org.elasticsearch.common.settings.Settings;
39+
import org.elasticsearch.core.Nullable;
4040
import org.elasticsearch.tasks.Task;
4141
import org.elasticsearch.transport.TransportService;
4242

src/main/java/org/elasticsearch/rest/prometheus/RestPrometheusMetricsAction.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
import org.elasticsearch.rest.*;
3535
import org.elasticsearch.rest.action.RestResponseListener;
3636

37-
import java.util.List;
38-
import java.util.Locale;
39-
4037
import static java.util.Arrays.asList;
4138
import static java.util.Collections.unmodifiableList;
4239

40+
import java.util.List;
41+
import java.util.Locale;
42+
4343
/**
4444
* REST action class for Prometheus Exporter plugin.
4545
*/

src/test/resources/rest-api-spec/api/prometheus.metrics.json renamed to src/yamlRestTest/resources/rest-api-spec/api/prometheus.metrics.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"url":"https://github.com/vvanholl/elasticsearch-prometheus-exporter/"
55
},
66
"stability": "stable",
7+
"visibility" : "public",
78
"url":{
89
"paths":[
910
{

src/test/resources/rest-api-spec/test/resthandler/20_10_cluster_settings_metrics_disabled.yml renamed to src/yamlRestTest/resources/rest-api-spec/test/resthandler/20_10_cluster_settings_metrics_disabled.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
\# \s HELP \s es_cluster_routing_allocation_disk_threshold_enabled (\s|\w|\d)+ \n
2525
\# \s TYPE \s es_cluster_routing_allocation_disk_threshold_enabled \s gauge \n
2626
es_cluster_routing_allocation_disk_threshold_enabled\{
27-
cluster="integTest"
27+
cluster="yamlRestTest"
2828
\,} \s 1\.0 \n?
2929
.*/
3030
@@ -153,6 +153,6 @@
153153
\# \s HELP \s es_cluster_routing_allocation_disk_threshold_enabled (\s|\w|\d)+ \n
154154
\# \s TYPE \s es_cluster_routing_allocation_disk_threshold_enabled \s gauge \n
155155
es_cluster_routing_allocation_disk_threshold_enabled\{
156-
cluster="integTest"
156+
cluster="yamlRestTest"
157157
\,} \s 1\.0 \n?
158158
.*/

src/test/resources/rest-api-spec/test/resthandler/20_11_index_level_metrics_disabled.yml renamed to src/yamlRestTest/resources/rest-api-spec/test/resthandler/20_11_index_level_metrics_disabled.yml

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
- do:
2222
index:
2323
index: twitter
24-
type: foo
2524
id: 1
2625
body: { foo: bar }
2726

src/test/resources/rest-api-spec/test/resthandler/30_00_index_level_info.yml renamed to src/yamlRestTest/resources/rest-api-spec/test/resthandler/30_00_index_level_info.yml

+7-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
- do:
1515
index:
1616
index: twitter
17-
type: foo
1817
id: 1
1918
body: { foo: bar }
2019

@@ -34,8 +33,8 @@
3433
\# \s TYPE \s es_index_shards_number \s gauge \n
3534
(
3635
es_index_shards_number\{
37-
cluster="integTest",
38-
type="(active_primary|initializing|relocating|shards|active|unassigned)",
36+
cluster="yamlRestTest",
37+
type="(active_primary|delayed_unassigned|initializing|relocating|shards|active|unassigned)",
3938
index="twitter"
4039
,\} \s+ \d+\.\d+ \n?
4140
){6}
@@ -47,7 +46,7 @@
4746
\# \s HELP \s es_index_status (\s|\w|\d)+ \n
4847
\# \s TYPE \s es_index_status \s gauge \n
4948
es_index_status\{
50-
cluster="integTest",index="twitter"
49+
cluster="yamlRestTest",index="twitter"
5150
\,} \s \d+\.\d+ \n?
5251
.*/
5352
@@ -57,7 +56,7 @@
5756
\# \s HELP \s es_index_replicas_number (\s|\w|\d)+ \n
5857
\# \s TYPE \s es_index_replicas_number \s gauge \n
5958
es_index_replicas_number\{
60-
cluster="integTest",index="twitter"
59+
cluster="yamlRestTest",index="twitter"
6160
,\} \s+ \d+\.\d+ \n?
6261
.*/
6362
@@ -77,7 +76,6 @@
7776
- do:
7877
index:
7978
index: twitter
80-
type: foo
8179
id: 1
8280
body: { foo: bar }
8381

@@ -97,7 +95,7 @@
9795
\# \s TYPE \s es_index_doc_number \s gauge \n
9896
(
9997
es_index_doc_number\{
100-
cluster="integTest",index="twitter",context="(primaries|total)"
98+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
10199
,\} \s+ \d+\.\d+ \n?
102100
){2}
103101
.*/
@@ -109,7 +107,7 @@
109107
\# \s TYPE \s es_index_doc_deleted_number \s gauge \n
110108
(
111109
es_index_doc_deleted_number\{
112-
cluster="integTest",index="twitter",context="(primaries|total)"
110+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
113111
,\} \s+ \d+\.\d+ \n?
114112
){2}
115113
.*/
@@ -121,7 +119,7 @@
121119
\# \s TYPE \s es_index_store_size_bytes \s gauge \n
122120
(
123121
es_index_store_size_bytes\{
124-
cluster="integTest",index="twitter",context="(primaries|total)"
122+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
125123
,\} \s+ \d+\.\d+ \n?
126124
){2}
127125
.*/

src/test/resources/rest-api-spec/test/resthandler/30_10_index_indexing.yml renamed to src/yamlRestTest/resources/rest-api-spec/test/resthandler/30_10_index_indexing.yml

+10-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
- do:
1515
index:
1616
index: twitter
17-
type: foo
1817
id: 1
1918
body: { foo: bar }
2019

@@ -34,7 +33,7 @@
3433
\# \s TYPE \s es_index_indexing_delete_count \s gauge \n
3534
(
3635
es_index_indexing_delete_count\{
37-
cluster="integTest",index="twitter",context="(primaries|total)"
36+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
3837
,\} \s+ \d+\.\d+ \n?
3938
){2}
4039
.*/
@@ -46,7 +45,7 @@
4645
\# \s TYPE \s es_index_indexing_delete_current_number \s gauge \n
4746
(
4847
es_index_indexing_delete_current_number\{
49-
cluster="integTest",index="twitter",context="(primaries|total)"
48+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
5049
,\} \s+ \d+\.\d+ \n?
5150
){2}
5251
.*/
@@ -58,7 +57,7 @@
5857
\# \s TYPE \s es_index_indexing_delete_time_seconds \s gauge \n
5958
(
6059
es_index_indexing_delete_time_seconds\{
61-
cluster="integTest",index="twitter",context="(primaries|total)"
60+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
6261
,\} \s+ \d+\.\d+ \n?
6362
){2}
6463
.*/
@@ -70,7 +69,7 @@
7069
\# \s TYPE \s es_index_indexing_index_count \s gauge \n
7170
(
7271
es_index_indexing_index_count\{
73-
cluster="integTest",index="twitter",context="(primaries|total)"
72+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
7473
,\} \s+ \d+\.\d+ \n?
7574
){2}
7675
.*/
@@ -82,7 +81,7 @@
8281
\# \s TYPE \s es_index_indexing_index_current_number \s gauge \n
8382
(
8483
es_index_indexing_index_current_number\{
85-
cluster="integTest",index="twitter",context="(primaries|total)"
84+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
8685
,\} \s+ \d+\.\d+ \n?
8786
){2}
8887
.*/
@@ -94,7 +93,7 @@
9493
\# \s TYPE \s es_index_indexing_index_failed_count \s gauge \n
9594
(
9695
es_index_indexing_index_failed_count\{
97-
cluster="integTest",index="twitter",context="(primaries|total)"
96+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
9897
,\} \s+ \d+\.\d+ \n?
9998
){2}
10099
.*/
@@ -106,7 +105,7 @@
106105
\# \s TYPE \s es_index_indexing_index_time_seconds \s gauge \n
107106
(
108107
es_index_indexing_index_time_seconds\{
109-
cluster="integTest",index="twitter",context="(primaries|total)"
108+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
110109
,\} \s+ \d+\.\d+ \n?
111110
){2}
112111
.*/
@@ -118,7 +117,7 @@
118117
\# \s TYPE \s es_index_indexing_noop_update_count \s gauge \n
119118
(
120119
es_index_indexing_noop_update_count\{
121-
cluster="integTest",index="twitter",context="(primaries|total)"
120+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
122121
,\} \s+ \d+\.\d+ \n?
123122
){2}
124123
.*/
@@ -130,7 +129,7 @@
130129
\# \s TYPE \s es_index_indexing_is_throttled_bool \s gauge \n
131130
(
132131
es_index_indexing_is_throttled_bool\{
133-
cluster="integTest",index="twitter",context="(primaries|total)"
132+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
134133
,\} \s+ \d+\.\d+ \n?
135134
){2}
136135
.*/
@@ -142,7 +141,7 @@
142141
\# \s TYPE \s es_index_indexing_throttle_time_seconds \s gauge \n
143142
(
144143
es_index_indexing_throttle_time_seconds\{
145-
cluster="integTest",index="twitter",context="(primaries|total)"
144+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
146145
,\} \s+ \d+\.\d+ \n?
147146
){2}
148147
.*/

src/test/resources/rest-api-spec/test/resthandler/30_11_index_get.yml renamed to src/yamlRestTest/resources/rest-api-spec/test/resthandler/30_11_index_get.yml

+7-8
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
- do:
1515
index:
1616
index: twitter
17-
type: foo
1817
id: 1
1918
body: { foo: bar }
2019

@@ -34,7 +33,7 @@
3433
\# \s TYPE \s es_index_get_count \s gauge \n
3534
(
3635
es_index_get_count\{
37-
cluster="integTest",index="twitter",context="(primaries|total)"
36+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
3837
,\} \s+ \d+\.\d+ \n?
3938
){2}
4039
.*/
@@ -46,7 +45,7 @@
4645
\# \s TYPE \s es_index_get_time_seconds \s gauge \n
4746
(
4847
es_index_get_time_seconds\{
49-
cluster="integTest",index="twitter",context="(primaries|total)"
48+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
5049
,\} \s+ \d+\.\d+ \n?
5150
){2}
5251
.*/
@@ -58,7 +57,7 @@
5857
\# \s TYPE \s es_index_get_exists_count \s gauge \n
5958
(
6059
es_index_get_exists_count\{
61-
cluster="integTest",index="twitter",context="(primaries|total)"
60+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
6261
,\} \s+ \d+\.\d+ \n?
6362
){2}
6463
.*/
@@ -70,7 +69,7 @@
7069
\# \s TYPE \s es_index_get_exists_time_seconds \s gauge \n
7170
(
7271
es_index_get_exists_time_seconds\{
73-
cluster="integTest",index="twitter",context="(primaries|total)"
72+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
7473
,\} \s+ \d+\.\d+ \n?
7574
){2}
7675
.*/
@@ -82,7 +81,7 @@
8281
\# \s TYPE \s es_index_get_missing_count \s gauge \n
8382
(
8483
es_index_get_missing_count\{
85-
cluster="integTest",index="twitter",context="(primaries|total)"
84+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
8685
,\} \s+ \d+\.\d+ \n?
8786
){2}
8887
.*/
@@ -94,7 +93,7 @@
9493
\# \s TYPE \s es_index_get_missing_time_seconds \s gauge \n
9594
(
9695
es_index_get_missing_time_seconds\{
97-
cluster="integTest",index="twitter",context="(primaries|total)"
96+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
9897
,\} \s+ \d+\.\d+ \n?
9998
){2}
10099
.*/
@@ -106,7 +105,7 @@
106105
\# \s TYPE \s es_index_get_current_number \s gauge \n
107106
(
108107
es_index_get_current_number\{
109-
cluster="integTest",index="twitter",context="(primaries|total)"
108+
cluster="yamlRestTest",index="twitter",context="(primaries|total)"
110109
,\} \s+ \d+\.\d+ \n?
111110
){2}
112111
.*/

0 commit comments

Comments
 (0)