Skip to content
Closed
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 @@ -167,10 +167,12 @@ class BlockManagerMaster(
* amount of remaining memory.
*/
def getMemoryStatus: Map[BlockManagerId, (Long, Long)] = {
if (driverEndpoint == null) return Map.empty
Copy link
Member Author

@dongjoon-hyun dongjoon-hyun Apr 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although only getStorageStatus is used, I added the preventive code into getMemoryStatus together.

driverEndpoint.askSync[Map[BlockManagerId, (Long, Long)]](GetMemoryStatus)
}

def getStorageStatus: Array[StorageStatus] = {
if (driverEndpoint == null) return Array.empty
driverEndpoint.askSync[Array[StorageStatus]](GetStorageStatus)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.storage

import org.junit.Assert.assertTrue

import org.apache.spark.{SparkConf, SparkFunSuite}

class BlockManagerMasterSuite extends SparkFunSuite {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests to BlockManagerSuite should be enough?

Copy link
Member Author

@dongjoon-hyun dongjoon-hyun Apr 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered that, but BlockManagerSuite looks misleading to me because this is BlockManagerManger. If there is a more broader suite, it could be a candidate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think it should be ok because we always test BlockManagerMaster together with BlockManager. And there're already some tests which test BlockManagerMaster only, e.g.

  • query locations of blockIds

  • SPARK-30594: Do not post SparkListenerBlockUpdated when updateBlockInfo returns false

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I don't think so. In your example, query locations of blockIds is just do mocking instead of testing.

test("query locations of blockIds") {
    val mockBlockManagerMaster = mock(classOf[BlockManagerMaster])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, BlockManagerSuite is already large with 1805 lines. In general, we had better have a proper UT case.


test("SPARK-31422: getMemoryStatus should not fail after BlockManagerMaster stops") {
val bmm = new BlockManagerMaster(null, null, new SparkConf, true)
assertTrue(bmm.getMemoryStatus.isEmpty)
}

test("SPARK-31422: getStorageStatus should not fail after BlockManagerMaster stops") {
val bmm = new BlockManagerMaster(null, null, new SparkConf, true)
assertTrue(bmm.getStorageStatus.isEmpty)
}
}