From 87f7bb475c0b3eaef64828543b6c48e5dfdb3fcd Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Wed, 20 Jan 2021 10:58:27 -0500 Subject: [PATCH] Fix flaky test by marking mock expectations as optional (#9596) These expectations are optional because in a slow CI environment the deadline to cancell the context might occur before the go routine reaches issuing the RPC. Either way we are successfully ensuring context cancellation is working. --- agent/auto-config/auto_config_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/auto-config/auto_config_test.go b/agent/auto-config/auto_config_test.go index e3469862a4..71421a01ba 100644 --- a/agent/auto-config/auto_config_test.go +++ b/agent/auto-config/auto_config_test.go @@ -248,8 +248,8 @@ func TestInitialConfiguration_cancelled(t *testing.T) { JWT: "blarg", } - mcfg.directRPC.On("RPC", "dc1", "autoconf", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 8300}, "AutoConfig.InitialConfiguration", &expectedRequest, mock.Anything).Return(fmt.Errorf("injected error")).Times(0) - mcfg.serverProvider.On("FindLANServer").Return(nil).Times(0) + mcfg.directRPC.On("RPC", "dc1", "autoconf", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1), Port: 8300}, "AutoConfig.InitialConfiguration", &expectedRequest, mock.Anything).Return(fmt.Errorf("injected error")).Times(0).Maybe() + mcfg.serverProvider.On("FindLANServer").Return(nil).Times(0).Maybe() ac, err := New(mcfg.Config) require.NoError(t, err)