You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "aglinxinyuan (via GitHub)" <gi...@apache.org> on 2026/05/03 04:22:57 UTC
[PR] test(amber): add unit test coverage for checkpoint subsystem [texera]
aglinxinyuan opened a new pull request, #4838:
URL: https://github.com/apache/texera/pull/4838
### What changes were proposed in this PR?
Add `CheckpointSubsystemSpec` covering the three classes/traits in `amber/.../engine/common` that make up the checkpoint data contract:
- `SerializedState`: well-known key constants pinned (`CP_STATE_KEY`, `DP_STATE_KEY`, `IN_FLIGHT_MSG_KEY`, `DP_QUEUED_MSG_KEY`, `OUTPUT_MSG_KEY`); `fromObject` / `toObject` round-trip via the configured Pekko Serialization; field-shape and size accounting
- `CheckpointState`: defaults, save/load round-trip on primitive and String values, overwrite-by-key, multi-key independence, missing-key RuntimeException, size summation across entries
- `CheckpointSupport` trait: implementable by a custom subclass forwarding to a `CheckpointState`, exercising `serializeState` / `deserializeState` / `getEstimatedCheckpointCost`
Complements the in-flight #4687 (CheckpointState unknown-key negative test in `CheckpointSpec`) with dedicated unit-level coverage.
### Any related issues, documentation, discussions?
Closes #4837
### How was this PR tested?
`sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.common.CheckpointSubsystemSpec"` - 11/11 tests pass.
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.7)
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(amber): add unit test coverage for checkpoint subsystem [texera]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #4838:
URL: https://github.com/apache/texera/pull/4838#discussion_r3177622964
##########
amber/src/test/scala/org/apache/texera/amber/engine/common/CheckpointSubsystemSpec.scala:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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.common
+
+import org.apache.texera.amber.core.tuple.TupleLike
+import org.apache.texera.amber.core.workflow.PortIdentity
+import org.scalatest.flatspec.AnyFlatSpec
+
+class CheckpointSubsystemSpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // SerializedState
+ // ---------------------------------------------------------------------------
+
+ "SerializedState" should "expose stable well-known key constants" in {
+ // These constants are referenced from outside the engine; pin the strings
+ // so a rename surfaces as a test failure.
+ assert(SerializedState.CP_STATE_KEY == "Amber_CPState")
+ assert(SerializedState.DP_STATE_KEY == "Amber_DPState")
+ assert(SerializedState.IN_FLIGHT_MSG_KEY == "Amber_Inflight_Messages")
+ assert(SerializedState.DP_QUEUED_MSG_KEY == "Amber_DP_Queued_Messages")
+ assert(SerializedState.OUTPUT_MSG_KEY == "Amber_Output_Messages")
+ }
+
+ it should "round-trip a value through fromObject / toObject using the configured Serialization" in {
+ val original: java.lang.Integer = Integer.valueOf(42)
+ val state = SerializedState.fromObject(original, AmberRuntime.serde)
+ assert(state.bytes.length > 0)
+ assert(state.size() == state.bytes.length.toLong)
+ val restored = state.toObject[java.lang.Integer](AmberRuntime.serde)
+ assert(restored == original)
+ }
+
+ it should "carry the serializer id and manifest given at construction" in {
+ val s = SerializedState(Array[Byte](1, 2, 3), serializerId = 7, manifest = "manifest-x")
+ assert(s.bytes.toSeq == Seq[Byte](1, 2, 3))
+ assert(s.serializerId == 7)
+ assert(s.manifest == "manifest-x")
+ assert(s.size() == 3L)
+ }
+
+ // ---------------------------------------------------------------------------
+ // CheckpointState
+ // ---------------------------------------------------------------------------
+
+ "CheckpointState" should "default to size = 0 with no entries" in {
+ val cp = new CheckpointState()
+ assert(cp.size() == 0L)
+ assert(!cp.has("anything"))
+ }
+
+ "CheckpointState.save / load" should "round-trip a primitive value" in {
+ val cp = new CheckpointState()
+ cp.save("answer", java.lang.Integer.valueOf(42))
+ assert(cp.has("answer"))
+ val restored: java.lang.Integer = cp.load[java.lang.Integer]("answer")
+ assert(restored == java.lang.Integer.valueOf(42))
Review Comment:
These `CheckpointState.save`/`load` calls also hit `AmberRuntime.serde` under the hood, so this spec still creates a global Pekko `ActorSystem` without ever terminating it. Even if the direct `SerializedState.fromObject(..., AmberRuntime.serde)` test is fixed, the suite will continue to leak runtime threads until it owns a local actor system and shuts it down in `afterAll`.
##########
amber/src/test/scala/org/apache/texera/amber/engine/common/CheckpointSubsystemSpec.scala:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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.common
+
+import org.apache.texera.amber.core.tuple.TupleLike
+import org.apache.texera.amber.core.workflow.PortIdentity
+import org.scalatest.flatspec.AnyFlatSpec
+
+class CheckpointSubsystemSpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // SerializedState
+ // ---------------------------------------------------------------------------
+
+ "SerializedState" should "expose stable well-known key constants" in {
+ // These constants are referenced from outside the engine; pin the strings
+ // so a rename surfaces as a test failure.
+ assert(SerializedState.CP_STATE_KEY == "Amber_CPState")
+ assert(SerializedState.DP_STATE_KEY == "Amber_DPState")
+ assert(SerializedState.IN_FLIGHT_MSG_KEY == "Amber_Inflight_Messages")
+ assert(SerializedState.DP_QUEUED_MSG_KEY == "Amber_DP_Queued_Messages")
+ assert(SerializedState.OUTPUT_MSG_KEY == "Amber_Output_Messages")
+ }
+
+ it should "round-trip a value through fromObject / toObject using the configured Serialization" in {
+ val original: java.lang.Integer = Integer.valueOf(42)
+ val state = SerializedState.fromObject(original, AmberRuntime.serde)
+ assert(state.bytes.length > 0)
+ assert(state.size() == state.bytes.length.toLong)
+ val restored = state.toObject[java.lang.Integer](AmberRuntime.serde)
Review Comment:
This test calls `AmberRuntime.serde`, which lazily creates a new `ActorSystem("Amber", ...)` when no runtime has been initialized yet. Because the spec never shuts that system down—and `AmberRuntime.serde` does not even keep a handle to the temporary system it creates—the suite leaks Pekko threads globally, which can make the test process hang or interfere with later tests. Please use a suite-local `ActorSystem`/`SerializationExtension` that is terminated in `afterAll` instead of the global singleton here.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(amber): add unit test coverage for checkpoint subsystem [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang merged PR #4838:
URL: https://github.com/apache/texera/pull/4838
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(amber): add unit test coverage for checkpoint subsystem [texera]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #4838:
URL: https://github.com/apache/texera/pull/4838#issuecomment-4365384290
## [Codecov](https://app.codecov.io/gh/apache/texera/pull/4838?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 42.84%. Comparing base ([`945849c`](https://app.codecov.io/gh/apache/texera/commit/945849ce4f7ba77091e930b53b0b35440e33b994?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`f91cece`](https://app.codecov.io/gh/apache/texera/commit/f91cecee4ebb9a4e32799883af8420681960b220?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 1 commits behind head on main.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #4838 +/- ##
=========================================
Coverage 42.84% 42.84%
Complexity 2027 2027
=========================================
Files 957 957
Lines 34077 34077
Branches 3753 3753
=========================================
Hits 14600 14600
Misses 18693 18693
Partials 784 784
```
| [Flag](https://app.codecov.io/gh/apache/texera/pull/4838/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [python](https://app.codecov.io/gh/apache/texera/pull/4838/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `84.15% <ø> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/texera/pull/4838?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] test(amber): add unit test coverage for checkpoint subsystem [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan commented on code in PR #4838:
URL: https://github.com/apache/texera/pull/4838#discussion_r3177871653
##########
amber/src/test/scala/org/apache/texera/amber/engine/common/CheckpointSubsystemSpec.scala:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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.common
+
+import org.apache.texera.amber.core.tuple.TupleLike
+import org.apache.texera.amber.core.workflow.PortIdentity
+import org.scalatest.flatspec.AnyFlatSpec
+
+class CheckpointSubsystemSpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // SerializedState
+ // ---------------------------------------------------------------------------
+
+ "SerializedState" should "expose stable well-known key constants" in {
+ // These constants are referenced from outside the engine; pin the strings
+ // so a rename surfaces as a test failure.
+ assert(SerializedState.CP_STATE_KEY == "Amber_CPState")
+ assert(SerializedState.DP_STATE_KEY == "Amber_DPState")
+ assert(SerializedState.IN_FLIGHT_MSG_KEY == "Amber_Inflight_Messages")
+ assert(SerializedState.DP_QUEUED_MSG_KEY == "Amber_DP_Queued_Messages")
+ assert(SerializedState.OUTPUT_MSG_KEY == "Amber_Output_Messages")
+ }
+
+ it should "round-trip a value through fromObject / toObject using the configured Serialization" in {
+ val original: java.lang.Integer = Integer.valueOf(42)
+ val state = SerializedState.fromObject(original, AmberRuntime.serde)
+ assert(state.bytes.length > 0)
+ assert(state.size() == state.bytes.length.toLong)
+ val restored = state.toObject[java.lang.Integer](AmberRuntime.serde)
Review Comment:
Done in 584dc7a880 — moved to a suite-local `ActorSystem` injected into `AmberRuntime` via reflection (`_actorSystem`/`_serde`), and added an `afterAll` that shuts it down with `TestKit.shutdownActorSystem`. The spec no longer leaks a globally-initialized Pekko system.
##########
amber/src/test/scala/org/apache/texera/amber/engine/common/CheckpointSubsystemSpec.scala:
##########
@@ -0,0 +1,143 @@
+/*
+ * 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.common
+
+import org.apache.texera.amber.core.tuple.TupleLike
+import org.apache.texera.amber.core.workflow.PortIdentity
+import org.scalatest.flatspec.AnyFlatSpec
+
+class CheckpointSubsystemSpec extends AnyFlatSpec {
+
+ // ---------------------------------------------------------------------------
+ // SerializedState
+ // ---------------------------------------------------------------------------
+
+ "SerializedState" should "expose stable well-known key constants" in {
+ // These constants are referenced from outside the engine; pin the strings
+ // so a rename surfaces as a test failure.
+ assert(SerializedState.CP_STATE_KEY == "Amber_CPState")
+ assert(SerializedState.DP_STATE_KEY == "Amber_DPState")
+ assert(SerializedState.IN_FLIGHT_MSG_KEY == "Amber_Inflight_Messages")
+ assert(SerializedState.DP_QUEUED_MSG_KEY == "Amber_DP_Queued_Messages")
+ assert(SerializedState.OUTPUT_MSG_KEY == "Amber_Output_Messages")
+ }
+
+ it should "round-trip a value through fromObject / toObject using the configured Serialization" in {
+ val original: java.lang.Integer = Integer.valueOf(42)
+ val state = SerializedState.fromObject(original, AmberRuntime.serde)
+ assert(state.bytes.length > 0)
+ assert(state.size() == state.bytes.length.toLong)
+ val restored = state.toObject[java.lang.Integer](AmberRuntime.serde)
+ assert(restored == original)
+ }
+
+ it should "carry the serializer id and manifest given at construction" in {
+ val s = SerializedState(Array[Byte](1, 2, 3), serializerId = 7, manifest = "manifest-x")
+ assert(s.bytes.toSeq == Seq[Byte](1, 2, 3))
+ assert(s.serializerId == 7)
+ assert(s.manifest == "manifest-x")
+ assert(s.size() == 3L)
+ }
+
+ // ---------------------------------------------------------------------------
+ // CheckpointState
+ // ---------------------------------------------------------------------------
+
+ "CheckpointState" should "default to size = 0 with no entries" in {
+ val cp = new CheckpointState()
+ assert(cp.size() == 0L)
+ assert(!cp.has("anything"))
+ }
+
+ "CheckpointState.save / load" should "round-trip a primitive value" in {
+ val cp = new CheckpointState()
+ cp.save("answer", java.lang.Integer.valueOf(42))
+ assert(cp.has("answer"))
+ val restored: java.lang.Integer = cp.load[java.lang.Integer]("answer")
+ assert(restored == java.lang.Integer.valueOf(42))
Review Comment:
Done in 584dc7a880 — same fix as the sibling thread: `CheckpointState.save`/`load` now route through a suite-local `Serialization` instance injected into `AmberRuntime`, and the suite shuts the underlying `ActorSystem` down via `TestKit.shutdownActorSystem` in `afterAll`.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org