diff --git a/go/cmd/dolt/commands/engine/sqlengine.go b/go/cmd/dolt/commands/engine/sqlengine.go index 57fb2a7cd4..706c152f73 100644 --- a/go/cmd/dolt/commands/engine/sqlengine.go +++ b/go/cmd/dolt/commands/engine/sqlengine.go @@ -16,8 +16,10 @@ package engine import ( "context" + "github.com/sirupsen/logrus" "os" "runtime" + "strconv" "strings" gms "github.com/dolthub/go-mysql-server" @@ -354,7 +356,21 @@ func configureEventScheduler(config *SqlEngineConfig, engine *gms.Engine, sessFa }, nil } - return engine.InitializeEventScheduler(getCtxFunc, config.EventSchedulerStatus) + // A hidden env var allows overriding the event scheduler period for testing. This option is not + // exposed via configuration because we do not want to encourage customers to use it. If the value + // is equal to or less than 0, then the period is ignored and the default period, 30s, is used. + eventSchedulerPeriod := 0 + eventSchedulerPeriodEnvVar := "DOLT_EVENT_SCHEDULER_PERIOD" + if s, ok := os.LookupEnv(eventSchedulerPeriodEnvVar); ok { + i, err := strconv.Atoi(s) + if err != nil { + logrus.Warnf("unable to parse value '%s' from env var '%s' as an integer", s, eventSchedulerPeriodEnvVar) + } else { + logrus.Warnf("overriding Dolt event scheduler period to %d seconds", i) + eventSchedulerPeriod = i + } + } + return engine.InitializeEventScheduler(getCtxFunc, config.EventSchedulerStatus, eventSchedulerPeriod) } // sqlContextFactory returns a contextFactory that creates a new sql.Context with the initial database provided diff --git a/integration-tests/bats/events.bats b/integration-tests/bats/events.bats index dfb7f61fa6..57e6a130b9 100644 --- a/integration-tests/bats/events.bats +++ b/integration-tests/bats/events.bats @@ -6,7 +6,12 @@ make_test_repo_and_start_server() { rm -rf ./"$1" mkdir "$1" cd "$1" + + # Override the default event scheduler period (30s) and set it to 1s so that we can run + # tests faster, without having to wait for the default 30s period to elapse several times. + export DOLT_EVENT_SCHEDULER_PERIOD=1 start_sql_server + dolt sql-client -P $PORT -u dolt --use-db information_schema -q "CREATE DATABASE repo1;" dolt sql-client -P $PORT -u dolt --use-db repo1 -q "CREATE TABLE totals (id int PRIMARY KEY AUTO_INCREMENT, int_col int);" dolt sql-client -P $PORT -u dolt --use-db repo1 -q "call dolt_commit('-Am', 'creating table');"