Looks like this test currently does not induce spilling. I would set up the memory constraints as follows:

val conf = new SparkConf()
conf.set("spark.shuffle.memoryFraction", "0.001")
sc = new SparkContext("local-cluster[1,1,512]", "test", conf)

(Note that in this test it is crucial for SparkConf to take in no arguments. This is a workaround for the hacky way we currently pass in environment variables in the tests)