layer1: add namespace manager summary
This commit is contained in:
@@ -59,6 +59,10 @@ func TestNamespaceManagerSnapshotAndGet(t *testing.T) {
|
||||
if record.Name != "tenant-a" || record.Phase != NamespacePhaseDiscovered {
|
||||
t.Fatalf("unexpected record returned: %+v", record)
|
||||
}
|
||||
summary := manager.Summary()
|
||||
if summary.TotalNamespaces != 2 {
|
||||
t.Fatalf("expected summary total namespaces to be 2, got %d", summary.TotalNamespaces)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamespaceManagerUpsertIncrementsGeneration(t *testing.T) {
|
||||
@@ -448,6 +452,29 @@ func TestPrepareManagedNamespaceWatcher(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamespaceManagerSummary(t *testing.T) {
|
||||
manager := NewNamespaceManager()
|
||||
manager.Upsert(NamespaceEvent{Type: NamespaceEventAdd, Name: "tenant-a", Source: NamespaceSourceWatcher})
|
||||
manager.Upsert(NamespaceEvent{Type: NamespaceEventAdd, Name: "tenant-b", Source: NamespaceSourceWatcher})
|
||||
_, _ = manager.MarkPartRegistering("tenant-a", "router")
|
||||
manager.Upsert(NamespaceEvent{Type: NamespaceEventRemove, Name: "tenant-b", Source: NamespaceSourceWatcher})
|
||||
manager.Subscribe(&testNamespaceSubscriber{name: "router"})
|
||||
|
||||
summary := manager.Summary()
|
||||
if summary.TotalNamespaces != 2 {
|
||||
t.Fatalf("expected total namespaces 2, got %d", summary.TotalNamespaces)
|
||||
}
|
||||
if summary.PhaseCounts[NamespacePhaseRegistering] != 1 {
|
||||
t.Fatalf("expected one registering namespace")
|
||||
}
|
||||
if summary.PhaseCounts[NamespacePhaseRemoved] != 1 {
|
||||
t.Fatalf("expected one removed namespace")
|
||||
}
|
||||
if !reflect.DeepEqual([]string{"router"}, summary.Subscribers) {
|
||||
t.Fatalf("expected router subscriber in summary")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamespaceManagerDispatchAdd(t *testing.T) {
|
||||
manager := NewNamespaceManager()
|
||||
manager.Upsert(NamespaceEvent{Type: NamespaceEventAdd, Name: "tenant-a", Source: NamespaceSourceWatcher})
|
||||
|
||||
Reference in New Issue
Block a user