From b6937e9482a05fd53e3c5b8195fd54100e7f4da4 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Tue, 29 Oct 2024 18:40:57 -0500 Subject: [PATCH] core: parallelize some tests to speed up suite (#14976) --- core/capabilities/compute/cache_test.go | 2 ++ core/capabilities/compute/compute_test.go | 3 +++ core/services/gateway/network/httpserver_test.go | 3 +++ core/services/gateway/network/wsconnection_test.go | 1 + core/services/gateway/network/wsserver_test.go | 3 +++ .../ocr2/plugins/ccip/tokendata/usdc/usdc_blackbox_test.go | 1 + core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go | 5 +++++ .../evmregistry/v21/mercury/v02/v02_request_test.go | 2 ++ .../evmregistry/v21/mercury/v03/v03_request_test.go | 1 + 9 files changed, 21 insertions(+) diff --git a/core/capabilities/compute/cache_test.go b/core/capabilities/compute/cache_test.go index 358eb37f4e3..3b38cc23001 100644 --- a/core/capabilities/compute/cache_test.go +++ b/core/capabilities/compute/cache_test.go @@ -21,6 +21,7 @@ const ( ) func TestCache(t *testing.T) { + t.Parallel() clock := clockwork.NewFakeClock() tick := 1 * time.Second timeout := 1 * time.Second @@ -55,6 +56,7 @@ func TestCache(t *testing.T) { } func TestCache_EvictAfterSize(t *testing.T) { + t.Parallel() ctx := tests.Context(t) clock := clockwork.NewFakeClock() tick := 1 * time.Second diff --git a/core/capabilities/compute/compute_test.go b/core/capabilities/compute/compute_test.go index b88e5694a8a..ec82533f2bb 100644 --- a/core/capabilities/compute/compute_test.go +++ b/core/capabilities/compute/compute_test.go @@ -82,6 +82,7 @@ func TestComputeStartAddsToRegistry(t *testing.T) { } func TestComputeExecuteMissingConfig(t *testing.T) { + t.Parallel() th := setup(t, defaultConfig) require.NoError(t, th.compute.Start(tests.Context(t))) @@ -123,6 +124,7 @@ func TestComputeExecuteMissingBinary(t *testing.T) { } func TestComputeExecute(t *testing.T) { + t.Parallel() th := setup(t, defaultConfig) require.NoError(t, th.compute.Start(tests.Context(t))) @@ -176,6 +178,7 @@ func TestComputeExecute(t *testing.T) { } func TestComputeFetch(t *testing.T) { + t.Parallel() workflowID := "15c631d295ef5e32deb99a10ee6804bc4af13855687559d7ff6552ac6dbb2ce0" workflowExecutionID := "95ef5e32deb99a10ee6804bc4af13855687559d7ff6552ac6dbb2ce0abbadeed" th := setup(t, defaultConfig) diff --git a/core/services/gateway/network/httpserver_test.go b/core/services/gateway/network/httpserver_test.go index dac00df2a12..2d85f3d583e 100644 --- a/core/services/gateway/network/httpserver_test.go +++ b/core/services/gateway/network/httpserver_test.go @@ -56,6 +56,7 @@ func sendRequest(t *testing.T, url string, body []byte) *http.Response { } func TestHTTPServer_HandleRequest_Correct(t *testing.T) { + t.Parallel() server, handler, url := startNewServer(t, 100_000, 100_000) defer server.Close() @@ -69,6 +70,7 @@ func TestHTTPServer_HandleRequest_Correct(t *testing.T) { } func TestHTTPServer_HandleRequest_RequestBodyTooBig(t *testing.T) { + t.Parallel() server, _, url := startNewServer(t, 5, 100_000) defer server.Close() @@ -77,6 +79,7 @@ func TestHTTPServer_HandleRequest_RequestBodyTooBig(t *testing.T) { } func TestHTTPServer_HandleHealthCheck(t *testing.T) { + t.Parallel() server, _, url := startNewServer(t, 100_000, 100_000) defer server.Close() diff --git a/core/services/gateway/network/wsconnection_test.go b/core/services/gateway/network/wsconnection_test.go index 4ded4f40b10..01a47313dfd 100644 --- a/core/services/gateway/network/wsconnection_test.go +++ b/core/services/gateway/network/wsconnection_test.go @@ -31,6 +31,7 @@ func (ssl *serverSideLogic) wsHandler(w http.ResponseWriter, r *http.Request) { } func TestWSConnectionWrapper_ClientReconnect(t *testing.T) { + t.Parallel() lggr := logger.TestLogger(t) // server ssl := &serverSideLogic{connWrapper: network.NewWSConnectionWrapper(lggr)} diff --git a/core/services/gateway/network/wsserver_test.go b/core/services/gateway/network/wsserver_test.go index 0b24dbe6614..6b50afe0c1f 100644 --- a/core/services/gateway/network/wsserver_test.go +++ b/core/services/gateway/network/wsserver_test.go @@ -60,6 +60,7 @@ func sendRequestWithHeader(t *testing.T, url string, headerName string, headerVa } func TestWSServer_HandleRequest_AuthHeaderTooBig(t *testing.T) { + t.Parallel() server, _, url := startNewWSServer(t, 100_000) defer server.Close() @@ -73,6 +74,7 @@ func TestWSServer_HandleRequest_AuthHeaderTooBig(t *testing.T) { } func TestWSServer_HandleRequest_AuthHeaderIncorrectlyBase64Encoded(t *testing.T) { + t.Parallel() server, _, url := startNewWSServer(t, 100_000) defer server.Close() @@ -81,6 +83,7 @@ func TestWSServer_HandleRequest_AuthHeaderIncorrectlyBase64Encoded(t *testing.T) } func TestWSServer_HandleRequest_AuthHeaderInvalid(t *testing.T) { + t.Parallel() server, acceptor, url := startNewWSServer(t, 100_000) defer server.Close() diff --git a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_blackbox_test.go b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_blackbox_test.go index 95b309ff74e..fd18d0a2b93 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_blackbox_test.go +++ b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_blackbox_test.go @@ -29,6 +29,7 @@ type attestationResponse struct { } func TestUSDCReader_ReadTokenData(t *testing.T) { + t.Parallel() tests := []struct { name string attestationResponse attestationResponse diff --git a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go index c4221b2dc0f..4210ecf75ea 100644 --- a/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go +++ b/core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go @@ -51,6 +51,7 @@ func TestUSDCReader_callAttestationApi(t *testing.T) { } func TestUSDCReader_callAttestationApiMock(t *testing.T) { + t.Parallel() response := attestationResponse{ Status: attestationStatusSuccess, Attestation: "720502893578a89a8a87982982ef781c18b193", @@ -186,6 +187,7 @@ func TestUSDCReader_callAttestationApiMockError(t *testing.T) { for _, test := range tests { t.Run(test.name, func(t *testing.T) { + t.Parallel() ts := test.getTs() defer ts.Close() @@ -225,6 +227,7 @@ func getMockUSDCEndpoint(t *testing.T, response attestationResponse) *httptest.S } func TestGetUSDCMessageBody(t *testing.T) { + t.Parallel() expectedBody := []byte("0x0000000000000001000000020000000000048d71000000000000000000000000eb08f243e5d3fcff26a9e38ae5520a669f4019d000000000000000000000000023a04d5935ed8bc8e3eb78db3541f0abfb001c6e0000000000000000000000006cb3ed9b441eb674b58495c8b3324b59faff5243000000000000000000000000000000005425890298aed601595a70ab815c96711a31bc65000000000000000000000000ab4f961939bfe6a93567cc57c59eed7084ce2131000000000000000000000000000000000000000000000000000000000000271000000000000000000000000035e08285cfed1ef159236728f843286c55fc0861") usdcReader := ccipdatamocks.USDCReader{} usdcReader.On("GetUSDCMessagePriorToLogIndexInTx", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(expectedBody, nil) @@ -251,6 +254,7 @@ func TestGetUSDCMessageBody(t *testing.T) { } func TestTokenDataReader_getUsdcTokenEndOffset(t *testing.T) { + t.Parallel() usdcToken := utils.RandomAddress() nonUsdcToken := utils.RandomAddress() @@ -303,6 +307,7 @@ func TestTokenDataReader_getUsdcTokenEndOffset(t *testing.T) { } func TestUSDCReader_rateLimiting(t *testing.T) { + t.Parallel() testCases := []struct { name string requests uint64 diff --git a/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/v02/v02_request_test.go b/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/v02/v02_request_test.go index 8fc55abc7e7..2abe9c9717a 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/v02/v02_request_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/v02/v02_request_test.go @@ -312,6 +312,7 @@ func TestV02_SingleFeedRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() c := setupClient(t) defer c.Close() hc := new(MockHttpClient) @@ -583,6 +584,7 @@ func TestV02_DoMercuryRequestV02(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() c := setupClient(t) defer c.Close() if tt.pluginRetries != 0 { diff --git a/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/v03/v03_request_test.go b/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/v03/v03_request_test.go index cce00646aeb..022fd8a1e46 100644 --- a/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/v03/v03_request_test.go +++ b/core/services/ocr2/plugins/ocr2keeper/evmregistry/v21/mercury/v03/v03_request_test.go @@ -818,6 +818,7 @@ func TestV03_MultiFeedRequest(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { + t.Parallel() c := setupClient(t) defer c.Close() if tt.pluginRetries != 0 {