diff --git a/internal/client/client_test.go b/internal/client/client_test.go index 36bff62..182a110 100644 --- a/internal/client/client_test.go +++ b/internal/client/client_test.go @@ -41,7 +41,7 @@ func createMockCluster(id string) map[string]interface{} { "observed_generation": 5, }, { - "type": "Available", + "type": "LastKnownReconciled", "status": "True", "created_time": "2025-01-01T09:00:00Z", "last_transition_time": "2025-01-01T10:00:00Z", @@ -587,7 +587,7 @@ func TestFetchResources_NodePools(t *testing.T) { "observed_generation": 3, }, { - "type": "Available", + "type": "LastKnownReconciled", "status": "True", "created_time": "2025-01-01T09:00:00Z", "last_transition_time": "2025-01-01T10:00:00Z", diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 7d5ba0b..058a8a8 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -608,7 +608,7 @@ func TestValidate_ParamsNoDependencies(t *testing.T) { md := &MessageDecisionConfig{ Params: []Param{ {Name: "a", Expr: `condition("Reconciled").status`}, - {Name: "b", Expr: `condition("Available").status`}, + {Name: "b", Expr: `condition("LastKnownReconciled").status`}, }, Result: "a == b", } diff --git a/internal/engine/decision_test.go b/internal/engine/decision_test.go index b990686..c4872a3 100644 --- a/internal/engine/decision_test.go +++ b/internal/engine/decision_test.go @@ -338,9 +338,9 @@ func TestDecisionEngine_Evaluate_CustomExpressions(t *testing.T) { t.Run("condition function with custom condition name", func(t *testing.T) { cfg := &config.MessageDecisionConfig{ Params: []config.Param{ - {Name: "is_available", Expr: `condition("Available").status == "True"`}, + {Name: "is_last_known_reconciled", Expr: `condition("LastKnownReconciled").status == "True"`}, }, - Result: "is_available", + Result: "is_last_known_reconciled", } engine, err := NewDecisionEngine(cfg) if err != nil { @@ -353,17 +353,17 @@ func TestDecisionEngine_Evaluate_CustomExpressions(t *testing.T) { Generation: 1, Status: client.ResourceStatus{ Conditions: []client.Condition{ - {Type: "Available", Status: "True", LastUpdatedTime: now}, + {Type: "LastKnownReconciled", Status: "True", LastUpdatedTime: now}, }, }, } decision := engine.Evaluate(resource, now) if !decision.ShouldPublish { - t.Error("expected ShouldPublish=true for Available=True condition") + t.Error("expected ShouldPublish=true for LastKnownReconciled=True condition") } - // Missing Available condition → zero-value → status="" → false + // Missing LastKnownReconciled condition → zero-value → status="" → false resource2 := &client.Resource{ ID: testResourceID, Kind: testResourceKind, @@ -377,7 +377,7 @@ func TestDecisionEngine_Evaluate_CustomExpressions(t *testing.T) { decision2 := engine.Evaluate(resource2, now) if decision2.ShouldPublish { - t.Error("expected ShouldPublish=false when Available condition is missing") + t.Error("expected ShouldPublish=false when LastKnownReconciled condition is missing") } }) } @@ -466,7 +466,7 @@ func TestBuildConditionsLookup(t *testing.T) { ObservedGeneration: 3, }, { - Type: "Available", + Type: "LastKnownReconciled", Status: "False", LastUpdatedTime: now.Add(-5 * time.Minute), LastTransitionTime: now.Add(-10 * time.Minute), @@ -491,12 +491,12 @@ func TestBuildConditionsLookup(t *testing.T) { t.Errorf("Reconciled observed_generation = %v, want 3", reconciled["observed_generation"]) } - avail, ok := lookup["Available"] + lkr, ok := lookup["LastKnownReconciled"] if !ok { - t.Fatal("missing Available condition") + t.Fatal("missing LastKnownReconciled condition") } - if avail["status"] != "False" { - t.Errorf("Available status = %v, want False", avail["status"]) + if lkr["status"] != "False" { + t.Errorf("LastKnownReconciled status = %v, want False", lkr["status"]) } } diff --git a/test/integration/integration_test.go b/test/integration/integration_test.go index a053c06..1a357dd 100644 --- a/test/integration/integration_test.go +++ b/test/integration/integration_test.go @@ -86,7 +86,7 @@ func createMockClusterWithLabels(id string, generation int, observedGeneration i "conditions": []map[string]interface{}{ reconciledCondition, { - "type": "Available", + "type": "LastKnownReconciled", "status": reconciledStatus, "created_time": "2025-01-01T09:00:00Z", "last_transition_time": "2025-01-01T10:00:00Z", diff --git a/test/mock-hyperfleet-api/main.go b/test/mock-hyperfleet-api/main.go index 9f9f2ee..671fd34 100644 --- a/test/mock-hyperfleet-api/main.go +++ b/test/mock-hyperfleet-api/main.go @@ -269,8 +269,8 @@ func buildConditions(generation int32) []map[string]any { conditions := []map[string]any{ makeCondition("Reconciled", "True", "AllAdaptersReconciled", "All adapters reported Reconciled True for the current generation"), - makeCondition("Available", "True", "AllAdaptersAvailable", - "All adapters reported Available True for the same generation"), + makeCondition("LastKnownReconciled", "True", "AllAdaptersLastKnownReconciled", + "All required adapters were reconciled at a common observed generation"), } for _, adapter := range adapterNames {