Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/8880#discussion_r47559284
  
    --- Diff: 
yarn/src/test/scala/org/apache/spark/deploy/yarn/YarnShuffleEncryptionSuite.scala
 ---
    @@ -0,0 +1,289 @@
    +/*
    + * 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.deploy.yarn
    +
    +import java.io._
    +import java.nio.ByteBuffer
    +import java.security.PrivilegedExceptionAction
    +import java.util.{Random, UUID}
    +
    +import scala.runtime.AbstractFunction1
    +
    +import com.google.common.collect.HashMultiset
    +import com.google.common.io.ByteStreams
    +import org.apache.hadoop.security.{Credentials, UserGroupInformation}
    +import org.junit.Assert.assertEquals
    +import org.mockito.Mock
    +import org.mockito.MockitoAnnotations
    +import org.mockito.invocation.InvocationOnMock
    +import org.mockito.stubbing.Answer
    +import org.mockito.Answers.RETURNS_SMART_NULLS
    +import org.mockito.Matchers.{eq => meq, _}
    +import org.mockito.Mockito._
    +import org.scalatest.{BeforeAndAfterEach, Matchers}
    +
    +import org.apache.spark._
    +import org.apache.spark.crypto.CryptoConf._
    +import org.apache.spark.crypto.CryptoConf
    +import org.apache.spark.deploy.SparkHadoopUtil
    +import org.apache.spark.executor.{ShuffleWriteMetrics, TaskMetrics}
    +import org.apache.spark.io.CompressionCodec
    +import org.apache.spark.memory.{TestMemoryManager, TaskMemoryManager}
    +import org.apache.spark.network.buffer.NioManagedBuffer
    +import org.apache.spark.serializer.{KryoSerializer, SerializerInstance}
    +import org.apache.spark.shuffle.{RecordingManagedBuffer, BaseShuffleHandle,
    +  BlockStoreShuffleReader, IndexShuffleBlockResolver}
    +import org.apache.spark.shuffle.sort.{SerializedShuffleHandle, 
UnsafeShuffleWriter}
    +import org.apache.spark.storage._
    +import org.apache.spark.util.Utils
    +
    +private[spark] class YarnShuffleEncryptionSuite extends SparkFunSuite with 
Matchers with
    +                                                        BeforeAndAfterEach 
with LocalSparkContext {
    +
    +  @Mock(answer = RETURNS_SMART_NULLS) private[this] var blockManager: 
BlockManager = _
    +  @Mock(answer = RETURNS_SMART_NULLS) private[this] var diskBlockManager: 
DiskBlockManager = _
    +  @Mock(answer = RETURNS_SMART_NULLS) private[this] var taskContext: 
TaskContext = _
    +  @Mock(answer = RETURNS_SMART_NULLS) private[this] var blockResolver: 
IndexShuffleBlockResolver = _
    +  @Mock(
    +    answer = RETURNS_SMART_NULLS) private[this] var shuffleDep: 
ShuffleDependency[Int, Int, Int] = _
    +
    +  private[this] val NUM_PARTITITONS = 4
    +  private[this] val NUM_MAPS = 1
    +  private[this] val SHUFFLE_ID = 0
    +  private[this] val REDUCE_ID = 1
    +  private[this] val conf = new SparkConf()
    +  private[this] val memoryManager = new TestMemoryManager(conf)
    +  private[this] val taskMemoryManager = new 
TaskMemoryManager(memoryManager, 0)
    +  private[this] val serializer = new KryoSerializer(conf)
    +  private[this] val hashPartitioner = new HashPartitioner(NUM_PARTITITONS)
    +  private[this] val taskMetrics = new TaskMetrics()
    +  private[this] val spillFilesCreated = new java.util.LinkedList[File]()
    +
    +  private[this] var tempDir: File = _
    +  private[this] var mergedOutputFile: File = _
    +  private[this] var partitionSizesInMergedFile: Array[Long] = _
    +  private[this] val ugi = 
UserGroupInformation.createUserForTesting("testuser", Array[String] {
    +    "testgroup"
    +  })
    +
    +  // Create a mocked shuffle handle to pass into HashShuffleReader.
    +  private[this] val shuffleHandle = {
    +    val dependency = mock(classOf[ShuffleDependency[Int, Int, Int]])
    +    when(dependency.serializer).thenReturn(Some(serializer))
    +    when(dependency.aggregator).thenReturn(None)
    +    when(dependency.keyOrdering).thenReturn(None)
    +    new BaseShuffleHandle(SHUFFLE_ID, NUM_MAPS, dependency)
    +  }
    +
    +  // Make a mocked MapOutputTracker for the shuffle reader to use to 
determine what
    +  // shuffle data to read.
    +  private[this] val mapOutputTracker = mock(classOf[MapOutputTracker])
    +
    +  override def beforeEach(): Unit = {
    +    super.beforeEach()
    +    MockitoAnnotations.initMocks(this)
    +    tempDir = Utils.createTempDir("test", "test")
    --- End diff --
    
    Please remove the arguments here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to