Skip to content

Commit 0a428cf

Browse files
committed
add unit tests
1 parent 158b2dc commit 0a428cf

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark.scheduler
19+
20+
import org.apache.spark.{SparkConf, SparkException, SparkContext}
21+
import org.apache.spark.util.{SerializableBuffer, AkkaUtils}
22+
import org.apache.spark.SparkContext._
23+
import java.nio.ByteBuffer
24+
25+
import org.scalatest.{BeforeAndAfterAll, BeforeAndAfter, FunSuite}
26+
class CoarseGrainedSchedulerBackendSuite extends FunSuite with
27+
BeforeAndAfter with BeforeAndAfterAll {
28+
29+
override def beforeAll {
30+
System.setProperty("spark.akka.frameSize", "1")
31+
System.setProperty("spark.default.parallelism", "1")
32+
33+
}
34+
35+
override def afterAll {
36+
System.clearProperty("spark.akka.frameSize")
37+
System.clearProperty("spark.default.parallelism")
38+
}
39+
40+
test("serialized task larger than Akka frame size") {
41+
val conf = new SparkConf
42+
val sc = new SparkContext("local-cluster[2 , 1 , 512]", "test", conf)
43+
val frameSize = AkkaUtils.maxFrameSizeBytes(sc.conf)
44+
val buffer = new SerializableBuffer(ByteBuffer.allocate(2 * frameSize))
45+
val larger = sc.parallelize(Seq(buffer))
46+
val thrown = intercept[SparkException] {
47+
larger.collect()
48+
}
49+
assert(thrown.getMessage.contains("Consider using broadcast variables for large values"))
50+
val smaller = sc.parallelize(1 to 4).collect()
51+
assert(smaller.size === 4)
52+
}
53+
54+
}

0 commit comments

Comments
 (0)