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


##########
amber/src/test/integration/org/apache/texera/amber/engine/e2e/LoopIntegrationSpec.scala:
##########
@@ -0,0 +1,232 @@
+/*
+ * 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.texera.amber.engine.e2e
+
+import com.twitter.util.Duration
+import org.apache.pekko.actor.{ActorSystem, Props}
+import org.apache.pekko.testkit.{ImplicitSender, TestKit}
+import org.apache.pekko.util.Timeout
+import org.apache.texera.amber.clustering.SingleNodeListener
+import org.apache.texera.amber.core.virtualidentity.OperatorIdentity
+import org.apache.texera.amber.core.workflow.{
+  ExecutionMode,
+  PortIdentity,
+  WorkflowContext,
+  WorkflowSettings
+}
+import org.apache.texera.amber.engine.common.AmberRuntime
+import org.apache.texera.amber.engine.e2e.TestUtils.{
+  buildWorkflow,
+  cleanupWorkflowExecutionData,
+  initiateTexeraDBForTestCases,
+  runWorkflowAndReadResults,
+  setUpWorkflowExecutionData,
+  workflowContext
+}
+import org.apache.texera.amber.operator.LogicalOp
+import org.apache.texera.amber.operator.loop.{LoopEndOpDesc, LoopStartOpDesc}
+import org.apache.texera.amber.operator.source.scan.text.TextInputSourceOpDesc
+import org.apache.texera.amber.tags.IntegrationTest
+import org.apache.texera.workflow.LogicalLink
+import org.scalatest.flatspec.AnyFlatSpecLike
+import org.scalatest.{BeforeAndAfterAll, BeforeAndAfterEach, Outcome, Retries}
+
+import scala.concurrent.duration.DurationInt
+
+/**
+  * End-to-end loop tests: run a real TextInput -> LoopStart -> LoopEnd 
workflow
+  * through the engine (controller + Python workers + the DCM back-jump and
+  * region re-execution) and assert both that it terminates AND that it ran the
+  * expected number of iterations.
+  *
+  * Termination alone is too weak: a counter bug that still terminated (e.g.
+  * off-by-one) would pass. So each test asserts the LoopEnd's MATERIALIZED
+  * result-table row count, read from iceberg after the run. LoopEnd is an
+  * identity pass-through on data, so the rows it materializes equal the rows
+  * that flowed through it: a single (outermost) LoopEnd accumulates every
+  * iteration (3 for the single loop; 9 for the terminal outer LoopEnd of the
+  * 3x3 nested loop), and an inner LoopEnd resets once per outer iteration (so
+  * 3, not 9).
+  *
+  * NOTE: the cumulative `ExecutionStatsUpdate` output count is NOT usable as
+  * the iteration count here. A loop region's workers are recreated on every
+  * `JumpToOperatorRegion` re-execution (each iteration spawns a fresh worker
+  * actor), so the per-logical-op output statistic reflects only the final
+  * iteration's worker and does not accumulate. The iceberg result, by
+  * contrast, persists across iterations (the scheduler reuses a LoopEnd's
+  * output document via its output port's `reuseStorage` flag), so it is
+  * the reliable signal.
+  *
+  * Tagged @IntegrationTest because it spawns Python workers; routed to the
+  * `amber-integration` CI job.
+  */
+@IntegrationTest
+class LoopIntegrationSpec
+    extends TestKit(ActorSystem("LoopIntegrationSpec", 
AmberRuntime.pekkoConfig))
+    with ImplicitSender
+    with AnyFlatSpecLike
+    with BeforeAndAfterAll
+    with BeforeAndAfterEach
+    with Retries {
+
+  override def withFixture(test: NoArgTest): Outcome =
+    withRetry { super.withFixture(test) }
+
+  implicit val timeout: Timeout = Timeout(5.seconds)
+
+  // Unique per-suite id so the seeded user/workflow/version/execution rows
+  // (and the context's workflow/execution ids) don't collide with the other
+  // integration suites running against the shared test database (#5888).
+  private val specId = 5

Review Comment:
   Good catch — `MultiRegionWorkflowIntegrationSpec` came in with the latest 
main merge and also uses 5. Bumped this suite to `specId = 6` (1-5 are now 
taken), so it no longer shares the seeded user/workflow/execution rows. 
(784e13d)



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