Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions internal/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand Down
22 changes: 11 additions & 11 deletions internal/engine/decision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand All @@ -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")
}
})
}
Expand Down Expand Up @@ -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),
Expand All @@ -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"])
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions test/mock-hyperfleet-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down