domain: add test

This commit is contained in:
xia
2015-11-23 14:00:28 +08:00
parent e640d837a6
commit 8cd710b1d4
2 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -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)
}