diff --git a/domain/domain.go b/domain/domain.go index 6a25d18fcf..413fc69938 100644 --- a/domain/domain.go +++ b/domain/domain.go @@ -157,9 +157,6 @@ func (do *Domain) mustReload() { } } -// check schema every 300 seconds default. -const defaultLoadTime = 300 * time.Second - const maxReloadTimeout = 60 * time.Second const minReloadTimeout = 20 * time.Second @@ -176,6 +173,9 @@ func getReloadTimeout(lease time.Duration) time.Duration { return timeout } +// check schema every 300 seconds default. +const defaultLoadTime = 300 * time.Second + func (do *Domain) loadSchemaInLoop(lease time.Duration) { if lease <= 0 { lease = defaultLoadTime diff --git a/domain/domain_test.go b/domain/domain_test.go index e047a1984c..62963c48e9 100644 --- a/domain/domain_test.go +++ b/domain/domain_test.go @@ -63,3 +63,12 @@ func (*testSuite) TestT(c *C) { store.Close() time.Sleep(1 * time.Second) } + +func (*testSuite) GetReloadTimeoutTest(c *C) { + timeout := getReloadTimeout(241) + c.Assert(timeout, Equals, maxReloadTimeout) + timeout = getReloadTimeout(84) + c.Assert(timeout, Equals, minReloadTimeout) + timeout = getReloadTimeout(120) + c.Assert(timeout, Equals, 30) +}