Files
platform/event/partition_test.go
T
mats 16655e8dbc feat(tracking): ship the shell rebuild — k8s replicas 3 + REDIS_ONLY + HPA, partitioned ingest live
- deploy/k8s/25-tracking-orders.yaml: SHELL-REBUILD gating removed (LIVE) —
  replicas 3 + RollingUpdate, actor-pool=tracking label + POD_IP/NAMESPACE,
  REDIS_ONLY=1, TRACKING_PARTITIONS=16, HPA 3..12
- deploy/k8s/00-namespace-config.yaml: tracking PVC note → rebuild live (mount
  vestigial, kept for rollback)
- deploy/docker-compose.yml: TRACKING_PARTITIONS=16 on the reader producer +
  tracking consumer (partitioned ingest in the dev stack too)
- deploy/k8s/build-push.sh: gocartactor named context for the tracking image
- platform: rabbit.PublishEventTo (caller routing key) + event.PartitionOf /
  PartitionRoutingKey (shared §8 fnv1a hash) + tests
- docs: plan-tracking-shell-rebuild.md (config write half, pod-watcher
  assignment, real-AOF tape gate, R6 re-measure), status.md, CONTEXT,
  event-sourcing-stance, platform-architecture-review, read-model-projections;
  scripts/load-test-coordinator.sh
- submodules: slask-tracking ecbf894 (shell rebuild), slask-finder 84f7ff7
  (§8 partition-routed producer)

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
2026-08-17 14:41:17 +02:00

37 lines
1.1 KiB
Go

package event
import "testing"
func TestPartitionOf_DeterministicInRange(t *testing.T) {
const n = 16
for _, key := range []string{"0", "1", "42", "9007199254740993", "sendA", "list-7"} {
first := PartitionOf(key, n)
if first < 0 || first >= n {
t.Fatalf("PartitionOf(%q, %d) = %d, out of range", key, n, first)
}
if again := PartitionOf(key, n); again != first {
t.Fatalf("PartitionOf(%q, %d) not deterministic: %d vs %d", key, n, first, again)
}
}
}
func TestPartitionOf_SameKeySamePartition(t *testing.T) {
// A session's sessionId must pin every beacon to one partition (per-session
// FIFO): the same key always hashes to the same partition across callers.
if PartitionOf("123456789", 32) != PartitionOf("123456789", 32) {
t.Fatal("same key mapped to different partitions")
}
}
func TestPartitionOf_SinglePartition(t *testing.T) {
if PartitionOf("anything", 1) != 0 || PartitionOf("anything", 0) != 0 {
t.Fatal("n <= 1 must collapse to partition 0")
}
}
func TestPartitionRoutingKey(t *testing.T) {
if got := PartitionRoutingKey(7); got != "track.partition.7" {
t.Fatalf("PartitionRoutingKey(7) = %q", got)
}
}