Fix TTL migration issue.

This commit is contained in:
Ben Johnson 2013-11-05 15:57:53 -07:00
parent d3bfc49b7c
commit 8c6606ed12
2 changed files with 15 additions and 10 deletions

View File

@ -16,6 +16,12 @@ import (
// The default version to set when the store is first initialized.
const defaultVersion = 2
var minExpireTime time.Time
func init() {
minExpireTime, _ = time.Parse(time.RFC3339, "2000-01-01T00:00:00Z")
}
type Store interface {
Version() int
CommandFactory() CommandFactory
@ -344,6 +350,13 @@ func (s *store) internalCreate(nodePath string, value string, unique bool, repla
nodePath = path.Clean(path.Join("/", nodePath))
// Assume expire times that are way in the past are not valid.
// This can occur when the time is serialized to JSON and read back in.
if expireTime.Before(minExpireTime) {
expireTime = Permanent
}
dir, newNodeName := path.Split(nodePath)
// walk through the nodePath, create dirs and get the last directory node

View File

@ -21,7 +21,7 @@ func TestV1SoloMigration(t *testing.T) {
nodepath := filepath.Join(path, "node0")
fixturepath, _ := filepath.Abs("../fixtures/v1.solo/node0")
fmt.Println("DATA_DIR =", nodepath)
// Copy over fixture files.
c := exec.Command("cp", "-rf", fixturepath, nodepath)
@ -44,19 +44,11 @@ func TestV1SoloMigration(t *testing.T) {
defer process.Kill()
time.Sleep(time.Second)
time.Sleep(120 * time.Second)
// Ensure deleted message is removed.
resp, err := tests.Get("http://localhost:4001/v2/keys/message")
tests.ReadBody(resp)
assert.Nil(t, err, "")
assert.Equal(t, resp.StatusCode, 404, "")
// Ensure TTL'd message is removed.
resp, err = tests.Get("http://localhost:4001/v2/keys/foo")
tests.ReadBody(resp)
assert.Nil(t, err, "")
assert.Equal(t, resp.StatusCode, 404, "")
assert.Equal(t, resp.StatusCode, 200, "")
}
// Ensure that we can start a v2 cluster from the logs of a v1 cluster.