From 2a86989b0770f563a574e8313e74f972d85046a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Th=C3=B6mmes?= Date: Mon, 13 Jul 2020 08:46:45 +0200 Subject: [PATCH] Make sorting consistent in GC test. One of the tests ("keep recent lastPinned") failed fairly often because it used two revisions with the same LastPinned timestamp. Sorting a slice is unstable so in a lot of occasions, the given order was flipped and revision 5555 was tried to be deleted, even though it shouldn't even have been considered to be deleted. Note: sort.SliceStable doesn't help because the incoming list's order is already non-consistent. --- pkg/reconciler/gc/v2/gc_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/reconciler/gc/v2/gc_test.go b/pkg/reconciler/gc/v2/gc_test.go index d48a745a4537..9a77c167722f 100644 --- a/pkg/reconciler/gc/v2/gc_test.go +++ b/pkg/reconciler/gc/v2/gc_test.go @@ -54,6 +54,7 @@ var revisionSpec = v1.RevisionSpec{ func TestCollect(t *testing.T) { now := time.Now() + nineMinutesAgo := now.Add(-9 * time.Minute) tenMinutesAgo := now.Add(-10 * time.Minute) old := now.Add(-11 * time.Minute) @@ -164,7 +165,7 @@ func TestCollect(t *testing.T) { rev("keep-recent-last-pinned", "foo", 5555, MarkRevisionReady, WithRevName("5555"), WithCreationTimestamp(older), - WithLastPinned(tenMinutesAgo)), + WithLastPinned(nineMinutesAgo)), rev("keep-recent-last-pinned", "foo", 5556, MarkRevisionReady, WithRevName("5556"), WithCreationTimestamp(old),