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

    https://github.com/apache/spark/pull/22760#discussion_r233174157
  
    --- Diff: 
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/features/HadoopConfExecutorFeatureStepSuite.scala
 ---
    @@ -0,0 +1,68 @@
    +/*
    + * 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.k8s.features
    +
    +import org.mockito.{Mock, MockitoAnnotations}
    +import org.mockito.Matchers.{eq => Eq}
    +import org.mockito.Mockito.when
    +import org.mockito.invocation.InvocationOnMock
    +import org.mockito.stubbing.Answer
    +import org.scalatest.BeforeAndAfter
    +
    +import org.apache.spark.{SparkConf, SparkFunSuite}
    +import org.apache.spark.deploy.k8s.{KubernetesConf, 
KubernetesExecutorSpecificConf, SparkPod}
    +import org.apache.spark.deploy.k8s.Constants.HADOOP_CONFIG_MAP_NAME
    +import org.apache.spark.deploy.k8s.features.hadooputils.HadoopBootstrapUtil
    +
    +class HadoopConfExecutorFeatureStepSuite extends SparkFunSuite with 
BeforeAndAfter {
    +  private val hadoopConfMapName = "HADOOP_CONF_NAME"
    +  private val sparkPod = SparkPod.initialPod()
    +
    +  @Mock
    +  private var kubernetesConf: 
KubernetesConf[KubernetesExecutorSpecificConf] = _
    +
    +  @Mock
    +  private var hadoopBootstrapUtil: HadoopBootstrapUtil = _
    +
    +  before {
    +    MockitoAnnotations.initMocks(this)
    +    val sparkConf = new SparkConf(false)
    +      .set(HADOOP_CONFIG_MAP_NAME, hadoopConfMapName)
    +    when(kubernetesConf.sparkConf).thenReturn(sparkConf)
    +  }
    +
    +  test("bootstrapHadoopConf being applied to a base spark pod") {
    +    when(hadoopBootstrapUtil.bootstrapHadoopConfDir(
    --- End diff --
    
    So after I spent some time cleaning other code in the k8s backend, I 
started to really dislike this kind of test that over-mocks things. This test 
is actually just a result of a lot of other things that I think are wrong in 
the current code (not just kerberos-related, but in the k8s backend in general).
    
    Basically you have a lot of code and mocks here to test a single thing: 
that the feature step is calling this one method with the parameters you expect.
    
    If instead the feature step was written to be more easily testable, this 
wouldn't be needed. You wouldn't need to mock anything, and it would just run 
the normal code and you'd assert that the resulting pod has what you expect.
    
    I filed SPARK-25874 to fix all this stuff (with a few sub-tasks), and I'm 
now thinking it's better to do that first. It would simplify the tests here a 
lot. It would avoid all this noisy and IMO unnecessary mocking. And we'd have 
better tests. You can look at my p.o.c. code linked from that bug to see what I 
mean.
    
    As another data point, to address the comments on SPARK-25815 I'm having to 
rewrite a bunch of code in this area. So all these tests would have to be 
largely rewritten (on which PR, it depends on which one goes in first).
    
    So, long story short, checking this in would mean I'd be rewriting all this 
code very, very soon. So I'm not seeing a lot of gains here...


---

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

Reply via email to