Skip to content

Commit 825458e

Browse files
authored
Merge pull request #575 from karlkfi/karl-event-logs
chore: Log events at -v=3 for e2e tests
2 parents d6e0b72 + 0cb52c6 commit 825458e

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test:
7070

7171
test-e2e: $(MYGOBIN)/ginkgo $(MYGOBIN)/kind
7272
kind delete cluster --name=cli-utils-e2e && kind create cluster --name=cli-utils-e2e --wait 5m
73-
$(GOPATH)/bin/ginkgo ./test/e2e/...
73+
$(GOPATH)/bin/ginkgo -v ./test/e2e/... -- -v 3
7474

7575
.PHONY: test-e2e-focus
7676
test-e2e-focus: $(MYGOBIN)/ginkgo $(MYGOBIN)/kind

pkg/apply/event/event.go

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ type Event struct {
7474
// String returns a string suitable for logging
7575
func (e Event) String() string {
7676
var sb strings.Builder
77-
sb.WriteString("Event{ ")
7877
switch e.Type {
7978
case InitType:
8079
sb.WriteString(e.InitEvent.String())
@@ -95,7 +94,6 @@ func (e Event) String() string {
9594
case ValidationType:
9695
sb.WriteString(e.ValidationEvent.String())
9796
}
98-
sb.WriteString(" }")
9997
return sb.String()
10098
}
10199

@@ -221,8 +219,12 @@ type ApplyEvent struct {
221219

222220
// String returns a string suitable for logging
223221
func (ae ApplyEvent) String() string {
224-
return fmt.Sprintf("ApplyEvent{ GroupName: %q, Status: %q, Identifier: %q, Error: %q }",
225-
ae.GroupName, ae.Status, ae.Identifier, ae.Error)
222+
if ae.Error != nil {
223+
return fmt.Sprintf("ApplyEvent{ GroupName: %q, Status: %q, Identifier: %q, Error: %q }",
224+
ae.GroupName, ae.Status, ae.Identifier, ae.Error)
225+
}
226+
return fmt.Sprintf("ApplyEvent{ GroupName: %q, Status: %q, Identifier: %q }",
227+
ae.GroupName, ae.Status, ae.Identifier)
226228
}
227229

228230
type StatusEvent struct {
@@ -242,8 +244,12 @@ func (se StatusEvent) String() string {
242244
gen = se.PollResourceInfo.Resource.GetGeneration()
243245
}
244246
}
245-
return fmt.Sprintf("StatusEvent{ Status: %q, Generation: %d, Identifier: %q, Error: %q }",
246-
status, gen, se.Identifier, se.Error)
247+
if se.Error != nil {
248+
return fmt.Sprintf("StatusEvent{ Status: %q, Generation: %d, Identifier: %q, Error: %q }",
249+
status, gen, se.Identifier, se.Error)
250+
}
251+
return fmt.Sprintf("StatusEvent{ Status: %q, Generation: %d, Identifier: %q }",
252+
status, gen, se.Identifier)
247253
}
248254

249255
//go:generate stringer -type=PruneEventStatus -linecomment
@@ -266,8 +272,12 @@ type PruneEvent struct {
266272

267273
// String returns a string suitable for logging
268274
func (pe PruneEvent) String() string {
269-
return fmt.Sprintf("PruneEvent{ GroupName: %q, Status: %q, Identifier: %q, Error: %q }",
270-
pe.GroupName, pe.Status, pe.Identifier, pe.Error)
275+
if pe.Error != nil {
276+
return fmt.Sprintf("PruneEvent{ GroupName: %q, Status: %q, Identifier: %q, Error: %q }",
277+
pe.GroupName, pe.Status, pe.Identifier, pe.Error)
278+
}
279+
return fmt.Sprintf("PruneEvent{ GroupName: %q, Status: %q, Identifier: %q }",
280+
pe.GroupName, pe.Status, pe.Identifier)
271281
}
272282

273283
//go:generate stringer -type=DeleteEventStatus -linecomment
@@ -290,8 +300,12 @@ type DeleteEvent struct {
290300

291301
// String returns a string suitable for logging
292302
func (de DeleteEvent) String() string {
293-
return fmt.Sprintf("DeleteEvent{ GroupName: %q, Status: %q, Identifier: %q, Error: %q }",
294-
de.GroupName, de.Status, de.Identifier, de.Error)
303+
if de.Error != nil {
304+
return fmt.Sprintf("DeleteEvent{ GroupName: %q, Status: %q, Identifier: %q, Error: %q }",
305+
de.GroupName, de.Status, de.Identifier, de.Error)
306+
}
307+
return fmt.Sprintf("DeleteEvent{ GroupName: %q, Status: %q, Identifier: %q }",
308+
de.GroupName, de.Status, de.Identifier)
295309
}
296310

297311
type ValidationEvent struct {
@@ -301,6 +315,10 @@ type ValidationEvent struct {
301315

302316
// String returns a string suitable for logging
303317
func (ve ValidationEvent) String() string {
304-
return fmt.Sprintf("ValidationEvent{ Identifiers: %+v, Error: %q }",
305-
ve.Identifiers, ve.Error)
318+
if ve.Error != nil {
319+
return fmt.Sprintf("ValidationEvent{ Identifiers: %+v, Error: %q }",
320+
ve.Identifiers, ve.Error)
321+
}
322+
return fmt.Sprintf("ValidationEvent{ Identifiers: %+v }",
323+
ve.Identifiers)
306324
}

pkg/apply/taskrunner/context.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (tc *TaskContext) SetGraph(g *graph.Graph) {
6363

6464
// SendEvent sends an event on the event channel
6565
func (tc *TaskContext) SendEvent(e event.Event) {
66-
klog.V(5).Infof("sending event: %s", e)
66+
klog.V(3).Infof("Sending event: %v", e)
6767
tc.eventChannel <- e
6868
}
6969

0 commit comments

Comments
 (0)