dongjoon-hyun commented on a change in pull request #23805: [SPARK-26420][k8s] 
Generate more unique IDs when creating k8s resource names.
URL: https://github.com/apache/spark/pull/23805#discussion_r261423536
 
 

 ##########
 File path: 
resource-managers/kubernetes/core/src/test/scala/org/apache/spark/deploy/k8s/features/DriverServiceFeatureStepSuite.scala
 ##########
 @@ -92,25 +91,22 @@ class DriverServiceFeatureStepSuite extends SparkFunSuite {
   }
 
   test("Long prefixes should switch to using a generated name.") {
-    val clock = new ManualClock()
-    clock.setTime(10000)
     val sparkConf = new SparkConf(false)
       .set(KUBERNETES_NAMESPACE, "my-namespace")
-    val configurationStep = new DriverServiceFeatureStep(
-      KubernetesTestConf.createDriverConf(
-        sparkConf = sparkConf,
-        resourceNamePrefix = Some(LONG_RESOURCE_NAME_PREFIX),
-        labels = DRIVER_LABELS),
-      clock)
+    val kconf = KubernetesTestConf.createDriverConf(
+      sparkConf = sparkConf,
+      resourceNamePrefix = Some(LONG_RESOURCE_NAME_PREFIX),
+      labels = DRIVER_LABELS)
+    val configurationStep = new DriverServiceFeatureStep(kconf)
+
     val driverService = configurationStep
       .getAdditionalKubernetesResources()
       .head
       .asInstanceOf[Service]
-    val expectedServiceName = 
s"spark-10000${DriverServiceFeatureStep.DRIVER_SVC_POSTFIX}"
-    assert(driverService.getMetadata.getName === expectedServiceName)
-    val expectedHostName = s"$expectedServiceName.my-namespace.svc"
+    
assert(!driverService.getMetadata.getName.startsWith(kconf.resourceNamePrefix))
 
 Review comment:
   Hi, @vanzin . Can we check the actual pattern you introduced here? Maybe, we 
can use `.startWith` and `.endWith`.
   ```scala
   val shorterServiceName = s"spark-$randomServiceId$DRIVER_SVC_POSTFIX"
   ```
   Negative assertions(at 106 and 109) looks insufficient to check the new 
logic. If something happens on the patterns, this test doesn't catch the change 
at all. Previously, we check the name pattern 
[exactly](https://github.com/apache/spark/pull/23805/files#diff-0d7a047564dda7b7bdbb656040c0600bL110)
 in this test case.
   
   Another test case is doing some check the post-fix pattern, but it's also 
partial because it used 
[kconf.resourceNamePrefix](https://github.com/apache/spark/pull/23805/files#diff-0d7a047564dda7b7bdbb656040c0600bR70).

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to