diff --git a/release_version.go b/release_version.go new file mode 100644 index 000000000..5285c9763 --- /dev/null +++ b/release_version.go @@ -0,0 +1,2 @@ +package main +const releaseVersion = "v0.1.2-33-g1a2a9d6" diff --git a/tests/fixtures/v1/README b/tests/fixtures/v1/README new file mode 100644 index 000000000..0940522bb --- /dev/null +++ b/tests/fixtures/v1/README @@ -0,0 +1,14 @@ +README + +The scripts in this directory should be run from the project root: + +$ cd $GOPATH/src/github.com/coreos/etcd +$ tests/fixtures/v1/complete.1.sh + +Scripts with numbers should be run in separate terminal windows (in order): + +$ tests/fixtures/v1/complete.1.sh +$ tests/fixtures/v1/complete.2.sh +$ tests/fixtures/v1/complete.3.sh + +The resulting server state data can be found in tmp/node0. diff --git a/tests/fixtures/v1/complete.1.sh b/tests/fixtures/v1/complete.1.sh new file mode 100644 index 000000000..ee77deaed --- /dev/null +++ b/tests/fixtures/v1/complete.1.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +./build +./etcd -d tmp/node0 -n node0 diff --git a/tests/fixtures/v1/complete.2.sh b/tests/fixtures/v1/complete.2.sh new file mode 100644 index 000000000..1b067eb2b --- /dev/null +++ b/tests/fixtures/v1/complete.2.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +./etcd -s 127.0.0.1:7002 -c 127.0.0.1:4002 -C 127.0.0.1:7001 -d tmp/node2 -n node2 diff --git a/tests/fixtures/v1/complete.3.sh b/tests/fixtures/v1/complete.3.sh new file mode 100644 index 000000000..a1c9c6b3e --- /dev/null +++ b/tests/fixtures/v1/complete.3.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +./etcd -s 127.0.0.1:7003 -c 127.0.0.1:4003 -C 127.0.0.1:7001 -d tmp/node3 -n node3 diff --git a/tests/fixtures/v1/complete.4.sh b/tests/fixtures/v1/complete.4.sh new file mode 100644 index 000000000..b228b1a1d --- /dev/null +++ b/tests/fixtures/v1/complete.4.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +curl -L http://127.0.0.1:4001/v1/keys/message -d value="Hello world" +curl -L http://127.0.0.1:4001/v1/keys/message -d value="Hello etcd" +curl -L http://127.0.0.1:4001/v1/keys/message -X DELETE +curl -L http://127.0.0.1:4001/v1/keys/foo -d value=bar -d ttl=5 +curl -L http://127.0.0.1:4001/v1/keys/foo -d value=one +curl -L http://127.0.0.1:4001/v1/keys/foo -d prevValue=two -d value=three +curl -L http://127.0.0.1:4001/v1/keys/foo -d prevValue=one -d value=two +curl -L http://127.0.0.1:4001/v1/keys/bar -d prevValue= -d value=four +curl -L http://127.0.0.1:4001/v1/keys/bar -d prevValue= -d value=five +curl -X DELETE http://127.0.0.1:4001/v1/keys/_etcd/machines diff --git a/tests/fixtures/v1/complete/conf b/tests/fixtures/v1/complete/conf new file mode 100644 index 000000000..827bb86d1 --- /dev/null +++ b/tests/fixtures/v1/complete/conf @@ -0,0 +1 @@ +{"commitIndex":13,"peers":[]} \ No newline at end of file diff --git a/tests/fixtures/v1/complete/info b/tests/fixtures/v1/complete/info new file mode 100644 index 000000000..398c8e1e8 --- /dev/null +++ b/tests/fixtures/v1/complete/info @@ -0,0 +1,18 @@ +{ + "name": "node0", + "raftURL": "http://127.0.0.1:7001", + "etcdURL": "http://127.0.0.1:4001", + "webURL": "", + "raftListenHost": "127.0.0.1:7001", + "etcdListenHost": "127.0.0.1:4001", + "raftTLS": { + "CertFile": "", + "KeyFile": "", + "CAFile": "" + }, + "etcdTLS": { + "CertFile": "", + "KeyFile": "", + "CAFile": "" + } +} diff --git a/tests/fixtures/v1/complete/log b/tests/fixtures/v1/complete/log new file mode 100644 index 000000000..5ed55603d Binary files /dev/null and b/tests/fixtures/v1/complete/log differ diff --git a/tests/functional/v1_migration_test.go b/tests/functional/v1_migration_test.go new file mode 100644 index 000000000..f6f892287 --- /dev/null +++ b/tests/functional/v1_migration_test.go @@ -0,0 +1,51 @@ +package test + +import ( + "fmt" + "io/ioutil" + "os" + "os/exec" + "testing" + "time" + + "github.com/coreos/etcd/tests" + "github.com/stretchr/testify/assert" +) + +// Ensure that we can start a v2 node from the log of a v1 node. +func TestV1Migration(t *testing.T) { + path, _ := ioutil.TempDir("", "etcd-") + os.RemoveAll(path) + defer os.RemoveAll(path) + + // Copy over fixture files. + if err := exec.Command("cp", "-r", "../fixtures/v1/complete", path).Run(); err != nil { + panic("Fixture initialization error") + } + + procAttr := new(os.ProcAttr) + procAttr.Files = []*os.File{nil, os.Stdout, os.Stderr} + args := []string{"etcd", fmt.Sprintf("-d=%s", path)} + + process, err := os.StartProcess(EtcdBinPath, args, procAttr) + if err != nil { + t.Fatal("start process failed:" + err.Error()) + return + } + defer process.Kill() + time.Sleep(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, "") +} +