layer1: derive namespace phases step 10
This commit is contained in:
@@ -53,13 +53,16 @@ func TestNamespaceManagerMarkPartState(t *testing.T) {
|
||||
manager := NewNamespaceManager()
|
||||
manager.Upsert(NamespaceEvent{Type: NamespaceEventAdd, Name: "tenant-a", Source: NamespaceSourceWatcher})
|
||||
|
||||
record, ok := manager.MarkPartState("tenant-a", "router", NamespacePartState{State: "active"})
|
||||
record, ok := manager.MarkPartState("tenant-a", "router", NamespacePartState{State: NamespacePartStateActive})
|
||||
if !ok {
|
||||
t.Fatalf("expected mark part state to succeed")
|
||||
}
|
||||
if record.RegisteredParts["router"].State != "active" {
|
||||
if record.RegisteredParts["router"].State != NamespacePartStateActive {
|
||||
t.Fatalf("expected router part state to be stored")
|
||||
}
|
||||
if record.Phase != NamespacePhaseActive {
|
||||
t.Fatalf("expected phase to become active, got %s", record.Phase)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamespaceManagerRemove(t *testing.T) {
|
||||
@@ -85,7 +88,7 @@ func TestNamespaceManagerSnapshotRecordsReturnsCopies(t *testing.T) {
|
||||
Source: NamespaceSourceWatcher,
|
||||
Labels: map[string]string{"fission.io/managed": "true"},
|
||||
})
|
||||
_, _ = manager.MarkPartState("tenant-a", "router", NamespacePartState{State: "active"})
|
||||
_, _ = manager.MarkPartState("tenant-a", "router", NamespacePartState{State: NamespacePartStateActive})
|
||||
|
||||
records := manager.SnapshotRecords()
|
||||
records[0].Labels["fission.io/managed"] = "false"
|
||||
@@ -98,7 +101,7 @@ func TestNamespaceManagerSnapshotRecordsReturnsCopies(t *testing.T) {
|
||||
if record.Labels["fission.io/managed"] != "true" {
|
||||
t.Fatalf("expected snapshot records to be detached copies")
|
||||
}
|
||||
if record.RegisteredParts["router"].State != "active" {
|
||||
if record.RegisteredParts["router"].State != NamespacePartStateActive {
|
||||
t.Fatalf("expected part states to be detached copies")
|
||||
}
|
||||
}
|
||||
@@ -113,4 +116,25 @@ func TestNamespaceManagerSubscribers(t *testing.T) {
|
||||
if !reflect.DeepEqual(expected, manager.SnapshotSubscribers()) {
|
||||
t.Fatalf("expected subscribers %v, got %v", expected, manager.SnapshotSubscribers())
|
||||
}
|
||||
}
|
||||
|
||||
func TestNamespaceManagerMarkPartStateDerivesPhase(t *testing.T) {
|
||||
manager := NewNamespaceManager()
|
||||
manager.Upsert(NamespaceEvent{Type: NamespaceEventAdd, Name: "tenant-a", Source: NamespaceSourceWatcher})
|
||||
|
||||
record, ok := manager.MarkPartState("tenant-a", "router", NamespacePartState{State: NamespacePartStateRegistering})
|
||||
if !ok {
|
||||
t.Fatalf("expected registering state update to succeed")
|
||||
}
|
||||
if record.Phase != NamespacePhaseRegistering {
|
||||
t.Fatalf("expected phase registering, got %s", record.Phase)
|
||||
}
|
||||
|
||||
record, ok = manager.MarkPartState("tenant-a", "router", NamespacePartState{State: NamespacePartStateFailed})
|
||||
if !ok {
|
||||
t.Fatalf("expected failed state update to succeed")
|
||||
}
|
||||
if record.Phase != NamespacePhaseFailed {
|
||||
t.Fatalf("expected phase failed, got %s", record.Phase)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user