Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -121,6 +121,21 @@
<artifactId>hadoop-shaded-guava</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
Expand All @@ -139,12 +154,6 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
*/
package org.apache.hadoop.yarn.server.timelineservice.storage.common;

import org.junit.jupiter.api.Test;

import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.junit.Assert;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Test for HBaseTimelineStorageUtils.convertApplicationIdToString(),
Expand All @@ -29,11 +31,11 @@
*/
public class TestCustomApplicationIdConversion {
@Test
public void testConvertAplicationIdToString() {
void testConvertAplicationIdToString() {
ApplicationId applicationId = ApplicationId.newInstance(0, 1);
String applicationIdStr =
HBaseTimelineSchemaUtils.convertApplicationIdToString(applicationId);
Assert.assertEquals(applicationId,
assertEquals(applicationId,
ApplicationId.fromString(applicationIdStr));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@

package org.apache.hadoop.yarn.server.timelineservice.storage.common;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.jupiter.api.Test;

import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* Unit tests for key converters for various tables' row keys.
Expand All @@ -33,7 +34,7 @@
public class TestKeyConverters {

@Test
public void testAppIdKeyConverter() {
void testAppIdKeyConverter() {
AppIdKeyConverter appIdKeyConverter = new AppIdKeyConverter();
long currentTs = System.currentTimeMillis();
ApplicationId appId1 = ApplicationId.newInstance(currentTs, 1);
Expand All @@ -48,23 +49,20 @@ public void testAppIdKeyConverter() {
// App ids' should be encoded in a manner wherein descending order
// is maintained.
assertTrue(
"Ordering of app ids' is incorrect",
Bytes.compareTo(appIdBytes1, appIdBytes2) > 0
&& Bytes.compareTo(appIdBytes1, appIdBytes3) > 0
&& Bytes.compareTo(appIdBytes2, appIdBytes3) > 0);
&& Bytes.compareTo(appIdBytes2, appIdBytes3) > 0,
"Ordering of app ids' is incorrect");
String decodedAppId1 = appIdKeyConverter.decode(appIdBytes1);
String decodedAppId2 = appIdKeyConverter.decode(appIdBytes2);
String decodedAppId3 = appIdKeyConverter.decode(appIdBytes3);
assertTrue("Decoded app id is not same as the app id encoded",
appIdStr1.equals(decodedAppId1));
assertTrue("Decoded app id is not same as the app id encoded",
appIdStr2.equals(decodedAppId2));
assertTrue("Decoded app id is not same as the app id encoded",
appIdStr3.equals(decodedAppId3));
assertEquals(appIdStr1, decodedAppId1);
assertEquals(appIdStr2, decodedAppId2);
assertEquals(appIdStr3, decodedAppId3);
}

@Test
public void testEventColumnNameConverter() {
void testEventColumnNameConverter() {
String eventId = "=foo_=eve=nt=";
byte[] valSepBytes = Bytes.toBytes(Separator.VALUES.getValue());
byte[] maxByteArr =
Expand All @@ -91,7 +89,7 @@ public void testEventColumnNameConverter() {
}

@Test
public void testLongKeyConverter() {
void testLongKeyConverter() {
LongKeyConverter longKeyConverter = new LongKeyConverter();
confirmLongKeyConverter(longKeyConverter, Long.MIN_VALUE);
confirmLongKeyConverter(longKeyConverter, -1234567890L);
Expand All @@ -113,7 +111,7 @@ private void confirmLongKeyConverter(LongKeyConverter longKeyConverter,
}

@Test
public void testStringKeyConverter() {
void testStringKeyConverter() {
StringKeyConverter stringKeyConverter = new StringKeyConverter();
String phrase = "QuackAttack now!";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@
*/
package org.apache.hadoop.yarn.server.timelineservice.storage.common;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.jupiter.api.Test;

import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.yarn.api.records.ApplicationId;
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEntity;
import org.apache.hadoop.yarn.server.timelineservice.storage.application.ApplicationRowKey;
import org.apache.hadoop.yarn.server.timelineservice.storage.application.ApplicationRowKeyPrefix;
import org.apache.hadoop.yarn.server.timelineservice.storage.apptoflow.AppToFlowRowKey;
import org.apache.hadoop.yarn.server.timelineservice.storage.domain.DomainRowKey;
import org.apache.hadoop.yarn.server.timelineservice.storage.entity.EntityRowKey;
import org.apache.hadoop.yarn.server.timelineservice.storage.entity.EntityRowKeyPrefix;
import org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowActivityRowKey;
import org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowActivityRowKeyPrefix;
import org.apache.hadoop.yarn.server.timelineservice.storage.flow.FlowRunRowKey;
import org.apache.hadoop.yarn.server.timelineservice.storage.subapplication.SubApplicationRowKey;
import org.apache.hadoop.yarn.server.timelineservice.storage.domain.DomainRowKey;
import org.junit.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;


/**
Expand Down Expand Up @@ -81,14 +82,14 @@ private static void verifyRowPrefixBytes(byte[] byteRowKeyPrefix) {
int sepLen = QUALIFIER_SEP_BYTES.length;
for (int i = 0; i < sepLen; i++) {
assertTrue(
"Row key prefix not encoded properly.",
byteRowKeyPrefix[byteRowKeyPrefix.length - sepLen + i] ==
QUALIFIER_SEP_BYTES[i]);
QUALIFIER_SEP_BYTES[i],
"Row key prefix not encoded properly.");
}
}

@Test
public void testApplicationRowKey() {
void testApplicationRowKey() {
byte[] byteRowKey =
new ApplicationRowKey(CLUSTER, USER, FLOW_NAME, FLOW_RUN_ID,
APPLICATION_ID).getRowKey();
Expand All @@ -104,7 +105,7 @@ public void testApplicationRowKey() {
.getRowKeyPrefix();
byte[][] splits =
Separator.QUALIFIERS.split(byteRowKeyPrefix,
new int[] {Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE,
new int[]{Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE,
Separator.VARIABLE_SIZE, Bytes.SIZEOF_LONG,
Separator.VARIABLE_SIZE});
assertEquals(5, splits.length);
Expand All @@ -118,9 +119,9 @@ public void testApplicationRowKey() {
byteRowKeyPrefix =
new ApplicationRowKeyPrefix(CLUSTER, USER, FLOW_NAME).getRowKeyPrefix();
splits =
Separator.QUALIFIERS.split(byteRowKeyPrefix, new int[] {
Separator.QUALIFIERS.split(byteRowKeyPrefix, new int[]{
Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE,
Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE });
Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE});
assertEquals(4, splits.length);
assertEquals(0, splits[3].length);
assertEquals(FLOW_NAME,
Expand All @@ -133,14 +134,14 @@ public void testApplicationRowKey() {
* corresponding rowkey.
*/
@Test
public void testAppToFlowRowKey() {
void testAppToFlowRowKey() {
byte[] byteRowKey = new AppToFlowRowKey(APPLICATION_ID).getRowKey();
AppToFlowRowKey rowKey = AppToFlowRowKey.parseRowKey(byteRowKey);
assertEquals(APPLICATION_ID, rowKey.getAppId());
}

@Test
public void testEntityRowKey() {
void testEntityRowKey() {
TimelineEntity entity = new TimelineEntity();
entity.setId("!ent!ity!!id!");
entity.setType("entity!Type");
Expand All @@ -163,14 +164,14 @@ public void testEntityRowKey() {
byte[] byteRowKeyPrefix =
new EntityRowKeyPrefix(CLUSTER, USER, FLOW_NAME, FLOW_RUN_ID,
APPLICATION_ID, entity.getType(), null, null)
.getRowKeyPrefix();
.getRowKeyPrefix();
byte[][] splits =
Separator.QUALIFIERS.split(
byteRowKeyPrefix,
new int[] {Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE,
new int[]{Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE,
Separator.VARIABLE_SIZE, Bytes.SIZEOF_LONG,
AppIdKeyConverter.getKeySize(), Separator.VARIABLE_SIZE,
Bytes.SIZEOF_LONG, Separator.VARIABLE_SIZE });
Bytes.SIZEOF_LONG, Separator.VARIABLE_SIZE});
assertEquals(7, splits.length);
assertEquals(APPLICATION_ID, new AppIdKeyConverter().decode(splits[4]));
assertEquals(entity.getType(),
Expand All @@ -183,7 +184,7 @@ public void testEntityRowKey() {
splits =
Separator.QUALIFIERS.split(
byteRowKeyPrefix,
new int[] {Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE,
new int[]{Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE,
Separator.VARIABLE_SIZE, Bytes.SIZEOF_LONG,
AppIdKeyConverter.getKeySize(), Separator.VARIABLE_SIZE});
assertEquals(6, splits.length);
Expand All @@ -194,7 +195,7 @@ public void testEntityRowKey() {
}

@Test
public void testFlowActivityRowKey() {
void testFlowActivityRowKey() {
Long ts = 1459900830000L;
Long dayTimestamp = HBaseTimelineSchemaUtils.getTopOfTheDayTimestamp(ts);
byte[] byteRowKey =
Expand All @@ -208,8 +209,8 @@ public void testFlowActivityRowKey() {
byte[] byteRowKeyPrefix =
new FlowActivityRowKeyPrefix(CLUSTER).getRowKeyPrefix();
byte[][] splits =
Separator.QUALIFIERS.split(byteRowKeyPrefix, new int[] {
Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE });
Separator.QUALIFIERS.split(byteRowKeyPrefix, new int[]{
Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE});
assertEquals(2, splits.length);
assertEquals(0, splits[1].length);
assertEquals(CLUSTER,
Expand All @@ -220,7 +221,7 @@ public void testFlowActivityRowKey() {
new FlowActivityRowKeyPrefix(CLUSTER, ts).getRowKeyPrefix();
splits =
Separator.QUALIFIERS.split(byteRowKeyPrefix,
new int[] {Separator.VARIABLE_SIZE, Bytes.SIZEOF_LONG,
new int[]{Separator.VARIABLE_SIZE, Bytes.SIZEOF_LONG,
Separator.VARIABLE_SIZE});
assertEquals(3, splits.length);
assertEquals(0, splits[2].length);
Expand All @@ -232,7 +233,7 @@ public void testFlowActivityRowKey() {
}

@Test
public void testFlowRunRowKey() {
void testFlowRunRowKey() {
byte[] byteRowKey =
new FlowRunRowKey(CLUSTER, USER, FLOW_NAME, FLOW_RUN_ID).getRowKey();
FlowRunRowKey rowKey = FlowRunRowKey.parseRowKey(byteRowKey);
Expand All @@ -244,9 +245,9 @@ public void testFlowRunRowKey() {
byte[] byteRowKeyPrefix =
new FlowRunRowKey(CLUSTER, USER, FLOW_NAME, null).getRowKey();
byte[][] splits =
Separator.QUALIFIERS.split(byteRowKeyPrefix, new int[] {
Separator.QUALIFIERS.split(byteRowKeyPrefix, new int[]{
Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE,
Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE });
Separator.VARIABLE_SIZE, Separator.VARIABLE_SIZE});
assertEquals(4, splits.length);
assertEquals(0, splits[3].length);
assertEquals(FLOW_NAME,
Expand All @@ -255,7 +256,7 @@ public void testFlowRunRowKey() {
}

@Test
public void testSubAppRowKey() {
void testSubAppRowKey() {
TimelineEntity entity = new TimelineEntity();
entity.setId("entity1");
entity.setType("DAG");
Expand All @@ -275,7 +276,7 @@ public void testSubAppRowKey() {
}

@Test
public void testDomainRowKey() {
void testDomainRowKey() {
String clusterId = "cluster1@dc1";
String domainId = "helloworld";
byte[] byteRowKey =
Expand All @@ -291,7 +292,7 @@ public void testDomainRowKey() {
}

@Test
public void testDomainRowKeySpecialChars() {
void testDomainRowKeySpecialChars() {
String clusterId = "cluster1!temp!dc1";
String domainId = "hello=world";
byte[] byteRowKey =
Expand Down
Loading