use of com.fasterxml.jackson.databind.JsonNode in project hive by apache.
the class MetricsTestUtils method verifyMetricsJson.
public static void verifyMetricsJson(String json, MetricsCategory category, String metricsName, Object expectedValue) throws Exception {
JsonNode jsonNode = getJsonNode(json, category, metricsName);
Assert.assertEquals(expectedValue.toString(), jsonNode.asText());
}
use of com.fasterxml.jackson.databind.JsonNode in project hive by apache.
the class MetricsTestUtils method verifyMetricsJson.
public static void verifyMetricsJson(String json, MetricsCategory category, String metricsName, Double expectedValue, Double delta) throws Exception {
JsonNode jsonNode = getJsonNode(json, category, metricsName);
Assert.assertEquals(expectedValue, Double.valueOf(jsonNode.asText()), delta);
}
use of com.fasterxml.jackson.databind.JsonNode in project kafka by apache.
the class JsonConverterTest method shortToJson.
@Test
public void shortToJson() {
JsonNode converted = parse(converter.fromConnectData(TOPIC, Schema.INT16_SCHEMA, (short) 12));
validateEnvelope(converted);
assertEquals(parse("{ \"type\": \"int16\", \"optional\": false }"), converted.get(JsonSchema.ENVELOPE_SCHEMA_FIELD_NAME));
assertEquals(12, converted.get(JsonSchema.ENVELOPE_PAYLOAD_FIELD_NAME).intValue());
}
use of com.fasterxml.jackson.databind.JsonNode in project cassandra-mesos-deprecated by mesosphere.
the class LiveEndpointsControllerTest method testLiveNodes.
@Test
public void testLiveNodes() throws Exception {
Tuple2<Integer, JsonNode> tup = fetchJson("/live-nodes?limit=2", false);
// must return HTTP/500 if no nodes are present
assertEquals(400, tup._1.intValue());
// add one live node
addNode("exec1", "1.2.3.4");
tup = fetchJson("/live-nodes?limit=2", false);
assertEquals(200, tup._1.intValue());
JsonNode json = tup._2;
assertEquals(9042, json.get("nativePort").asInt());
assertEquals(9160, json.get("rpcPort").asInt());
assertEquals(7199, json.get("jmxPort").asInt());
JsonNode nodes = json.get("liveNodes");
assertEquals(JsonNodeType.ARRAY, nodes.getNodeType());
assertThat(nodes).hasSize(1).contains(TextNode.valueOf("1.2.3.4"));
// test more output formats
Tuple2<Integer, String> str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
assertEquals(200, str._1.intValue());
assertEquals("1.2.3.4 9042", str._2);
str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
assertEquals(200, str._1.intValue());
assertEquals("-node 1.2.3.4 -port native=9042 thrift=9160 jmx=7199", str._2);
str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
assertEquals(200, str._1.intValue());
assertEquals("-h 1.2.3.4 -p 7199", str._2);
str = fetchText("/live-nodes/text?limit=2", "text/plain");
assertEquals(200, str._1.intValue());
assertEquals("NATIVE: 9042\n" + "RPC: 9160\n" + "JMX: 7199\n" + "IP: 1.2.3.4\n", str._2);
str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
assertEquals(200, str._1.intValue());
assertEquals("1.2.3.4 9042", str._2);
str = fetchText("/live-nodes/stress", "text/x-cassandra-stress");
assertEquals(200, str._1.intValue());
assertEquals("-node 1.2.3.4 -port native=9042 thrift=9160 jmx=7199", str._2);
str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
assertEquals(200, str._1.intValue());
assertEquals("-h 1.2.3.4 -p 7199", str._2);
str = fetchText("/live-nodes/text", "text/plain");
assertEquals(200, str._1.intValue());
assertEquals("NATIVE: 9042\n" + "RPC: 9160\n" + "JMX: 7199\n" + "IP: 1.2.3.4\n", str._2);
//
// mark node as dead
//
cluster.recordHealthCheck("exec1", healthCheckDetailsFailed());
tup = fetchJson("/live-nodes?limit=2", false);
assertEquals(400, tup._1.intValue());
str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
assertEquals(400, str._1.intValue());
str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
assertEquals(400, str._1.intValue());
str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
assertEquals(400, str._1.intValue());
str = fetchText("/live-nodes/text?limit=2", "text/plain");
assertEquals(400, str._1.intValue());
// add a live nodes
addNode("exec2", "2.2.2.2");
tup = fetchJson("/live-nodes?limit=2", false);
assertEquals(200, tup._1.intValue());
json = tup._2;
assertEquals(9042, json.get("nativePort").asInt());
assertEquals(9160, json.get("rpcPort").asInt());
assertEquals(7199, json.get("jmxPort").asInt());
nodes = json.get("liveNodes");
assertEquals(JsonNodeType.ARRAY, nodes.getNodeType());
assertThat(nodes).hasSize(1).contains(TextNode.valueOf("2.2.2.2"));
str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
assertEquals(200, str._1.intValue());
assertEquals("2.2.2.2 9042", str._2);
str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
assertEquals(200, str._1.intValue());
assertEquals("-node 2.2.2.2 -port native=9042 thrift=9160 jmx=7199", str._2);
str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
assertEquals(200, str._1.intValue());
assertEquals("-h 2.2.2.2 -p 7199", str._2);
str = fetchText("/live-nodes/text?limit=2", "text/plain");
assertEquals(200, str._1.intValue());
assertEquals("NATIVE: 9042\n" + "RPC: 9160\n" + "JMX: 7199\n" + "IP: 2.2.2.2\n", str._2);
// mark 1st node as live
cluster.recordHealthCheck("exec1", healthCheckDetailsSuccess("NORMAL", true));
tup = fetchJson("/live-nodes?limit=2", false);
assertEquals(200, tup._1.intValue());
json = tup._2;
assertEquals(9042, json.get("nativePort").asInt());
assertEquals(9160, json.get("rpcPort").asInt());
assertEquals(7199, json.get("jmxPort").asInt());
nodes = json.get("liveNodes");
assertEquals(JsonNodeType.ARRAY, nodes.getNodeType());
assertThat(nodes).hasSize(2).contains(TextNode.valueOf("1.2.3.4")).contains(TextNode.valueOf("2.2.2.2"));
str = fetchText("/live-nodes/cqlsh", "text/x-cassandra-cqlsh");
assertEquals(200, str._1.intValue());
str = fetchText("/live-nodes/stress?limit=2", "text/x-cassandra-stress");
assertEquals(200, str._1.intValue());
str = fetchText("/live-nodes/nodetool", "text/x-cassandra-nodetool");
assertEquals(200, str._1.intValue());
str = fetchText("/live-nodes/text?limit=2", "text/plain");
assertEquals(200, str._1.intValue());
}
use of com.fasterxml.jackson.databind.JsonNode in project cassandra-mesos-deprecated by mesosphere.
the class QaReportControllerTest method testQaReportResources.
@Test
public void testQaReportResources() throws Exception {
threeNodeCluster();
final Tuple2<Integer, JsonNode> tup = fetchJson("/qa/report/resources", false);
assertEquals(200, tup._1.intValue());
final JsonNode json = tup._2;
for (int i = 0; i < activeNodes; i++) {
final Tuple2<Protos.SlaveID, String> slave = slaves[i];
final JsonNode node = json.get("nodes").get(executorMetadata[i].getExecutor().getExecutorId().getValue());
assertEquals(slave._2, node.get("ip").asText());
assertTrue(node.has("workdir"));
assertTrue(node.has("hostname"));
assertTrue(node.has("targetRunState"));
assertTrue(node.has("jmxIp"));
assertTrue(node.has("jmxPort"));
assertTrue(node.has("live"));
assertTrue(node.get("logfiles").isArray());
assertEquals(2, node.get("logfiles").size());
}
}
Aggregations