Skip to content

Commit

Permalink
Retain improvements made in #4981 PR that had been reverted due to in…
Browse files Browse the repository at this point in the history
…stability. the changes here should net improve test reliability and rationale for why several are not marked parallel.
  • Loading branch information
gmalouf committed Jan 10, 2023
1 parent 63f05c6 commit 415ccc2
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
16 changes: 8 additions & 8 deletions data/account/participationRegistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -738,15 +738,15 @@ func TestParticipion_Blobs(t *testing.T) {
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("writetest_root", false, true)
access, err := db.MakeAccessor(t.Name()+"_writetest_root", false, true)
if err != nil {
panic(err)
}
root, err := GenerateRoot(access)
access.Close()
a.NoError(err)

access, err = db.MakeAccessor("writetest", false, true)
access, err = db.MakeAccessor(t.Name()+"_writetest", false, true)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -781,15 +781,15 @@ func TestParticipion_EmptyBlobs(t *testing.T) {
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("writetest_root", false, true)
access, err := db.MakeAccessor(t.Name()+"_writetest_root", false, true)
if err != nil {
panic(err)
}
root, err := GenerateRoot(access)
access.Close()
a.NoError(err)

access, err = db.MakeAccessor("writetest", false, true)
access, err = db.MakeAccessor(t.Name()+"_writetest", false, true)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -963,7 +963,7 @@ func TestGetRoundSecretsWithNilStateProofVerifier(t *testing.T) {
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("stateprooftest", false, true)
access, err := db.MakeAccessor(t.Name()+"_stateprooftest", false, true)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -1012,7 +1012,7 @@ func TestAddingSecretTwice(t *testing.T) {
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("stateprooftest", false, true)
access, err := db.MakeAccessor(t.Name()+"_stateprooftest", false, true)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -1050,7 +1050,7 @@ func TestGetRoundSecretsWithoutStateProof(t *testing.T) {
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("stateprooftest", false, true)
access, err := db.MakeAccessor(t.Name()+"_stateprooftest", false, true)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -1177,7 +1177,7 @@ func TestFlushResetsLastError(t *testing.T) {
registry, dbfile := getRegistry(t)
defer registryCloseTest(t, registry, dbfile)

access, err := db.MakeAccessor("stateprooftest", false, true)
access, err := db.MakeAccessor(t.Name()+"_stateprooftest", false, true)
a.NoError(err)

root, err := GenerateRoot(access)
Expand Down
2 changes: 1 addition & 1 deletion data/account/participation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ func TestFillDBWithParticipationKeys(t *testing.T) {
a.NoError(err)
}

func TestKeyregValidityPeriod(t *testing.T) {
func TestKeyregValidityPeriod(t *testing.T) { //nolint:paralleltest // Not parallel because it modifies config.Consensus
partitiontest.PartitionTest(t)
a := require.New(t)

Expand Down
2 changes: 1 addition & 1 deletion data/bookkeeping/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func TestMakeBlockUpgrades(t *testing.T) {
require.Equal(t, bd2.NextProtocolSwitchOn-bd2.NextProtocolVoteBefore, basics.Round(5))
}

func TestBlockUnsupported(t *testing.T) {
func TestBlockUnsupported(t *testing.T) { //nolint:paralleltest // Not parallel because it modifies config.Consensus
partitiontest.PartitionTest(t)

var b Block
Expand Down
6 changes: 6 additions & 0 deletions data/transactions/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/algorand/go-algorand/data/transactions"
"github.com/algorand/go-algorand/data/txntest"
"github.com/algorand/go-algorand/protocol"
"github.com/algorand/go-algorand/test/partitiontest"
"github.com/stretchr/testify/require"
)

Expand All @@ -45,6 +46,8 @@ func compact(data []byte) string {

// TestJsonMarshal ensures that BoxRef names are b64 encoded, since they may not be characters.
func TestJsonMarshal(t *testing.T) {
partitiontest.PartitionTest(t)

marshal := protocol.EncodeJSON(transactions.BoxRef{Index: 4, Name: []byte("joe")})
require.Equal(t, `{"i":4,"n":"am9l"}`, compact(marshal))

Expand All @@ -60,6 +63,7 @@ func TestJsonMarshal(t *testing.T) {

// TestJsonUnmarshal ensures that BoxRef unmarshaling expects b64 names
func TestJsonUnmarshal(t *testing.T) {
partitiontest.PartitionTest(t)
var br transactions.BoxRef

decode(t, `{"i":4,"n":"am9l"}`, &br)
Expand All @@ -82,6 +86,8 @@ func TestJsonUnmarshal(t *testing.T) {
// encoded. These things could change without breaking the protocol, should stay
// the same for the sake of REST API compatibility.
func TestTxnJson(t *testing.T) {
partitiontest.PartitionTest(t)

txn := txntest.Txn{
Sender: basics.Address{0x01, 0x02, 0x03},
}
Expand Down
9 changes: 6 additions & 3 deletions data/transactions/verify/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ func TestTxnValidationEmptySig(t *testing.T) {

const spProto = protocol.ConsensusVersion("test-state-proof-enabled")

func TestTxnValidationStateProof(t *testing.T) {
func TestTxnValidationStateProof(t *testing.T) { //nolint:paralleltest // Not parallel because it modifies config.Consensus
partitiontest.PartitionTest(t)

proto := config.Consensus[protocol.ConsensusCurrentVersion]
Expand Down Expand Up @@ -1195,7 +1195,7 @@ byte base64 5rZMNsevs5sULO+54aN+OvU6lQ503z2X+SSYUABIx7E=
}

// TestStreamVerifierPoolShutdown tests what happens when the exec pool shuts down
func TestStreamVerifierPoolShutdown(t *testing.T) {
func TestStreamVerifierPoolShutdown(t *testing.T) { //nolint:paralleltest // Not parallel because it depends on the default logger
partitiontest.PartitionTest(t)

// only one transaction should be sufficient for the batch verifier
Expand Down Expand Up @@ -1350,6 +1350,7 @@ func TestStreamVerifierRestart(t *testing.T) {

// TestBlockWatcher runs multiple goroutines to check the concurency and correctness of the block watcher
func TestStreamVerifierBlockWatcher(t *testing.T) {
partitiontest.PartitionTest(t)
blkHdr := createDummyBlockHeader()
nbw := MakeNewBlockWatcher(blkHdr)
startingRound := blkHdr.Round
Expand Down Expand Up @@ -1458,7 +1459,7 @@ func TestStreamVerifierCtxCancel(t *testing.T) {
// so that the batch is sent to the pool. Since the pool is saturated,
// the task will be stuck waiting to be queued when the context is canceled
// everything should be gracefully terminated
func TestStreamVerifierCtxCancelPoolQueue(t *testing.T) {
func TestStreamVerifierCtxCancelPoolQueue(t *testing.T) { //nolint:paralleltest // Not parallel because it depends on the default logger
partitiontest.PartitionTest(t)

verificationPool, holdTasks := getSaturatedExecPool(t)
Expand Down Expand Up @@ -1537,6 +1538,7 @@ func TestStreamVerifierCtxCancelPoolQueue(t *testing.T) {
// TestStreamVerifierPostVBlocked tests the behavior when the return channel (result chan) of verified
// transactions is blocked, and checks droppedFromPool counter to confirm the drops
func TestStreamVerifierPostVBlocked(t *testing.T) {
partitiontest.PartitionTest(t)

// prepare the stream verifier
verificationPool := execpool.MakeBacklog(nil, 0, execpool.LowPriority, t)
Expand Down Expand Up @@ -1622,6 +1624,7 @@ func TestStreamVerifierPostVBlocked(t *testing.T) {
}

func TestStreamVerifierMakeStreamVerifierErr(t *testing.T) {
partitiontest.PartitionTest(t)
_, err := MakeStreamVerifier(nil, nil, nil, &DummyLedgerForSignature{badHdr: true}, nil, nil)
require.Error(t, err)
}
Expand Down
18 changes: 10 additions & 8 deletions data/txHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1109,23 +1109,23 @@ func BenchmarkTxHandlerDecoderMsgp(b *testing.B) {
}

// TestTxHandlerIncomingTxHandle checks the correctness with single txns
func TestTxHandlerIncomingTxHandle(t *testing.T) {
func TestTxHandlerIncomingTxHandle(t *testing.T) { //nolint:paralleltest // Not parallel because incomingTxHandlerProcessing mutates global metrics
partitiontest.PartitionTest(t)

numberOfTransactionGroups := 1000
incomingTxHandlerProcessing(1, numberOfTransactionGroups, t)
}

// TestTxHandlerIncomingTxGroupHandle checks the correctness with txn groups
func TestTxHandlerIncomingTxGroupHandle(t *testing.T) {
func TestTxHandlerIncomingTxGroupHandle(t *testing.T) { //nolint:paralleltest // Not parallel because incomingTxHandlerProcessing mutates global metrics
partitiontest.PartitionTest(t)

numberOfTransactionGroups := 1000 / proto.MaxTxGroupSize
incomingTxHandlerProcessing(proto.MaxTxGroupSize, numberOfTransactionGroups, t)
}

// TestTxHandlerIncomingTxHandleDrops accounts for the dropped txns when the verifier/exec pool is saturated
func TestTxHandlerIncomingTxHandleDrops(t *testing.T) {
func TestTxHandlerIncomingTxHandleDrops(t *testing.T) { //nolint:paralleltest // Not parallel because it changes the backlog size
partitiontest.PartitionTest(t)

// use smaller backlog size to test the message drops
Expand Down Expand Up @@ -1903,7 +1903,7 @@ func runHandlerBenchmarkWithBacklog(b *testing.B, txGen txGenIf, tps int, useBac
handler.Stop() // cancel the handler ctx
}

func TestTxHandlerPostProcessError(t *testing.T) {
func TestTxHandlerPostProcessError(t *testing.T) { //nolint:paralleltest // Not parallel because it mutates global metrics
partitiontest.PartitionTest(t)

defer func() {
Expand Down Expand Up @@ -1975,7 +1975,7 @@ func TestTxHandlerPostProcessError(t *testing.T) {
require.Len(t, result, expected+1)
}

func TestTxHandlerPostProcessErrorWithVerify(t *testing.T) {
func TestTxHandlerPostProcessErrorWithVerify(t *testing.T) { //nolint:paralleltest // Not parallel because it mutates global metrics
partitiontest.PartitionTest(t)

defer func() {
Expand Down Expand Up @@ -2006,7 +2006,7 @@ func TestTxHandlerPostProcessErrorWithVerify(t *testing.T) {
}

// TestTxHandlerRememberReportErrors checks Is and As statements work as expected
func TestTxHandlerRememberReportErrors(t *testing.T) {
func TestTxHandlerRememberReportErrors(t *testing.T) { //nolint:paralleltest // Not parallel because incomingTxHandlerProcessing mutates global metrics
partitiontest.PartitionTest(t)

defer func() {
Expand Down Expand Up @@ -2079,7 +2079,7 @@ func (t *blockTicker) Wait() {
}
}

func TestTxHandlerRememberReportErrorsWithTxPool(t *testing.T) {
func TestTxHandlerRememberReportErrorsWithTxPool(t *testing.T) { //nolint:paralleltest // Not parallel because it mutates global metrics
partitiontest.PartitionTest(t)
defer func() {
transactionMessageTxPoolRememberCounter = metrics.NewTagCounter(
Expand Down Expand Up @@ -2311,6 +2311,7 @@ func TestTxHandlerRememberReportErrorsWithTxPool(t *testing.T) {
}

func TestMakeTxHandlerErrors(t *testing.T) {
partitiontest.PartitionTest(t)
opts := TxHandlerOpts{
nil, nil, nil, &mocks.MockNetwork{}, "", crypto.Digest{}, config.Local{},
}
Expand All @@ -2330,7 +2331,8 @@ func TestMakeTxHandlerErrors(t *testing.T) {
// TestTxHandlerRestartWithBacklogAndTxPool starts txHandler, sends transactions,
// stops, starts in a loop, sends more transactions, and makes sure all the transactions
// are accounted for. It uses the production backlog worker
func TestTxHandlerRestartWithBacklogAndTxPool(t *testing.T) {
func TestTxHandlerRestartWithBacklogAndTxPool(t *testing.T) { //nolint:paralleltest // Not parallel because it mutates global metrics
partitiontest.PartitionTest(t)
transactionMessagesDroppedFromBacklog = metrics.MakeCounter(metrics.TransactionMessagesDroppedFromBacklog)
transactionMessagesDroppedFromPool = metrics.MakeCounter(metrics.TransactionMessagesDroppedFromPool)
transactionMessagesTxnSigVerificationFailed = metrics.MakeCounter(metrics.TransactionMessagesTxnSigVerificationFailed)
Expand Down

0 comments on commit 415ccc2

Please sign in to comment.