Skip to content

Commit 3778d67

Browse files
committed
remove duplicate log sink
1 parent 5f022e2 commit 3778d67

File tree

2 files changed

+4
-48
lines changed

2 files changed

+4
-48
lines changed

internal/controller/state/graph/backend_tls_policy_test.go

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,9 @@ func TestAddGatewaysForBackendTLSPoliciesAncestorLimit(t *testing.T) {
674674

675675
// Create a test logger that captures log output
676676
var logBuf bytes.Buffer
677-
testLogger := logr.New(&testLogSink{buffer: &logBuf})
677+
testLogger := logr.New(&testNGFLogSink{buffer: &logBuf})
678678

679-
// Create BackendTLSPolicy with 16 ancestors (full)
679+
// Helper function to create ancestor references
680680
getAncestorRef := func(ctlrName, parentName string) v1alpha2.PolicyAncestorStatus {
681681
return v1alpha2.PolicyAncestorStatus{
682682
ControllerName: gatewayv1.GatewayController(ctlrName),
@@ -793,7 +793,7 @@ func TestAddGatewaysForBackendTLSPoliciesAncestorLimit(t *testing.T) {
793793
g.Expect(condition.Type).To(Equal(string(v1alpha2.PolicyConditionAccepted)))
794794
g.Expect(condition.Status).To(Equal(metav1.ConditionFalse))
795795
g.Expect(condition.Reason).To(Equal(string(conditions.PolicyReasonAncestorLimitReached)))
796-
g.Expect(condition.Message).To(ContainSubstring("ancestor status list has reached the maximum size of 16"))
796+
g.Expect(condition.Message).To(ContainSubstring("ancestor status list has reached the maximum size"))
797797

798798
// Verify that gateway2 did not receive any conditions (normal case)
799799
gateway2 := gateways[types.NamespacedName{Namespace: "test", Name: "gateway2"}]
@@ -808,47 +808,3 @@ func TestAddGatewaysForBackendTLSPoliciesAncestorLimit(t *testing.T) {
808808
g.Expect(logOutput).To(ContainSubstring("policyKind=BackendTLSPolicy"))
809809
g.Expect(logOutput).To(ContainSubstring("ancestor=test/gateway1"))
810810
}
811-
812-
// testLogSink implements logr.LogSink for testing.
813-
type testLogSink struct {
814-
buffer *bytes.Buffer
815-
}
816-
817-
func (s *testLogSink) Init(_ logr.RuntimeInfo) {}
818-
819-
func (s *testLogSink) Enabled(_ int) bool {
820-
return true
821-
}
822-
823-
func (s *testLogSink) Info(_ int, msg string, keysAndValues ...interface{}) {
824-
s.buffer.WriteString(msg)
825-
for i := 0; i < len(keysAndValues); i += 2 {
826-
if i+1 < len(keysAndValues) {
827-
s.buffer.WriteString(" ")
828-
if key, ok := keysAndValues[i].(string); ok {
829-
s.buffer.WriteString(key)
830-
}
831-
s.buffer.WriteString("=")
832-
if value, ok := keysAndValues[i+1].(string); ok {
833-
s.buffer.WriteString(value)
834-
}
835-
}
836-
}
837-
s.buffer.WriteString("\n")
838-
}
839-
840-
func (s *testLogSink) Error(err error, msg string, _ ...interface{}) {
841-
s.buffer.WriteString("ERROR: ")
842-
s.buffer.WriteString(msg)
843-
s.buffer.WriteString(" error=")
844-
s.buffer.WriteString(err.Error())
845-
s.buffer.WriteString("\n")
846-
}
847-
848-
func (s *testLogSink) WithValues(_ ...interface{}) logr.LogSink {
849-
return s
850-
}
851-
852-
func (s *testLogSink) WithName(_ string) logr.LogSink {
853-
return s
854-
}

internal/controller/state/graph/policies_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2303,7 +2303,7 @@ func TestNGFPolicyAncestorLimitHandling(t *testing.T) {
23032303
g.Expect(condition.Type).To(Equal(string(v1alpha2.PolicyConditionAccepted)))
23042304
g.Expect(condition.Status).To(Equal(metav1.ConditionFalse))
23052305
g.Expect(condition.Reason).To(Equal(string(conditions.PolicyReasonAncestorLimitReached)))
2306-
g.Expect(condition.Message).To(ContainSubstring("ancestor status list has reached the maximum size of 16"))
2306+
g.Expect(condition.Message).To(ContainSubstring("ancestor status list has reached the maximum size"))
23072307

23082308
// Verify that gateway2 did not receive any conditions (normal case)
23092309
gateway2 := gateways[types.NamespacedName{Namespace: "test", Name: "gateway2"}]

0 commit comments

Comments
 (0)