Skip to content

Commit

Permalink
core: parallelize some tests to speed up suite (#14976)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmank88 authored Oct 29, 2024
1 parent 63e3cf0 commit b6937e9
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/capabilities/compute/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
)

func TestCache(t *testing.T) {
t.Parallel()
clock := clockwork.NewFakeClock()
tick := 1 * time.Second
timeout := 1 * time.Second
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions core/capabilities/compute/compute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down Expand Up @@ -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)))
Expand Down Expand Up @@ -176,6 +178,7 @@ func TestComputeExecute(t *testing.T) {
}

func TestComputeFetch(t *testing.T) {
t.Parallel()
workflowID := "15c631d295ef5e32deb99a10ee6804bc4af13855687559d7ff6552ac6dbb2ce0"
workflowExecutionID := "95ef5e32deb99a10ee6804bc4af13855687559d7ff6552ac6dbb2ce0abbadeed"
th := setup(t, defaultConfig)
Expand Down
3 changes: 3 additions & 0 deletions core/services/gateway/network/httpserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()

Expand All @@ -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()

Expand Down
1 change: 1 addition & 0 deletions core/services/gateway/network/wsconnection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down
3 changes: 3 additions & 0 deletions core/services/gateway/network/wsserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()

Expand All @@ -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()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type attestationResponse struct {
}

func TestUSDCReader_ReadTokenData(t *testing.T) {
t.Parallel()
tests := []struct {
name string
attestationResponse attestationResponse
Expand Down
5 changes: 5 additions & 0 deletions core/services/ocr2/plugins/ccip/tokendata/usdc/usdc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func TestUSDCReader_callAttestationApi(t *testing.T) {
}

func TestUSDCReader_callAttestationApiMock(t *testing.T) {
t.Parallel()
response := attestationResponse{
Status: attestationStatusSuccess,
Attestation: "720502893578a89a8a87982982ef781c18b193",
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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)
Expand All @@ -251,6 +254,7 @@ func TestGetUSDCMessageBody(t *testing.T) {
}

func TestTokenDataReader_getUsdcTokenEndOffset(t *testing.T) {
t.Parallel()
usdcToken := utils.RandomAddress()
nonUsdcToken := utils.RandomAddress()

Expand Down Expand Up @@ -303,6 +307,7 @@ func TestTokenDataReader_getUsdcTokenEndOffset(t *testing.T) {
}

func TestUSDCReader_rateLimiting(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
requests uint64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit b6937e9

Please sign in to comment.