diff --git a/storage/sql_test.go b/storage/sql_test.go index ee99b988a..4199c91eb 100644 --- a/storage/sql_test.go +++ b/storage/sql_test.go @@ -18,8 +18,8 @@ import ( ) func TestSchemaIsCurrent(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) @@ -43,8 +43,8 @@ func TestSchemaIsCurrent(t *testing.T) { } func TestLeaseStateChanges(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) @@ -142,8 +142,8 @@ func TestLeaseStateChanges(t *testing.T) { } func TestMarkStateChangeComplete(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) @@ -237,8 +237,8 @@ func truncateVisorProcessingTables(tb testing.TB, db *pg.DB) { } func TestLeaseActors(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) @@ -345,8 +345,8 @@ func TestLeaseActors(t *testing.T) { } func TestMarkActorComplete(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) @@ -416,8 +416,8 @@ func TestMarkActorComplete(t *testing.T) { } func TestLeaseBlockMessages(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) @@ -515,8 +515,8 @@ func TestLeaseBlockMessages(t *testing.T) { } func TestMarkTipSetMessagesComplete(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) @@ -582,12 +582,11 @@ func TestMarkTipSetMessagesComplete(t *testing.T) { require.NoError(t, err) assert.Equal(t, 1, count) }) - } func TestLeaseGasOutputsMessages(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) @@ -785,8 +784,8 @@ func TestLeaseGasOutputsMessages(t *testing.T) { } func TestMarkGasOutputsMessagesComplete(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) @@ -852,5 +851,4 @@ func TestMarkGasOutputsMessagesComplete(t *testing.T) { require.NoError(t, err) assert.Equal(t, 1, count) }) - } diff --git a/tasks/actorstate/genesis_test.go b/tasks/actorstate/genesis_test.go index 42a45cc3a..0ff68a9c2 100644 --- a/tasks/actorstate/genesis_test.go +++ b/tasks/actorstate/genesis_test.go @@ -39,8 +39,8 @@ func init() { } func TestGenesisProcessor(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) @@ -122,7 +122,6 @@ func TestGenesisProcessor(t *testing.T) { require.NoError(t, err) assert.NotEqual(t, 0, count) }) - } // truncateGenesisTables ensures the indexing tables are empty diff --git a/tasks/indexer/chainheadindexer_test.go b/tasks/indexer/chainheadindexer_test.go index 2119e1d44..0d4dd880e 100644 --- a/tasks/indexer/chainheadindexer_test.go +++ b/tasks/indexer/chainheadindexer_test.go @@ -42,8 +42,8 @@ func init() { } func TestChainHeadIndexer(t *testing.T) { - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) @@ -159,7 +159,6 @@ func TestChainHeadIndexer(t *testing.T) { assert.True(t, exists, "tsk: %s", tsk) } }) - } type blockHeaderList []*types.BlockHeader diff --git a/tasks/indexer/chainhistoryindexer_test.go b/tasks/indexer/chainhistoryindexer_test.go index a87909eda..8ff30da3a 100644 --- a/tasks/indexer/chainhistoryindexer_test.go +++ b/tasks/indexer/chainhistoryindexer_test.go @@ -7,7 +7,6 @@ import ( apitest "github.com/filecoin-project/lotus/api/test" nodetest "github.com/filecoin-project/lotus/node/test" - logging "github.com/ipfs/go-log/v2" "github.com/go-pg/pg/v10" "github.com/stretchr/testify/assert" @@ -21,10 +20,8 @@ import ( ) func TestChainHistoryIndexer(t *testing.T) { - logging.SetLogLevel("*", "debug") - - if testing.Short() || !testutil.DatabaseAvailable() { - t.Skip("short testing requested or VISOR_TEST_DB not set") + if testing.Short() { + t.Skip("short testing requested") } ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) @@ -136,5 +133,4 @@ func TestChainHistoryIndexer(t *testing.T) { assert.True(t, exists, "tsk: %s", tsk) } }) - } diff --git a/testutil/db.go b/testutil/db.go index 43cf2f9e8..ada8d3aa7 100644 --- a/testutil/db.go +++ b/testutil/db.go @@ -28,7 +28,7 @@ func Database() string { // WaitForExclusiveDatabase waits for exclusive access to the test database until the context is done or the // exclusive access is granted. It returns a cleanup function that should be called to close the database connection. func WaitForExclusiveDatabase(ctx context.Context, tb testing.TB) (*pg.DB, func() error, error) { - require.NotEmpty(tb, testDatabase, "set VISOR_TEST_DB") + require.NotEmpty(tb, testDatabase, "No test database available: VISOR_TEST_DB not set") opt, err := pg.ParseURL(testDatabase) require.NoError(tb, err) @@ -50,8 +50,10 @@ func WaitForExclusiveDatabase(ctx context.Context, tb testing.TB) (*pg.DB, func( return db, cleanup, nil } -const testDatabaseLockID = 88899888 -const testDatabaseLockCheckInterval = 2 * time.Millisecond +const ( + testDatabaseLockID = 88899888 + testDatabaseLockCheckInterval = 2 * time.Millisecond +) // WaitForExclusiveDatabaseLock waits for a an exclusive lock on the test database until the context is done or the // exclusive access is granted. It returns a cleanup function that should be called to release the exclusive lock. In any