Commit e57ad63a authored by Hamdi Allam's avatar Hamdi Allam Committed by GitHub

parallel tests (#8695)

parent b9d7c68f
...@@ -57,6 +57,12 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite { ...@@ -57,6 +57,12 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
dbUser := os.Getenv("DB_USER") dbUser := os.Getenv("DB_USER")
dbName := setupTestDatabase(t) dbName := setupTestDatabase(t)
// E2E tests can run on the order of magnitude of minutes. Once
// the system is running, mark this test for Parallel execution.
// We mark the test as parallel before starting the devnet to
// reduce that number of idle routines when paused.
t.Parallel()
// Rollup System Configuration. Unless specified, // Rollup System Configuration. Unless specified,
// omit logs emitted by the various components. Maybe // omit logs emitted by the various components. Maybe
// we can eventually dump these logs to a temp file // we can eventually dump these logs to a temp file
...@@ -64,9 +70,11 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite { ...@@ -64,9 +70,11 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
opCfg := op_e2e.DefaultSystemConfig(t) opCfg := op_e2e.DefaultSystemConfig(t)
if len(os.Getenv("ENABLE_ROLLUP_LOGS")) == 0 { if len(os.Getenv("ENABLE_ROLLUP_LOGS")) == 0 {
t.Log("set env 'ENABLE_ROLLUP_LOGS' to show rollup logs") t.Log("set env 'ENABLE_ROLLUP_LOGS' to show rollup logs")
for name, logger := range opCfg.Loggers { for name := range opCfg.Loggers {
t.Logf("discarding logs for %s", name) t.Logf("discarding logs for %s", name)
logger.SetHandler(log.DiscardHandler()) noopLog := log.New()
noopLog.SetHandler(log.DiscardHandler())
opCfg.Loggers[name] = noopLog
} }
} }
...@@ -77,12 +85,7 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite { ...@@ -77,12 +85,7 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
// Indexer Configuration and Start // Indexer Configuration and Start
indexerCfg := &config.Config{ indexerCfg := &config.Config{
DB: config.DBConfig{ DB: config.DBConfig{Host: "127.0.0.1", Port: 5432, Name: dbName, User: dbUser},
Host: "127.0.0.1",
Port: 5432,
Name: dbName,
User: dbUser,
},
RPCs: config.RPCsConfig{ RPCs: config.RPCsConfig{
L1RPC: opSys.EthInstances["l1"].HTTPEndpoint(), L1RPC: opSys.EthInstances["l1"].HTTPEndpoint(),
L2RPC: opSys.EthInstances["sequencer"].HTTPEndpoint(), L2RPC: opSys.EthInstances["sequencer"].HTTPEndpoint(),
...@@ -105,10 +108,6 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite { ...@@ -105,10 +108,6 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
MetricsServer: config.ServerConfig{Host: "127.0.0.1", Port: 0}, MetricsServer: config.ServerConfig{Host: "127.0.0.1", Port: 0},
} }
// E2E tests can run on the order of magnitude of minutes. Once
// the system is running, mark this test for Parallel execution
t.Parallel()
indexerLog := testlog.Logger(t, log.LvlInfo).New("role", "indexer") indexerLog := testlog.Logger(t, log.LvlInfo).New("role", "indexer")
ix, err := indexer.NewIndexer(context.Background(), indexerLog, indexerCfg, func(cause error) { ix, err := indexer.NewIndexer(context.Background(), indexerLog, indexerCfg, func(cause error) {
if cause != nil { if cause != nil {
...@@ -116,25 +115,18 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite { ...@@ -116,25 +115,18 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
} }
}) })
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, ix.Start(context.Background()), "cleanly start indexer") require.NoError(t, ix.Start(context.Background()), "cleanly start indexer")
t.Cleanup(func() { t.Cleanup(func() {
require.NoError(t, ix.Stop(context.Background()), "cleanly shut down indexer") require.NoError(t, ix.Stop(context.Background()), "cleanly shut down indexer")
}) })
// API Configuration and Start
apiLog := testlog.Logger(t, log.LvlInfo).New("role", "indexer_api") apiLog := testlog.Logger(t, log.LvlInfo).New("role", "indexer_api")
apiCfg := &api.Config{ apiCfg := &api.Config{
DB: &api.TestDBConnector{BridgeTransfers: ix.DB.BridgeTransfers}, // reuse the same DB DB: &api.TestDBConnector{BridgeTransfers: ix.DB.BridgeTransfers}, // reuse the same DB
HTTPServer: config.ServerConfig{ HTTPServer: config.ServerConfig{Host: "127.0.0.1", Port: 0},
Host: "127.0.0.1", MetricsServer: config.ServerConfig{Host: "127.0.0.1", Port: 0},
Port: 0,
},
MetricsServer: config.ServerConfig{
Host: "127.0.0.1",
Port: 0,
},
} }
apiService, err := api.NewApi(context.Background(), apiLog, apiCfg) apiService, err := api.NewApi(context.Background(), apiLog, apiCfg)
...@@ -148,10 +140,7 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite { ...@@ -148,10 +140,7 @@ func createE2ETestSuite(t *testing.T) E2ETestSuite {
// Wait for the API to start listening // Wait for the API to start listening
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
client, err := client.NewClient(&client.Config{ client, err := client.NewClient(&client.Config{PaginationLimit: 100, BaseURL: "http://" + apiService.Addr()})
PaginationLimit: 100,
BaseURL: "http://" + apiService.Addr(),
})
require.NoError(t, err, "must open indexer API client") require.NoError(t, err, "must open indexer API client")
return E2ETestSuite{ return E2ETestSuite{
...@@ -193,9 +182,9 @@ func setupTestDatabase(t *testing.T) string { ...@@ -193,9 +182,9 @@ func setupTestDatabase(t *testing.T) string {
Password: "", Password: "",
} }
silentLog := log.New() noopLog := log.New()
silentLog.SetHandler(log.DiscardHandler()) noopLog.SetHandler(log.DiscardHandler())
db, err := database.NewDB(context.Background(), silentLog, dbConfig) db, err := database.NewDB(context.Background(), noopLog, dbConfig)
require.NoError(t, err) require.NoError(t, err)
defer db.Close() defer db.Close()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment