layer1: add namespace bootstrap dispatch step 26
This commit is contained in:
@@ -179,6 +179,50 @@ func TestNamespaceManagerBootstrap(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamespaceManagerBootstrapAndDispatch(t *testing.T) {
|
||||
manager := NewNamespaceManager()
|
||||
router := &testNamespaceSubscriber{name: "router"}
|
||||
builder := &testNamespaceSubscriber{name: "buildermgr"}
|
||||
manager.Subscribe(router)
|
||||
manager.Subscribe(builder)
|
||||
|
||||
records, err := manager.BootstrapAndDispatch(context.Background(), []string{"tenant-b", "tenant-a"}, NamespaceSourceBackfill, time.Now().UTC())
|
||||
if err != nil {
|
||||
t.Fatalf("expected bootstrap and dispatch success: %v", err)
|
||||
}
|
||||
if len(records) != 2 {
|
||||
t.Fatalf("expected 2 records, got %d", len(records))
|
||||
}
|
||||
if router.addCalls != 2 || builder.addCalls != 2 {
|
||||
t.Fatalf("expected both subscribers to be called for each namespace")
|
||||
}
|
||||
if records[0].Phase != NamespacePhaseActive || records[1].Phase != NamespacePhaseActive {
|
||||
t.Fatalf("expected active records after bootstrap dispatch")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamespaceManagerBootstrapAndDispatchFailure(t *testing.T) {
|
||||
manager := NewNamespaceManager()
|
||||
router := &testNamespaceSubscriber{name: "router", addErr: errors.New("router failed")}
|
||||
builder := &testNamespaceSubscriber{name: "buildermgr"}
|
||||
manager.Subscribe(router)
|
||||
manager.Subscribe(builder)
|
||||
|
||||
records, err := manager.BootstrapAndDispatch(context.Background(), []string{"tenant-a"}, NamespaceSourceBackfill, time.Now().UTC())
|
||||
if err == nil {
|
||||
t.Fatalf("expected bootstrap dispatch failure")
|
||||
}
|
||||
if len(records) != 1 {
|
||||
t.Fatalf("expected single record result")
|
||||
}
|
||||
if records[0].Phase != NamespacePhaseFailed {
|
||||
t.Fatalf("expected failed phase after subscriber error, got %s", records[0].Phase)
|
||||
}
|
||||
if records[0].RegisteredParts["router"].LastError != "router failed" {
|
||||
t.Fatalf("expected router failure to be stored")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamespaceManagerPartStateHelpers(t *testing.T) {
|
||||
manager := NewNamespaceManager()
|
||||
manager.Upsert(NamespaceEvent{Type: NamespaceEventAdd, Name: "tenant-a", Source: NamespaceSourceWatcher})
|
||||
|
||||
Reference in New Issue
Block a user