From dd96d35c1b251a7ef77f057fc5c4f92ea2b285b4 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Thu, 9 Feb 2017 10:56:04 -0800 Subject: [PATCH] ocsp: fix test flakiness The test was assuming that the OCSP creation wouldn't cross a minute boundary, which is flakey nonsense. Instead assert that the timestamp in the OCSP response is within an hour of when we check it. Change-Id: I3c822b738e9b04385319eb29a1cd275dc2ed112e Reviewed-on: https://go-review.googlesource.com/36648 Reviewed-by: Brad Fitzpatrick Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- ocsp/ocsp_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ocsp/ocsp_test.go b/ocsp/ocsp_test.go index a3c8986..d325d85 100644 --- a/ocsp/ocsp_test.go +++ b/ocsp/ocsp_test.go @@ -225,7 +225,6 @@ func TestOCSPResponse(t *testing.T) { }, } - producedAt := time.Now().Truncate(time.Minute) thisUpdate := time.Date(2010, 7, 7, 15, 1, 5, 0, time.UTC) nextUpdate := time.Date(2010, 7, 7, 18, 35, 17, 0, time.UTC) template := Response{ @@ -284,8 +283,9 @@ func TestOCSPResponse(t *testing.T) { t.Errorf("resp.Extensions: got %v, want %v", resp.Extensions, template.ExtraExtensions) } - if !resp.ProducedAt.Equal(producedAt) { - t.Errorf("resp.ProducedAt: got %d, want %d", resp.ProducedAt, producedAt) + delay := time.Since(resp.ProducedAt) + if delay < -time.Hour || delay > time.Hour { + t.Errorf("resp.ProducedAt: got %s, want close to current time (%s)", resp.ProducedAt, time.Now()) } if resp.Status != template.Status {