From 8cd710b1d4c19f23ecb583bc5ce258314b52848b Mon Sep 17 00:00:00 2001 From: xia Date: Mon, 23 Nov 2015 14:00:28 +0800 Subject: [PATCH] domain: add test --- domain/domain.go | 6 +++--- domain/domain_test.go | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) 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) +}