YARN-11269. Upgrade JUnit from 4 to 5 in hadoop-yarn-server-timeline-pluginstorage (#4771)
Co-authored-by: Ashutosh Gupta <ashugpt@amazon.com> Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
parent
f75c58a1ca
commit
b253b3be9f
|
@ -71,7 +71,7 @@
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.hadoop</groupId>
|
<groupId>org.apache.hadoop</groupId>
|
||||||
<artifactId>hadoop-yarn-common</artifactId>
|
<artifactId>hadoop-yarn-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -129,6 +129,21 @@
|
||||||
<artifactId>assertj-core</artifactId>
|
<artifactId>assertj-core</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</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.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-params</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
|
|
@ -49,8 +49,8 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility methods related to the ATS v1.5 plugin storage tests.
|
* Utility methods related to the ATS v1.5 plugin storage tests.
|
||||||
|
@ -176,10 +176,8 @@ public class PluginStoreTestUtils {
|
||||||
UserGroupInformation.getLoginUser());
|
UserGroupInformation.getLoginUser());
|
||||||
assertNotNull(entity1);
|
assertNotNull(entity1);
|
||||||
assertNotNull(entity2);
|
assertNotNull(entity2);
|
||||||
assertEquals("Failed to read out entity 1",
|
assertEquals((Long) 123l, entity1.getStartTime(), "Failed to read out entity 1");
|
||||||
(Long) 123l, entity1.getStartTime());
|
assertEquals((Long) 456l, entity2.getStartTime(), "Failed to read out entity 2");
|
||||||
assertEquals("Failed to read out entity 2",
|
|
||||||
(Long) 456l, entity2.getStartTime());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -43,14 +43,12 @@ import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.yarn.server.timeline.EntityGroupFSTimelineStore.AppState;
|
import org.apache.hadoop.yarn.server.timeline.EntityGroupFSTimelineStore.AppState;
|
||||||
import org.apache.hadoop.yarn.server.timeline.TimelineReader.Field;
|
import org.apache.hadoop.yarn.server.timeline.TimelineReader.Field;
|
||||||
import org.apache.hadoop.yarn.util.ConverterUtils;
|
import org.apache.hadoop.yarn.util.ConverterUtils;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterAll;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.AfterClass;
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Rule;
|
import org.junit.jupiter.api.TestInfo;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.rules.TestName;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import com.fasterxml.jackson.core.JsonFactory;
|
import com.fasterxml.jackson.core.JsonFactory;
|
||||||
|
@ -78,11 +76,12 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -118,12 +117,10 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
private EntityGroupFSTimelineStore store;
|
private EntityGroupFSTimelineStore store;
|
||||||
private TimelineEntity entityNew;
|
private TimelineEntity entityNew;
|
||||||
|
|
||||||
@Rule
|
|
||||||
public TestName currTestName = new TestName();
|
|
||||||
private File rootDir;
|
private File rootDir;
|
||||||
private File testJar;
|
private File testJar;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeAll
|
||||||
public static void setupClass() throws Exception {
|
public static void setupClass() throws Exception {
|
||||||
config.setBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, false);
|
config.setBoolean(YarnConfiguration.TIMELINE_SERVICE_TTL_ENABLE, false);
|
||||||
config.set(
|
config.set(
|
||||||
|
@ -163,8 +160,8 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
testActiveDirPath.toString());
|
testActiveDirPath.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws Exception {
|
public void setup(TestInfo testInfo) throws Exception {
|
||||||
for (ApplicationId appId : sampleAppIds) {
|
for (ApplicationId appId : sampleAppIds) {
|
||||||
Path attemotDirPath =
|
Path attemotDirPath =
|
||||||
new Path(new Path(testActiveDirPath, appId.toString()),
|
new Path(new Path(testActiveDirPath, appId.toString()),
|
||||||
|
@ -173,7 +170,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
store = new EntityGroupFSTimelineStore();
|
store = new EntityGroupFSTimelineStore();
|
||||||
if (currTestName.getMethodName().contains("Plugin")) {
|
if (testInfo.getTestMethod().get().getName().contains("Plugin")) {
|
||||||
rootDir = GenericTestUtils.getTestDir(getClass()
|
rootDir = GenericTestUtils.getTestDir(getClass()
|
||||||
.getSimpleName());
|
.getSimpleName());
|
||||||
if (!rootDir.exists()) {
|
if (!rootDir.exists()) {
|
||||||
|
@ -201,7 +198,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
store.start();
|
store.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
store.stop();
|
store.stop();
|
||||||
for (ApplicationId appId : sampleAppIds) {
|
for (ApplicationId appId : sampleAppIds) {
|
||||||
|
@ -213,7 +210,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterAll
|
||||||
public static void tearDownClass() throws Exception {
|
public static void tearDownClass() throws Exception {
|
||||||
hdfsCluster.shutdown();
|
hdfsCluster.shutdown();
|
||||||
FileContext fileContext = FileContext.getLocalFSFileContext();
|
FileContext fileContext = FileContext.getLocalFSFileContext();
|
||||||
|
@ -222,10 +219,10 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAppLogsScanLogs() throws Exception {
|
void testAppLogsScanLogs() throws Exception {
|
||||||
EntityGroupFSTimelineStore.AppLogs appLogs =
|
EntityGroupFSTimelineStore.AppLogs appLogs =
|
||||||
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
||||||
AppState.COMPLETED);
|
AppState.COMPLETED);
|
||||||
appLogs.scanForLogs();
|
appLogs.scanForLogs();
|
||||||
List<LogInfo> summaryLogs = appLogs.getSummaryLogs();
|
List<LogInfo> summaryLogs = appLogs.getSummaryLogs();
|
||||||
List<LogInfo> detailLogs = appLogs.getDetailLogs();
|
List<LogInfo> detailLogs = appLogs.getDetailLogs();
|
||||||
|
@ -245,13 +242,13 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAppLogsDomainLogLastlyScanned() throws Exception {
|
void testAppLogsDomainLogLastlyScanned() throws Exception {
|
||||||
EntityGroupFSTimelineStore.AppLogs appLogs =
|
EntityGroupFSTimelineStore.AppLogs appLogs =
|
||||||
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
||||||
AppState.COMPLETED);
|
AppState.COMPLETED);
|
||||||
Path attemptDirPath = new Path(new Path(testActiveDirPath,
|
Path attemptDirPath = new Path(new Path(testActiveDirPath,
|
||||||
mainTestAppId.toString()),
|
mainTestAppId.toString()),
|
||||||
getAttemptDirName(mainTestAppId));
|
getAttemptDirName(mainTestAppId));
|
||||||
//Delete the domain log from AppDirPath so first scan won't find it
|
//Delete the domain log from AppDirPath so first scan won't find it
|
||||||
fs.delete(new Path(attemptDirPath, TEST_DOMAIN_LOG_FILE_NAME), false);
|
fs.delete(new Path(attemptDirPath, TEST_DOMAIN_LOG_FILE_NAME), false);
|
||||||
appLogs.scanForLogs();
|
appLogs.scanForLogs();
|
||||||
|
@ -261,7 +258,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
|
|
||||||
//Generate the domain log
|
//Generate the domain log
|
||||||
FSDataOutputStream out = fs.create(
|
FSDataOutputStream out = fs.create(
|
||||||
new Path(attemptDirPath, TEST_DOMAIN_LOG_FILE_NAME));
|
new Path(attemptDirPath, TEST_DOMAIN_LOG_FILE_NAME));
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
appLogs.scanForLogs();
|
appLogs.scanForLogs();
|
||||||
|
@ -270,10 +267,10 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMoveToDone() throws Exception {
|
void testMoveToDone() throws Exception {
|
||||||
EntityGroupFSTimelineStore.AppLogs appLogs =
|
EntityGroupFSTimelineStore.AppLogs appLogs =
|
||||||
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
||||||
AppState.COMPLETED);
|
AppState.COMPLETED);
|
||||||
Path pathBefore = appLogs.getAppDirPath();
|
Path pathBefore = appLogs.getAppDirPath();
|
||||||
appLogs.moveToDone();
|
appLogs.moveToDone();
|
||||||
Path pathAfter = appLogs.getAppDirPath();
|
Path pathAfter = appLogs.getAppDirPath();
|
||||||
|
@ -284,13 +281,13 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseSummaryLogs() throws Exception {
|
void testParseSummaryLogs() throws Exception {
|
||||||
TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
|
TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
|
||||||
MutableCounterLong scanned = store.metrics.getEntitiesReadToSummary();
|
MutableCounterLong scanned = store.metrics.getEntitiesReadToSummary();
|
||||||
long beforeScan = scanned.value();
|
long beforeScan = scanned.value();
|
||||||
EntityGroupFSTimelineStore.AppLogs appLogs =
|
EntityGroupFSTimelineStore.AppLogs appLogs =
|
||||||
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
||||||
AppState.COMPLETED);
|
AppState.COMPLETED);
|
||||||
appLogs.scanForLogs();
|
appLogs.scanForLogs();
|
||||||
appLogs.parseSummaryLogs(tdm);
|
appLogs.parseSummaryLogs(tdm);
|
||||||
PluginStoreTestUtils.verifyTestEntities(tdm);
|
PluginStoreTestUtils.verifyTestEntities(tdm);
|
||||||
|
@ -298,31 +295,31 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testWithAnonymousUser() throws Exception {
|
void testWithAnonymousUser() throws Exception {
|
||||||
try {
|
try {
|
||||||
TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
|
TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
|
||||||
EntityGroupFSTimelineStore.AppLogs appLogs =
|
EntityGroupFSTimelineStore.AppLogs appLogs =
|
||||||
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
||||||
AppState.COMPLETED);
|
AppState.COMPLETED);
|
||||||
FileStatus fileStatus = mock(FileStatus.class);
|
FileStatus fileStatus = mock(FileStatus.class);
|
||||||
when(fileStatus.getOwner()).thenReturn(null);
|
when(fileStatus.getOwner()).thenReturn(null);
|
||||||
appLogs.scanForLogs();
|
appLogs.scanForLogs();
|
||||||
appLogs.parseSummaryLogs(tdm);
|
appLogs.parseSummaryLogs(tdm);
|
||||||
PluginStoreTestUtils.verifyTestEntities(tdm);
|
PluginStoreTestUtils.verifyTestEntities(tdm);
|
||||||
} catch (IllegalArgumentException ie) {
|
} catch (IllegalArgumentException ie) {
|
||||||
Assert.fail("No exception needs to be thrown as anonymous user is configured");
|
fail("No exception needs to be thrown as anonymous user is configured");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCleanLogs() throws Exception {
|
void testCleanLogs() throws Exception {
|
||||||
// Create test dirs and files
|
// Create test dirs and files
|
||||||
// Irrelevant file, should not be reclaimed
|
// Irrelevant file, should not be reclaimed
|
||||||
String appDirName = mainTestAppId.toString();
|
String appDirName = mainTestAppId.toString();
|
||||||
String attemptDirName = ApplicationAttemptId.appAttemptIdStrPrefix
|
String attemptDirName = ApplicationAttemptId.appAttemptIdStrPrefix
|
||||||
+ appDirName + "_1";
|
+ appDirName + "_1";
|
||||||
Path irrelevantFilePath = new Path(
|
Path irrelevantFilePath = new Path(
|
||||||
testDoneDirPath, "irrelevant.log");
|
testDoneDirPath, "irrelevant.log");
|
||||||
FSDataOutputStream stream = fs.create(irrelevantFilePath);
|
FSDataOutputStream stream = fs.create(irrelevantFilePath);
|
||||||
stream.close();
|
stream.close();
|
||||||
// Irrelevant directory, should not be reclaimed
|
// Irrelevant directory, should not be reclaimed
|
||||||
|
@ -395,7 +392,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCleanBuckets() throws Exception {
|
void testCleanBuckets() throws Exception {
|
||||||
// ClusterTimeStampDir with App Log Dirs
|
// ClusterTimeStampDir with App Log Dirs
|
||||||
Path clusterTimeStampDir1 = new Path(testDoneDirPath,
|
Path clusterTimeStampDir1 = new Path(testDoneDirPath,
|
||||||
Long.toString(sampleAppIds.get(0).getClusterTimestamp()));
|
Long.toString(sampleAppIds.get(0).getClusterTimestamp()));
|
||||||
|
@ -441,17 +438,17 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testNullCheckGetEntityTimelines() throws Exception {
|
void testNullCheckGetEntityTimelines() throws Exception {
|
||||||
try {
|
try {
|
||||||
store.getEntityTimelines("YARN_APPLICATION", null, null, null, null,
|
store.getEntityTimelines("YARN_APPLICATION", null, null, null, null,
|
||||||
null);
|
null);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
Assert.fail("NPE when getEntityTimelines called with Null EntityIds");
|
fail("NPE when getEntityTimelines called with Null EntityIds");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPluginRead() throws Exception {
|
void testPluginRead() throws Exception {
|
||||||
// Verify precondition
|
// Verify precondition
|
||||||
assertEquals(EntityGroupPlugInForTest.class.getName(),
|
assertEquals(EntityGroupPlugInForTest.class.getName(),
|
||||||
store.getConfig().get(
|
store.getConfig().get(
|
||||||
|
@ -459,8 +456,8 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
List<TimelineEntityGroupPlugin> currPlugins = store.getPlugins();
|
List<TimelineEntityGroupPlugin> currPlugins = store.getPlugins();
|
||||||
for (TimelineEntityGroupPlugin plugin : currPlugins) {
|
for (TimelineEntityGroupPlugin plugin : currPlugins) {
|
||||||
ClassLoader pluginClassLoader = plugin.getClass().getClassLoader();
|
ClassLoader pluginClassLoader = plugin.getClass().getClassLoader();
|
||||||
assertTrue("Should set up ApplicationClassLoader",
|
assertTrue(pluginClassLoader instanceof ApplicationClassLoader,
|
||||||
pluginClassLoader instanceof ApplicationClassLoader);
|
"Should set up ApplicationClassLoader");
|
||||||
URL[] paths = ((URLClassLoader) pluginClassLoader).getURLs();
|
URL[] paths = ((URLClassLoader) pluginClassLoader).getURLs();
|
||||||
boolean foundJAR = false;
|
boolean foundJAR = false;
|
||||||
for (URL path : paths) {
|
for (URL path : paths) {
|
||||||
|
@ -468,13 +465,13 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
foundJAR = true;
|
foundJAR = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue("Not found path " + testJar.getAbsolutePath()
|
assertTrue(foundJAR, "Not found path " + testJar.getAbsolutePath()
|
||||||
+ " for plugin " + plugin.getClass().getName(), foundJAR);
|
+ " for plugin " + plugin.getClass().getName());
|
||||||
}
|
}
|
||||||
// Load data and cache item, prepare timeline store by making a cache item
|
// Load data and cache item, prepare timeline store by making a cache item
|
||||||
EntityGroupFSTimelineStore.AppLogs appLogs =
|
EntityGroupFSTimelineStore.AppLogs appLogs =
|
||||||
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
||||||
AppState.COMPLETED);
|
AppState.COMPLETED);
|
||||||
EntityCacheItem cacheItem = new EntityCacheItem(
|
EntityCacheItem cacheItem = new EntityCacheItem(
|
||||||
EntityGroupPlugInForTest.getStandardTimelineGroupId(mainTestAppId),
|
EntityGroupPlugInForTest.getStandardTimelineGroupId(mainTestAppId),
|
||||||
config);
|
config);
|
||||||
|
@ -514,11 +511,11 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSummaryRead() throws Exception {
|
void testSummaryRead() throws Exception {
|
||||||
// Load data
|
// Load data
|
||||||
EntityGroupFSTimelineStore.AppLogs appLogs =
|
EntityGroupFSTimelineStore.AppLogs appLogs =
|
||||||
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
store.new AppLogs(mainTestAppId, mainTestAppDirPath,
|
||||||
AppState.COMPLETED);
|
AppState.COMPLETED);
|
||||||
MutableCounterLong summaryLogEntityRead
|
MutableCounterLong summaryLogEntityRead
|
||||||
= store.metrics.getGetEntityToSummaryOps();
|
= store.metrics.getGetEntityToSummaryOps();
|
||||||
long numEntityReadBefore = summaryLogEntityRead.value();
|
long numEntityReadBefore = summaryLogEntityRead.value();
|
||||||
|
@ -543,7 +540,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetEntityPluginRead() throws Exception {
|
void testGetEntityPluginRead() throws Exception {
|
||||||
EntityGroupFSTimelineStore store = null;
|
EntityGroupFSTimelineStore store = null;
|
||||||
ApplicationId appId =
|
ApplicationId appId =
|
||||||
ApplicationId.fromString("application_1501509265053_0001");
|
ApplicationId.fromString("application_1501509265053_0001");
|
||||||
|
@ -571,7 +568,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testScanActiveLogsWithInvalidFile() throws Exception {
|
void testScanActiveLogsWithInvalidFile() throws Exception {
|
||||||
Path invalidFile = new Path(testActiveDirPath, "invalidfile");
|
Path invalidFile = new Path(testActiveDirPath, "invalidfile");
|
||||||
try {
|
try {
|
||||||
if (!fs.exists(invalidFile)) {
|
if (!fs.exists(invalidFile)) {
|
||||||
|
@ -579,7 +576,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
store.scanActiveLogs();
|
store.scanActiveLogs();
|
||||||
} catch (StackOverflowError error) {
|
} catch (StackOverflowError error) {
|
||||||
Assert.fail("EntityLogScanner crashed with StackOverflowError");
|
fail("EntityLogScanner crashed with StackOverflowError");
|
||||||
} finally {
|
} finally {
|
||||||
if (fs.exists(invalidFile)) {
|
if (fs.exists(invalidFile)) {
|
||||||
fs.delete(invalidFile, false);
|
fs.delete(invalidFile, false);
|
||||||
|
@ -588,7 +585,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testScanActiveLogsAndMoveToDonePluginRead() throws Exception {
|
void testScanActiveLogsAndMoveToDonePluginRead() throws Exception {
|
||||||
EntityGroupFSTimelineStore store = null;
|
EntityGroupFSTimelineStore store = null;
|
||||||
ApplicationId appId =
|
ApplicationId appId =
|
||||||
ApplicationId.fromString("application_1501509265053_0002");
|
ApplicationId.fromString("application_1501509265053_0002");
|
||||||
|
@ -637,7 +634,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testIfAnyDuplicateEntities() throws Exception {
|
void testIfAnyDuplicateEntities() throws Exception {
|
||||||
// Create an application with some entities
|
// Create an application with some entities
|
||||||
ApplicationId appId =
|
ApplicationId appId =
|
||||||
ApplicationId.fromString("application_1501509265053_0002");
|
ApplicationId.fromString("application_1501509265053_0002");
|
||||||
|
@ -683,15 +680,14 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
return TestTimelineStore.getEntitiesCount() == 2;
|
return TestTimelineStore.getEntitiesCount() == 2;
|
||||||
}
|
}
|
||||||
}, 100, 10000);
|
}, 100, 10000);
|
||||||
assertEquals("Wrong Initial Entities Count",
|
assertEquals(2, TestTimelineStore.getEntitiesCount(), "Wrong Initial Entities Count");
|
||||||
2, TestTimelineStore.getEntitiesCount());
|
|
||||||
|
|
||||||
// Append the Summary log file with few more entities
|
// Append the Summary log file with few more entities
|
||||||
TimelineEntities entities = PluginStoreTestUtils.generateTestEntities();
|
TimelineEntities entities = PluginStoreTestUtils.generateTestEntities();
|
||||||
FSDataOutputStream outStream = fs.append(
|
FSDataOutputStream outStream = fs.append(
|
||||||
new Path(attemptDirPath, TEST_SUMMARY_LOG_FILE_NAME));
|
new Path(attemptDirPath, TEST_SUMMARY_LOG_FILE_NAME));
|
||||||
JsonGenerator jsonGenerator
|
JsonGenerator jsonGenerator
|
||||||
= new JsonFactory().createGenerator((OutputStream)outStream);
|
= new JsonFactory().createGenerator((OutputStream) outStream);
|
||||||
jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n"));
|
jsonGenerator.setPrettyPrinter(new MinimalPrettyPrinter("\n"));
|
||||||
ObjectMapper objMapper = new ObjectMapper();
|
ObjectMapper objMapper = new ObjectMapper();
|
||||||
objMapper.setAnnotationIntrospector(
|
objMapper.setAnnotationIntrospector(
|
||||||
|
@ -710,8 +706,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
return TestTimelineStore.getEntitiesCount() == 4;
|
return TestTimelineStore.getEntitiesCount() == 4;
|
||||||
}
|
}
|
||||||
}, 100, 10000);
|
}, 100, 10000);
|
||||||
assertEquals("Duplicate Entities present",
|
assertEquals(4, TestTimelineStore.getEntitiesCount(), "Duplicate Entities present");
|
||||||
4, TestTimelineStore.getEntitiesCount());
|
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (newStore != null) {
|
if (newStore != null) {
|
||||||
|
@ -722,7 +717,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStateStoreAndRecovery() throws Exception {
|
void testStateStoreAndRecovery() throws Exception {
|
||||||
// Prepare the AppLogs Data
|
// Prepare the AppLogs Data
|
||||||
EntityGroupFSTimelineStore.AppLogs appLogs =
|
EntityGroupFSTimelineStore.AppLogs appLogs =
|
||||||
store.new AppLogs(mainTestAppId, mainTestAppDirPath, AppState.COMPLETED);
|
store.new AppLogs(mainTestAppId, mainTestAppDirPath, AppState.COMPLETED);
|
||||||
|
@ -736,7 +731,7 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
try (DataOutputStream dataOutputStream = fs.create(checkpointFile)) {
|
try (DataOutputStream dataOutputStream = fs.create(checkpointFile)) {
|
||||||
store.storeLogFiles(logsList, dataOutputStream);
|
store.storeLogFiles(logsList, dataOutputStream);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Assert.fail("Failed to store the log files");
|
fail("Failed to store the log files");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recover the Log files and validate the contents
|
// Recover the Log files and validate the contents
|
||||||
|
@ -748,14 +743,14 @@ public class TestEntityGroupFSTimelineStore extends TimelineStoreTestUtils {
|
||||||
String logFileName = logInfo.getAttemptDirName() +
|
String logFileName = logInfo.getAttemptDirName() +
|
||||||
Path.SEPARATOR + logInfo.getFilename();
|
Path.SEPARATOR + logInfo.getFilename();
|
||||||
Pair<Long, Long> pair = logFiles.get(logFileName);
|
Pair<Long, Long> pair = logFiles.get(logFileName);
|
||||||
assertNotNull("Failed to recover " + logFileName, pair);
|
assertNotNull(pair, "Failed to recover " + logFileName);
|
||||||
assertTrue("LastProcessedTime is not same",
|
assertTrue(logInfo.getLastProcessedTime() == pair.getLeft(),
|
||||||
logInfo.getLastProcessedTime() == pair.getLeft());
|
"LastProcessedTime is not same");
|
||||||
assertTrue("Offset is not same",
|
assertTrue(logInfo.getOffset() == pair.getRight(),
|
||||||
logInfo.getOffset() == pair.getRight());
|
"Offset is not same");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Assert.fail("Failed to recover the log files");
|
fail("Failed to recover the log files");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,16 +20,17 @@ package org.apache.hadoop.yarn.server.timeline;
|
||||||
|
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.apache.hadoop.util.ReflectionUtils;
|
import org.apache.hadoop.util.ReflectionUtils;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
|
|
||||||
public class TestLevelDBCacheTimelineStore extends TimelineStoreTestUtils {
|
public class TestLevelDBCacheTimelineStore extends TimelineStoreTestUtils {
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
store = new LevelDBCacheTimelineStore("app1");
|
store = new LevelDBCacheTimelineStore("app1");
|
||||||
store.init(new YarnConfiguration());
|
store.init(new YarnConfiguration());
|
||||||
|
@ -39,7 +40,7 @@ public class TestLevelDBCacheTimelineStore extends TimelineStoreTestUtils {
|
||||||
loadTestDomainData();
|
loadTestDomainData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
store.stop();
|
store.stop();
|
||||||
}
|
}
|
||||||
|
@ -49,13 +50,13 @@ public class TestLevelDBCacheTimelineStore extends TimelineStoreTestUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultConstructor() {
|
void testDefaultConstructor() {
|
||||||
TimelineStore store = null;
|
TimelineStore store = null;
|
||||||
try {
|
try {
|
||||||
store = ReflectionUtils.newInstance(LevelDBCacheTimelineStore.class,
|
store = ReflectionUtils.newInstance(LevelDBCacheTimelineStore.class,
|
||||||
new YarnConfiguration());
|
new YarnConfiguration());
|
||||||
} finally {
|
} finally {
|
||||||
assertNotNull("LevelDBCacheTimelineStore failed to instantiate", store);
|
assertNotNull(store, "LevelDBCacheTimelineStore failed to instantiate");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,18 +34,18 @@ import org.apache.hadoop.yarn.api.records.timeline.TimelineDomain;
|
||||||
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntities;
|
||||||
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
|
import org.apache.hadoop.yarn.api.records.timeline.TimelineEntity;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.junit.After;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.Before;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
public class TestLogInfo {
|
public class TestLogInfo {
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class TestLogInfo {
|
||||||
|
|
||||||
private static final short FILE_LOG_DIR_PERMISSIONS = 0770;
|
private static final short FILE_LOG_DIR_PERMISSIONS = 0770;
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void setup() throws Exception {
|
public void setup() throws Exception {
|
||||||
config.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEST_ROOT_DIR.toString());
|
config.set(MiniDFSCluster.HDFS_MINIDFS_BASEDIR, TEST_ROOT_DIR.toString());
|
||||||
HdfsConfiguration hdfsConfig = new HdfsConfiguration();
|
HdfsConfiguration hdfsConfig = new HdfsConfiguration();
|
||||||
|
@ -101,7 +101,7 @@ public class TestLogInfo {
|
||||||
writeBrokenFile(new Path(testAppDirPath, TEST_BROKEN_FILE_NAME));
|
writeBrokenFile(new Path(testAppDirPath, TEST_BROKEN_FILE_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
@After
|
@AfterEach
|
||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
jsonGenerator.close();
|
jsonGenerator.close();
|
||||||
outStream.close();
|
outStream.close();
|
||||||
|
@ -110,7 +110,7 @@ public class TestLogInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMatchesGroupId() throws Exception {
|
void testMatchesGroupId() throws Exception {
|
||||||
String testGroupId = "app1_group1";
|
String testGroupId = "app1_group1";
|
||||||
// Match
|
// Match
|
||||||
EntityLogInfo testLogInfo = new EntityLogInfo(TEST_ATTEMPT_DIR_NAME,
|
EntityLogInfo testLogInfo = new EntityLogInfo(TEST_ATTEMPT_DIR_NAME,
|
||||||
|
@ -145,7 +145,7 @@ public class TestLogInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseEntity() throws Exception {
|
void testParseEntity() throws Exception {
|
||||||
// Load test data
|
// Load test data
|
||||||
TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
|
TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
|
||||||
EntityLogInfo testLogInfo = new EntityLogInfo(TEST_ATTEMPT_DIR_NAME,
|
EntityLogInfo testLogInfo = new EntityLogInfo(TEST_ATTEMPT_DIR_NAME,
|
||||||
|
@ -159,7 +159,7 @@ public class TestLogInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseBrokenEntity() throws Exception {
|
void testParseBrokenEntity() throws Exception {
|
||||||
// Load test data
|
// Load test data
|
||||||
TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
|
TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
|
||||||
EntityLogInfo testLogInfo = new EntityLogInfo(TEST_ATTEMPT_DIR_NAME,
|
EntityLogInfo testLogInfo = new EntityLogInfo(TEST_ATTEMPT_DIR_NAME,
|
||||||
|
@ -177,7 +177,7 @@ public class TestLogInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testParseDomain() throws Exception {
|
void testParseDomain() throws Exception {
|
||||||
// Load test data
|
// Load test data
|
||||||
TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
|
TimelineDataManager tdm = PluginStoreTestUtils.getTdmWithMemStore(config);
|
||||||
DomainLogInfo domainLogInfo = new DomainLogInfo(TEST_ATTEMPT_DIR_NAME,
|
DomainLogInfo domainLogInfo = new DomainLogInfo(TEST_ATTEMPT_DIR_NAME,
|
||||||
|
|
|
@ -22,20 +22,21 @@ import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
import org.apache.hadoop.yarn.api.records.ApplicationId;
|
||||||
import org.apache.hadoop.yarn.client.api.YarnClient;
|
import org.apache.hadoop.yarn.client.api.YarnClient;
|
||||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||||
import org.junit.Assert;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class TestOverrideTimelineStoreYarnClient {
|
public class TestOverrideTimelineStoreYarnClient {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testLifecycleAndOverride() throws Throwable {
|
void testLifecycleAndOverride() throws Throwable {
|
||||||
YarnConfiguration conf = new YarnConfiguration();
|
YarnConfiguration conf = new YarnConfiguration();
|
||||||
try(NoRMStore store = new NoRMStore()) {
|
try (NoRMStore store = new NoRMStore()) {
|
||||||
store.init(conf);
|
store.init(conf);
|
||||||
store.start();
|
store.start();
|
||||||
Assert.assertEquals(EntityGroupFSTimelineStore.AppState.ACTIVE,
|
assertEquals(EntityGroupFSTimelineStore.AppState.ACTIVE,
|
||||||
store.getAppState(ApplicationId.newInstance(1, 1)));
|
store.getAppState(ApplicationId.newInstance(1, 1)));
|
||||||
store.stop();
|
store.stop();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue