Commit 4f56946
authored
test(workflow-core): add unit test coverage for port-identity serde helpers (#4954)
### What changes were proposed in this PR?
Adds `PortIdentitySerdeSpec` covering three Jackson / VFS-URI serde
helpers in `org.apache.texera.amber.util.serde`, and tightens the
production contract on `GlobalPortIdentitySerde` after review.
Production change (added per review):
| Surface | Change |
| --- | --- |
| `GlobalPortIdentitySerde.serializeAsString` | Rejects `portId < 0`,
`logicalOpId` containing `_`, `layerName` containing `_` with
`IllegalArgumentException`. |
| `GlobalPortIdentitySerde.deserializeFromString` | Symmetrically
rejects `portId < 0`. |
| Python `serialize_global_port_identity` /
`deserialize_global_port_identity` | Mirrored: raises `ValueError` on
the same invariants. |
| Iceberg test fixtures (`IcebergTableStatsSpec`, `IcebergDocumentSpec`,
`test_iceberg_document.py`) | Op-id `test_table_<uuid>` →
`test-table-<uuid>` to honor the new contract.
`IcebergDocumentConsoleMessagesSpec` is unchanged —
`createConsoleMessagesURI` does not go through `serializeAsString`. |
Test coverage:
| Helper | Pinned by this spec |
| --- | --- |
| `GlobalPortIdentitySerde.serializeAsString` / `deserializeFromString`
| Default + per-field round-trip; exact format pin (default +
non-default values); special-character pass-through (dashes / dots);
negative `portId` rejected (serialize + deserialize); underscored
`logicalOpId` rejected; underscored `layerName` rejected;
format-character no-underscore invariant; seven negative paths —
completely malformed, missing field, wrong field order, trailing
content, empty body, non-numeric `portId` → `NumberFormatException`,
non-boolean flag → `IllegalArgumentException` |
| `PortIdentityKeySerializer.portIdToString` | Exact `id_internal`
format. |
| `PortIdentityKeySerializer` + `PortIdentityKeyDeserializer` (Jackson
wiring) | The production `JSONUtils.objectMapper`, round-tripping
`Map[PortIdentity, String]` and an empty map. |
| `PortIdentityKeyDeserializer.deserializeKey` | Four negative paths
(non-integer id, non-boolean flag, missing-separator with non-numeric
body, missing-separator with numeric-only body); current lenient
extra-segments behavior pinned in a characterization test, with a
`pendingUntilFixed` for the stricter contract. |
### Any related issues, documentation, discussions?
Closes #4953
### How was this PR tested?
```
sbt "WorkflowCore/Test/testOnly org.apache.texera.amber.util.serde.PortIdentitySerdeSpec"
# 24 tests, all pass (1 unchanged pendingUntilFixed for PortIdentityKeyDeserializer)
sbt "WorkflowCore/Test/testOnly org.apache.texera.amber.core.storage.VFSURIFactorySpec org.apache.texera.amber.storage.result.iceberg.IcebergDocumentSpec org.apache.texera.amber.storage.result.iceberg.IcebergTableStatsSpec org.apache.texera.amber.storage.result.iceberg.IcebergDocumentConsoleMessagesSpec"
# 30 tests, all pass
sbt "WorkflowExecutionService/Test/testOnly org.apache.texera.web.resource.dashboard.user.workflow.WorkflowExecutionsResourceSpec"
# 2 tests, all pass
pytest core/util/virtual_identity/
# 17 tests, all pass
sbt "WorkflowCore/scalafmtCheck; WorkflowCore/Test/scalafmtCheck"
# clean
```
### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.7)1 parent 4862b92 commit 4f56946
7 files changed
Lines changed: 379 additions & 6 deletions
File tree
- amber/src
- main/python/core/util
- test/python/core
- storage/iceberg
- util
- common/workflow-core/src
- main/scala/org/apache/texera/amber/util/serde
- test/scala/org/apache/texera/amber
- storage/result/iceberg
- util/serde
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
49 | 52 | | |
50 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
51 | 66 | | |
52 | 67 | | |
53 | 68 | | |
| |||
72 | 87 | | |
73 | 88 | | |
74 | 89 | | |
| 90 | + | |
| 91 | + | |
75 | 92 | | |
76 | 93 | | |
77 | 94 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
89 | | - | |
| 89 | + | |
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
108 | 123 | | |
109 | 124 | | |
110 | 125 | | |
| |||
137 | 152 | | |
138 | 153 | | |
139 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
140 | 163 | | |
141 | 164 | | |
142 | 165 | | |
| |||
Lines changed: 16 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
| 38 | + | |
| 39 | + | |
37 | 40 | | |
38 | 41 | | |
39 | 42 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
45 | 57 | | |
46 | 58 | | |
47 | 59 | | |
| |||
58 | 70 | | |
59 | 71 | | |
60 | 72 | | |
| 73 | + | |
61 | 74 | | |
62 | 75 | | |
63 | 76 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
| |||
0 commit comments