Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: set beelocal branch to update-k3s-1.30.3 and go 1.23 upgrade #4878

Merged
merged 10 commits into from
Nov 5, 2024
Prev Previous commit
Next Next commit
chore: fix linting issue that var is copied
  • Loading branch information
gacevicljubisa committed Oct 29, 2024
commit 79715bb800c74e70320ecc59fbf4aa00c043208b
3 changes: 1 addition & 2 deletions CODINGSTYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,10 @@ Use the Golang [testing package](https://pkg.go.dev/testing) from the standard l

### Parallel Test Execution

Run tests in parallel where possible but don't forget about variable scope gotchas.
Run tests in parallel where possible.

```go
for tc := range tt {
tc := tc // must not forget this
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
//execute
Expand Down
5 changes: 0 additions & 5 deletions pkg/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ func TestParseName(t *testing.T) {
s.Mount()
s.EnableFullAPI()

tC := tC
t.Run(tC.desc, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -453,7 +452,6 @@ func TestPostageHeaderError(t *testing.T) {
)
content := []byte{7: 0} // 8 zeros
for _, endpoint := range endpoints {
endpoint := endpoint
t.Run(endpoint+": empty batch", func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -538,7 +536,6 @@ func TestOptions(t *testing.T) {
expectedMethods: "GET, HEAD",
},
} {
tc := tc
t.Run(tc.endpoint+" options test", func(t *testing.T) {
t.Parallel()

Expand All @@ -555,8 +552,6 @@ func TestPostageDirectAndDeferred(t *testing.T) {
t.Parallel()

for _, endpoint := range []string{"bytes", "bzz", "chunks"} {
endpoint := endpoint

if endpoint != "chunks" {
t.Run(endpoint+" deferred", func(t *testing.T) {
t.Parallel()
Expand Down
3 changes: 0 additions & 3 deletions pkg/api/balances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ func TestConsumedBalances(t *testing.T) {
if !equalBalances(got, expected) {
t.Errorf("got balances: %v, expected: %v", got, expected)
}

}

func TestConsumedError(t *testing.T) {
Expand Down Expand Up @@ -328,7 +327,6 @@ func Test_peerBalanceHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -377,7 +375,6 @@ func Test_compensatedPeerBalanceHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
3 changes: 0 additions & 3 deletions pkg/api/bytes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ func TestBytesInvalidStamp(t *testing.T) {
jsonhttptest.WithRequestBody(bytes.NewReader(content)),
)
})

}

func TestBytesUploadHandlerInvalidInputs(t *testing.T) {
Expand Down Expand Up @@ -314,7 +313,6 @@ func TestBytesUploadHandlerInvalidInputs(t *testing.T) {
}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -364,7 +362,6 @@ func TestBytesGetHandlerInvalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
8 changes: 0 additions & 8 deletions pkg/api/bzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,8 @@ func TestBzzUploadDownloadWithRedundancy_FLAKY(t *testing.T) {
})
}
for _, rLevel := range []redundancy.Level{1, 2, 3, 4} {
rLevel := rLevel
t.Run(fmt.Sprintf("level=%d", rLevel), func(t *testing.T) {
for _, encrypt := range []bool{false, true} {
encrypt := encrypt
shardCnt := rLevel.GetMaxShards()
parityCnt := rLevel.GetParities(shardCnt)
if encrypt {
Expand All @@ -230,7 +228,6 @@ func TestBzzUploadDownloadWithRedundancy_FLAKY(t *testing.T) {
case 3:
chunkCnt = shardCnt*shardCnt + 1
}
levels := levels
t.Run(fmt.Sprintf("encrypt=%v levels=%d chunks=%d", encrypt, levels, chunkCnt), func(t *testing.T) {
if levels > 2 && (encrypt == (rLevel%2 == 1)) {
t.Skip("skipping to save time")
Expand Down Expand Up @@ -619,7 +616,6 @@ func TestBzzFilesRangeRequests(t *testing.T) {
}

for _, upload := range uploads {
upload := upload
t.Run(upload.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -886,7 +882,6 @@ func Test_bzzDownloadHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -934,7 +929,6 @@ func TestInvalidBzzParams(t *testing.T) {
jsonhttptest.WithRequestBody(tr),
jsonhttptest.WithRequestHeader(api.ContentTypeHeader, api.ContentTypeTar),
)

})

t.Run("batch exists", func(t *testing.T) {
Expand Down Expand Up @@ -962,7 +956,6 @@ func TestInvalidBzzParams(t *testing.T) {
jsonhttptest.WithRequestBody(tr),
jsonhttptest.WithRequestHeader(api.ContentTypeHeader, api.ContentTypeTar),
)

})

t.Run("batch not found", func(t *testing.T) {
Expand Down Expand Up @@ -1057,7 +1050,6 @@ func TestInvalidBzzParams(t *testing.T) {
address := "f30c0aa7e9e2a0ef4c9b1b750ebfeaeb7c7c24da700bb089da19a46e3677824b"
jsonhttptest.Request(t, client, http.MethodGet, fmt.Sprintf("/bzz/%s/", address), http.StatusNotFound)
})

}

// TestDirectUploadBzz tests that the direct upload endpoint give correct error message in dev mode
Expand Down
6 changes: 0 additions & 6 deletions pkg/api/chequebook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ func TestChequebookLastCheques(t *testing.T) {
if !LastChequesEqual(got, expected) {
t.Fatalf("Got: \n %+v \n\n Expected: \n %+v \n\n", got, expected)
}

}

func TestChequebookLastChequesPeer(t *testing.T) {
Expand All @@ -433,7 +432,6 @@ func TestChequebookLastChequesPeer(t *testing.T) {
sig := make([]byte, 65)

lastSentChequeFunc := func(swarm.Address) (*chequebook.SignedCheque, error) {

sig := make([]byte, 65)

lastSentCheque := &chequebook.SignedCheque{
Expand All @@ -449,7 +447,6 @@ func TestChequebookLastChequesPeer(t *testing.T) {
}

lastReceivedChequeFunc := func(swarm.Address) (*chequebook.SignedCheque, error) {

lastReceivedCheque := &chequebook.SignedCheque{
Cheque: chequebook.Cheque{
Beneficiary: beneficiary0,
Expand Down Expand Up @@ -488,7 +485,6 @@ func TestChequebookLastChequesPeer(t *testing.T) {
if !reflect.DeepEqual(got, expected) {
t.Fatalf("Got: \n %+v \n\n Expected: \n %+v \n\n", got, expected)
}

}

func TestChequebookCashout(t *testing.T) {
Expand Down Expand Up @@ -753,7 +749,6 @@ func Test_chequebookLastPeerHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -765,7 +760,6 @@ func Test_chequebookLastPeerHandler_invalidInputs(t *testing.T) {
}

func LastChequesEqual(a, b *api.ChequebookLastChequesResponse) bool {

var state bool

for akeys := range a.LastCheques {
Expand Down
1 change: 0 additions & 1 deletion pkg/api/chunk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func TestChunkHandlersInvalidInputs(t *testing.T) {

method := http.MethodGet
for _, tc := range tests {
tc := tc
t.Run(method+" "+tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
7 changes: 2 additions & 5 deletions pkg/api/cors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func TestCORSHeaders(t *testing.T) {
wantCORS: false,
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -116,7 +115,6 @@ func TestCORSHeaders(t *testing.T) {
}
})
}

}

// TestCors tests whether CORs work correctly with OPTIONS method
Expand All @@ -135,7 +133,8 @@ func TestCors(t *testing.T) {
{
endpoint: "bzz",
expectedMethods: "POST",
}, {
},
{
endpoint: "bzz/0101011",
expectedMethods: "GET, HEAD",
},
Expand All @@ -156,7 +155,6 @@ func TestCors(t *testing.T) {
expectedMethods: "GET, HEAD",
},
} {
tc := tc
t.Run(tc.endpoint, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -212,7 +210,6 @@ func TestCorsStatus(t *testing.T) {
allowedMethods: "GET, HEAD",
},
} {
tc := tc
t.Run(tc.endpoint, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions pkg/api/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func Test_loggerGetHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -244,7 +243,6 @@ func Test_loggerSetVerbosityHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
2 changes: 0 additions & 2 deletions pkg/api/peer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ func Test_peerConnectHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -289,7 +288,6 @@ func Test_peerDisconnectHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
4 changes: 0 additions & 4 deletions pkg/api/pin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ func TestPinHandlers(t *testing.T) {
rootHash = strings.Trim(header.Get(api.ETagHeader), "\"")
checkPinHandlers(t, client, rootHash, false)
})

}

func TestPinHandlersInvalidInputs(t *testing.T) {
Expand Down Expand Up @@ -177,9 +176,7 @@ func TestPinHandlersInvalidInputs(t *testing.T) {
}}

for _, method := range []string{http.MethodGet, http.MethodPost, http.MethodDelete} {
method := method
for _, tc := range tests {
tc := tc
t.Run(method+" "+tc.name, func(t *testing.T) {
t.Parallel()

Expand All @@ -194,7 +191,6 @@ func TestPinHandlersInvalidInputs(t *testing.T) {
const pinRef = "620fcd78c7ce54da2d1b7cc2274a02e190cbe8fecbc3bd244690ab6517ce8f39"

func TestIntegrityHandler(t *testing.T) {

t.Parallel()

t.Run("ok", func(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/api/pingpong_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ func Test_pingpongHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
8 changes: 1 addition & 7 deletions pkg/api/postage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ func TestPostageGetBuckets(t *testing.T) {

jsonhttptest.Request(t, tsNotFound, http.MethodGet, "/stamps/"+batchOkStr+"/buckets", http.StatusNotFound)
})

}

func TestReserveState(t *testing.T) {
Expand Down Expand Up @@ -397,6 +396,7 @@ func TestReserveState(t *testing.T) {
)
})
}

func TestChainState(t *testing.T) {
t.Parallel()

Expand All @@ -423,7 +423,6 @@ func TestChainState(t *testing.T) {
}),
)
})

}

func TestPostageTopUpStamp(t *testing.T) {
Expand Down Expand Up @@ -683,7 +682,6 @@ func TestPostageDiluteStamp(t *testing.T) {
TxHash: txHash.String(),
}),
)

})
}

Expand Down Expand Up @@ -770,8 +768,6 @@ func TestPostageAccessHandler(t *testing.T) {

for _, op1 := range success {
for _, op2 := range failure {
op1 := op1
op2 := op2
t.Run(op1.name+"-"+op2.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -914,7 +910,6 @@ func Test_postageGetStampBucketsHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -976,7 +971,6 @@ func Test_postageGetStampHandler_invalidInputs(t *testing.T) {
}}

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

Expand Down
Loading