Fix flakiness in VA test. (#2767)

When the VA validates a domain, it runs both CAA check and validation check in
parallel. If the validation check returns a failed result before the CAA check is done,
the VA returns immediately. However, the CAA check increments a stat. So there's
a flaky condition where, depending on the timing, that stat increment may or may
not get called on the MockScope. Add `.AnyTimes()` to our mock statements to
indicate we don't care whether Inc gets called.
This commit is contained in:
Jacob Hoffman-Andrews 2017-05-15 16:44:59 -07:00 committed by Roland Bracewell Shoemaker
parent e1bff721a7
commit 2d0734d35b
1 changed files with 2 additions and 2 deletions

View File

@ -869,7 +869,7 @@ func TestPerformValidationInvalid(t *testing.T) {
mockScope := mock_metrics.NewMockScope(ctrl)
va.stats = mockScope
mockScope.EXPECT().TimingDuration("Validations.dns-01.invalid", gomock.Any()).Return(nil)
mockScope.EXPECT().Inc(gomock.Any(), gomock.Any()).Return(nil)
mockScope.EXPECT().Inc(gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
chalDNS := createChallenge(core.ChallengeTypeDNS01)
_, prob := va.PerformValidation(context.Background(), "foo.com", chalDNS, core.Authorization{})
@ -903,7 +903,7 @@ func TestPerformValidationValid(t *testing.T) {
mockScope := mock_metrics.NewMockScope(ctrl)
va.stats = mockScope
mockScope.EXPECT().TimingDuration("Validations.dns-01.valid", gomock.Any()).Return(nil)
mockScope.EXPECT().Inc(gomock.Any(), gomock.Any()).Return(nil)
mockScope.EXPECT().Inc(gomock.Any(), gomock.Any()).Return(nil).AnyTimes()
// create a challenge with well known token
chalDNS := core.DNSChallenge01()