Skip to content

Commit

Permalink
HBASE-25895 Implement a Cluster Metrics JSON endpoint (addendum)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndimiduk committed Mar 14, 2022
1 parent 36a5f86 commit f640b7f
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.ConnectionRule;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MiniClusterRule;
import org.apache.hadoop.hbase.ServerName;
Expand Down Expand Up @@ -72,8 +73,9 @@ public class TestApiV1ClusterMetricsResource {
.build())
.setConfiguration(() -> {
// enable Master InfoServer and random port selection
final Configuration conf = new Configuration();
final Configuration conf = HBaseConfiguration.create();
conf.setInt(HConstants.MASTER_INFO_PORT, 0);
conf.set("hbase.http.jersey.tracing.type", "ON_DEMAND");
return conf;
})
.build();
Expand Down Expand Up @@ -148,6 +150,7 @@ protected void after() {
public void testGetRoot() {
final String response = classRule.getTarget()
.request(MediaType.APPLICATION_JSON_TYPE)
.header("X-Jersey-Tracing-Accept", true)
.get(String.class);
assertThat(response, allOf(
containsString("\"hbase_version\":"),
Expand All @@ -160,6 +163,7 @@ public void testGetRoot() {
public void testGetRootHtml() {
assertThrows(NotAcceptableException.class, () -> classRule.getTarget()
.request(MediaType.TEXT_HTML_TYPE)
.header("X-Jersey-Tracing-Accept", true)
.get(String.class));
}

Expand All @@ -168,6 +172,7 @@ public void testGetLiveServers() {
final String response = classRule.getTarget()
.path("live_servers")
.request(MediaType.APPLICATION_JSON_TYPE)
.header("X-Jersey-Tracing-Accept", true)
.get(String.class);
assertThat(response, allOf(
startsWith("{\"data\":["),
Expand All @@ -179,6 +184,7 @@ public void testGetLiveServersHtml() {
assertThrows(NotAcceptableException.class, () -> classRule.getTarget()
.path("live_servers")
.request(MediaType.TEXT_HTML_TYPE)
.header("X-Jersey-Tracing-Accept", true)
.get(String.class));
}

Expand All @@ -187,6 +193,7 @@ public void testGetDeadServers() {
final String response = classRule.getTarget()
.path("dead_servers")
.request(MediaType.APPLICATION_JSON_TYPE)
.header("X-Jersey-Tracing-Accept", true)
.get(String.class);
assertThat(response, allOf(
startsWith("{\"data\":["),
Expand All @@ -198,6 +205,7 @@ public void testGetDeadServersHtml() {
assertThrows(NotAcceptableException.class, () -> classRule.getTarget()
.path("dead_servers")
.request(MediaType.TEXT_HTML_TYPE)
.header("X-Jersey-Tracing-Accept", true)
.get(String.class));
}
}

0 comments on commit f640b7f

Please sign in to comment.