Skip to content

Commit e78ca44

Browse files
authored
tests: add more logging around problematic test timeout (#3718)
Trying to figure out why this test keeps timing out.
1 parent f3e7008 commit e78ca44

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

porch/test/e2e/suite.go

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,27 +195,53 @@ func (c *TestSuite) list(ctx context.Context, list client.ObjectList, opts []cli
195195
}
196196
}
197197

198+
func DebugFormat(obj client.Object) string {
199+
var s string
200+
gvk := obj.GetObjectKind().GroupVersionKind()
201+
if gvk.Empty() {
202+
s = fmt.Sprintf("%T", obj)
203+
} else {
204+
s = gvk.Kind
205+
}
206+
ns := obj.GetNamespace()
207+
if ns != "" {
208+
s += " " + ns + "/"
209+
} else {
210+
s += " "
211+
}
212+
s += obj.GetName()
213+
return s
214+
}
215+
198216
func (c *TestSuite) create(ctx context.Context, obj client.Object, opts []client.CreateOption, eh ErrorHandler) {
217+
c.Logf("creating object %v", DebugFormat(obj))
218+
199219
if err := c.client.Create(ctx, obj, opts...); err != nil {
200-
eh("failed to create resource %s %s/%s: %v", obj.GetObjectKind().GroupVersionKind(), obj.GetNamespace(), obj.GetName(), err)
220+
eh("failed to create resource %s: %v", DebugFormat(obj), err)
201221
}
202222
}
203223

204224
func (c *TestSuite) delete(ctx context.Context, obj client.Object, opts []client.DeleteOption, eh ErrorHandler) {
225+
c.Logf("deleting object %v", DebugFormat(obj))
226+
205227
if err := c.client.Delete(ctx, obj, opts...); err != nil {
206-
eh("failed to delete resource %s %s/%s: %v", obj.GetObjectKind().GroupVersionKind(), obj.GetNamespace(), obj.GetName(), err)
228+
eh("failed to delete resource %s: %v", DebugFormat(obj), err)
207229
}
208230
}
209231

210232
func (t *TestSuite) update(ctx context.Context, obj client.Object, opts []client.UpdateOption, eh ErrorHandler) {
233+
t.Logf("updating object %v", DebugFormat(obj))
234+
211235
if err := t.client.Update(ctx, obj, opts...); err != nil {
212-
eh("failed to update resource %s %s/%s: %v", obj.GetObjectKind().GroupVersionKind(), obj.GetNamespace(), obj.GetName(), err)
236+
eh("failed to update resource %s: %v", DebugFormat(obj), err)
213237
}
214238
}
215239

216240
func (t *TestSuite) patch(ctx context.Context, obj client.Object, patch client.Patch, opts []client.PatchOption, eh ErrorHandler) {
241+
t.Logf("patching object %v", DebugFormat(obj))
242+
217243
if err := t.client.Patch(ctx, obj, patch, opts...); err != nil {
218-
eh("failed to patch resource %s %s/%s: %v", obj.GetObjectKind().GroupVersionKind(), obj.GetNamespace(), obj.GetName(), err)
244+
eh("failed to patch resource %s: %v", DebugFormat(obj), err)
219245
}
220246
}
221247

0 commit comments

Comments
 (0)