Run test in parallel
diff --git a/batch_test.go b/batch_test.go index cc2a121..998d66f 100644 --- a/batch_test.go +++ b/batch_test.go
@@ -70,11 +70,15 @@ require.NoError(t, err) } t.Run("disk mode", func(t *testing.T) { + t.Parallel() + runBadgerTest(t, nil, func(t *testing.T, db *DB) { test(t, db) }) }) t.Run("InMemory mode", func(t *testing.T) { + t.Parallel() + opt := getTestOptions("") opt.InMemory = true db, err := Open(opt) @@ -87,6 +91,8 @@ // This test ensures we don't end up in deadlock in case of empty writebatch. func TestEmptyWriteBatch(t *testing.T) { t.Run("normal mode", func(t *testing.T) { + t.Parallel() + runBadgerTest(t, nil, func(t *testing.T, db *DB) { wb := db.NewWriteBatch() require.NoError(t, wb.Flush()) @@ -97,6 +103,8 @@ }) }) t.Run("managed mode", func(t *testing.T) { + t.Parallel() + opt := getTestOptions("") opt.managedTxns = true runBadgerTest(t, &opt, func(t *testing.T, db *DB) {
diff --git a/db2_test.go b/db2_test.go index 7fa57b1..549a079 100644 --- a/db2_test.go +++ b/db2_test.go
@@ -437,11 +437,15 @@ } } t.Run("disk mode", func(t *testing.T) { + t.Parallel() + runBadgerTest(t, &opts, func(t *testing.T, db *DB) { test(t, db) }) }) t.Run("InMemory mode", func(t *testing.T) { + t.Parallel() + opts.InMemory = true opts.Dir = "" opts.ValueDir = "" @@ -583,6 +587,8 @@ } t.Run("Test Read Again Plain Text", func(t *testing.T) { + t.Parallel() + opt := getTestOptions("") // Forcing to read from vlog opt.ValueThreshold = 1 @@ -593,6 +599,8 @@ }) t.Run("Test Read Again Encryption", func(t *testing.T) { + t.Parallel() + opt := getTestOptions("") opt.ValueThreshold = 1 // Generate encryption key.
diff --git a/db_test.go b/db_test.go index 95ccdf3..f8df2fb 100644 --- a/db_test.go +++ b/db_test.go
@@ -276,11 +276,15 @@ txn.Discard() } t.Run("disk mode", func(t *testing.T) { + t.Parallel() + runBadgerTest(t, nil, func(t *testing.T, db *DB) { test(t, db) }) }) t.Run("InMemory mode", func(t *testing.T) { + t.Parallel() + opts := DefaultOptions("").WithInMemory(true) db, err := Open(opts) require.NoError(t, err) @@ -288,6 +292,8 @@ require.NoError(t, db.Close()) }) t.Run("cache disabled", func(t *testing.T) { + t.Parallel() + opts := DefaultOptions("").WithInMemory(true).WithMaxCacheSize(0) db, err := Open(opts) require.NoError(t, err) @@ -644,11 +650,15 @@ fmt.Println("Done and closing") } t.Run("disk mode", func(t *testing.T) { + t.Parallel() + runBadgerTest(t, nil, func(t *testing.T, db *DB) { test(t, db) }) }) t.Run("InMemory mode", func(t *testing.T) { + t.Parallel() + opt := DefaultOptions("").WithInMemory(true) db, err := Open(opt) require.NoError(t, err) @@ -718,11 +728,15 @@ it.Close() } t.Run("disk mode", func(t *testing.T) { + t.Parallel() + runBadgerTest(t, nil, func(t *testing.T, db *DB) { test(t, db) }) }) t.Run("InMemory mode", func(t *testing.T) { + t.Parallel() + opt := DefaultOptions("").WithInMemory(true) db, err := Open(opt) require.NoError(t, err) @@ -787,11 +801,15 @@ fmt.Printf("FileIDs: %v\n", fileIDs) } t.Run("TestLoad Without Encryption/Compression", func(t *testing.T) { + t.Parallel() + opt := getTestOptions("") opt.Compression = options.None testLoad(t, opt) }) t.Run("TestLoad With Encryption and no compression", func(t *testing.T) { + t.Parallel() + key := make([]byte, 32) _, err := rand.Read(key) require.NoError(t, err) @@ -801,6 +819,8 @@ testLoad(t, opt) }) t.Run("TestLoad With Encryption and compression", func(t *testing.T) { + t.Parallel() + key := make([]byte, 32) _, err := rand.Read(key) require.NoError(t, err) @@ -810,6 +830,8 @@ testLoad(t, opt) }) t.Run("TestLoad without Encryption and with compression", func(t *testing.T) { + t.Parallel() + opt := getTestOptions("") opt.Compression = options.ZSTD testLoad(t, opt) @@ -1306,6 +1328,8 @@ } t.Run("Test plain text", func(t *testing.T) { + t.Parallel() + dir, err := ioutil.TempDir("", "badger-test") require.NoError(t, err) defer removeDir(dir) @@ -1314,6 +1338,8 @@ }) t.Run("Test encryption", func(t *testing.T) { + t.Parallel() + dir, err := ioutil.TempDir("", "badger-test") require.NoError(t, err) defer removeDir(dir) @@ -1377,6 +1403,8 @@ require.NoError(t, db.Close()) } t.Run("disk mode", func(t *testing.T) { + t.Parallel() + dir, err := ioutil.TempDir("", "badger-test") require.NoError(t, err) defer removeDir(dir) @@ -1384,6 +1412,8 @@ test(t, opt) }) t.Run("InMemory mode", func(t *testing.T) { + t.Parallel() + opt := DefaultOptions("").WithValueLogFileSize(1024 * 1024 * 1024) opt.InMemory = true test(t, opt) @@ -1812,9 +1842,13 @@ require.Equal(t, before, runtime.NumGoroutine()) } t.Run("disk mode", func(t *testing.T) { + t.Parallel() + test(t, nil) }) t.Run("InMemory mode", func(t *testing.T) { + t.Parallel() + opt := DefaultOptions("").WithInMemory(true) test(t, &opt) }) @@ -2094,9 +2128,13 @@ }) } t.Run("Testing Verify Checksum without encryption", func(t *testing.T) { + t.Parallel() + testVerfiyCheckSum(t, getTestOptions("")) }) t.Run("Testing Verify Checksum with Encryption", func(t *testing.T) { + t.Parallel() + key := make([]byte, 32) _, err := rand.Read(key) require.NoError(t, err)
diff --git a/managed_db_test.go b/managed_db_test.go index 932744b..6762dad 100644 --- a/managed_db_test.go +++ b/managed_db_test.go
@@ -164,6 +164,8 @@ require.NoError(t, db.DropAll()) } t.Run("disk mode", func(t *testing.T) { + t.Parallel() + dir, err := ioutil.TempDir("", "badger-test") require.NoError(t, err) defer removeDir(dir) @@ -172,6 +174,8 @@ test(t, opts) }) t.Run("InMemory mode", func(t *testing.T) { + t.Parallel() + opts := getTestOptions("") opts.InMemory = true test(t, opts) @@ -716,6 +720,8 @@ } t.Run("writebatch", func(t *testing.T) { + t.Parallel() + opt := DefaultOptions("") opt.MaxTableSize = 1 << 15 // This would create multiple transactions in write batch. @@ -732,6 +738,8 @@ }) }) t.Run("writebatch at", func(t *testing.T) { + t.Parallel() + opt := DefaultOptions("") opt.MaxTableSize = 1 << 15 // This would create multiple transactions in write batch. opt.managedTxns = true
diff --git a/value_test.go b/value_test.go index 8c3c67a..8bbef58 100644 --- a/value_test.go +++ b/value_test.go
@@ -1161,6 +1161,8 @@ k := []byte("KEY") v := []byte(fmt.Sprintf("val%100d", 10)) t.Run("ok", func(t *testing.T) { + t.Parallel() + dir, err := ioutil.TempDir("", "badger-test") require.NoError(t, err) defer removeDir(dir) @@ -1189,6 +1191,8 @@ }) // Regression test for https://github.com/dgraph-io/badger/issues/1049 t.Run("Corruption", func(t *testing.T) { + t.Parallel() + dir, err := ioutil.TempDir("", "badger-test") require.NoError(t, err) defer removeDir(dir)