Yicong-Huang commented on code in PR #6099:
URL: https://github.com/apache/texera/pull/6099#discussion_r3523858186


##########
common/workflow-operator/src/test/scala/org/apache/texera/amber/util/ObjectMapperUtilsSpec.scala:
##########
@@ -17,27 +17,28 @@
  * under the License.
  */
 
-package org.apache.texera.common.config
+package org.apache.texera.amber.util
 
 import org.scalatest.flatspec.AnyFlatSpec
 import org.scalatest.matchers.should.Matchers
 
-/**
-  * Spec for [[ComputingUnitConfig]]. Reading each value forces resolution 
from computing-unit.conf,
-  * so a renamed or mistyped key surfaces here as a ConfigException. Both 
flags carry a `${?ENV}`
-  * override, so exact-value assertions are guarded.
-  */
-class ComputingUnitConfigSpec extends AnyFlatSpec with Matchers {
+class ObjectMapperUtilsSpec extends AnyFlatSpec with Matchers {
 
-  private def ifUnset(name: String)(assertion: => Any): Unit =
-    if (!sys.env.contains(name) && !sys.props.contains(name)) assertion
+  private def findWarmupThread(): Option[Thread] = {
+    val threads = new Array[Thread](Thread.activeCount() * 2 + 16)
+    val count = Thread.enumerate(threads)
+    threads.take(count).find(t => t != null && t.getName == 
"ObjectMapperWarmupForOperatorsThread")
+  }
 
-  "ComputingUnitConfig" should "resolve the local/sharing flags from 
computing-unit.conf" in {
-    ifUnset("COMPUTING_UNIT_LOCAL_ENABLED")(
-      ComputingUnitConfig.localComputingUnitEnabled shouldBe true
-    )
-    ifUnset("COMPUTING_UNIT_SHARING_ENABLED")(
-      ComputingUnitConfig.sharingComputingUnitEnabled shouldBe false
-    )
+  "warmupObjectMapperForOperatorsSerde" should "spawn the named warmup thread 
and complete" in {
+    noException should be thrownBy 
ObjectMapperUtils.warmupObjectMapperForOperatorsSerde()
+    // the warmup runs a full operator-metadata scan (seconds), so the thread 
is observable
+    // right after start(); assert it was actually spawned, then join so its 
body runs
+    val thread = findWarmupThread()
+    thread shouldBe defined
+    thread.foreach { t =>
+      t.join(60000)
+      t.isAlive shouldBe false
+    }

Review Comment:
   I feel this can be flaky with race condition? is there a more deterministic 
way to test it?
   
   also join 60000 is too long to fail. consider change to 1-3 seconds .



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to