aglinxinyuan commented on code in PR #6099:
URL: https://github.com/apache/texera/pull/6099#discussion_r3524177596


##########
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:
   Made it deterministic — `warmupObjectMapperForOperatorsSerde()` now returns 
the started thread, so the test joins that directly instead of scanning 
`Thread.enumerate()` (385cb2e). On the timeout: the warmup runs a full 
operator-metadata scan that takes ~4-5s cold, so 1-3s would false-fail; I 
dropped it to 20s, which still surfaces a genuine hang far faster than the old 
60s. Happy to tune the bound if you'd prefer.



-- 
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