Skip to content

Commit ea03684

Browse files
committed
Adding esplugin integaration tests
Closes vvanholl#127
1 parent 4dd4716 commit ea03684

26 files changed

+522
-54
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# I do not know why this file is left in the <ROOT> after `gradle build` or `gradle check`
2+
# and why `gradle clean` does not delete it.
3+
# See https://discuss.elastic.co/t/leftovers-after-integtestrunner-in-root/152610
4+
\.local*-integTestRunner-execution-times.log
5+
16
# Eclipse
27
.classpath
38
.project
@@ -7,10 +12,13 @@
712
.idea/
813
*.iml
914
*.iws
15+
*.ipr
1016

1117
# Gradle
1218
.gradle
1319
build
20+
gradle-wrapper.jar
21+
gradle-wrapper.properties
1422

1523
# Mac
1624
.DS_Store

NOTICE.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This product includes software developed by Prometheus.io
2+
and contributors (https://github.com/prometheus/client_java).

build.gradle

+48-37
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
11
import com.github.mgk.gradle.*
22

3+
buildscript {
4+
repositories {
5+
mavenLocal()
6+
mavenCentral()
7+
jcenter()
8+
}
9+
10+
dependencies {
11+
classpath "org.elasticsearch.gradle:build-tools:6.4.2" // How can we use ${versions.elasticsearch} here ???
12+
}
13+
}
14+
315
plugins {
416
id "java"
517
id "checkstyle"
618
id "co.riiid.gradle" version "0.4.2"
719
id "com.github.mgk.gradle.s3" version "1.4.0"
820
}
921

22+
apply plugin: 'java'
23+
apply plugin: 'idea'
24+
apply plugin: 'elasticsearch.esplugin'
25+
26+
// license of this project
27+
licenseFile = rootProject.file('LICENSE.txt')
28+
// copyright notices
29+
noticeFile = rootProject.file('NOTICE.txt')
30+
31+
// dependency license check needs can be enabled
32+
dependencyLicenses.enabled = false
33+
34+
// thirdparty audit needs can be enabled
35+
thirdPartyAudit.enabled = false
36+
37+
// license header checks can be disabled
38+
licenseHeaders.enabled = true
39+
40+
// There are only integration tests
41+
integTestRunner.enabled = true
42+
test.enabled = false
43+
1044
println "Host: " + java.net.InetAddress.getLocalHost()
1145
println "Gradle: " + gradle.gradleVersion + " JVM: " + org.gradle.internal.jvm.Jvm.current() + " Groovy: " + GroovySystem.getVersion()
1246
println "Build: group: '${project.group}', name: '${project.name}', version: '${project.version}'"
@@ -21,7 +55,7 @@ ext {
2155
versions = [
2256
"elasticsearch": version.replaceAll(/\.[0-9]+(|-SNAPSHOT)$/, ""),
2357
"prometheus" : "0.4.0",
24-
"log4j" : "2.9.1",
58+
"log4j" : "2.11.1",
2559
"junit" : "4.12"
2660
]
2761
}
@@ -48,49 +82,25 @@ tasks.withType(JavaCompile) {
4882
options.compilerArgs << "-Xlint:unchecked,deprecation"
4983
}
5084

51-
task javadocJar(type: Jar, dependsOn: classes) {
52-
from javadoc
53-
into "build/tmp"
54-
classifier "javadoc"
55-
}
56-
57-
task sourcesJar(type: Jar, dependsOn: classes) {
58-
from sourceSets.main.allSource
59-
into "build/tmp/sources"
60-
classifier "sources"
61-
}
62-
63-
task copyPluginFiles(type: Copy) {
64-
from "src/main/templates"
65-
into "build/tmp/plugin"
66-
expand([
67-
"descriptor": [
68-
"name" : pluginName,
69-
"classname" : pluginClassname,
70-
"description" : pluginDescription,
71-
"version" : project.property("version"),
72-
"javaVersion" : project.property("targetCompatibility"),
73-
"elasticsearchVersion": versions.elasticsearch
74-
]
75-
])
76-
outputs.upToDateWhen { false }
77-
}
78-
79-
task buildPluginZip(type: Zip, dependsOn: [":jar", "copyPluginFiles"]) {
80-
from configurations.releaseJars
81-
from "build/tmp/plugin"
85+
esplugin {
86+
licenseFile rootProject.file('LICENSE.txt')
87+
noticeFile rootProject.file('NOTICE.txt')
88+
name pluginName
89+
description pluginDescription
90+
classname pluginClassname
8291
}
8392

84-
artifacts {
85-
archives javadocJar, sourcesJar, buildPluginZip
93+
integTestCluster {
94+
numNodes = 2
95+
clusterName = "PrometheusExporterITCluster"
8696
}
8797

8898
checkstyle {
8999
configFile = new File(rootDir, "checkstyle.xml")
90100
toolVersion = "8.2"
91101
}
92102

93-
task S3Upload(type: S3Upload, dependsOn: buildPluginZip) {
103+
task S3Upload(type: S3Upload /*, dependsOn: buildPluginZip*/) {
94104
bucket = s3_bucket
95105
key = "elasticsearch/${project.name}-${version}.zip"
96106
file = "build/distributions/${project.name}-${version}.zip"
@@ -109,7 +119,7 @@ github {
109119
}
110120

111121
githubRelease {
112-
dependsOn("buildPluginZip")
122+
//dependsOn("buildPluginZip")
113123
mustRunAfter("S3Upload")
114124
}
115125

@@ -119,6 +129,7 @@ task release() {
119129
println("SNAPSHOT: Nothing to release !")
120130
}
121131
} else {
122-
dependsOn(["S3Upload", "githubRelease"])
132+
// dependsOn(["S3Upload", "githubRelease"])
133+
dependsOn("S3Upload")
123134
}
124135
}

src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCatalog.java

+22-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright [2016] [Vincent VAN HOLLEBEKE]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
package org.compuscene.metrics.prometheus;
219

320
import org.apache.logging.log4j.Logger;
@@ -7,6 +24,8 @@
724
import java.io.StringWriter;
825
import java.io.Writer;
926
import java.util.HashMap;
27+
import java.util.Locale;
28+
1029
import io.prometheus.client.CollectorRegistry;
1130
import io.prometheus.client.Gauge;
1231
import io.prometheus.client.Summary;
@@ -87,7 +106,7 @@ public void registerClusterGauge(String metric, String help, String... labels) {
87106

88107
metrics.put(metric, gauge);
89108

90-
logger.debug(String.format("Registered new cluster gauge %s", metric));
109+
logger.debug(String.format(Locale.ENGLISH, "Registered new cluster gauge %s", metric));
91110
}
92111

93112
public void setClusterGauge(String metric, double value, String... labelValues) {
@@ -104,7 +123,7 @@ public void registerNodeGauge(String metric, String help, String... labels) {
104123

105124
metrics.put(metric, gauge);
106125

107-
logger.debug(String.format("Registered new node gauge %s", metric));
126+
logger.debug(String.format(Locale.ENGLISH, "Registered new node gauge %s", metric));
108127
}
109128

110129
public void setNodeGauge(String metric, double value, String... labelValues) {
@@ -121,7 +140,7 @@ public void registerSummaryTimer(String metric, String help, String... labels) {
121140

122141
metrics.put(metric, summary);
123142

124-
logger.debug(String.format("Registered new summary %s", metric));
143+
logger.debug(String.format(Locale.ENGLISH, "Registered new summary %s", metric));
125144
}
126145

127146
public Summary.Timer startSummaryTimer(String metric, String... labelValues) {

src/main/java/org/compuscene/metrics/prometheus/PrometheusMetricsCollector.java

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright [2016] [Vincent VAN HOLLEBEKE]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
package org.compuscene.metrics.prometheus;
219

320
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;

src/main/java/org/compuscene/metrics/prometheus/package-info.java

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright [2016] [Vincent VAN HOLLEBEKE]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
/**
219
* Classes used to produce the Prometheus Exporter plugin metrics.
320
*/

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

+16
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright [2016] [Vincent VAN HOLLEBEKE]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
117
package org.elasticsearch.action;
218

319
import org.elasticsearch.client.ElasticsearchClient;

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

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright [2016] [Vincent VAN HOLLEBEKE]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
package org.elasticsearch.action;
219

320
import org.elasticsearch.action.support.master.MasterNodeReadRequest;

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

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright [2016] [Vincent VAN HOLLEBEKE]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
package org.elasticsearch.action;
219

320
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;

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

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright [2016] [Vincent VAN HOLLEBEKE]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
package org.elasticsearch.action;
219

320
import org.elasticsearch.action.support.master.MasterNodeReadOperationRequestBuilder;

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

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright [2016] [Vincent VAN HOLLEBEKE]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
package org.elasticsearch.action;
219

320
import org.elasticsearch.ElasticsearchException;

src/main/java/org/elasticsearch/action/package-info.java

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
/*
2+
* Copyright [2016] [Vincent VAN HOLLEBEKE]
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
118
/**
219
* Classes used for Prometheus Exporter plugin transport actions.
320
*/

0 commit comments

Comments
 (0)