Skip to content

Commit 0d048d5

Browse files
author
Marcelo Vanzin
committed
Cleanup test code a bit.
Rename variables / apps so that it's easier to follow which one is which, and also tweak the app times so that they better test the sorting code.
1 parent 2585119 commit 0d048d5

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

core/src/test/scala/org/apache/spark/deploy/history/FsHistoryProviderSuite.scala

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,38 +49,38 @@ class FsHistoryProviderSuite extends FunSuite with BeforeAndAfter with Matchers
4949
val provider = new FsHistoryProvider(createTestConf())
5050

5151
// Write a new-style application log.
52-
val logFile1 = new File(testDir, "new1")
53-
writeFile(logFile1, true, None,
54-
SparkListenerApplicationStart("app1-1", None, 2L, "test"),
55-
SparkListenerApplicationEnd(3L)
52+
val newAppComplete = new File(testDir, "new1")
53+
writeFile(newAppComplete, true, None,
54+
SparkListenerApplicationStart("new-app-complete", None, 1L, "test"),
55+
SparkListenerApplicationEnd(4L)
5656
)
5757

5858
// Write an unfinished app, new-style.
59-
val logFile2 = new File(testDir, "new2" + EventLoggingListener.IN_PROGRESS)
60-
writeFile(logFile2, true, None,
61-
SparkListenerApplicationStart("app2-2", None, 1L, "test")
59+
val newAppIncomplete = new File(testDir, "new2" + EventLoggingListener.IN_PROGRESS)
60+
writeFile(newAppIncomplete, true, None,
61+
SparkListenerApplicationStart("new-app-incomplete", None, 1L, "test")
6262
)
6363

6464
// Write an old-style application log.
65-
val oldLog = new File(testDir, "old1")
66-
oldLog.mkdir()
67-
createEmptyFile(new File(oldLog, provider.SPARK_VERSION_PREFIX + "1.0"))
68-
writeFile(new File(oldLog, provider.LOG_PREFIX + "1"), false, None,
69-
SparkListenerApplicationStart("app3", None, 1L, "test"),
70-
SparkListenerApplicationEnd(4L)
65+
val oldAppComplete = new File(testDir, "old1")
66+
oldAppComplete.mkdir()
67+
createEmptyFile(new File(oldAppComplete, provider.SPARK_VERSION_PREFIX + "1.0"))
68+
writeFile(new File(oldAppComplete, provider.LOG_PREFIX + "1"), false, None,
69+
SparkListenerApplicationStart("old-app-complete", None, 2L, "test"),
70+
SparkListenerApplicationEnd(3L)
7171
)
72-
createEmptyFile(new File(oldLog, provider.APPLICATION_COMPLETE))
72+
createEmptyFile(new File(oldAppComplete, provider.APPLICATION_COMPLETE))
7373

7474
// Check for logs so that we force the older unfinished app to be loaded, to make
7575
// sure unfinished apps are also sorted correctly.
7676
provider.checkForLogs()
7777

7878
// Write an unfinished app, old-style.
79-
val oldLog2 = new File(testDir, "old2")
80-
oldLog2.mkdir()
81-
createEmptyFile(new File(oldLog2, provider.SPARK_VERSION_PREFIX + "1.0"))
82-
writeFile(new File(oldLog2, provider.LOG_PREFIX + "1"), false, None,
83-
SparkListenerApplicationStart("app4", None, 2L, "test")
79+
val oldAppIncomplete = new File(testDir, "old2")
80+
oldAppIncomplete.mkdir()
81+
createEmptyFile(new File(oldAppIncomplete, provider.SPARK_VERSION_PREFIX + "1.0"))
82+
writeFile(new File(oldAppIncomplete, provider.LOG_PREFIX + "1"), false, None,
83+
SparkListenerApplicationStart("old-app-incomplete", None, 2L, "test")
8484
)
8585

8686
// Force a reload of data from the log directory, and check that both logs are loaded.
@@ -92,14 +92,14 @@ class FsHistoryProviderSuite extends FunSuite with BeforeAndAfter with Matchers
9292
list.size should be (4)
9393
list.count(e => e.completed) should be (2)
9494

95-
list(0) should be (ApplicationHistoryInfo(oldLog.getName(), "app3", 2L, 3L,
96-
oldLog.lastModified(), "test", true))
97-
list(1) should be (ApplicationHistoryInfo(logFile1.getName(), "app1-1", 1L, 2L,
98-
logFile1.lastModified(), "test", true))
99-
list(2) should be (ApplicationHistoryInfo(oldLog2.getName(), "app4", 2L, -1L,
100-
oldLog2.lastModified(), "test", false))
101-
list(3) should be (ApplicationHistoryInfo(logFile2.getName(), "app2-2", 1L, -1L,
102-
logFile2.lastModified(), "test", false))
95+
list(0) should be (ApplicationHistoryInfo(newAppComplete.getName(), "new-app-complete", 1L, 4L,
96+
newAppComplete.lastModified(), "test", true))
97+
list(1) should be (ApplicationHistoryInfo(oldAppComplete.getName(), "old-app-complete", 2L, 3L,
98+
oldAppComplete.lastModified(), "test", true))
99+
list(2) should be (ApplicationHistoryInfo(oldAppIncomplete.getName(), "old-app-incomplete", 2L,
100+
-1L, oldAppIncomplete.lastModified(), "test", false))
101+
list(3) should be (ApplicationHistoryInfo(newAppIncomplete.getName(), "new-app-incomplete", 1L,
102+
-1L, newAppIncomplete.lastModified(), "test", false))
103103

104104
// Make sure the UI can be rendered.
105105
list.foreach { case info =>

0 commit comments

Comments
 (0)