Commit b4bf81c
committed
test(sqs): tighten typed-nil regression + add genuine groupMutations test
Round 3 + Round 4 review on PR #715 caught two test gaps. Both
were real — the regressions they claim to catch were not actually
caught by the tests as written.
Round 3: requireNilInterface used testify's require.Nil
testify's require.Nil reflects through to the underlying pointer
and considers a nil pointer wrapped in a non-nil interface as
"nil". So if buildSQSPartitionResolver's return type were reverted
to *adapter.SQSPartitionResolver (the typed-nil bug), the
regression test would still pass — require.Nil on the typed nil
returns true.
Switch to require.True(t, r == nil, msg). Go's `==` operator on
the interface checks BOTH the type tag AND the value tag — it
only returns true for a true nil interface, which is the exact
invariant the typed-nil fix produces.
Round 4: TestShardedCoordinator_DispatchHonoursPartitionResolver
did not actually regress the groupMutations bypass
For a single-mutation batch, the test passes even if
groupMutations bypasses the resolver, because rawLogs produces
one pb.Request and router.Commit's groupRequests re-routes by
the raw key — the router rescues the mis-routing the coordinator
would have introduced.
To genuinely regress the bypass, the test must dispatch TWO
mutations belonging to TWO different partition groups. With the
buggy groupMutations both end up under the engine-default group,
rawLogs produces one request, and router.Commit puts both
mutations on whichever group claims Mutations[0].Key — the second
group receives nothing.
Added TestShardedCoordinator_DispatchSplitsMutationsByResolverGroup:
- Engine routes everything to group 1.
- Resolver claims keyP0 → group 42, keyP1 → group 43.
- Dispatch with [Put keyP0, Put keyP1].
- Asserts BOTH g42 and g43 each receive exactly one request.
- Pre-fix: g43 receives ZERO (bypass put both under group 1's
rawLog, then router put them under g42 because of Mutations[0]).
- Post-fix: groupMutations splits via c.router.ResolveGroup, two
separate requests, each group gets its own.
Updated TestShardedCoordinator_DispatchHonoursPartitionResolver
comment to reflect what it actually pins (WithPartitionResolver
wiring + raw-key dispatch, not groupMutations).1 parent 9cfc779 commit b4bf81c
2 files changed
Lines changed: 104 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
61 | 58 | | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
118 | 198 | | |
119 | 199 | | |
120 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
66 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
67 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
68 | 77 | | |
69 | 78 | | |
70 | | - | |
| 79 | + | |
71 | 80 | | |
0 commit comments