mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-08-28 10:54:59 +00:00
For on-prem serverless, if we restart the process containing the controller and computer(s), when they come back up, the controller doesn't know that the computers have been restarted, so it doesn't send them a directive. This change forces the controller to send a directive upon startup by a computer.
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package balancer_test
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/featurebasedb/featurebase/v3/dax/controller/sqldb"
|
|
"github.com/featurebasedb/featurebase/v3/logger"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
os.Exit(run(m))
|
|
}
|
|
|
|
// SQLTransactor is a global connection to a SQL database which is
|
|
// created, migrated, and destroyed for each test run. The database
|
|
// gets a randomized name and is used by all the tests in this
|
|
// package.
|
|
var SQLTransactor sqldb.Transactor
|
|
|
|
// run is a separate function so that we can defer cleanups. (deferred functions won't run if os.Exit is called)
|
|
func run(m *testing.M) int {
|
|
// We connect to a randomized database, create it, and run migrations. Then we drop it when tests are done.
|
|
conf := sqldb.GetTestConfigRandomDB("balancer_test")
|
|
var err error
|
|
SQLTransactor, err = sqldb.NewTransactor(conf, logger.StderrLogger)
|
|
if err != nil {
|
|
fmt.Printf("couldn't set up transactor: %v", err)
|
|
return -1
|
|
}
|
|
if err := SQLTransactor.Start(); err != nil {
|
|
fmt.Printf("couldn't start transactor: %v", err)
|
|
return -1
|
|
}
|
|
|
|
defer sqldb.DropDatabase(SQLTransactor)
|
|
code := m.Run()
|
|
return code
|
|
}
|