|
@@ -30,6 +30,11 @@ import java.util.HashSet;
|
|
|
import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
|
|
|
+import org.junit.jupiter.api.AfterAll;
|
|
|
+import org.junit.jupiter.api.BeforeAll;
|
|
|
+import org.junit.jupiter.api.BeforeEach;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+
|
|
|
import org.apache.commons.csv.CSVFormat;
|
|
|
import org.apache.commons.csv.CSVPrinter;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
@@ -53,11 +58,9 @@ import org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineKeyVa
|
|
|
import org.apache.hadoop.yarn.server.timelineservice.reader.filter.TimelineKeyValuesFilter;
|
|
|
import org.apache.hadoop.yarn.server.timelineservice.storage.TimelineReader.Field;
|
|
|
import org.apache.hadoop.yarn.util.timeline.TimelineUtils;
|
|
|
-import org.junit.AfterClass;
|
|
|
-import org.junit.Assert;
|
|
|
-import org.junit.Before;
|
|
|
-import org.junit.BeforeClass;
|
|
|
-import org.junit.Test;
|
|
|
+
|
|
|
+import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
+import static org.junit.jupiter.api.Assertions.fail;
|
|
|
|
|
|
public class TestFileSystemTimelineReaderImpl {
|
|
|
|
|
@@ -65,7 +68,7 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
TestFileSystemTimelineReaderImpl.class.getSimpleName()).getAbsolutePath();
|
|
|
private FileSystemTimelineReaderImpl reader;
|
|
|
|
|
|
- @BeforeClass
|
|
|
+ @BeforeAll
|
|
|
public static void setup() throws Exception {
|
|
|
initializeDataDirectory(ROOT_DIR);
|
|
|
}
|
|
@@ -89,12 +92,12 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
(new File(rootDir)).deleteOnExit();
|
|
|
}
|
|
|
|
|
|
- @AfterClass
|
|
|
+ @AfterAll
|
|
|
public static void tearDown() throws Exception {
|
|
|
FileUtils.deleteDirectory(new File(ROOT_DIR));
|
|
|
}
|
|
|
|
|
|
- @Before
|
|
|
+ @BeforeEach
|
|
|
public void init() throws Exception {
|
|
|
reader = new FileSystemTimelineReaderImpl();
|
|
|
Configuration conf = new YarnConfiguration();
|
|
@@ -313,141 +316,141 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testGetEntityDefaultView() throws Exception {
|
|
|
+ void testGetEntityDefaultView() throws Exception {
|
|
|
// If no fields are specified, entity is returned with default view i.e.
|
|
|
// only the id, type and created time.
|
|
|
TimelineEntity result = reader.getEntity(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", "id_1"),
|
|
|
+ "app", "id_1"),
|
|
|
new TimelineDataToRetrieve(null, null, null, null, null, null));
|
|
|
- Assert.assertEquals(
|
|
|
+ assertEquals(
|
|
|
(new TimelineEntity.Identifier("app", "id_1")).toString(),
|
|
|
result.getIdentifier().toString());
|
|
|
- Assert.assertEquals((Long)1425016502000L, result.getCreatedTime());
|
|
|
- Assert.assertEquals(0, result.getConfigs().size());
|
|
|
- Assert.assertEquals(0, result.getMetrics().size());
|
|
|
+ assertEquals((Long) 1425016502000L, result.getCreatedTime());
|
|
|
+ assertEquals(0, result.getConfigs().size());
|
|
|
+ assertEquals(0, result.getMetrics().size());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testGetEntityByClusterAndApp() throws Exception {
|
|
|
+ void testGetEntityByClusterAndApp() throws Exception {
|
|
|
// Cluster and AppId should be enough to get an entity.
|
|
|
TimelineEntity result = reader.getEntity(
|
|
|
new TimelineReaderContext("cluster1", null, null, null, "app1", "app",
|
|
|
- "id_1"),
|
|
|
+ "id_1"),
|
|
|
new TimelineDataToRetrieve(null, null, null, null, null, null));
|
|
|
- Assert.assertEquals(
|
|
|
+ assertEquals(
|
|
|
(new TimelineEntity.Identifier("app", "id_1")).toString(),
|
|
|
result.getIdentifier().toString());
|
|
|
- Assert.assertEquals((Long)1425016502000L, result.getCreatedTime());
|
|
|
- Assert.assertEquals(0, result.getConfigs().size());
|
|
|
- Assert.assertEquals(0, result.getMetrics().size());
|
|
|
+ assertEquals((Long) 1425016502000L, result.getCreatedTime());
|
|
|
+ assertEquals(0, result.getConfigs().size());
|
|
|
+ assertEquals(0, result.getMetrics().size());
|
|
|
}
|
|
|
|
|
|
/** This test checks whether we can handle commas in app flow mapping csv. */
|
|
|
@Test
|
|
|
- public void testAppFlowMappingCsv() throws Exception {
|
|
|
+ void testAppFlowMappingCsv() throws Exception {
|
|
|
// Test getting an entity by cluster and app where flow entry
|
|
|
// in app flow mapping csv has commas.
|
|
|
TimelineEntity result = reader.getEntity(
|
|
|
new TimelineReaderContext("cluster1", null, null, null, "app2",
|
|
|
- "app", "id_5"),
|
|
|
+ "app", "id_5"),
|
|
|
new TimelineDataToRetrieve(null, null, null, null, null, null));
|
|
|
- Assert.assertEquals(
|
|
|
+ assertEquals(
|
|
|
(new TimelineEntity.Identifier("app", "id_5")).toString(),
|
|
|
result.getIdentifier().toString());
|
|
|
- Assert.assertEquals((Long)1425016502050L, result.getCreatedTime());
|
|
|
+ assertEquals((Long) 1425016502050L, result.getCreatedTime());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testGetEntityCustomFields() throws Exception {
|
|
|
+ void testGetEntityCustomFields() throws Exception {
|
|
|
// Specified fields in addition to default view will be returned.
|
|
|
TimelineEntity result = reader.getEntity(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", "id_1"),
|
|
|
+ "app", "id_1"),
|
|
|
new TimelineDataToRetrieve(null, null,
|
|
|
- EnumSet.of(Field.INFO, Field.CONFIGS, Field.METRICS), null, null,
|
|
|
- null));
|
|
|
- Assert.assertEquals(
|
|
|
+ EnumSet.of(Field.INFO, Field.CONFIGS, Field.METRICS), null, null,
|
|
|
+ null));
|
|
|
+ assertEquals(
|
|
|
(new TimelineEntity.Identifier("app", "id_1")).toString(),
|
|
|
result.getIdentifier().toString());
|
|
|
- Assert.assertEquals((Long)1425016502000L, result.getCreatedTime());
|
|
|
- Assert.assertEquals(3, result.getConfigs().size());
|
|
|
- Assert.assertEquals(3, result.getMetrics().size());
|
|
|
- Assert.assertEquals(2, result.getInfo().size());
|
|
|
+ assertEquals((Long) 1425016502000L, result.getCreatedTime());
|
|
|
+ assertEquals(3, result.getConfigs().size());
|
|
|
+ assertEquals(3, result.getMetrics().size());
|
|
|
+ assertEquals(2, result.getInfo().size());
|
|
|
// No events will be returned
|
|
|
- Assert.assertEquals(0, result.getEvents().size());
|
|
|
+ assertEquals(0, result.getEvents().size());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testGetEntityAllFields() throws Exception {
|
|
|
+ void testGetEntityAllFields() throws Exception {
|
|
|
// All fields of TimelineEntity will be returned.
|
|
|
TimelineEntity result = reader.getEntity(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", "id_1"),
|
|
|
+ "app", "id_1"),
|
|
|
new TimelineDataToRetrieve(null, null, EnumSet.of(Field.ALL), null,
|
|
|
- null, null));
|
|
|
- Assert.assertEquals(
|
|
|
+ null, null));
|
|
|
+ assertEquals(
|
|
|
(new TimelineEntity.Identifier("app", "id_1")).toString(),
|
|
|
result.getIdentifier().toString());
|
|
|
- Assert.assertEquals((Long)1425016502000L, result.getCreatedTime());
|
|
|
- Assert.assertEquals(3, result.getConfigs().size());
|
|
|
- Assert.assertEquals(3, result.getMetrics().size());
|
|
|
+ assertEquals((Long) 1425016502000L, result.getCreatedTime());
|
|
|
+ assertEquals(3, result.getConfigs().size());
|
|
|
+ assertEquals(3, result.getMetrics().size());
|
|
|
// All fields including events will be returned.
|
|
|
- Assert.assertEquals(2, result.getEvents().size());
|
|
|
+ assertEquals(2, result.getEvents().size());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testGetAllEntities() throws Exception {
|
|
|
+ void testGetAllEntities() throws Exception {
|
|
|
Set<TimelineEntity> result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null), new TimelineEntityFilters.Builder().build(),
|
|
|
+ "app", null), new TimelineEntityFilters.Builder().build(),
|
|
|
new TimelineDataToRetrieve(null, null, EnumSet.of(Field.ALL), null,
|
|
|
- null, null));
|
|
|
+ null, null));
|
|
|
// All 4 entities will be returned
|
|
|
- Assert.assertEquals(4, result.size());
|
|
|
+ assertEquals(4, result.size());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testGetEntitiesWithLimit() throws Exception {
|
|
|
+ void testGetEntitiesWithLimit() throws Exception {
|
|
|
Set<TimelineEntity> result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().entityLimit(2L).build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(2, result.size());
|
|
|
+ assertEquals(2, result.size());
|
|
|
// Needs to be rewritten once hashcode and equals for
|
|
|
// TimelineEntity is implemented
|
|
|
// Entities with id_1 and id_4 should be returned,
|
|
|
// based on created time, descending.
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1") && !entity.getId().equals("id_4")) {
|
|
|
- Assert.fail("Entity not sorted by created time");
|
|
|
+ fail("Entity not sorted by created time");
|
|
|
}
|
|
|
}
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().entityLimit(3L).build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
// Even though 2 entities out of 4 have same created time, one entity
|
|
|
// is left out due to limit
|
|
|
- Assert.assertEquals(3, result.size());
|
|
|
+ assertEquals(3, result.size());
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testGetEntitiesByTimeWindows() throws Exception {
|
|
|
+ void testGetEntitiesByTimeWindows() throws Exception {
|
|
|
// Get entities based on created time start and end time range.
|
|
|
Set<TimelineEntity> result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().createdTimeBegin(1425016502030L)
|
|
|
.createTimeEnd(1425016502060L).build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(1, result.size());
|
|
|
+ assertEquals(1, result.size());
|
|
|
// Only one entity with ID id_4 should be returned.
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_4")) {
|
|
|
- Assert.fail("Incorrect filtering based on created time range");
|
|
|
+ fail("Incorrect filtering based on created time range");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -458,44 +461,44 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
new TimelineEntityFilters.Builder().createTimeEnd(1425016502010L)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(3, result.size());
|
|
|
+ assertEquals(3, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (entity.getId().equals("id_4")) {
|
|
|
- Assert.fail("Incorrect filtering based on created time range");
|
|
|
+ fail("Incorrect filtering based on created time range");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Get entities if only created time start is specified.
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().createdTimeBegin(1425016502010L)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(1, result.size());
|
|
|
+ assertEquals(1, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_4")) {
|
|
|
- Assert.fail("Incorrect filtering based on created time range");
|
|
|
+ fail("Incorrect filtering based on created time range");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testGetFilteredEntities() throws Exception {
|
|
|
+ void testGetFilteredEntities() throws Exception {
|
|
|
// Get entities based on info filters.
|
|
|
TimelineFilterList infoFilterList = new TimelineFilterList();
|
|
|
infoFilterList.addFilter(
|
|
|
new TimelineKeyValueFilter(TimelineCompareOp.EQUAL, "info2", 3.5));
|
|
|
Set<TimelineEntity> result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().infoFilters(infoFilterList).build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(1, result.size());
|
|
|
+ assertEquals(1, result.size());
|
|
|
// Only one entity with ID id_3 should be returned.
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_3")) {
|
|
|
- Assert.fail("Incorrect filtering based on info filters");
|
|
|
+ fail("Incorrect filtering based on info filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -507,14 +510,14 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
new TimelineKeyValueFilter(TimelineCompareOp.EQUAL, "config_3", "abc"));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().configFilters(confFilterList)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(1, result.size());
|
|
|
+ assertEquals(1, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_3")) {
|
|
|
- Assert.fail("Incorrect filtering based on config filters");
|
|
|
+ fail("Incorrect filtering based on config filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -526,13 +529,13 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
new TimelineExistsFilter(TimelineCompareOp.EQUAL, "event_4"));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().eventFilters(eventFilters).build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(1, result.size());
|
|
|
+ assertEquals(1, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_3")) {
|
|
|
- Assert.fail("Incorrect filtering based on event filters");
|
|
|
+ fail("Incorrect filtering based on event filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -542,15 +545,15 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
TimelineCompareOp.GREATER_OR_EQUAL, "metric3", 0L));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().metricFilters(metricFilterList)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(2, result.size());
|
|
|
+ assertEquals(2, result.size());
|
|
|
// Two entities with IDs' id_1 and id_2 should be returned.
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1") && !entity.getId().equals("id_2")) {
|
|
|
- Assert.fail("Incorrect filtering based on metric filters");
|
|
|
+ fail("Incorrect filtering based on metric filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -569,14 +572,14 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
new TimelineFilterList(Operator.OR, list1, list2);
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().configFilters(confFilterList1)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(2, result.size());
|
|
|
+ assertEquals(2, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1") && !entity.getId().equals("id_2")) {
|
|
|
- Assert.fail("Incorrect filtering based on config filters");
|
|
|
+ fail("Incorrect filtering based on config filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -592,14 +595,14 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
new TimelineFilterList(Operator.OR, list3, list4);
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().configFilters(confFilterList2)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(2, result.size());
|
|
|
+ assertEquals(2, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1") && !entity.getId().equals("id_2")) {
|
|
|
- Assert.fail("Incorrect filtering based on config filters");
|
|
|
+ fail("Incorrect filtering based on config filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -610,14 +613,14 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
TimelineCompareOp.NOT_EQUAL, "config_3", "abc"));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().configFilters(confFilterList3)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(1, result.size());
|
|
|
- for(TimelineEntity entity : result) {
|
|
|
+ assertEquals(1, result.size());
|
|
|
+ for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_2")) {
|
|
|
- Assert.fail("Incorrect filtering based on config filters");
|
|
|
+ fail("Incorrect filtering based on config filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -628,11 +631,11 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
TimelineCompareOp.EQUAL, "config_3", "def"));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().configFilters(confFilterList4)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(0, result.size());
|
|
|
+ assertEquals(0, result.size());
|
|
|
|
|
|
TimelineFilterList confFilterList5 = new TimelineFilterList(Operator.OR);
|
|
|
confFilterList5.addFilter(new TimelineKeyValueFilter(
|
|
@@ -641,14 +644,14 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
TimelineCompareOp.EQUAL, "config_3", "def"));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().configFilters(confFilterList5)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(1, result.size());
|
|
|
+ assertEquals(1, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_2")) {
|
|
|
- Assert.fail("Incorrect filtering based on config filters");
|
|
|
+ fail("Incorrect filtering based on config filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -665,15 +668,15 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
new TimelineFilterList(Operator.OR, list6, list7);
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().metricFilters(metricFilterList1)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(2, result.size());
|
|
|
+ assertEquals(2, result.size());
|
|
|
// Two entities with IDs' id_2 and id_3 should be returned.
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_2") && !entity.getId().equals("id_3")) {
|
|
|
- Assert.fail("Incorrect filtering based on metric filters");
|
|
|
+ fail("Incorrect filtering based on metric filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -684,14 +687,14 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
TimelineCompareOp.LESS_OR_EQUAL, "metric3", 23));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().metricFilters(metricFilterList2)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(1, result.size());
|
|
|
+ assertEquals(1, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1")) {
|
|
|
- Assert.fail("Incorrect filtering based on metric filters");
|
|
|
+ fail("Incorrect filtering based on metric filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -702,11 +705,11 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
TimelineCompareOp.LESS_OR_EQUAL, "metric3", 23));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().metricFilters(metricFilterList3)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(0, result.size());
|
|
|
+ assertEquals(0, result.size());
|
|
|
|
|
|
TimelineFilterList metricFilterList4 = new TimelineFilterList(Operator.OR);
|
|
|
metricFilterList4.addFilter(new TimelineCompareFilter(
|
|
@@ -715,14 +718,14 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
TimelineCompareOp.LESS_OR_EQUAL, "metric3", 23));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().metricFilters(metricFilterList4)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(2, result.size());
|
|
|
+ assertEquals(2, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1") && !entity.getId().equals("id_2")) {
|
|
|
- Assert.fail("Incorrect filtering based on metric filters");
|
|
|
+ fail("Incorrect filtering based on metric filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -731,14 +734,14 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
TimelineCompareOp.NOT_EQUAL, "metric2", 74));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().metricFilters(metricFilterList5)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(2, result.size());
|
|
|
+ assertEquals(2, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1") && !entity.getId().equals("id_2")) {
|
|
|
- Assert.fail("Incorrect filtering based on metric filters");
|
|
|
+ fail("Incorrect filtering based on metric filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -749,11 +752,11 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
new TimelineKeyValueFilter(TimelineCompareOp.NOT_EQUAL, "info4", 20));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().infoFilters(infoFilterList1)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(0, result.size());
|
|
|
+ assertEquals(0, result.size());
|
|
|
|
|
|
TimelineFilterList infoFilterList2 = new TimelineFilterList(Operator.OR);
|
|
|
infoFilterList2.addFilter(
|
|
@@ -762,14 +765,14 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
new TimelineKeyValueFilter(TimelineCompareOp.EQUAL, "info1", "val1"));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().infoFilters(infoFilterList2)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(2, result.size());
|
|
|
+ assertEquals(2, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1") && !entity.getId().equals("id_3")) {
|
|
|
- Assert.fail("Incorrect filtering based on info filters");
|
|
|
+ fail("Incorrect filtering based on info filters");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -780,11 +783,11 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
new TimelineKeyValueFilter(TimelineCompareOp.EQUAL, "info2", "val5"));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().infoFilters(infoFilterList3)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(0, result.size());
|
|
|
+ assertEquals(0, result.size());
|
|
|
|
|
|
TimelineFilterList infoFilterList4 = new TimelineFilterList(Operator.OR);
|
|
|
infoFilterList4.addFilter(
|
|
@@ -793,55 +796,55 @@ public class TestFileSystemTimelineReaderImpl {
|
|
|
new TimelineKeyValueFilter(TimelineCompareOp.EQUAL, "info2", "val5"));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().infoFilters(infoFilterList4)
|
|
|
.build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(1, result.size());
|
|
|
+ assertEquals(1, result.size());
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1")) {
|
|
|
- Assert.fail("Incorrect filtering based on info filters");
|
|
|
+ fail("Incorrect filtering based on info filters");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
- public void testGetEntitiesByRelations() throws Exception {
|
|
|
+ void testGetEntitiesByRelations() throws Exception {
|
|
|
// Get entities based on relatesTo.
|
|
|
TimelineFilterList relatesTo = new TimelineFilterList(Operator.OR);
|
|
|
Set<Object> relatesToIds =
|
|
|
- new HashSet<Object>(Arrays.asList((Object)"flow1"));
|
|
|
+ new HashSet<Object>(Arrays.asList((Object) "flow1"));
|
|
|
relatesTo.addFilter(new TimelineKeyValuesFilter(
|
|
|
TimelineCompareOp.EQUAL, "flow", relatesToIds));
|
|
|
Set<TimelineEntity> result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().relatesTo(relatesTo).build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(1, result.size());
|
|
|
+ assertEquals(1, result.size());
|
|
|
// Only one entity with ID id_1 should be returned.
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1")) {
|
|
|
- Assert.fail("Incorrect filtering based on relatesTo");
|
|
|
+ fail("Incorrect filtering based on relatesTo");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// Get entities based on isRelatedTo.
|
|
|
TimelineFilterList isRelatedTo = new TimelineFilterList(Operator.OR);
|
|
|
Set<Object> isRelatedToIds =
|
|
|
- new HashSet<Object>(Arrays.asList((Object)"tid1_2"));
|
|
|
+ new HashSet<Object>(Arrays.asList((Object) "tid1_2"));
|
|
|
isRelatedTo.addFilter(new TimelineKeyValuesFilter(
|
|
|
TimelineCompareOp.EQUAL, "type1", isRelatedToIds));
|
|
|
result = reader.getEntities(
|
|
|
new TimelineReaderContext("cluster1", "user1", "flow1", 1L, "app1",
|
|
|
- "app", null),
|
|
|
+ "app", null),
|
|
|
new TimelineEntityFilters.Builder().isRelatedTo(isRelatedTo).build(),
|
|
|
new TimelineDataToRetrieve());
|
|
|
- Assert.assertEquals(2, result.size());
|
|
|
+ assertEquals(2, result.size());
|
|
|
// Two entities with IDs' id_1 and id_3 should be returned.
|
|
|
for (TimelineEntity entity : result) {
|
|
|
if (!entity.getId().equals("id_1") && !entity.getId().equals("id_3")) {
|
|
|
- Assert.fail("Incorrect filtering based on isRelatedTo");
|
|
|
+ fail("Incorrect filtering based on isRelatedTo");
|
|
|
}
|
|
|
}
|
|
|
}
|