Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@

package org.apache.hadoop.yarn.server.timelineservice.reader;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
Expand All @@ -43,7 +44,6 @@
import org.apache.hadoop.yarn.server.timelineservice.storage.DataGeneratorForTest;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.HttpUrlConnectorProvider;
import org.junit.Assert;

/**
* Test Base for TimelineReaderServer HBase tests.
Expand Down Expand Up @@ -101,7 +101,7 @@ protected void addFilters(Configuration conf) {
server.start();
serverPort = server.getWebServerPort();
} catch (Exception e) {
Assert.fail("Web server failed to start");
fail("Web server failed to start");
}
}

Expand Down Expand Up @@ -138,8 +138,8 @@ protected Response getResponse(Client client, URI uri)
protected void verifyHttpResponse(Client client, URI uri, Response.Status status) {
Response resp = client.target(uri).request(MediaType.APPLICATION_JSON).get();
assertNotNull(resp);
assertTrue("Response from server should have been " + status,
resp.getStatusInfo().getStatusCode() == status.getStatusCode());
assertTrue(resp.getStatusInfo().getStatusCode() == status.getStatusCode(),
"Response from server should have been " + status);
System.out.println("Response is: " + resp.readEntity(String.class));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

package org.apache.hadoop.yarn.server.timelineservice.reader;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import javax.ws.rs.client.Client;

Expand Down Expand Up @@ -59,9 +59,9 @@
import org.apache.hadoop.yarn.server.timelineservice.storage.HBaseTimelineWriterImpl;
import org.apache.hadoop.yarn.server.timelineservice.storage.common.HBaseTimelineSchemaUtils;
import org.apache.hadoop.yarn.server.utils.BuilderUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;

Expand All @@ -75,14 +75,14 @@ public class TestTimelineReaderWebServicesHBaseStorage
HBaseTimelineSchemaUtils.getTopOfTheDayTimestamp(ts);
private static String doAsUser = "remoteuser";

@BeforeClass
@BeforeAll
public static void setupBeforeClass() throws Exception {
setup();
loadData();
initialize();
}

@AfterClass
@AfterAll
public static void tearDownAfterClass() throws Exception {
tearDown();
}
Expand Down Expand Up @@ -505,13 +505,14 @@ public void testGetFlowRuns() throws Exception {
assertNotNull(entities);
assertEquals(2, entities.size());
for (FlowRunEntity entity : entities) {
assertTrue("Id, run id or start time does not match.",
assertTrue(
((entity.getId().equals("user1@flow_name/1002345678919")) &&
(entity.getRunId() == 1002345678919L) &&
(entity.getStartTime() == 1425016501000L)) ||
((entity.getId().equals("user1@flow_name/1002345678920")) &&
(entity.getRunId() == 1002345678920L) &&
(entity.getStartTime() == 1425016501034L)));
(entity.getStartTime() == 1425016501034L)),
"Id, run id or start time does not match.");
assertEquals(0, entity.getMetrics().size());
}

Expand All @@ -525,10 +526,11 @@ public void testGetFlowRuns() throws Exception {
assertNotNull(entities);
assertEquals(1, entities.size());
for (FlowRunEntity entity : entities) {
assertTrue("Id, run id or start time does not match.",
assertTrue(
entity.getId().equals("user1@flow_name/1002345678920") &&
entity.getRunId() == 1002345678920L &&
entity.getStartTime() == 1425016501034L);
entity.getStartTime() == 1425016501034L,
"Id, run id or start time does not match.");
assertEquals(0, entity.getMetrics().size());
}

Expand All @@ -542,10 +544,11 @@ public void testGetFlowRuns() throws Exception {
assertNotNull(entities);
assertEquals(1, entities.size());
for (FlowRunEntity entity : entities) {
assertTrue("Id, run id or start time does not match.",
assertTrue(
entity.getId().equals("user1@flow_name/1002345678920") &&
entity.getRunId() == 1002345678920L &&
entity.getStartTime() == 1425016501034L);
entity.getStartTime() == 1425016501034L,
"Id, run id or start time does not match.");
assertEquals(0, entity.getMetrics().size());
}

Expand All @@ -559,13 +562,14 @@ public void testGetFlowRuns() throws Exception {
assertNotNull(entities);
assertEquals(2, entities.size());
for (FlowRunEntity entity : entities) {
assertTrue("Id, run id or start time does not match.",
assertTrue(
((entity.getId().equals("user1@flow_name/1002345678919")) &&
(entity.getRunId() == 1002345678919L) &&
(entity.getStartTime() == 1425016501000L)) ||
((entity.getId().equals("user1@flow_name/1002345678920")) &&
(entity.getRunId() == 1002345678920L) &&
(entity.getStartTime() == 1425016501034L)));
(entity.getStartTime() == 1425016501034L)),
"Id, run id or start time does not match.");
assertEquals(0, entity.getMetrics().size());
}

Expand All @@ -579,10 +583,11 @@ public void testGetFlowRuns() throws Exception {
assertNotNull(entities);
assertEquals(1, entities.size());
for (FlowRunEntity entity : entities) {
assertTrue("Id, run id or start time does not match.",
assertTrue(
entity.getId().equals("user1@flow_name/1002345678919") &&
entity.getRunId() == 1002345678919L &&
entity.getStartTime() == 1425016501000L);
entity.getStartTime() == 1425016501000L,
"Id, run id or start time does not match.");
assertEquals(0, entity.getMetrics().size());
}

Expand All @@ -596,15 +601,16 @@ public void testGetFlowRuns() throws Exception {
assertNotNull(entities);
assertEquals(2, entities.size());
for (FlowRunEntity entity : entities) {
assertTrue("Id, run id or start time does not match.",
assertTrue(
((entity.getId().equals("user1@flow_name/1002345678919")) &&
(entity.getRunId() == 1002345678919L) &&
(entity.getStartTime() == 1425016501000L) &&
(entity.getMetrics().size() == 3)) ||
((entity.getId().equals("user1@flow_name/1002345678920")) &&
(entity.getRunId() == 1002345678920L) &&
(entity.getStartTime() == 1425016501034L) &&
(entity.getMetrics().size() == 1)));
(entity.getMetrics().size() == 1)),
"Id, run id or start time does not match.");
}

// fields as CONFIGS will lead to a HTTP 400 as it makes no sense for
Expand Down Expand Up @@ -1999,11 +2005,12 @@ public void testGetFlowRunApps() throws Exception {
assertNotNull(entities);
assertEquals(2, entities.size());
for (TimelineEntity entity : entities) {
assertTrue("Unexpected app in result",
assertTrue(
(entity.getId().equals("application_1111111111_1111") &&
entity.getMetrics().size() == 3) ||
(entity.getId().equals("application_1111111111_2222") &&
entity.getMetrics().size() == 1));
entity.getMetrics().size() == 1),
"Unexpected app in result");
for (TimelineMetric metric : entity.getMetrics()) {
assertEquals(TimelineMetric.Type.SINGLE_VALUE, metric.getType());
assertEquals(1, metric.getValues().size());
Expand All @@ -2018,11 +2025,12 @@ public void testGetFlowRunApps() throws Exception {
assertNotNull(entities);
assertEquals(2, entities.size());
for (TimelineEntity entity : entities) {
assertTrue("Unexpected app in result",
assertTrue(
(entity.getId().equals("application_1111111111_1111") &&
entity.getMetrics().size() == 3) ||
(entity.getId().equals("application_1111111111_2222") &&
entity.getMetrics().size() == 1));
entity.getMetrics().size() == 1),
"Unexpected app in result");
for (TimelineMetric metric : entity.getMetrics()) {
assertTrue(metric.getValues().size() <= 2);
assertEquals(TimelineMetric.Type.TIME_SERIES, metric.getType());
Expand Down Expand Up @@ -2062,15 +2070,16 @@ public void testGetFlowApps() throws Exception {
assertNotNull(entities);
assertEquals(3, entities.size());
for (TimelineEntity entity : entities) {
assertTrue("Unexpected app in result",
assertTrue(
(entity.getId().equals("application_1111111111_1111") &&
entity.getConfigs().size() == 1 &&
entity.getConfigs().equals(ImmutableMap.of("cfg2", "value1"))) ||
(entity.getId().equals("application_1111111111_2222") &&
entity.getConfigs().size() == 1 &&
entity.getConfigs().equals(ImmutableMap.of("cfg1", "value1"))) ||
(entity.getId().equals("application_1111111111_2224") &&
entity.getConfigs().size() == 0));
entity.getConfigs().size() == 0),
"Unexpected app in result");
for (TimelineMetric metric : entity.getMetrics()) {
if (entity.getId().equals("application_1111111111_1111")) {
TimelineMetric m1 = newMetric(TimelineMetric.Type.SINGLE_VALUE,
Expand Down Expand Up @@ -2100,15 +2109,16 @@ public void testGetFlowApps() throws Exception {
assertNotNull(entities);
assertEquals(3, entities.size());
for (TimelineEntity entity : entities) {
assertTrue("Unexpected app in result",
assertTrue(
(entity.getId().equals("application_1111111111_1111") &&
entity.getConfigs().size() == 1 &&
entity.getConfigs().equals(ImmutableMap.of("cfg2", "value1"))) ||
(entity.getId().equals("application_1111111111_2222") &&
entity.getConfigs().size() == 1 &&
entity.getConfigs().equals(ImmutableMap.of("cfg1", "value1"))) ||
(entity.getId().equals("application_1111111111_2224") &&
entity.getConfigs().size() == 0));
entity.getConfigs().size() == 0),
"Unexpected app in result");
for (TimelineMetric metric : entity.getMetrics()) {
if (entity.getId().equals("application_1111111111_1111")) {
TimelineMetric m1 = newMetric(TimelineMetric.Type.TIME_SERIES,
Expand Down Expand Up @@ -2167,8 +2177,9 @@ public void testGetFlowAppsFilters() throws Exception {
resp.readEntity(new GenericType<Set<TimelineEntity>>(){});
assertNotNull(entities);
assertEquals(1, entities.size());
assertTrue("Unexpected app in result", entities.contains(
newEntity(entityType, "application_1111111111_1111")));
assertTrue(entities.contains(
newEntity(entityType, "application_1111111111_1111")),
"Unexpected app in result");

uri = URI.create("http://localhost:" + getServerPort() + "/ws/v2/" +
"timeline/clusters/cluster1/users/user1/flows/flow_name/apps?" +
Expand All @@ -2177,8 +2188,9 @@ public void testGetFlowAppsFilters() throws Exception {
entities = resp.readEntity(new GenericType<Set<TimelineEntity>>(){});
assertNotNull(entities);
assertEquals(1, entities.size());
assertTrue("Unexpected app in result", entities.contains(
newEntity(entityType, "application_1111111111_1111")));
assertTrue(entities.contains(
newEntity(entityType, "application_1111111111_1111")),
"Unexpected app in result");

uri = URI.create("http://localhost:" + getServerPort() + "/ws/v2/" +
"timeline/clusters/cluster1/users/user1/flows/flow_name/apps?" +
Expand All @@ -2187,8 +2199,9 @@ public void testGetFlowAppsFilters() throws Exception {
entities = resp.readEntity(new GenericType<Set<TimelineEntity>>(){});
assertNotNull(entities);
assertEquals(1, entities.size());
assertTrue("Unexpected app in result", entities.contains(
newEntity(entityType, "application_1111111111_2222")));
assertTrue(entities.contains(
newEntity(entityType, "application_1111111111_2222")),
"Unexpected app in result");
} finally {
client.close();
}
Expand Down
Loading