|
23 | 23 | import org.junit.jupiter.api.Test; |
24 | 24 |
|
25 | 25 | import static org.assertj.core.api.Assertions.assertThat; |
| 26 | +import static org.assertj.core.api.Assertions.assertThatThrownBy; |
26 | 27 |
|
27 | 28 | /** Tests for {@link PartitionEntry#merge(PartitionEntry)}. */ |
28 | 29 | public class PartitionEntryTest { |
@@ -103,21 +104,19 @@ public void testMergeWithDeleteEntryPreservesNewerTotalBuckets() { |
103 | 104 | } |
104 | 105 |
|
105 | 106 | @Test |
106 | | - public void testMergeWithEqualCreationTimeIsCommutative() { |
107 | | - // When creation times are equal, merge must be commutative: a.merge(b) == b.merge(a). |
108 | | - // The tie-break takes the larger totalBuckets so that the parallel, non-deterministic |
109 | | - // aggregation in readPartitionEntries() always produces the same result regardless of |
110 | | - // manifest processing order. |
| 107 | + public void testMergeWithEqualCreationTimeAndConflictingBucketsFails() { |
| 108 | + // Creation time alone cannot order layouts written in the same millisecond. Choosing one |
| 109 | + // of them (for example, the larger bucket count) can silently retain the old layout when |
| 110 | + // a partition is downscaled, so reject the ambiguous metadata instead. |
111 | 111 | PartitionEntry a = entry(1, 2, 1000L); |
112 | 112 | PartitionEntry b = entry(1, 4, 1000L); |
113 | 113 |
|
114 | | - PartitionEntry ab = a.merge(b); |
115 | | - PartitionEntry ba = b.merge(a); |
116 | | - |
117 | | - assertThat(ab.totalBuckets()).isEqualTo(4); // max(2, 4) = 4 |
118 | | - assertThat(ba.totalBuckets()).isEqualTo(4); // max(4, 2) = 4, commutative |
119 | | - assertThat(ab.fileCount()).isEqualTo(2); |
120 | | - assertThat(ba.fileCount()).isEqualTo(2); |
| 114 | + assertThatThrownBy(() -> a.merge(b)) |
| 115 | + .isInstanceOf(IllegalStateException.class) |
| 116 | + .hasMessageContaining("Cannot determine the bucket layout"); |
| 117 | + assertThatThrownBy(() -> b.merge(a)) |
| 118 | + .isInstanceOf(IllegalStateException.class) |
| 119 | + .hasMessageContaining("Cannot determine the bucket layout"); |
121 | 120 | } |
122 | 121 |
|
123 | 122 | @Test |
|
0 commit comments